资源网助手

OK资源网,最大资源网[kuyun] [m3u8]页面链接点击播放或直接跳转.类型页面改进翻页功能

当前为 2017-09-18 提交的版本,查看 最新版本

// ==UserScript==
// @name         资源网助手
// @namespace    https://gf.qytechs.cn/zh-CN/users/104201
// @version      0.3
// @description  OK资源网,最大资源网[kuyun] [m3u8]页面链接点击播放或直接跳转.类型页面改进翻页功能
// @author       黄盐
// @match        http://www.okokzy.com/?m=vod-*
// @match        http://www.zuidazy.com/?m=vod-*
// @require      https://gf.qytechs.cn/scripts/33311-videocontrols/code/videoControls.js?version=218883
// @grant        GM_addStyle
// @grant        GM_xmlhttpRequest
// @grant        unsafeWindow
// run-at        document-end
// ==/UserScript==

//openHLS();
(function() {
    'use strict';
    //适配详情页,http://*.com/?m=vod-detail-id-*.html
    if(location.search.indexOf("detail") != -1) {
        GM_addStyle(''+
                    //视频框CSS End
                    '#TM_f{z-index: 1000; position:fixed;top:0; padding:0; margin:0; width:100%;height:100%;}'+
                    '#TM_f:hover .ctrls{display:block; position:absolute; font-size:30px; text-align:center; right:20px; padding:0px 7px 5px 7px; background:white;border-radius:10px; cursor:pointer;}'+
                    '.ctrls{display:none;}'+
                    '#TM_f:hover .ctrls:hover{background:rgb(83, 226, 251);}'+
                    '#close{top:20%;} #wd{top:35%;} #scrn{top:50%;}'+
                    'video{ position: relative; top: 0; background:black; width: 100%; height: 100%; z-index: -1; }'+
                    '.GM_play{padding-left:30px;cursor:pointer; color:orange;};'+
                    //按键暂停等CSS
                    '#tip{ position: absolute; z-index: 999999; padding: 10px 15px 10px 20px; border-radius: 10px; background: white; font-size:30px; color:black;top: 50%;left: 50%; transform: translate(-50%,-50%);}'
                   );
        if(!jQuery){var a=document.createElement("script");a.src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js";document.head.appendChild(a);}
        var b=document.createElement("script");b.src="https://cdn.jsdelivr.net/npm/hls.js@latest";document.head.appendChild(b);
        //详情页使用的播放器



        var script= document.createElement("script");
        script.innerHTML=''+
            'var openHLS = function (src){'+
            'var TM_f=document.createElement("div");'+
            'TM_f.id="TM_f";'+
            'TM_f.innerHTML=\'<video id="video" controls="controls" autoplay="autoplay"></video>\'+'+
            '\'<div id="close" class="ctrls" onclick="changeSize ( \\\'close\\\' , \\\'TM_f\\\')" title="关闭视频">?</div>\'+'+
            '\'<div id="wd" class="ctrls" onclick="changeSize ( \\\'mid\\\' ,\\\'TM_f\\\')" title="中窗播放">?</div>\'+'+
            '\'<div id="scrn" class="ctrls" onclick="changeSize ( \\\'max\\\' , \\\'TM_f\\\')" title="网页全屏">?</div>\';'+
            'document.body.appendChild(TM_f);'+
            'if(Hls.isSupported()) {'+
            'var video = document.getElementById("video");'+
            'var hls = new Hls();'+
            'hls.loadSource(src);'+
            'hls.attachMedia(video);'+
            'hls.on(Hls.Events.MANIFEST_PARSED,function() {'+
            'video.play();'+
            '});'+
            '}'+
            '};'+
        //================改变框大小 Begin==========
        'function changeSize ( op , tgId) {'+
            'switch (op) {'+
                'case "close" : { document.getElementById(tgId).parentNode.removeChild(document.getElementById(tgId)); break;}'+
                'case "mid" : {document.getElementById(tgId).setAttribute("style","width:50%;height:auto;");break;}'+
                'case "max" : {document.getElementById(tgId).setAttribute("style","width:100%;height:100%;");break;}'+
            '}'+
        '}';
        //================改变框大小 End==========
        /////////
        document.head.append(script);


        var lis=document.querySelectorAll("div.vodplayinfo li");//文档中0~end 是链接项目,渲染结束后是6~end是链接项目
        var tmp, play;
        for(var i=0; i<lis.length; i++){
            tmp=lis[i].innerText;
            if(tmp.indexOf('m3u8') == -1) {play = '';} else {play = '<span class = "GM_play" onclick = "openHLS(this.previousElementSibling.href)">▶</span>';}
            lis[i].innerHTML=lis[i].childNodes[0].outerHTML+'<a target="_blank" href="'+tmp.slice(tmp.indexOf("http"))+'">'+tmp+'</a>'+play;
        }
    }
    //适配分类页,http://*.com/?m=vod-type-id-*.html 方便翻页
    if(location.search.indexOf("type") != -1) {
        GM_addStyle('.GM_page{position:fixed !important;bottom:0 !important; width:100% !important;}');
        var ms = function (){
            var evt = window.event || arguments[0];
            if(evt.pageY<(document.body.offsetHeight-window.innerHeight)){
                document.getElementsByClassName('pages')[0].className = "pages GM_page";
            }
            else {
                document.getElementsByClassName('pages')[0].className = "pages";
            }
        };

        //document.onmousemove = ms;
        document.onmousewheel = ms;
    }
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址