含羞草

含羞草-解析脚本,永久导航http://www.Fi11.tv 中转地址:http://www.pmeaqve.cn 遇到播放地址为旧播放地址或者无反应,请自行多刷新几次当前页面,重新播放即可

As of 2023-11-04. See the latest version.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         含羞草
// @namespace    http://tampermonkey.net/
// @version      1.4
// @description  含羞草-解析脚本,永久导航http://www.Fi11.tv 中转地址:http://www.pmeaqve.cn    遇到播放地址为旧播放地址或者无反应,请自行多刷新几次当前页面,重新播放即可
// @author       院长
// @match        *//:h5.*.com/
// @match        *//:h5.*.cn/
// @match        *//:www.fi*.com/
// @match        *//:www.hx*.cn/
// @match        https://*/playvideo/*
// @match        https://*/live/*
// @include      /^.*?://h5\.fi.*?\.com.+$/
// @include      /^.*?://h5\.hx.*?\.com.+$/
// @include      /^.*?://h5\.fi.*?\.cn.+$/
// @include      /^.*?://h5\.hx.*?\.cn.+$/
// @include      /^.*?://www\.fi.*?\.com.+$/
// @include      /^.*?://www\.hx.*?\.com.+$/
// @include      /^.*?://www\.fi.*?\.cn.+$/
// @include      /^.*?://www\.hx.*?\.cn.+$/
// @include      /^.*?://.*?/play/video.+$/
// @icon         https://www.google.com/s2/favicons?sz=64&domain=3kjs.com
// @grant        none
// @require      https://cdn.bootcdn.net/ajax/libs/crypto-js/4.1.1/crypto-js.min.js
// @require      https://cdn.bootcdn.net/ajax/libs/jquery/3.6.4/jquery.min.js
// @require      https://cdn.bootcdn.net/ajax/libs/dplayer/1.26.0/DPlayer.min.js
// @require      https://cdn.bootcdn.net/ajax/libs/hls.js/1.1.5/hls.min.js
// @run-at       document-end
// ==/UserScript==

//中转地址:http://www.zhongyouchuanmei.xyz
//含羞草永久导航:http://www.Fi11.tv http://fi11.com http://fi11.cn http://www.Fi11.live http://www.fi11av.com
//打开永久导航中的最新网址即可,若是脚本框架需要匹配域名,自行将导航中的最新网址填上即可
//遇到播放地址为旧播放地址或者无反应,请自行刷新当前页面,重新播放即可


/**********************************/

/*
含羞草-解析脚本
参考来源https://yaohuo.me/bbs-1210512.html

实现游客无限试用,无限获取真实播放地址

已兼容手机和电脑

*/
/**********************************/




// 权限认证标识
const TOKEN = 'hxc_1.0.0_token';
// 服务地址
let baseUrl = location.origin;
// 视频试看地址
const PRE_URL = baseUrl + '/api/videos/getPreUrl';
// 用户注册地址
const REG_URL = baseUrl + '/api/login/userReg';
var videoUrl = "";




// 参数加密
function Encrypt(word) {
    let keyStr = 'B77A9FF7F323B5404902102257503C2F';
    const key = CryptoJS.enc.Utf8.parse(keyStr);
    const iv = CryptoJS.enc.Utf8.parse(keyStr);
    const srcs = CryptoJS.enc.Utf8.parse(word);
    const encrypted = CryptoJS.AES.encrypt(srcs, key, {
        iv: iv,
        mode: CryptoJS.mode.CBC,
        padding: CryptoJS.pad.Pkcs7
    });
    return CryptoJS.enc.Base64.stringify(encrypted.ciphertext);
}

// 请求封装
const fetchData = async (url, body) => {
    return fetch(url, {
        method: 'post',
        body: JSON.stringify({
            endata: Encrypt(JSON.stringify(body))
        }),
        headers: {
            // 携带认证头
            auth: localStorage.getItem(TOKEN)?.replace(/"/g, ''),
            'Content-Type': 'application/json'
        }
    });
};






// 去除限制
const setValue = async () => {
    let isDetail = location.href.includes('play/video');
    if (isDetail) {
        //判断是h5还是电脑
        let videoId = location.href.match(/.+\/h5\..+\/play\/video\/(\d+)\/.+/);
        if(!videoId){
            videoId = location.href.match(/.+\/play\/video\/(\d+)/)[1];
            //电脑
            //console.log("电脑")
            var preInfo = localStorage.getItem("preInfo");
            if(preInfo){
                preInfo = JSON.parse(preInfo)
                preInfo.count = 0;
                preInfo = JSON.stringify(preInfo)
                localStorage.setItem("preInfo", preInfo);
            }

            //await setElement("pc",videoId);
            //console.log("最后的视频url:" + videoUrl)

            videoId = getVideoId()
            //用于判定当前页面的videoId是否变化
            if (window.videoId == videoId) {
                return
            }
            pc()


        }else{
            //手机
            //console.log("手机")
            videoId = videoId[1];
            var tryPlayNum = localStorage.getItem("tryPlayNum");
            if(tryPlayNum){
                tryPlayNum = JSON.parse(tryPlayNum)
                tryPlayNum.num = 0;
                tryPlayNum = JSON.stringify(tryPlayNum)
                localStorage.setItem("tryPlayNum", tryPlayNum);
            }
            //await setElement("mobile",videoId);

            if (!window.location.href.endsWith("0")) {
                return
            }
            videoId = getVideoId()
            if (window.videoId == videoId) {
                return
            }
            //console.log("执行手机操作========================")
            mobile()
        }

        //console.log("最后的视频ID:" + videoId);
        var videoId_File = localStorage.getItem("videoId");
        //console.log("===========================")
        if(videoId_File && videoId_File === videoId){
            //console.log("----------------------------")
            return
        }
        localStorage.setItem("videoId", videoId);
    }


}


function importJS(src) {
    let script = document.createElement('script');
    script.src = src;
    document.head.appendChild(script);
}

//导包
function importLib() {
    importJS("https://cdn.bootcdn.net/ajax/libs/crypto-js/4.1.1/crypto-js.min.js")
    importJS("https://cdn.bootcdn.net/ajax/libs/jquery/3.6.4/jquery.min.js")
    importJS("https://cdn.bootcdn.net/ajax/libs/dplayer/1.26.0/DPlayer.min.js")
    importJS("https://cdn.bootcdn.net/ajax/libs/hls.js/1.1.5/hls.min.js")
}

//获取视频id
function getVideoId() {
    let url = window.location.href;
    if (url.endsWith("0")) {
        let urlSplited = url.split("play/video")
        urlSplited = urlSplited[1].split("/")
        let videoId = urlSplited[1]
        return parseInt(videoId);
    }
    let urlSplited = url.split("/");
    let videoId = urlSplited[urlSplited.length - 1];
    return parseInt(videoId);
}


//获取视频链接(区分手机和电脑)
async function getVideoUrl(type,videoId){
    //很重要,区分是否当前页的id
    window.videoId = videoId
    //删除参数
    var waibubofan = "#waibubofan";
    var shipindizhi = "#shipindizhi";
    var delete_waibubofan = document.querySelectorAll(waibubofan);
    var delete_shipindizhi = document.querySelectorAll(shipindizhi);
    //先删除按键
    if(delete_waibubofan){
        for(let i=0;i<delete_waibubofan.length;i++){
            //console.log(`删除外部播放按键:${i}`)
            delete_waibubofan[i].remove()
        }
    }
    if(delete_shipindizhi){
        for(let i=0;i<delete_shipindizhi.length;i++){
            //console.log(`删除视频地址按键:${i}`)
            delete_shipindizhi[i].remove()
        }
    }

    //设置按钮
    let selectorParam = ".el-divider.el-divider--horizontal";
    if(type == "mobile"){
        selectorParam = ".tendency-row"
    }
    let json =await fetchData(PRE_URL, {
        videoId: Number(videoId)
    }).then(response => {
        return response.json();
    });
    const isSuccess = !!json.data.url;
    let el = document.querySelector(selectorParam);
    let a = document.createElement('a');
    a.style =
        'display:block;font-size:18px;padding:12px;color:#1890ff;';
    a.text = isSuccess ? '视频地址' : '获取失败';
    a.target = "_blank";
    a.id = "shipindizhi";
    if (isSuccess) {
        let parseUrl = json.data.url.replace(/start=\d+&end=\d+/, '');
        a.href = parseUrl;
        // 获取ts切片
        let m3u8Str = await fetch(parseUrl).then(async res => {
            let m3u8Str = await res.text();
            return m3u8Str
        });
        // 提取第一条记录
        let tsUrl = m3u8Str.split('\n').find(item => {
            return /^[^#]/.test(item);
        });
        // 拼接
        const linkUrl =
              'https://m3u8play.com/?play=' +
              new URL(parseUrl).origin +
              tsUrl;
        videoUrl = new URL(parseUrl).origin + tsUrl;
        let external = document.createElement('a');
        external.style =
            'display:block;font-size:18px;padding:12px;color:#1890ff;';
        external.text = '外部播放';
        external.href = linkUrl;
        external.target = "_blank";
        external.id = "waibubofan";
        el.parentNode.insertBefore(external, el);
    }

    el.parentNode.insertBefore(a, el);
    return videoUrl;
}


//电脑播放
function play(playerUrl, pic, container, playType) {
    container.style.zIndex = 99999
    var videoObject = {
        container: '#v_prism', //容器的ID或className
        // live: true,//指定为直播
        //seek: 'cookie',//指定跳转到cookie记录的时间,使用该属性必需配置属性cookie
        cookie: 'abcdefg',//cookie名称,请在同一域中保持唯一
        plug: 'hls.js',//使用hls.js插件播放m3u8
        video: playerUrl//视频地址
    }
    window.ck = new ckplayer(videoObject);
    //window.ck.volume(0.5);//修改音量为0.5
    window.ck.volume(1);
    window.ck.play()
}

//手机播放
function mobilePlay(playerUrl, pic, container, playType) {
    container.style.zIndex = 99999
    window.dp = new DPlayer({
        container: container,                                              // 可选,player元素
        autoplay: false,                                                   // 可选,自动播放视频,不支持移动浏览器
        theme: '#FADFA3',                                                  // 可选,主题颜色,默认: #b7daff
        loop: true,                                                        // 可选,循环播放音乐,默认:true
        lang: 'zh',                                                        // 可选,语言,`zh'用于中文,`en'用于英语,默认:Navigator language
        screenshot: true,                                                  // 可选,启用截图功能,默认值:false,注意:如果设置为true,视频和视频截图必须启用跨域
        hotkey: true,                                                      // 可选,绑定热键,包括左右键和空格,默认值:true
        preload: 'auto',                                                   // 可选,预加载的方式可以是'none''metadata''auto',默认值:'auto'
        video: {                                                           // 必需,视频信息
            url: playerUrl,                                                // 必填,视频网址
            pic: pic,                                                      // 可选,视频截图
            thumbnails: pic
        }
    });
}


async function pc() {
     if (window.location.href.endsWith("home")) {
        return
    }
    let videoId = getVideoId();
    //let videoUrl = await getVideoUrl(videoId)
    let videoUrl = await getVideoUrl("pc",videoId)
    if (videoUrl == null) {
        return
    }
    let pic = document.querySelector(".el-image.overflow-hidden > img")
    if (pic) {
        pic = pic.getAttribute("src")
    }
    let container = document.querySelector("#v_prism")
    let playType = 'live'
    let elem = document.querySelector(".vip-mask")
    if (elem) {
        elem.remove()
    }
    elem = document.querySelector(".el-image.overflow-hidden")
    if (elem) {
        elem.remove()
    }
    elem = document.querySelector(".absolute.bg-overlay")
    if (elem) {
        elem.remove()
    }
    //console.log(`-----------执行播放电脑视频事件-------------`);
    //console.log(`-----------视频地址:${videoUrl}`);
    play(videoUrl, pic, container, playType)
    //await setElement("pc",videoId);
}

async function mobile() {
    if (!window.location.href.endsWith("0")) {
        return
    }
    let videoId = getVideoId()
    //let videoUrl = await getVideoUrl(videoId)
    let videoUrl = await getVideoUrl("mobile",videoId)
    if (videoUrl == null) {
        return
    }

    let pic = document.querySelector(".pub-video-poster")
    if (pic) {
        pic = pic.getAttribute("src")
    }
    //container = document.querySelector(".van-sticky")
    let container = document.querySelector("#video1")
    let playType = 'live'
    //document.querySelector(".try-detail-video").remove()
    mobilePlay(videoUrl, pic, container, playType)
    //await setElement("mobile",videoId);
}


async function main() {
    /**********************************/
    // hook: 拦截路由地址变化
    const _historyWrap = function (type) {
        const orig = history[type];
        const e = new Event(type);
        return function () {
            const rv = orig.apply(this, arguments);
            e.arguments = arguments;
            window.dispatchEvent(e);
            return rv;
        };
    };
    // 监听路由操作
    ['pushState', 'replaceState'].forEach(method => {
        history[method] = _historyWrap(method);
        window.addEventListener(method, () => {
            //console.log('当前URL为:', document.location.href);
            setValue();
        });
    });

   /*
    window.addEventListener('popstate', function(event) {
        //console.log('当前URL为:', document.location.href);
    });
   */
    /**********************************/
    importLib()
}
// 等待网页完成加载
window.addEventListener('load', function() {
  // 加载完成后执行的代码
  main()
}, true);