// ==UserScript== // @name 全网VIP视频自动解析播放器(已适配手机) // @namespace https://www.tampermonkey.net/ // @version 1.1.1 // @homepage https://greasyfork.org/zh-CN/users/840688 // @license AGPL-3.0 // @description 无需跳转新网址,打开官网直接看,超清 无广告 随机去水印。支持:腾讯,爱奇艺,优酷,哔哩哔哩,咪咕,乐视,搜狐,芒果,西瓜,PPTV,1905电影网,华数。支持解析失败自动切换推荐解析源。适配各种浏览器,酷睿i5-8300 CPU性能测试消耗仅1%。请关闭浏览器阻止第三方Cookie的功能,否则解析源会解析失败,解析源解析失败作者无力解决。 // @icon data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/PjxzdmcgaWQ9IkxheWVyXzEiIHN0eWxlPSJlbmFibGUtYmFja2dyb3VuZDpuZXcgMCAwIDUxMiA1MTI7IiB2ZXJzaW9uPSIxLjEiIHZpZXdCb3g9IjAgMCA1MTIgNTEyIiB4bWw6c3BhY2U9InByZXNlcnZlIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIj48c3R5bGUgdHlwZT0idGV4dC9jc3MiPgoJLnN0MHtmaWxsOiNFNkU2RTY7fQoJLnN0MXtmaWxsOiM0RDUxNTI7fQoJLnN0MntmaWxsOiM2OUM5Qzk7fQo8L3N0eWxlPjxwYXRoIGNsYXNzPSJzdDAiIGQ9Ik0yNTUuOCwxOS42Yy0xMzAuMywwLTIzNiwxMDUuNi0yMzYsMjM2czEwNS42LDIzNiwyMzYsMjM2czIzNi0xMDUuNiwyMzYtMjM2UzM4Ni4xLDE5LjYsMjU1LjgsMTkuNnogICBNMTgzLjMsMzc0LjlWMjg2aC0xMHYtNjBoMTB2LTg4LjlsMjA2LDExOC45TDE4My4zLDM3NC45eiIvPjxnPjxwYXRoIGNsYXNzPSJzdDEiIGQ9Ik0yNTUuOSwzMGMxMTMuNSwwLDIwOS45LDg0LjgsMjI0LjIsMTk3LjNsMTkuOC0yLjVDNDg0LjQsMTAyLjMsMzc5LjUsMTAsMjU1LjksMTAgICBDMTkyLDEwLDEzMS40LDM0LjQsODUuNCw3OC43Yy00NS45LDQ0LjItNzIuNiwxMDMuNS03NS4zLDE2N2wyMCwwLjhDMzUuMSwxMjUuMSwxMzQuMywzMCwyNTUuOSwzMHoiLz48cGF0aCBjbGFzcz0ic3QxIiBkPSJNNTAxLjcsMjQ1LjZsLTIwLDAuOGMwLjEsMy4yLDAuMiw2LjQsMC4yLDkuNnMtMC4xLDYuNC0wLjIsOS42bDIwLDAuOGMwLjEtMy40LDAuMi02LjksMC4yLTEwLjQgICBTNTAxLjgsMjQ5LDUwMS43LDI0NS42eiIvPjxwYXRoIGNsYXNzPSJzdDEiIGQ9Ik0yNTUuOSw0ODJjLTEyMS42LDAtMjIwLjctOTUuMS0yMjUuOC0yMTYuNGwtMjAsMC44YzIuNiw2My41LDI5LjQsMTIyLjgsNzUuMywxNjYuOSAgIGM0Niw0NC4zLDEwNi42LDY4LjcsMTcwLjUsNjguN2MxMjMuNiwwLDIyOC41LTkyLjMsMjQ0LTIxNC43bC0xOS44LTIuNUM0NjUuOCwzOTcuMiwzNjkuNCw0ODIsMjU1LjksNDgyeiIvPjxwb2x5Z29uIGNsYXNzPSJzdDEiIHBvaW50cz0iMTYzLjMsNDA5LjYgNDI5LjMsMjU2IDE2My4zLDEwMi40IDE2My4zLDIyNiAxODMuMywyMjYgMTgzLjMsMTM3LjEgMzg5LjMsMjU2IDE4My4zLDM3NC45IDE4My4zLDI4NiAgICAxNjMuMywyODYgICIvPjxyZWN0IGNsYXNzPSJzdDEiIGhlaWdodD0iMjAiIHdpZHRoPSIyMCIgeD0iMTYzLjMiIHk9IjI0NiIvPjxwYXRoIGNsYXNzPSJzdDEiIGQ9Ik0yMDMuMywzNDAuM2wxNDYtODQuM2wtMTQ2LTg0LjNWMzQwLjN6IE0yMjMuMywyMDYuM2w4Niw0OS43bC04Niw0OS43VjIwNi4zeiIvPjwvZz48cG9seWdvbiBjbGFzcz0ic3QyIiBwb2ludHM9IjIyMy4zLDIwNi4zIDIyMy4zLDMwNS43IDMwOS4zLDI1NiAiLz48L3N2Zz4= // @author Tenfond // @match https://*/* // @match http://*/* // @grant none // @run-at document-start // @downloadURL none // ==/UserScript== (function () { const settings = {IntervalIds: []}; const setInterval = window.setInterval; // 匹配URL if (new RegExp("[?&](?:url|v)=https?://.+\\..+\\..+/.+").test(location.search) || new RegExp("^https?://api\\.leduotv\\.com/.+?vid=http").test(location.href)) { settings.isParse = true; } else if (// 如果没匹配到 前面不是 非.或非空且匹配项在末尾$ 时则退出。因为 ios系统不兼容 零宽后向断言,所以这里不使用(?\n" + " text{font-family: 微软雅黑,黑体,Droid Serif,Arial,sans-serif; font-size: 15px; color: #000; position: absolute; transform: translateY(-50%); top: 50%;}\n" + " label.parse-switch{position: absolute; transform: translateY(-50%); top: 50%; display: inline-block; width: 44px; height: 24px; box-shadow: 0 0 0 1px #ccc; border-radius: 30px; overflow: hidden;}\n" + " label.parse-switch>input[type=checkbox]{display: none;}\n" + " label.parse-switch>input[type=checkbox]+bg{position: absolute; transition: background-color 0.3s; background-color: #ccc; width: 100%; height: 100%;}\n" + " label.parse-switch>input[type=checkbox]:checked+bg{background-color: #4af}\n" + " label.parse-switch>input[type=checkbox]+bg+span{position: absolute; transition: left 0.3s; left: 0; width: 24px; height: 24px; border-radius: 50%; background-color: #fff;}\n" + " label.parse-switch>input[type=checkbox]:checked+bg+span{left: 20px}\n" + "\n" + " settings>button+ul>li{position: relative; background-color: #0000; width: 100%; height: 30px;}\n" + "\n" + "" + " \n" + " \n" + ""; let SettingsBlock = settings.toolsBar.querySelector("settings>button+ul"); let parseDBKeys = Object.keys(settings.parseDB); for (let i = 0; i < parseDBKeys.length; i++) { SettingsBlock.innerHTML += "
  • " + parseDBKeys[i] + "
  • \n"; } let SettingBlockSwitchs = SettingsBlock.querySelectorAll("li>label.parse-switch"); for (let i = 0; i < SettingBlockSwitchs.length; i++) { let checkBox = SettingBlockSwitchs[i].querySelector("input[type=checkbox]"); checkBox.checked = Boolean(settings.parseDB[parseDBKeys[i]]); SettingBlockSwitchs[i].querySelector("bg").addEventListener("transitionend", function () { if (checkBox.checked !== Boolean(settings.parseDB[parseDBKeys[i]])) { // 如果有变化才会执行,否则会重复执行,因为动画会有延迟,刚打开网页时也会触发此监听事件 if (checkBox.checked) { settings.parseDB[parseDBKeys[i]] = "\x01"; } else { settings.parseDB[parseDBKeys[i]] = ""; } localStorage.setItem("parse." + parseDBKeys[i], settings.parseDB[parseDBKeys[i]]); settings.parseDBFuntions[parseDBKeys[i]](); } }); } let SettingsBtn = settings.toolsBar.querySelector("settings>button"); SettingsBtn.addEventListener("click", function () { if (SettingsBlock.style.opacity === "0") { SettingsBtn.innerText = "关闭"; SettingsBlock.style.opacity = "1"; SettingsBlock.style.width = "200px"; } else { SettingsBtn.innerText = "设置"; SettingsBlock.style.opacity = "0"; SettingsBlock.style.width = "0"; } }); SettingsBtn.addEventListener("blur", function () { SettingsBtn.innerText = "设置"; SettingsBlock.style.opacity = "0"; SettingsBlock.style.width = "0"; }); if (settings.parseDB.解析开关) { if (!sessionStorage.getItem("parse.tip设置")) { showTip("右下角可以编辑 设置"); sessionStorage.setItem("parse.tip设置", "\x01"); } config(); } document.root.appendChild(settings.toolsBar); } else { config(); } })(); // 启动解析代码 function start() { function detectMobile() { return navigator.userAgent.match(new RegExp("(iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)", "i")); } const isMobile = Boolean(detectMobile()); function doElement(cssString, doFunction, waitMS = 0, failFunction = null) { let Element = document.querySelector(cssString); if (Element && Element.nodeType === 1) { doFunction(Element); console.log("%c已为 " + cssString + " 进行了操作", settings.fontStyle.ok); } else if (document.readyState !== "complete" || waitMS > 0) { console.log("正在查找 " + cssString); // TODO 10毫秒约函数执行时间 setTimeout(function () { return doElement(cssString, doFunction, document.readyState !== "complete" ? waitMS : waitMS - 10 - settings.getElementTimes, failFunction); }, settings.getElementTimes); } else { console.error("未找到 " + cssString); if (typeof failFunction === "function") return failFunction(); } } function doElements(cssString, doFunction, waitMS = 0, index = 0) { let Elements = document.querySelectorAll(cssString); if (Elements[index] && Elements[index].nodeType === 1) { doFunction(Elements); console.log("%c已为 All[" + index + "] " + cssString + " 进行了操作", settings.fontStyle.ok); } else if (document.readyState !== "complete" || waitMS > 0) { console.log("正在查找 All[" + index + "] " + cssString); // TODO 10毫秒约函数执行时间 setTimeout(function () { return doElements(cssString, doFunction, document.readyState !== "complete" ? waitMS : waitMS - 10 - settings.getElementTimes, index); }, settings.getElementTimes); } else { console.error("未找到 All[" + index + "] " + cssString); } } function forElements(cssString, doFunction, waitMS = 0, failFunction = null) { let forElementInterval = setInterval(function () { if (document.readyState !== "complete" || waitMS > 0) { let Elements = document.querySelectorAll(cssString); if (Elements && Elements.length > 0 && Elements[0].nodeType === 1) { doFunction(Elements, forElementInterval); console.log("%cforElements已为 " + cssString + " 进行了操作", settings.fontStyle.ok); } if (document.readyState === "complete") { waitMS = waitMS - 10 - settings.getElementTimes; } } else { if (typeof failFunction === "function") failFunction(); console.log("已清除 forElements Interval计时器"); clearInterval(forElementInterval); } }, settings.getElementTimes); } function removeElements(ElementsStrings) { console.log("正在检测并移除 " + ElementsStrings); let removeElementsInterval = setInterval(function () { if (ElementsStrings.length > 0) { for (let i in ElementsStrings) { try { let Elements = eval(ElementsStrings[i]); if (Elements && Elements.nodeType === 1) { console.log("%cremoveElemets 执行了移除 " + ElementsStrings[i], settings.fontStyle.ok); Elements.remove(); ElementsStrings.splice(i, 1); } else if (Elements[0] && Elements[0].nodeType === 1) { console.log("%cremoveElemets 执行了移除 " + ElementsStrings[i], settings.fontStyle.ok); for (let Element of Elements) { Element.remove(); } ElementsStrings.splice(i, 1); } } catch (e) { // 排除 null值未找到方法 错误 } } if (document.readyState === "complete") { console.error("removeElemets 移除失败 " + ElementsStrings); clearInterval(removeElementsInterval); } } else { clearInterval(removeElementsInterval); console.log("Elements 移除完毕"); } }, 200); } if (window === top) { // 自定义pull方法(与push相对) Array.prototype.pull = function (...items) { let result = {removed: [], failed: []}; for (const item of items) { let index = this.indexOf(item); if (index !== -1) { result.removed.push(this.splice(index, 1)[0]); } else { result.failed.push(item); } } if (!result.removed) delete result.removed; if (!result.failed) delete result.failed; return result; }; top.addEventListener("message", function (event) { if (event.source !== window) { try { let sql = settings.key.decrypt(event.data).split("\x00"); switch (sql[0]) { case "宝塔镇河妖": switch (sql[1]) { case "函数": // console.log("top执行了函数: " + sql[2]); eval(sql[2]); break; case "请求": switch (sql[2]) { case "用户数据库": event.source.postMessage(settings.key.encrypt("天王盖地虎\x00给予\x00用户数据库\x00" + JSON.stringify(settings.parseDB)), "*"); break; } break; case "给予": if (settings.address !== null) { switch (sql[2]) { case "0": settings.address.push(sql[3]); break; case "-1": settings.address.pull(sql[3]); if (settings.address.length === 0) { settings.randomSeleceParse(); } break; case "1": settings.address = null; localStorage.setItem('parse.historyParse', settings.src); break; } } break; case "按下Enter获取焦点": event.source.focus(); onkeydown = function (e) { if (e.key === 'Enter') { event.source.focus(); } }; break; } break; } } catch (e) { // 排除 sql 处理错误 } } }, true); if (!isMobile) { if (location.host.indexOf("v.qq.com") !== -1) { readyPlayerBox("腾讯视频", ["#mask_layer", ".mod_vip_popup,div.panel-tip-pay", "#mask_layer", "div.thumbplayer-barrage"], settings.Default解析["腾讯视频"]["电脑端"], "div#player,div.panel-tip-pay.panel-tip-pay-video", null); } else if (location.host.indexOf("iqiyi.com") !== -1) { doElement("div.side-cont.tvg", function () { return readyPlayerBox("爱奇艺", ["#playerPopup", "div[class^=qy-header-login-pop]"], settings.Default解析["爱奇艺"]["电脑端"], "iqpdiv.iqp-player[data-player-hook$=er]", null); }); } else if (location.host.indexOf("youku.com") !== -1) { readyPlayerBox("优酷视频", ["#iframaWrapper"], settings.Default解析["优酷视频"]["电脑端"], "div#player", null); } else if (location.host.indexOf("bilibili.com") !== -1) { doElements("div[role=tooltip]:not([class*=popover-])", function (loginTip) { return displayNone(["#" + loginTip[6].id]); }, 1000, 6); doElement("div.bpx-player-video-area,svg[aria-hidden=true],div.list-wrapper.simple>ul.clearfix", function () { return readyPlayerBox("哔哩哔哩", ["div.login-panel-popover,div.vip-panel-popover", "div.login-tip"], settings.Default解析["哔哩哔哩"]["电脑端"], "div.bpx-player-video-area,div.mask-container,div#player_module", null); }); // TODO || document.getElementById("bilibiliPlayer") || document.getElementById("live-player-ctnr") } else if (location.host.indexOf("miguvideo.com") !== -1) { readyPlayerBox("咪咕视频", null, settings.Default解析["咪咕视频"]["电脑端"], "section#mod-player", null); } else if (location.host.indexOf("le.com") !== -1) { readyPlayerBox("乐视TV", null, settings.Default解析["乐视TV"]["电脑端"], "#le_playbox", null); } else if (location.host.match(new RegExp("(?:tv|film)\\.sohu\\.com"))) { readyPlayerBox("搜狐视频", null, settings.Default解析["搜狐视频"]["电脑端"], "#player,#sohuplayer,.player-view", null); } else if (location.host.indexOf("mgtv.com") !== -1) { readyPlayerBox("芒果TV", null, settings.Default解析["芒果TV"]["电脑端"], "#mgtv-player-wrap", null); } else if (location.host.indexOf("ixigua.com") !== -1) { readyPlayerBox("西瓜视频", null, settings.Default解析["西瓜视频"]["电脑端"], "div.teleplayPage__playerSection", null); } else if (location.host.indexOf("pptv.com") !== -1) { readyPlayerBox("PPTV", null, settings.Default解析["PPTV"]["电脑端"], "div.w-video", null); } else if (location.host.indexOf("1905.com") !== -1) { readyPlayerBox("1905电影网", null, settings.Default解析["1905电影网"]["电脑端"], "div#playBox,div.mplayer", null); } else if (location.host.indexOf("www.wasu.cn") !== -1) { readyPlayerBox("华数TV", null, settings.Default解析["华数TV"]["电脑端"], "div#pcplayer", null); } } else { if (location.host.indexOf("v.qq.com") !== -1) { readyPlayerBox("腾讯视频", [".mod_vip_popup", "[class^=app_],[class^=app-],[class*=_app_],[class*=-app-],[class$=_app],[class$=-app]", "div[dt-eid=open_app_bottom]", "div.video_function.video_function_new", "a[open-app]", "section.mod_source", "section.mod_box.mod_sideslip_h.mod_multi_figures_h,section.mod_sideslip_privileges,section.mod_game_rec", "div#vipPosterContent"], settings.Default解析["腾讯视频"]["手机端"], "div.mod_play:not([style*='display: none;']) section.mod_player>div#player,div.player", null, function (href) { let location = hrefToLocation(href); href = searchToJSON(location.search); if (href) { if (href["cid"]) { if (href["id"]) { return location.protocol + '//v.qq.com/detail/' + href["cid"][0] + '/' + href["cid"] + '.html'; } else if (href["vid"]) { return location.protocol + '//v.qq.com/x/cover/' + href["cid"] + '/' + href["vid"] + '.html'; } else { return location.protocol + '//v.qq.com/x/cover/' + href["cid"] + '.html'; } } else if (href["vid"]) { return location.protocol + '//v.qq.com/x/page/' + href["vid"] + '.html'; } else if (href["lid"]) { return location.protocol + '//v.qq.com/detail/' + href["lid"][0] + '/' + href["lid"] + '.html'; } else { return null; } } else { return null; } }); } else if (location.host.indexOf("iqiyi.com") !== -1) { ready(function () { readyPlayerBox("爱奇艺", ["div.m-iqyGuide-layer", "a[down-app-android-url]", "[name=m-extendBar]", "[class*=ChannelHomeBanner]", "section.m-hotWords-bottom"], settings.Default解析["爱奇艺"]["手机端"], "div.m-video-player-wrap", null) }, "complete"); } else if (location.host.indexOf("youku.com") !== -1) { readyPlayerBox("优酷视频", ["#iframaWrapper", ".ad-banner-wrapper", ".h5-detail-guide,.h5-detail-vip-guide,[class$=ad],.Corner-container", "[data-spm='downloadApp'],.downloadApp", ".callEnd_box"], settings.Default解析["优酷视频"]["手机端"], "#player", null); } else if (location.host.indexOf("bilibili.com") !== -1) { readyPlayerBox("哔哩哔哩", ["div.fe-ui-open-app-btn,div.recom-wrapper,open-app-btn", "[class*=openapp]", "div.player-wrapper>div.player-mask.relative"], settings.Default解析["哔哩哔哩"]["手机端"], "div#app.main-container div.player-wrapper>div.player", null, function (href) { return href.replace("m.bilibili.com", "www.bilibili.com"); }); } else if (location.host.indexOf("miguvideo.com") !== -1) { readyPlayerBox("咪咕视频", ["[class^=app_],[class^=app-],[class*=_app_],[class*=-app-],[class$=_app],[class$=-app]", ".openClient", "div.group-item.programgroup .data-rate-01,div.group-item.programgroup .max-rate-01,div.group-item.programgroup .p-common"], settings.Default解析["咪咕视频"]["手机端"], "section#mod-player", null, function (href) { return href.replace("m.miguvideo.com", "www.miguvideo.com").replace("msite", "website"); }); } else if (location.host.indexOf("le.com") !== -1) { (function (block_show) { block_show.innerHTML = "div.layout{visibility: visible !important; display:block !important;}div.layout>*:not(style,script,#j-vote,#j-follow){visibility: visible !important; display: block !important;}"; document.head.insertBefore(block_show, document.head.firstChild); })(document.createElement("style")); doElement("a.j-close-gdt", function (jump_over) { jump_over.click(); return false; }); readyPlayerBox("乐视TV", ["a.leapp_btn", "div.full_gdt_bits[id^=full][data-url]", "[class*=Daoliu],[class*=daoliu],[class*=game]", "div.m-start", "[class*=icon_user]"], settings.Default解析["乐视TV"]["手机端"], "div.column.play", null); } else if (location.host.indexOf("m.tv.sohu.com") !== -1) { readyPlayerBox("搜狐视频", ["div[class^=banner]", "div.js-oper-pos", "div[id^=ad],div[id^=ad] *", "[id*=login],[class*=login]", "[class$=-app]", "div.app-vbox.ph-vbox,div.app-vbox.app-guess-vbox", "div.twinfo_iconwrap", "div[class$=banner],div[id$=banner]"], settings.Default解析["搜狐视频"]["手机端"], "#player,#sohuplayer,.player-view", null, async function (href) { return await new Promise(function (resolve) { xmlHttpRequest({ method: "GET", url: href, onload: function ({responseText}) { let result = responseText.match(new RegExp("var videoData = \{[^\x00]+tvUrl:\"(http.+)\",[\\r\\n]"))[1]; resolve(result); }, error: function () { return resolve(href); } }); }); }); } else if (location.host.indexOf("mgtv.com") !== -1) { readyPlayerBox("芒果TV", ["div.adFixedContain,div.ad-banner,div.m-list-graphicxcy.fstp-mark", "div[class^=mg-app],div#comment-id.video-comment div.ft,div.bd.clearfix,div.v-follower-info", "div.ht.mgui-btn.mgui-btn-nowelt", "div.personal", "div[data-v-41c9a64e]"], settings.Default解析["芒果TV"]["手机端"], "div.video-poster,div.video-area", null); } else if (location.host.indexOf("ixigua.com") !== -1) { readyPlayerBox("西瓜视频", ["div.xigua-download", "div.xigua-guide-button", "div.c-long-video-recommend.c-long-video-recommend-unfold"], settings.Default解析["西瓜视频"]["手机端"], "div.xigua-detailvideo-video", null); } else if (location.host.indexOf("pptv.com") !== -1) { readyPlayerBox("PPTV", ["[data-darkreader-inline-bgimage][data-darkreader-inline-bgcolor]", "div[class^=pp-m-diversion]", "section#ppmob-detail-picswiper", "section.layout.layout_ads", "div.foot_app", "div[modulename=导流位]", "a[class*=user]", "div.mod_video_info div.video_func"], settings.Default解析["PPTV"]["手机端"], "section.pp-details-video", null, function (href) { return href.replace("m.pptv.com", "v.pptv.com"); }); } else if (location.host.indexOf("1905.com") !== -1) { (function (movie_info) { movie_info.innerHTML = "section#movie_info{padding-top: 20px !important;}"; document.head.appendChild(movie_info); })(document.createElement("style")); readyPlayerBox("1905电影网", ["a.new_downLoad[target=_blank]", "iframe[srcdoc^='" + name + ""; } for (let name in settings.AD解析) { DIY_iframe_select.innerHTML += ""; } DIY_iframe_select.addEventListener("change", function (event) { settings.src = DIY_iframe_select.value; if (event.isTrusted) { // 预先设置历史解析源(用于适配不支持iframe执行脚本的浏览器) localStorage.setItem('parse.historyParse', settings.src); } }); settings.randomSeleceParse = function (message) { // arguments 代表输入的所有参数,看不懂可以百度搜索 “js 参数 arguments” // return arguments ? arguments[Math.floor(Math.random() * arguments.length)] : null; if (srcs.length > 0) { showTip(message ? message : "解析失败,正在切换解析源"); let random = Math.floor(Math.random() * srcs.length); settings.src = srcs.splice(random, 1)[0]; } else if (others) { showTip(message ? message : "解析失败,正在尝试其他解析源"); srcs = others; others = null; let random = Math.floor(Math.random() * srcs.length); settings.src = srcs.splice(random, 1)[0]; } else { showTip("该视频可能无法解析\n请尝试使用⚠广告解析\n如有疑问请反馈"); return false; } return true; }; (function () { const DIY_iframe_button = settings.toolsBar.querySelector("button"); settings.DIY_iframeFunction = function () { if (settings.parseDB.DIY解析栏 && DIY_iframe_select.style.display === "none") { DIY_iframe_select.style.display = DIY_iframe_select.style.visibility = ""; DIY_iframe_button.style.borderRadius = "0px 15px 15px 0px"; } else if (!settings.parseDB.DIY解析栏 && DIY_iframe_select.style.display !== "none") { DIY_iframe_select.style.display = "none"; DIY_iframe_select.style.visibility = "hidden"; DIY_iframe_button.style.borderRadius = "15px"; } } settings.DIY_iframeFunction(); const toolsBarSettings = settings.toolsBar.querySelector("settings"); toolsBarSettings.insertBefore(DIY_iframe_select, toolsBarSettings.firstChild); })(); })(document.createElement("select")); // 获取历史解析 settings.src = localStorage.getItem("parse.historyParse"); if (!settings.src) { settings.randomSeleceParse("正在引入解析源"); } playerBox.style.zIndex = "1"; playerBox.appendChild(iframe); console.log("%cplayerBox已建立解析连接", settings.fontStyle.max); setInterval(function () { let newPlayerBox = document.querySelector(cssString); if (newPlayerBox !== null && (newPlayerBox !== playerBox || newPlayerBox.querySelector("iframe[src='" + iframe.src + "']") === null)) { console.log("playerBox重新建立连接"); let src = iframe.src; iframe.src = ""; iframe = iframe.cloneNode(true); iframe.src = src; newPlayerBox.style.zIndex = "1"; newPlayerBox.appendChild(iframe); } }, settings.getElementTimes); function closeOldMedia() { Object.getOwnPropertyNames(top).forEach(function (property) { if (typeof window[property] === "function" && Boolean(window[property].prototype) && typeof window[property].prototype.addSourceBuffer === "function") { const $addSourceBuffer = window[property].prototype.addSourceBuffer; window[property].prototype.addSourceBuffer = function addSourceBuffer(mime) { if (window === top) { this.removeSourceBuffer($addSourceBuffer.call(this, mime)); return null; } else { return $addSourceBuffer.call(this, mime); } }; } }); for (const node of playerBox.querySelectorAll("*")) { if (node !== iframe) { node.addEventListener("loadeddata", function () { node.src = URL.createObjectURL(new Blob(new Array(0))); }, true); node.src = URL.createObjectURL(new Blob(new Array(0))); node.remove(); } } } // closeOldMedia(); // if (document.readyState.toLowerCase() != "complete") ready(closeOldMedia, "complete"); setInterval(function () { closeOldMedia(); }, 3000); if (doFunction) { doFunction(playerBox, iframe); } setInterval(function () { for (let other_iframe of document.querySelectorAll("iframe")) { if (other_iframe.src !== iframe.src || other_iframe.constructor.name !== iframe.constructor.name) { other_iframe.remove(); } } if (iframe.getAttribute("style") !== iframe_style) { iframe.setAttribute("style", iframe_style); } }, settings.getElementTimes); ['fullscreenchange', 'webkitfullscreenchange', 'mozfullscreenchange'].forEach(function (item) { window.addEventListener(item, function () { if (document.fullScreen || document.mozFullScreen || document.webkitIsFullScreen) { settings.toolsBar.style.display = 'none'; } else { settings.toolsBar.style.display = 'block'; } }, true); }); }); } } else { console.log(location.href + " 1ok"); function setParseVideo() { console.log(location.href + " 2ok"); forElements("video", async function (videos, thisInterval) { for (const video of videos) { if (video.poster) video.removeAttribute("poster"); if (video.src && video.duration > 7) { // 清除监听video计时器 clearInterval(thisInterval); // console.log("解析成功,清空解析列表缓存"); top.postMessage(settings.key.encrypt("宝塔镇河妖\x00给予\x001"), "*"); top.postMessage(settings.key.encrypt("宝塔镇河妖\x00按下Enter获取焦点"), "*"); // console.log("移除广告模块"); removeElements(['document.getElementById("ADplayer")', 'document.getElementById("ADtip")']); // console.log("等待数据得到响应,移除弹幕模块"); settings.parseDB = await settings.parseDB; if (!settings.parseDB.弹幕开关) { // console.log("正在移除弹幕功能"); removeElements(['document.querySelector("div[class$=player-video-wrap]").getElementsByTagName("div")', 'document.querySelector("div[class$=player-danmu]")', 'document.querySelector("div[class$=player-danmaku]")', 'document.querySelector("div[class*=player-comment-box]")', 'document.querySelector("div[class*=player-controller-mask]")', 'document.querySelector("[class*=player-list-icon]")', 'document.querySelector("div[class$=player-menu]")']); } (function () { video.loop = false; video.autopictureinpicture = true; const playbackRate = localStorage.getItem("parse.playbackRate"); if (playbackRate) { video.playbackRate = parseFloat(playbackRate); const playbackRateElement = document.querySelector("[class*=speeds] [class*=layer-label].title"); if (video.playbackRate !== 1 && playbackRateElement !== null) playbackRateElement.innerText = playbackRate + "x"; } video.addEventListener("ratechange", function () { localStorage.setItem("parse.playbackRate", video.playbackRate.toString()); }); })(); // console.log("进入/退出 全屏"); const openFullscreen = HTMLVideoElement.prototype.RequestFullScreen ? HTMLVideoElement.prototype.RequestFullScreen : //兼容Firefox HTMLVideoElement.prototype.mozRequestFullScreen ? HTMLVideoElement.prototype.mozRequestFullScreen ://兼容Chrome, Safari and Opera等 HTMLVideoElement.prototype.webkitRequestFullScreen ? HTMLVideoElement.prototype.webkitRequestFullScreen : //兼容IE/Edge HTMLVideoElement.prototype.msRequestFullscreen; const exitFullscreen = document.exitFullScreen ? document.exitFullScreen : //兼容Firefox document.mozCancelFullScreen ? document.mozCancelFullScreen : //兼容Chrome, Safari and Opera等 document.webkitExitFullscreen ? document.webkitExitFullscreen : //兼容IE/Edge document.body.msExitFullscreen; const getFullscreenElement = typeof document.fullscreenElement !== "undefined" ? function () { return document.fullscreenElement; } : typeof document.mozFullScreenElement !== "undefined" ? function () { return document.mozFullScreenElement; } : typeof document.msFullScreenElement !== "undefined" ? function () { return document.msFullScreenElement; } : function () { return document.webkitFullscreenElement; }; let fullscreen = (function (node) { return function (value) { if (typeof value === "undefined" ? Boolean(getFullscreenElement()) : !value) { exitFullscreen.apply(document); } else { openFullscreen.apply(node); } video.focus(); }; })(isMobile ? video : document.body); video.addEventListener("pause", function () { if ((video.currentTime - video.duration) > -5) { // console.log("视频播放结束了"); fullscreen(false); } }); if (!isMobile) { (function () { const fullscreen_btn = document.querySelector("[class*=fullscreen][class*=On],[class$=player-full] button[class$=full-icon]"); if (fullscreen_btn && fullscreen_btn.nodeType === 1) { fullscreen = function (value) { if (typeof value === "undefined") { fullscreen_btn.click(); } else if (value && !Boolean(getFullscreenElement())) { fullscreen_btn.click(); } else if (!value && Boolean(getFullscreenElement())) { fullscreen_btn.click(); } }; } })(); (function (isFullscreen) { window.addEventListener("keydown", function (event) { if (event.key === "Enter") { isFullscreen = Boolean(getFullscreenElement()); } }, true); window.addEventListener("keyup", function (event) { if (event.key === "Enter") { if (isFullscreen === Boolean(getFullscreenElement())) { fullscreen(); if (video.paused) { video.play(); } } } }, false); })(); showTip("回车,进入全屏播放"); } else { showTip("解析成功"); } fullscreen(settings.parseDB.自动全屏); if (video.paused) { video.play(); } } } }, 5000, function () { console.log(location.href + " 3ok"); top.postMessage(settings.key.encrypt("宝塔镇河妖\x00给予\x00-1\x00" + location.href), "*"); }); } if (location.host.indexOf("jiexi.t7g.cn") !== -1) { // 移除爱解析p2p提示 displayNone(["body>div#stats"]); setParseVideo(); } else if (location.host.indexOf("api.okjx.cc:3389") !== -1) { // 删除OK解析线路选择功能 (function (style) { style.innerHTML = ".slide,.panel,.slide *,.panel *{width: 0 !important; max-width: 0 !important; opacity: 0 !important;}"; document.head.appendChild(style); })(document.createElement("style")); setParseVideo(); } else if (location.host.indexOf("api.jiubojx.com") !== -1) { displayNone("div.adv_wrap_hh"); setParseVideo(); } else if (location.host.indexOf("yemu.xyz") !== -1) { if (location.pathname.indexOf("jx.php") === -1) { if (location.host.indexOf("www.yemu.xyz") !== -1) { // 删除夜幕解析线路选择功能 (function (style) { style.innerHTML = ".slide,.panel,.slide *,.panel *{width: 0 !important; max-width: 0 !important; opacity: 0 !important;}"; document.head.appendChild(style); })(document.createElement("style")); } else if (location.host.indexOf("jx.yemu.xyz") !== -1) { // 移除视频分类提示 及 解析框架处理 displayNone(["div.advisory"]); setParseVideo(); } } else { // 移除背景图片 doElement("div[style*='width:100%;height:100%;'][style*='.jpg']", function (background) { background.setAttribute("style", "width:100%; height:100%; position:relative; z-index:2147483647987;"); }, 5000); } } else if (location.host.indexOf('www.mtosz.com') !== -1) { displayNone([".video-panel-blur-image"]); // 似乎不管用? doElement(".video-panel-blur-image", function (element) { element.setAttribute("style", "display: none; height: 0; width: 0;"); }); setParseVideo(); } else if (location.host.indexOf('v.superchen.top:3389') !== -1) { setParseVideo(); } else if (location.host.indexOf('jx.parwix.com:4433') !== -1) { setParseVideo(); } else { setParseVideo(); } } function displayNone(Tags) { setTimeout(function () { let style = document.createElement("style"); style.innerHTML = "\n"; for (let i = 0; i < Tags.length; i++) { style.innerHTML += Tags[i] + "{display: none !important; height: 0 !important; width: 0 !important; visibility: hidden !important; max-height: 0 !important; max-width: 0 !important; opacity: 0 !important;}\n"; } document.head.insertBefore(style, document.head.firstChild); }); } } function showTip(msg, style = "") { try { // 该函数需要在top内运行,否则可能显示异常 if (window === top) { let tip = document.querySelector(":root>tip"); if (tip && tip.nodeType === 1) { // 防止中途新的showTip事件创建多个tip造成卡顿 tip.remove(); } tip = document.createElement("tip"); // pointer-events: none; 禁用鼠标事件,input标签使用 disabled='disabled' 禁用input标签 tip.setAttribute("style", style + "pointer-events: none; opacity: 0; background-color: #222a; color: #fff; font-family: 微软雅黑,黑体,Droid Serif,Arial,sans-serif; font-size: 20px; text-align: center; padding: 6px; border-radius: 16px; position: fixed; transform: translate(-50%, -50%); left: 50%; bottom: 15%; z-index: 2147483647;"); tip.innerHTML = "\n" + msg; let time = msg.replace(new RegExp("\\s"), "").length / 2; // TODO 2个字/秒 // cubic-bezier(起始点, 起始点偏移量, 结束点偏移量, 结束点),这里的 cubic-bezier函数 表示动画速度的变化规律 tip.style.animation = "showTip " + (time > 2 ? time : 2) + "s cubic-bezier(0," + ((time - 1) > 0 ? (time - 1) / time : 0) + "," + (1 - ((time - 1) > 0 ? (time - 1) / time : 0)) + ",1) 1 normal"; document.root.appendChild(tip); setTimeout(function () { try { tip.remove(); } catch (e) { // 排除root没有找到tip } }, time * 1000); } else { top.postMessage(settings.key.encrypt("宝塔镇河妖\x00函数\x00showTip('" + msg + "')"), "*"); } } catch (e) { console.log(msg); } } })(); function require(url) { const request = new XMLHttpRequest(); let result; request.open("GET", url, false); request.onload = function () { result = eval(request.response); console.log("use-scrypt.length = " + request.response.length); }; request.send(); return result; } })();