视频v3-自用-自动解析

无需跳转新网址,打开官网直接看,如有侵权请联系作者删除

  1. // ==UserScript==
  2. // @name 视频v3-自用-自动解析
  3. // @namespace https://www.tampermonkey.net/
  4. // @version 2.09
  5. // @license AGPL-3.0
  6. // @description 无需跳转新网址,打开官网直接看,如有侵权请联系作者删除
  7. // @author Tenfond
  8. // @match *
  9. // @include *
  10. // @grant none
  11. // @run-at document-body
  12. // ==/UserScript==
  13. /**
  14. * 任务清单:
  15. * 解析源更换优化,无推荐时,使用备用解析源
  16. * 更新 仅解析VIP 功能
  17. */
  18. // 有任何问题都可以联系我邮箱 tenfond@outlook.com
  19. // 读取配置后执行
  20. function readSettings() {
  21. // 获取框架循环时间,CPU性能好的可以设置为100,CPU性能不好的可以设置为1000
  22. settings.getElementTimes = 500;
  23. // log输出字体布局
  24. settings.fontStyle = {
  25. error: "font-family: 微软雅黑,黑体,Droid Serif,Arial,sans-serif; color: #f00;",
  26. warn: "font-family: 微软雅黑,黑体,Droid Serif,Arial,sans-serif; color: #ff0;",
  27. ok: "font-family: 微软雅黑,黑体,Droid Serif,Arial,sans-serif; color: #0f0;",
  28. maxTip: "font-family: 微软雅黑,黑体,Droid Serif,Arial,sans-serif; font-size: 30px; background-color: #222; text-shadow: 0px 0px 12px #fff; color: #fff;"
  29. };
  30. if (window === top) {
  31. /*
  32. * (): 小括号括住的表示推荐解析 画质高 速度快
  33. * : 无括号的表示视频带水印 或 原页面画质
  34. * []: 方括号表示标清画质 不推荐
  35. */
  36. settings.NoAD解析 = { // TODO by 17kyun.com/api.php?url= // TODO by tv.hzwdd.cn
  37. // 你可以在这里定义自己的解析接口,脚本会自动适配。格式如下:
  38. // "解析名称": "解析接口的链接", // TODO 注意 : 和 " 以及 , 都是英文的符号。
  39. "B站综合": "https://jx.jsonplayer.com/player/?url=" || "https://jx.playerjy.com/?url=", // TODO 腾讯 (芒果)
  40. "NNXV": "https://jx.xmflv.com/?url=" || "https://jx.nnxv.cn/tv.php?url=", // TODO 腾讯 (芒果)
  41. "OK解析": "https://api.okjx.cc:3389/jx.php?url=" || "https://okjx.cc/?url=" || "https://okjx.cc/?url=",
  42. "爱豆": "https://jx.aidouer.net/?url=" || "https://www.yemu.xyz/?url="
  43. };
  44. settings.AD解析 = { // TODO (有赌博广告,请勿相信,这么简单的骗术不会有人上当吧)
  45. "m1907解析": "https://z1.m1907.cn/?jx=",
  46. "plyaerjy解析": "https://jx.playerjy.com/?url=" // TODO (B站)
  47. };
  48. start();
  49. } else if (settings.isParse) {
  50. top.postMessage(key.ENCRYPT("宝塔镇河妖\x00给予\x000\x00" + location.href, settings.k1, settings.k2), "*");
  51. Object.defineProperty(console, "clear", {
  52. value: () => console.log("%c禁止清除控制台", settings.fontStyle.error), writable: false
  53. });
  54. settings.parseDB = new Promise(resolve => {
  55. window.addEventListener("message", event => {
  56. if (event.source !== window) {
  57. try {
  58. let sql = key.DECRYPT(event.data, settings.k1, settings.k2).split("\x00");
  59. if (sql[0] === "天王盖地虎") {
  60. if (sql[1] === "给予") {
  61. if (sql[2] === "用户数据库") {
  62. resolve(JSON.parse(sql[3]));
  63. }
  64. }
  65. }
  66. } catch (e) {
  67. // 排除 下标越界错误 及 指令处理错误
  68. }
  69. }
  70. });
  71. });
  72. // 需要先监听再发送数据
  73. top.postMessage(key.ENCRYPT("宝塔镇河妖\x00请求\x00用户数据库", settings.k1, settings.k2), "*");
  74. start();
  75. }
  76. }
  77. // 未经许可禁止抄袭算法,可以私用。
  78. const key = (() => {
  79. // 新方案定义私有变量。修复部分浏览器不支持 # 定义private私有变量
  80. const password = Symbol();
  81. const randomkey = Symbol();
  82. // 自定义加密算法,以防数据包被破解。
  83. class key {
  84. // _pwd; // 火狐v68版本貌似不支持这种方式声明变量。
  85. constructor(pwd = null) {
  86. // num,密码偏移量
  87. // key,排列长度偏移量
  88. // charCode,防止内存频繁运动,定义在外部
  89. let num = 7, charCode, key = 7;
  90. if (pwd) {
  91. if (typeof pwd === "string") {
  92. for (let i = 0; i < pwd.length; i++) {
  93. // 将pwd中 每个字 转换成 十进制ASCII值
  94. charCode = pwd[i].charCodeAt();
  95. // 将每个 ASCII值 中 第一个值加入到 排列长度偏移量
  96. key += parseInt(charCode.toString()[0]);
  97. // 用 hash算法 将 ASCII值 减去 31 作为新的值加入到num中
  98. // 以下方法是为了防止出现负数,ASCII字符集一共有65536个字符
  99. // num += charCode - 31 => (charCode + 65505) % 65536
  100. num = 31 * num + (charCode + 65505) % 65536;
  101. }
  102. } else if (typeof pwd === "number") {
  103. // 如果密码是数值型就使用此方法作为 密码偏移量 和 排列长度偏移量
  104. num = key = 7 + parseInt(Math.abs(pwd));
  105. } else {
  106. // 如果类型不匹配就直接提出错误
  107. console.error("Unsupported type '" + (typeof pwd) + "'. It only supports 'string' or 'numbers'.")
  108. }
  109. }
  110. // 让排列长度偏移量的转换成8进制,取第一个数字。加上密码转换成字符字符串的方式。数值+字符串 会将数值自动转换为字符串
  111. this[password] = key.toString(8)[0] + (num % 65536).toString();
  112. }
  113. encrypt(string) {
  114. if (string) {
  115. // subStart 排列长度的起始位置。subIndex 排列长度。 encryptPool 加密池,即去除的排列长度存放在这里。result 加密后的结果。
  116. let subStart = string.length, subIndex = parseInt(this[password][0]) + 3, encryptPool = [], result = "";
  117. // stringKey 加密字符偏移量的散列值的的个数。
  118. let stringKey = subStart + parseInt(this[password].substring(1));
  119. // stringKeyFloat 加密字符偏移量的偏移单位。stringKeyIndex 加密字符偏移量的位置
  120. let stringKeyFloat = 65536 / stringKey, stringKeyIndex = stringKey - 1;
  121. // 获取加密池。
  122. while (subStart > subIndex) {
  123. subStart -= subIndex;
  124. encryptPool.push(string.substr(subStart, subIndex));
  125. }
  126. encryptPool.push(string.substring(0, subStart));
  127. // 对加密池进行加密,并将加密的字符的结果放入 result 中。
  128. for (let i = 0, j; i < subIndex; i++) {
  129. for (j = 0; j < encryptPool.length; j++) {
  130. let char = encryptPool[j][i];
  131. if (char) {
  132. // 将字符的 ASCII值 偏移 指定量
  133. result += String.fromCharCode((char.charCodeAt() + parseInt(stringKeyFloat * (stringKeyIndex % 2 === 0 ? stringKeyIndex : stringKey - stringKeyIndex))) % 65536);
  134. stringKeyIndex = stringKeyIndex === 0 ? stringKey - 1 : stringKeyIndex - 1;
  135. } else {
  136. break;
  137. }
  138. }
  139. }
  140. // 返回加密结果
  141. return result;
  142. } else {
  143. // 如果加密字符串不存在就返回空字符串
  144. return "";
  145. }
  146. }
  147. /* 假设有7个字符
  148. 加密前 - 排列
  149. ( 1 ) ( 2 3 ) ( 4 5 ) ( 6 7 )
  150. 加密中 - 排列
  151. ︵ ︵ ︵ ︵
  152. 6 4 2 1
  153. 7 5 3 ︶
  154. ︶ ︶ ︶
  155. 加密后 - 排列
  156. ( 6 4 2 1 ) ( 7 5 3 )
  157. 解密中 - 排列
  158. ︵ ︵
  159. 6 7
  160. 4 5
  161. 2 3
  162. 1 ︶
  163. 解密后 - 排列
  164. 1 2 3 4 5 6 7 8
  165. */
  166. decrypt(string) {
  167. if (string) {
  168. // subStart 排列长度的起始位置。desubIndex 反向取加密池的长度。 decryptPool 解密池。
  169. let subStart = 0, desubIndex = Math.ceil(string.length / (parseInt(this[password][0]) + 3)),
  170. //NullCount 加密池中最后一个元素的元素空位。 desubIndex 反向取加密池的长度。 decryptPool 解密池,result 解密后的结果。
  171. NullCount = string.length % (parseInt(this[password][0]) + 3), decryptPool = [], result = "";
  172. // stringKey 加密字符偏移量的散列值的的个数。
  173. let stringKey = string.length + parseInt(this[password].substring(1)), // stringKeyFloat 加密字符偏移量的偏移单位。stringKeyIndex 加密字符偏移量的位置
  174. stringKeyFloat = 65536 / stringKey, stringKeyIndex;
  175. // 获取解密池
  176. while (string.length - subStart > desubIndex) {
  177. decryptPool.push(string.substr(subStart, desubIndex));
  178. subStart += desubIndex;
  179. if (decryptPool.length === NullCount) {
  180. desubIndex--;
  181. }
  182. }
  183. decryptPool.push(string.substring(subStart));
  184. // 对解密池进行解密 并将解密结果 加入到 result(结果) 中
  185. for (let j = decryptPool[0].length - 1, i; j > -1; j--) {
  186. // 为节省NullCount的空间利用,使用NullCount用来辅助计算 stringKeyIndex(加密字符偏移量的位置) 的位置
  187. // 画图排列就知道为什么要这样做了,上面做了一个加密到解密的排列的草图
  188. NullCount = 0;
  189. for (i = 0; i < decryptPool.length; i++) {
  190. let char = decryptPool[i][j];
  191. if (char) {
  192. NullCount += decryptPool[i].length;
  193. // 计算得到当前字符的位置
  194. stringKeyIndex = NullCount - decryptPool[i].length + j + 1;
  195. // 计算得到 stringKeyIndex(加密字符偏移量的位置) 的位置
  196. stringKeyIndex = (stringKey - stringKeyIndex % stringKey) % stringKey;
  197. // 让加密后的偏移量,偏移回去,得到原先的字符串
  198. result += String.fromCharCode((char.charCodeAt() - parseInt(stringKeyFloat * (stringKeyIndex % 2 === 0 ? stringKeyIndex : stringKey - stringKeyIndex)) + 65536) % 65536);
  199. }
  200. }
  201. }
  202. // 返回解密结果
  203. return result;
  204. } else {
  205. // 如果解密字符串不存在就返回空字符串
  206. return "";
  207. }
  208. }
  209. // encrypt 既可以用作加密 也可以用作解密,decrypt 既可以用作解密 也可以用作加密。
  210. static ENCRYPT() {
  211. if (arguments) {
  212. let strings = [], keys = [];
  213. for (let i = 0; i < arguments.length; i++) {
  214. // JavaScript如何用最简单的方法获取任意对象的类名?(包括自定义类) 判断对象类型?
  215. // 欢迎支持我的原创文档 https://blog.csdn.net/qq_37759464/article/details/121764755
  216. if (arguments[i].constructor.name === "key") {
  217. keys.push(arguments[i]);
  218. } else if (arguments[i].constructor.name === "String") {
  219. strings.push(arguments[i]);
  220. }
  221. }
  222. if (strings) {
  223. if (keys) {
  224. for (let i = 0, j; i < strings.length; i++) {
  225. for (j = 0; j < keys.length; j++) {
  226. strings[i] = i % 2 === 0 ? keys[j].encrypt(strings[i]) : keys[j].decrypt(strings[i]);
  227. }
  228. }
  229. return strings.length === 1 ? strings[0] : strings;
  230. } else {
  231. if (!this[randomkey]) {
  232. this[randomkey] = new key(parseInt(Math.random() * 1024) + 3);
  233. }
  234. // 为了使加密方法不一样,这里反过来
  235. strings[i] = this[randomkey].decrypt(this[randomkey].decrypt(strings[i]));
  236. return strings.length === 1 ? strings[0] : strings;
  237. }
  238. }
  239. }
  240. }
  241. static DECRYPT() {
  242. if (arguments) {
  243. let strings = [], keys = [];
  244. for (let i = 0; i < arguments.length; i++) {
  245. if (arguments[i].constructor.name === "key") {
  246. keys.push(arguments[i]);
  247. } else if (arguments[i].constructor.name === "String") {
  248. strings.push(arguments[i]);
  249. }
  250. }
  251. if (strings) {
  252. if (keys) {
  253. for (let i = 0, j; i < strings.length; i++) {
  254. for (j = keys.length - 1; j > -1; j--) {
  255. strings[i] = i % 2 === 0 ? keys[j].decrypt(strings[i]) : keys[j].encrypt(strings[i]);
  256. }
  257. }
  258. return strings.length === 1 ? strings[0] : strings;
  259. } else {
  260. if (!this[randomkey]) {
  261. this[randomkey] = new key(parseInt(Math.random() * 1024) + 3);
  262. }
  263. strings[i] = this[randomkey].encrypt(this[randomkey].encrypt(strings[i]));
  264. return strings.length === 1 ? strings[0] : strings;
  265. }
  266. }
  267. }
  268. }
  269. }
  270. return key;
  271. })();
  272. if (navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPad/i) || navigator.userAgent.match(/iPod/i)) {
  273. // 修改手机端UA,似乎改完这个UA还是没有效果。说明苹果端页面从数据请求就开始检测UA了。请手动修改浏览器UA。
  274. Object.defineProperty(navigator, 'userAgent', {
  275. // 这个UA会屏蔽百度搜索的广告?
  276. value: "Mozilla/5.0 (Linux; Android 8.0; MI 6 Build/OPR1.170623.027; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/48.0.2564.116 Mobile Safari/537.36 T7/10.3 SearchCraft/2.6.3 (Baidu; P1 8.0.0)",
  277. writable: false
  278. });
  279. }
  280. let settings = {};
  281. const root = document.querySelector(":root");
  282. (() => {
  283. if (location.search.match(/[?&]url=https?:\/\/.+\..+\..+\/.+/i) ||
  284. location.search.match(/[?&]v=https?:\/\/.+\..+\..+\/.+/i) ||
  285. location.href.match(/https?:\/\/api\.leduotv\.com\/.+?vid=/i)) {
  286. settings.isParse = true;
  287. }
  288. if (settings.isParse || location.host.indexOf("v.qq.com") !== -1 || location.host.indexOf("iqiyi.com") !== -1 || location.host.indexOf("youku.com") !== -1 || location.host.indexOf("bilibili.com") !== -1 || location.host.indexOf("miguvideo.com") !== -1 || location.host.indexOf("le.com") !== -1 || location.host.indexOf("tv.sohu.com") !== -1 || location.host.indexOf("film.sohu.com") !== -1 || location.host.indexOf("mgtv.com") !== -1 || location.host.indexOf("ixigua.com") !== -1 || location.host.indexOf("pptv.com") !== -1 || location.host.indexOf("vip.1905.com") !== -1 || location.host.indexOf("www.wasu.com") !== -1) {
  289. // 对符合条件的域名执行脚本
  290. // 调用自写加密算法,生成实例类
  291. settings.k1 = new key("Tenfond");
  292. settings.k2 = new key(" 腾 风 ");
  293. if (window === top) {
  294. settings.parseDB = {
  295. 解析开关: "\x01", 弹幕开关: "\x01", DIY解析栏: "\x01"
  296. };
  297. for (let name in settings.parseDB) {
  298. let data = localStorage.getItem("解析数据库." + name);
  299. if (data !== null) {
  300. settings.parseDB[name] = data;
  301. }
  302. }
  303. if (settings.parseDB.解析开关) {
  304. if (!sessionStorage.getItem("tip设置")) {
  305. showTip("右下角可以编辑 设置");
  306. sessionStorage.setItem("tip设置", "\x01");
  307. }
  308. readSettings();
  309. }
  310. settings.parseDBFuntions = {
  311. 解析开关: () => {
  312. if (!settings.parseDB.解析开关) {
  313. location.reload();
  314. // window 刷新时会自动清除缓存
  315. } else {
  316. readSettings();
  317. settings.parseDB.解析开关 = "\x01";
  318. }
  319. }, 弹幕开关: () => showTip("刷新页面即可生效"), DIY解析栏: () => {
  320. if (typeof settings.DIY_iframeFunction === "function") {
  321. settings.DIY_iframeFunction();
  322. } else {
  323. showTip("设置已生效");
  324. }
  325. }
  326. };
  327. let toolsBar = document.createElement("toolsbar");
  328. toolsBar.style = "display: block !important; visibility: visible !important; position: fixed; z-index: 2147483647 !important; left:0; bottom: 0; width: 100%; height: 0; font-family: 微软雅黑,黑体,Droid Serif,Arial,sans-serif; font-size: 15px; color: #000;";
  329. toolsBar.innerHTML = "<style>\n" +
  330. " text{font-family: 微软雅黑,黑体,Droid Serif,Arial,sans-serif; font-size: 15px; color: #000; position: absolute; transform: translateY(-50%); top: 50%;}\n" +
  331. " 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" +
  332. " label.parse-switch>input[type=checkbox]{display: none;}\n" +
  333. " label.parse-switch>input[type=checkbox]+bg{position: absolute; transition: background-color 0.3s; background-color: #ccc; width: 100%; height: 100%;}\n" +
  334. " label.parse-switch>input[type=checkbox]:checked+bg{background-color: #4af}\n" +
  335. " 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" +
  336. " label.parse-switch>input[type=checkbox]:checked+bg+span{left: 20px}\n" + "\n" +
  337. " settings>button+ul>li{position: relative; background-color: #0000; width: 100%; height: 30px;}\n" +
  338. "</style>\n" + "<settings style='box-shadow: 0 0 6px 2px #444; position: fixed; width: 50px; height: 30px; right: 7%; bottom: 45px; border-radius: 15px;'>" +
  339. " <button style='width: 100%; height: 100%; border-radius: 17px; background-color: #4af; border-color: #4af; text-align: center; color: #fff;'>\n" +
  340. " 设置\n" +
  341. " </button>\n" +
  342. " <ul style='position:absolute; transition: all 0.5s; right: 7%; bottom: 100%; opacity: 0; width: 0; height: auto; background-color: #fffc; border: 1px solid #ccc; border-radius: 5px;'>\n" +
  343. " </ul>\n" +
  344. "</settings>";
  345. let SettingsBlock = toolsBar.querySelector("settings>button+ul");
  346. let parseDBKeys = Object.keys(settings.parseDB);
  347. for (let i = 0; i < parseDBKeys.length; i++) {
  348. SettingsBlock.innerHTML += "<li><text style='left: 10px'>" + parseDBKeys[i] + "</text><label class='parse-switch' style='right: 10px;'><input type='checkbox'><bg></bg><span></span></label></li>\n";
  349. }
  350. let SettingBlockSwitchs = SettingsBlock.querySelectorAll("li>label.parse-switch");
  351. for (let i = 0; i < SettingBlockSwitchs.length; i++) {
  352. let checkBox = SettingBlockSwitchs[i].querySelector("input[type=checkbox]");
  353. checkBox.checked = Boolean(settings.parseDB[parseDBKeys[i]]);
  354. SettingBlockSwitchs[i].querySelector("bg").addEventListener("transitionend", () => {
  355. if (checkBox.checked !== Boolean(settings.parseDB[parseDBKeys[i]])) {
  356. // 如果有变化才会执行,否则会重复执行,因为动画会有延迟,刚打开网页时也会出发此监听事件
  357. if (checkBox.checked) {
  358. settings.parseDB[parseDBKeys[i]] = "\x01";
  359. } else {
  360. settings.parseDB[parseDBKeys[i]] = "";
  361. }
  362. localStorage.setItem("解析数据库." + parseDBKeys[i], settings.parseDB[parseDBKeys[i]]);
  363. settings.parseDBFuntions[parseDBKeys[i]]();
  364. }
  365. }, false);
  366. }
  367. let SettingsBtn = toolsBar.querySelector("settings>button");
  368. SettingsBtn.onclick = () => {
  369. if (SettingsBlock.style.opacity === "0") {
  370. SettingsBtn.innerText = "关闭";
  371. SettingsBlock.style.opacity = "1";
  372. SettingsBlock.style.width = "200px";
  373. } else {
  374. SettingsBtn.innerText = "设置";
  375. SettingsBlock.style.opacity = "0";
  376. SettingsBlock.style.width = "0";
  377. }
  378. }
  379. root.append(toolsBar);
  380. } else {
  381. readSettings();
  382. }
  383. }
  384. })();
  385. function start() {
  386. console.log("脚本运行在 " + location.href);
  387. function detectMobile() {
  388. return (navigator.userAgent.match(/Android/i) ||
  389. navigator.userAgent.match(/webOS/i) ||
  390. navigator.userAgent.match(/Windows Phone/i) ||
  391. navigator.userAgent.match(/Symbian/i) ||
  392. navigator.userAgent.match(/BlackBerry/i) ||
  393. navigator.userAgent.match(/hpwOS/i));
  394. }
  395. function doElement(cssString, doFunction, waitMS = 0) {
  396. let Element = document.querySelector(cssString);
  397. if (Element && Element.nodeType === 1) {
  398. doFunction(Element);
  399. console.log("%c已为 " + cssString + " 进行了操作", settings.fontStyle.ok);
  400. } else if (document.readyState !== "complete" || waitMS > 0) {
  401. console.log("正在查找 " + cssString); // TODO 10毫秒约函数执行时间
  402. setTimeout(() => doElement(cssString, doFunction, document.readyState !== "complete" ? waitMS : waitMS - 10 - settings.getElementTimes), settings.getElementTimes);
  403. } else {
  404. console.log("%c未找到 " + cssString, settings.fontStyle.error);
  405. }
  406. }
  407. function doElements(cssString, doFunction, waitMS = 0, index = 0) {
  408. let Elements = document.querySelectorAll(cssString);
  409. if (Elements[index] && Elements[index].nodeType === 1) {
  410. doFunction(Elements);
  411. console.log("%c已为 All[" + index + "] " + cssString + " 进行了操作", settings.fontStyle.ok);
  412. } else if (document.readyState !== "complete" || waitMS > 0) {
  413. console.log("正在查找 All[" + index + "] " + cssString); // TODO 10毫秒约函数执行时间
  414. setTimeout(() => doElements(cssString, doFunction, document.readyState !== "complete" ? waitMS : waitMS - 10 - settings.getElementTimes, index), settings.getElementTimes);
  415. } else {
  416. console.log("%c未找到 All[" + index + "] " + cssString, settings.fontStyle.error);
  417. }
  418. }
  419. function forElement(cssString, doFunction, waitMS = 0, failFunction = null) {
  420. let forElementInterval = setInterval(() => {
  421. if (document.readyState !== "complete" || waitMS > 0) {
  422. let Element = document.querySelector(cssString);
  423. if (Element && Element.nodeType === 1) {
  424. doFunction(Element, forElementInterval);
  425. console.log("%cforElement已为 " + cssString + " 进行了操作", settings.fontStyle.ok);
  426. }
  427. if (document.readyState === "complete") {
  428. waitMS = waitMS - 10 - settings.getElementTimes;
  429. }
  430. } else {
  431. if (failFunction) {
  432. failFunction();
  433. }
  434. console.log("已清除 forElement Interval计时器")
  435. clearInterval(forElementInterval);
  436. }
  437. }, settings.getElementTimes);
  438. }
  439. function removeElements(ElementsStrings) {
  440. console.log("正在检测并移除 " + ElementsStrings);
  441. let removeElementsInterval = setInterval(() => {
  442. if (ElementsStrings.length > 0) {
  443. for (let i in ElementsStrings) {
  444. try {
  445. let Elements = eval(ElementsStrings[i]);
  446. if (Elements && Elements.nodeType === 1) {
  447. console.log("%cremoveElemets 执行了移除 " + ElementsStrings[i], settings.fontStyle.ok);
  448. Elements.parentNode.removeChild(Elements);
  449. ElementsStrings.splice(i, 1);
  450. } else if (Elements[0] && Elements[0].nodeType === 1) {
  451. console.log("%cremoveElemets 执行了移除 " + ElementsStrings[i], settings.fontStyle.ok);
  452. for (let Element of Elements) {
  453. Element.parentNode.removeChild(Element);
  454. }
  455. ElementsStrings.splice(i, 1);
  456. }
  457. } catch (e) {
  458. // 排除 null值未找到方法 错误
  459. }
  460. }
  461. } else {
  462. clearInterval(removeElementsInterval);
  463. console.log("Elements 移除完毕");
  464. }
  465. }, 200);
  466. onFirstLoad(() => {
  467. console.log("%cremoveElemets 移除失败 " + ElementsStrings, settings.fontStyle.error);
  468. clearInterval(removeElementsInterval);
  469. });
  470. }
  471. if (window === top) {
  472. // 自定义remove方法,暂时用不着了,新方案代替了
  473. // Array.prototype.remove = value => {
  474. // for (let i = 0; i < this.length; i++) {
  475. // if (this[i] === value) {
  476. // this.splice(i, 1);
  477. // return i;
  478. // }
  479. // }
  480. // return -1;
  481. // }
  482. top.addEventListener("message", event => {
  483. if (event.source !== window) {
  484. try {
  485. let sql = key.DECRYPT(event.data, settings.k1, settings.k2).split("\x00");
  486. if (sql[0] === "宝塔镇河妖") {
  487. if (sql[1] === "函数") {
  488. console.log("top执行了函数: " + sql[2]);
  489. eval(sql[2]);
  490. } else if (sql[1] === "请求") {
  491. if (sql[2] === "用户数据库") {
  492. event.source.postMessage(key.ENCRYPT("天王盖地虎\x00给予\x00用户数据库\x00" + JSON.stringify(settings.parseDB), settings.k1, settings.k2), "*");
  493. }
  494. } else if (sql[1] === "给予") {
  495. if (sql[2] === "0") {
  496. if (settings.address !== null) {
  497. settings.address = sql[3];
  498. }
  499. console.log("%c" + settings.address, settings.fontStyle.warn);
  500. } else if (sql[2] === "-1") {
  501. if (settings.address === sql[3]) {
  502. showTip("解析失败,正在更换解析源");
  503. settings.randomSeleceParse();
  504. }
  505. }
  506. } else if (sql[1] === "按下Enter获取焦点") {
  507. onkeydown = e => {
  508. if (e.key === 'Enter') {
  509. event.source.focus();
  510. }
  511. }
  512. }
  513. }
  514. } catch (e) {
  515. console.log("%c" + e, settings.fontStyle.error);
  516. }
  517. }
  518. });
  519. if (!detectMobile()) {
  520. if (location.host.indexOf("v.qq.com") !== -1) {
  521. readyPlayerBox("已进入腾讯视频", ["#mask_layer", ".mod_vip_popup", "#mask_layer"], [settings.NoAD解析["OK解析"], settings.NoAD解析["TV解析"], settings.NoAD解析["天翼解析"], settings.NoAD解析["全民解析"]], "div#mod_player", null);
  522. } else if (location.host.indexOf("iqiyi.com") !== -1) {
  523. readyPlayerBox("已进入爱奇艺", ["#playerPopup", "div[class^=qy-header-login-pop]"], [settings.NoAD解析["OK解析"]], "iqpdiv.iqp-player[data-player-hook$=er]", null);
  524. } else if (location.host.indexOf("youku.com") !== -1) {
  525. readyPlayerBox("已进入优酷视频", ["#iframaWrapper"], [], "div#player", null);
  526. } else if (location.host.indexOf("bilibili.com") !== -1) {
  527. doElements("div[role=tooltip]:not([class*=popover-])", loginTip => displayNone(["#" + loginTip[6].id]), 1000, 6);
  528. doElement("svg[aria-hidden=true]", () => readyPlayerBox("已进入哔哩哔哩", null, [settings.NoAD解析["夜幕解析"], settings.NoAD解析["天翼解析"]], "div.bpx-player-video-area,div.mask-container", null)); // TODO || document.getElementById("bilibiliPlayer") || document.getElementById("live-player-ctnr")
  529. } else if (location.host.indexOf("miguvideo.com") !== -1) {
  530. readyPlayerBox("已进入咪咕视频", null, [], "section#mod-player", null);
  531. } else if (location.host.indexOf("le.com") !== -1) {
  532. readyPlayerBox("已进入乐视TV", null, [settings.NoAD解析["云解析"]], "#le_playbox", null);
  533. } else if (location.host.match(/(tv|film).sohu.com/)) {
  534. readyPlayerBox("已进入搜狐视频", null, [settings.NoAD解析["夜幕解析"]], "#player,#sohuplayer,.player-view", null);
  535. } else if (location.host.indexOf("mgtv.com") !== -1) {
  536. readyPlayerBox("已进入芒果TV", null, [settings.NoAD解析["爱解析"], settings.NoAD解析["OK解析"], settings.NoAD解析["全民解析"], settings.NoAD解析["云解析"], settings.NoAD解析["虾米解析"], settings.NoAD解析["夜幕解析"]], "#mgtv-player-wrap", null);
  537. } else if (location.host.indexOf("ixigua.com") !== -1) {
  538. readyPlayerBox("已进入西瓜视频", null, [settings.NoAD解析["夜幕解析"]], "div.teleplayPage__playerSection", null);
  539. } else if (location.host.indexOf("pptv.com") !== -1) {
  540. readyPlayerBox("已进入PPTV", null, [settings.NoAD解析["OK解析"]], "div.w-video", null);
  541. } else if (location.host.indexOf("vip.1905.com") !== -1) {
  542. readyPlayerBox("已进入1905电影网", null, [settings.NoAD解析["云解析"]], "div#playBox", null);
  543. } else if (location.host.indexOf("www.wasu.cn") !== -1) {
  544. readyPlayerBox("已进入华数TV", null, [settings.NoAD解析["OK解析"]], "div#pcplayer", null);
  545. }
  546. } else {
  547. if (location.host.indexOf("v.qq.com") !== -1) {
  548. 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"], [settings.NoAD解析["OK解析"]], "div.mod_play:not([style*='display: none;']) section.mod_player", null, href => {
  549. let location = hrefToLocation(href);
  550. href = searchToJSON(location.search);
  551. if (href) {
  552. if (href["cid"]) {
  553. if (href["id"]) {
  554. return location.protocol + '//v.qq.com/detail/' + href["cid"][0] + '/' + href["cid"] + '.html';
  555. } else if (href["vid"]) {
  556. return location.protocol + '//v.qq.com/x/cover/' + href["cid"] + '/' + href["vid"] + '.html';
  557. } else {
  558. return location.protocol + '//v.qq.com/x/cover/' + href["cid"] + '.html';
  559. }
  560. } else if (href["vid"]) {
  561. return location.protocol + '//v.qq.com/x/page/' + href["vid"] + '.html';
  562. } else if (href["lid"]) {
  563. return location.protocol + '//v.qq.com/detail/' + href["lid"][0] + '/' + href["lid"] + '.html';
  564. } else {
  565. return null;
  566. }
  567. } else {
  568. return null;
  569. }
  570. });
  571. } else if (location.host.indexOf("iqiyi.com") !== -1) {
  572. readyPlayerBox("已进入爱奇艺", ["div.m-iqyGuide-layer", "a[down-app-android-url]", "[name=m-extendBar]", "[class*=ChannelHomeBanner]", "section.m-hotWords-bottom"], [settings.NoAD解析["OK解析"]], "section.m-video-player", null);
  573. } else if (location.host.indexOf("youku.com") !== -1) {
  574. readyPlayerBox("已进入优酷视频", ["#iframaWrapper", ".ad-banner-wrapper", ".h5-detail-guide,.h5-detail-vip-guide", ".brief-btm"], [], "#player", null);
  575. } else if (location.host.indexOf("bilibili.com") !== -1) {
  576. readyPlayerBox("已进入哔哩哔哩", ["div.fe-ui-open-app-btn,div.recom-wrapper,open-app-btn", "[class*=openapp]"], [settings.NoAD解析["夜幕解析"], settings.NoAD解析["天翼解析"]], "div#app.main-container div.player-wrapper", null, href => href.replace("m.bilibili.com", "www.bilibili.com"));
  577. } else if (location.host.indexOf("miguvideo.com") !== -1) {
  578. 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"], [], "section#mod-player", null, href => href.replace("m.miguvideo.com", "www.miguvideo.com").replace("msite", "website"));
  579. } else if (location.host.indexOf("le.com") !== -1) {
  580. (block_show => {
  581. 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;}";
  582. document.head.insertBefore(block_show, document.head.firstChild);
  583. })(document.createElement("style"));
  584. doElement("a.j-close-gdt", jump_over => {
  585. jump_over.click();
  586. return false;
  587. });
  588. 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.NoAD解析["云解析"]], "div.column.play", null);
  589. } else if (location.host.indexOf("m.tv.sohu.com") !== -1) {
  590. 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.NoAD解析["夜幕解析"]], "#player,#sohuplayer,.player-view", null, async href => {
  591. return new Promise(resolve => {
  592. xmlHttpRequest({
  593. url: href, success: data => {
  594. let result = data.responseText.match(/var videoData = \{[^\x00]+tvUrl:"(http.+)",[\r\n]/)[1];
  595. resolve(result);
  596. }, error: () => resolve(href)
  597. });
  598. });
  599. });
  600. } else if (location.host.indexOf("mgtv.com") !== -1) {
  601. 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.NoAD解析["爱解析"], settings.NoAD解析["OK解析"], settings.NoAD解析["全民解析"], settings.NoAD解析["云解析"], settings.NoAD解析["虾米解析"], settings.NoAD解析["夜幕解析"]], "div.video-poster,div.video-area", null);
  602. } else if (location.host.indexOf("ixigua.com") !== -1) {
  603. readyPlayerBox("已进入西瓜视频", ["div.xigua-download", "div.xigua-guide-button", "div.c-long-video-recommend.c-long-video-recommend-unfold"], [settings.NoAD解析["夜幕解析"]], "div.xigua-detailvideo-video", null);
  604. } else if (location.host.indexOf("pptv.com") !== -1) {
  605. 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.NoAD解析["OK解析"]], "section.pp-details-video", null, href => href.replace("m.pptv.com", "v.pptv.com"));
  606. } else if (location.host.indexOf("vip.1905.com") !== -1) {
  607. (movie_info => {
  608. movie_info.innerHTML = "section#movie_info{padding-top: 20px !important;}";
  609. document.head.appendChild(movie_info);
  610. })(document.createElement("style"));
  611. readyPlayerBox("已进入1905电影网", ["a.new_downLoad[target=_blank]", "iframe[srcdoc^='<img src=']", "section.movieList_new.club_new", ".wakeAppBtn", "[class*=login]", "section.openMembershipBtn", ".ad", ".open-app,.openApp,ul.iconList li:not(.introduceWrap),div#zhichiBtnBox", "section#hot_movie,section#exclusive_movie,section#hot_telve"], [settings.NoAD解析["云解析"]], "div.area.areaShow.clearfix_smile", null);
  612. } else if (location.host.indexOf("www.wasu.cn") !== -1) {
  613. readyPlayerBox("已进入华数TV", ["div.ws_poster", "div.appdown,div.player_menu_con", "div#play_and_info_fix_adv"], [settings.NoAD解析["OK解析"]], "div#player,div#pop", null);
  614. }
  615. }
  616. function readyPlayerBox(Tip, displayNones, srcs, cssString, doFunction, doHref = null) {
  617. if (Tip) {
  618. console.log("%c" + Tip, settings.fontStyle.maxTip);
  619. }
  620. onLocationChange(() => location.reload()); // TODO 如果网页rul变了就刷新页面
  621. if (displayNones) {
  622. displayNone(displayNones);
  623. }
  624. doElement(cssString, async playerBox => {
  625. setInterval(() => {
  626. for (let link of document.querySelectorAll("a")) {
  627. link.onclick = () => {
  628. if (link.host === location.host) {
  629. location.href = link.href;
  630. }
  631. }
  632. }
  633. }, 1500);
  634. let iframe = document.createElement("iframe");
  635. iframe.allowFullscreen = true;
  636. iframe.frameBorder = "0"; // HTML5已弃用此属性,并使用style.border代替
  637. iframe.width = "100%";
  638. iframe.height = "100%";
  639. iframe.style = "background-color: #000 !important; border: 0 !important; display: block !important; visibility: visible !important; opacity: 1 !important;" + " min-width: 100% !important; width: 100% !important; max-width: 100% !important; min-height: 100% !important; height: 100% !important; max-height: 100% !important;" + " position: absolute !important; left: 0px !important; top: 0px !important; z-index: 2147483647 !important; overflow: hidden;";
  640. let iframeStartTime, tested = false, others = Object.values(settings.NoAD解析).filter(value => {
  641. // 求出 srcs 在 NoAD解析 中的补集
  642. return srcs.indexOf(value) === -1;
  643. });
  644. settings.randomSeleceParse = async () => {
  645. // arguments 代表输入的所有参数,看不懂可以百度搜索 “js 参数 arguments”
  646. // return arguments ? arguments[Math.floor(Math.random() * arguments.length)] : null;
  647. if (srcs.length > 0) {
  648. let random = Math.floor(Math.random() * srcs.length);
  649. src = srcs[random];
  650. srcs.splice(random, 1);
  651. } else {
  652. if (tested) {
  653. showTip("该视频可能无法解析\n请尝试使用z1解析\n如有疑问请反馈");
  654. return false;
  655. } else {
  656. showTip("解析失败,正在尝试其他解析源");
  657. srcs = others;
  658. others = null;
  659. tested = true;
  660. let random = Math.floor(Math.random() * srcs.length);
  661. src = srcs[random];
  662. srcs.splice(random, 1);
  663. }
  664. }
  665. if (typeof doHref === "function") {
  666. let href = await doHref(location.href);
  667. iframe.src = src ? src + (href ? href : location.href) : "";
  668. } else {
  669. iframe.src = src ? src + location.href : "";
  670. }
  671. iframeStartTime = new Date().getTime();
  672. return true;
  673. }
  674. let src = null;
  675. await settings.randomSeleceParse();
  676. playerBox.style.zIndex = "1";
  677. iframe.onload = () => {
  678. // 判断iframe加载完成的时间
  679. if (new Date().getTime() - iframeStartTime < 500) {
  680. // 如果加载时间小于半秒,并且检测网页加载出错,说明网页有问题。
  681. xmlHttpRequest({
  682. url: iframe.src,
  683. error: () => {
  684. showTip("该解析已失效,已切换推荐解析源");
  685. settings.randomSeleceParse();
  686. }
  687. })
  688. }
  689. }
  690. playerBox.appendChild(iframe);
  691. console.log(iframe);
  692. console.log("%cplayerBox已建立解析连接", settings.fontStyle.maxTip);
  693. let DIY_iframe;
  694. settings.DIY_iframeFunction = () => {
  695. if (settings.parseDB.DIY解析栏) {
  696. if (!DIY_iframe || DIY_iframe.constructor.name !== "HTMLDivElement") {
  697. // 自定义解析地址
  698. DIY_iframe = document.createElement("div");
  699. DIY_iframe.style = "display: flex; background-color: #0000; font-family: 微软雅黑,黑体,Droid Serif,Arial,sans-serif; font-size: 15px;" + " position: fixed; height: 30px; width: 86%; transform: translateX(-50%); left: 50%; max-width: 600px; border-radius: 15px; box-shadow: 0 0 6px 2px #444; bottom: 5px;";
  700. DIY_iframe.innerHTML = "<select style='border: 0; background-color: #ddd; text-align: center; min-width: 80px; width: 80px; height: 100%; border-bottom-left-radius: 15px; border-top-left-radius: 15px;'></select>" + "<input type='text' style='border: 0; background-color: #eee; padding-left: 10px; flex-grow: 1; width: 123px; height: 100%;' placeholder='(当前网址请留空)'>" + "<button style='background-color: #4af; border-color: #4af; text-align: center; color: #fff; min-width: 54px; width: 54px; height: 100%; border-bottom-right-radius: 15px; border-top-right-radius: 15px;'>解析</button>";
  701. let DIY_iframe_text = DIY_iframe.querySelector("input[type=text]");
  702. async function DIY_iframe_src() {
  703. let newiframe = document.querySelector("iframe[id*=player]");
  704. if (newiframe) {
  705. iframe = newiframe;
  706. }
  707. if (typeof doHref === "function") {
  708. let href = await doHref(DIY_iframe_text.value ? DIY_iframe_text.value : location.href);
  709. iframe.src = DIY_iframe_select.options[DIY_iframe_select.selectedIndex].value + (href ? href : (DIY_iframe_text.value ? DIY_iframe_text.value : location.href))
  710. } else {
  711. iframe.src = DIY_iframe_select.options[DIY_iframe_select.selectedIndex].value + (DIY_iframe_text.value ? DIY_iframe_text.value : location.href);
  712. }
  713. iframeStartTime = new Date().getTime();
  714. }
  715. let DIY_iframe_select = DIY_iframe.querySelector("select");
  716. for (let name in settings.NoAD解析) {
  717. DIY_iframe_select.innerHTML += "<option value='" + settings.NoAD解析[name] + "' style='text-align: center'>" + name + "</option>";
  718. }
  719. for (let name in settings.AD解析) {
  720. DIY_iframe_select.innerHTML += "<option value='" + settings.AD解析[name] + "' style='text-align: center; color: #fa0; '>⚠" + name + "</option>";
  721. }
  722. DIY_iframe.querySelector("option[value='" + src + "']").selected = true;
  723. settings.randomSeleceParse = async () => {
  724. // arguments 代表输入的所有参数,看不懂可以百度搜索 “js 参数 arguments”
  725. // return arguments ? arguments[Math.floor(Math.random() * arguments.length)] : null;
  726. if (srcs.length > 0) {
  727. let random = Math.floor(Math.random() * srcs.length);
  728. src = srcs[random];
  729. srcs.splice(random, 1);
  730. DIY_iframe.querySelector("option[value='" + src + "']").selected = true;
  731. } else {
  732. if (tested) {
  733. showTip("该视频可能无法解析\n请尝试使用z1解析\n如有疑问请反馈");
  734. return false;
  735. } else {
  736. showTip("解析失败,正在尝试其他解析源");
  737. srcs = others;
  738. others = null;
  739. tested = true;
  740. let random = Math.floor(Math.random() * srcs.length);
  741. src = srcs[random];
  742. srcs.splice(random, 1);
  743. }
  744. }
  745. settings.address = {"0": 0, "-1": 1};
  746. if (typeof doHref === "function") {
  747. let href = await doHref(location.href);
  748. iframe.src = src ? src + (href ? href : location.href) : "";
  749. } else {
  750. iframe.src = src ? src + location.href : "";
  751. }
  752. iframeStartTime = new Date().getTime();
  753. return true;
  754. }
  755. DIY_iframe.querySelector("button").onclick = () => DIY_iframe_src();
  756. DIY_iframe_text.onkeydown = DIY_iframe_select.onkeydown = event => {
  757. if (event.key === "Enter") {
  758. DIY_iframe_src();
  759. }
  760. }
  761. doElement("toolsbar", toolsBar => {
  762. toolsBar.appendChild(DIY_iframe);
  763. });
  764. } else if (DIY_iframe.style.visibility === "hidden") {
  765. DIY_iframe.style.display = "flex";
  766. DIY_iframe.style.visibility = "";
  767. }
  768. } else if (DIY_iframe && DIY_iframe.constructor.name === "HTMLDivElement" && DIY_iframe.style.visibility === "") {
  769. DIY_iframe.style.display = "none";
  770. DIY_iframe.style.visibility = "hidden";
  771. }
  772. }
  773. settings.DIY_iframeFunction();
  774. (waiter => {
  775. waiter /= settings.getElementTimes;
  776. let resetPlayerBoxInterval = setInterval(() => {
  777. let newPlayerBox = document.querySelector(cssString);
  778. if (newPlayerBox !== playerBox && newPlayerBox !== null || newPlayerBox !== null && newPlayerBox.querySelector("iframe[src='" + iframe.src + "']") === null) {
  779. console.log("playerBox重新建立连接");
  780. let src = iframe.src;
  781. iframe.src = "";
  782. iframe = iframe.cloneNode(true);
  783. iframe.src = src;
  784. newPlayerBox.style.zIndex = "1";
  785. newPlayerBox.appendChild(iframe);
  786. clearInterval(resetPlayerBoxInterval);
  787. } else if (document.readyState === "complete" && waiter-- <= 0) {
  788. clearInterval(resetPlayerBoxInterval);
  789. }
  790. }, settings.getElementTimes)
  791. })(0);
  792. if (doFunction) {
  793. doFunction(playerBox, iframe);
  794. }
  795. setInterval(() => {
  796. for (let video of document.getElementsByTagName("video")) {
  797. if (video.src) {
  798. video.removeAttribute("src");
  799. video.load();
  800. video.muted = true;
  801. }
  802. }
  803. }, settings.getElementTimes);
  804. ['fullscreenchange', 'webkitfullscreenchange', 'mozfullscreenchange'].forEach((item, index) => {
  805. window.addEventListener(item, () => {
  806. let toolsBar = document.querySelector("toolsbar");
  807. if (document.fullScreen || document.mozFullScreen || document.webkitIsFullScreen) {
  808. toolsBar.style.display = 'none';
  809. } else {
  810. toolsBar.style.display = 'block';
  811. }
  812. }, true);
  813. });
  814. });
  815. }
  816. function hrefToLocation(href) {
  817. let location = {href: href}, c = 0, start = 0, search;
  818. for (let i = 0, port; i < href.length; i++) {
  819. if (href[i] === "/") {
  820. if (++c === 1) {
  821. location.protocol = href.substring(start, i);
  822. } else if (c === 3) {
  823. location.host = href.substring(start + 1, i);
  824. if (port) {
  825. location.port = href.substring(port + 1, i);
  826. } else {
  827. location.hostname = location.host;
  828. location.port = "";
  829. }
  830. }
  831. if (c <= 3) {
  832. start = i;
  833. }
  834. } else if (href[i] === ":" && c === 2) {
  835. location.hostname = href.substring(start + 1, i);
  836. port = i;
  837. } else if (href[i] === "?" && !search) {
  838. location.pathname = href.substring(start, i);
  839. search = i;
  840. } else if (href[i] === "#" && !location.hash) {
  841. location.hash = href.substr(i);
  842. if (location.pathname === undefined) {
  843. location.pathname = href.substring(c, i);
  844. } else if (search) {
  845. location.search = href.substring(search, i);
  846. }
  847. break;
  848. }
  849. }
  850. if (location.pathname === undefined) {
  851. location.pathname = c === 3 ? href.substr(start) : "";
  852. location.search = location.hash = "";
  853. }
  854. if (location.search === undefined) {
  855. if (search) {
  856. location.search = href.substr(search);
  857. } else {
  858. location.search = "";
  859. }
  860. }
  861. if (location.hash === undefined) {
  862. location.hash = "";
  863. }
  864. return location;
  865. }
  866. } else {
  867. async function setParseBox() {
  868. // 移除广告模块
  869. removeElements(['document.getElementById("ADplayer")', 'document.getElementById("ADtip")']);
  870. // 设置解析播放器
  871. setParseVideo();
  872. // 等待数据得到响应,移除弹幕模块
  873. await settings.parseDB;
  874. if (!settings.parseDB.弹幕开关) {
  875. console.log("正在移除弹幕功能");
  876. removeElements(['document.querySelector("div[class$=player-video-wrap]").getElementsByTagName("div")', 'document.querySelector("div[class$=playr-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]")']);
  877. }
  878. }
  879. function setParseVideo() {
  880. console.log(location.href + " 正在查找video 准备移除poster")
  881. forElement("video", (video, thisInterval) => {
  882. if (video.src) {
  883. top.postMessage(key.ENCRYPT("宝塔镇河妖\x00函数\x00settings.address = null", settings.k1, settings.k2), "*");
  884. if (!detectMobile()) {
  885. let fullscreen_btn = document.querySelector("[class*=fullscreen],[class$=player-full] button[class$=full-icon]");
  886. if (fullscreen_btn && fullscreen_btn.nodeType === 1) {
  887. // 阻止事件冒泡
  888. fullscreen_btn.parentNode.parentNode.onkeyup = event => event.stopPropagation();
  889. }
  890. video.onkeyup = event => event.stopPropagation();
  891. top.postMessage(key.ENCRYPT("宝塔镇河妖\x00按下Enter获取焦点", settings.k1, settings.k2), "*")
  892. onkeyup = video.onkeyup = event => {
  893. if (event.key === "Enter") {
  894. if (video.paused) {
  895. video.play();
  896. }
  897. if (fullscreen_btn && fullscreen_btn.nodeType === 1) {
  898. fullscreen_btn.click();
  899. return false;
  900. } else if (video.webkitDisplayingFullscreen) {
  901. if (video.webkitExitFullScreen) {
  902. video.webkitExitFullScreen();
  903. } else if (video.webkitExitFullscreen) {
  904. video.webkitExitFullscreen();
  905. }
  906. } else {
  907. if (video.webkitEnterFullScreen) {
  908. video.webkitEnterFullScreen();
  909. } else if (video.webkitEnterFullscreen) {
  910. video.webkitEnterFullscreen();
  911. }
  912. }
  913. }
  914. }
  915. focus();
  916. showTip("按下Enter回车键,进入全屏 并 自动播放");
  917. video.addEventListener("pause", () => {
  918. if ((video.currentTime - video.duration) > -5) {
  919. console.log("视频播放结束了");
  920. if (fullscreen_btn && fullscreen_btn.nodeType === 1 && ((video.clientWidth || video.scrollWidth) === screen.width) || ((video.clientHeight || video.scrollHeight) === screen.height)) {
  921. fullscreen_btn.click();
  922. return false;
  923. } else if (video.webkitExitFullScreen) {
  924. video.webkitExitFullScreen();
  925. } else if (video.webkitExitFullscreen) {
  926. video.webkitExitFullscreen();
  927. } else {
  928. console.log("不支持退出全屏");
  929. }
  930. }
  931. }, false);
  932. } else {
  933. // showTip("解析成功");
  934. }
  935. clearInterval(thisInterval);
  936. }
  937. }, 3000, function () {
  938. top.postMessage(key.ENCRYPT("宝塔镇河妖\x00给予\x00-1\x00" + location.href, settings.k1, settings.k2), "*");
  939. });
  940. }
  941. if (location.host.indexOf("jiexi.t7g.cn") !== -1) {
  942. // 移除爱解析p2p提示
  943. displayNone(["body>div#stats"]);
  944. setParseBox();
  945. } else if (location.host.indexOf("api.okjx.cc:3389") !== -1) {
  946. // 删除OK解析线路选择功能
  947. (style => {
  948. style.innerHTML = ".slide,.panel,.slide *,.panel *{width: 0 !important; max-width: 0 !important; opacity: 0 !important;}";
  949. document.head.appendChild(style);
  950. })(document.createElement("style"));
  951. setParseBox();
  952. } else if (location.host.indexOf("api.jiubojx.com") !== -1) {
  953. displayNone("div.adv_wrap_hh");
  954. setParseBox();
  955. } else if (location.host.indexOf("yemu.xyz") !== -1) {
  956. if (location.pathname.indexOf("jx.php") === -1) {
  957. if (location.host.indexOf("www.yemu.xyz") !== -1) {
  958. // 删除夜幕解析线路选择功能
  959. (style => {
  960. style.innerHTML = ".slide,.panel,.slide *,.panel *{width: 0 !important; max-width: 0 !important; opacity: 0 !important;}";
  961. document.head.appendChild(style);
  962. })(document.createElement("style"));
  963. } else if (location.host.indexOf("jx.yemu.xyz") !== -1) {
  964. // 移除视频分类提示 及 解析框架处理
  965. displayNone(["div.advisory"]);
  966. setParseBox();
  967. }
  968. } else {
  969. // 移除背景图片
  970. doElement("div[style*='width:100%;height:100%;'][style*='.jpg']", background => {
  971. background.style = "width:100%;height:100%;position:relative;z-index:2147483647987;";
  972. }, 5000);
  973. }
  974. } else if (location.host.indexOf('www.mtosz.com') !== -1) {
  975. displayNone([".video-panel-blur-image"]); // 似乎不管用?
  976. doElement(".video-panel-blur-image", element => {
  977. element.style = "display: none; height: 0; width: 0;";
  978. });
  979. setParseBox();
  980. } else if (location.host.indexOf('v.superchen.top:3389') !== -1) {
  981. setParseBox();
  982. } else if (location.host.indexOf('jx.parwix.com:4433') !== -1) {
  983. setParseBox();
  984. } else if (location.pathname) {
  985. setParseVideo();
  986. }
  987. }
  988. function displayNone(Tags) {
  989. let style = document.createElement("style");
  990. style.innerHTML = "\n";
  991. for (let i = 0; i < Tags.length; i++) {
  992. 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";
  993. }
  994. document.head.insertBefore(style, document.head.firstChild);
  995. }
  996. function onLocationChange(handler) {
  997. let url = top.location.pathname;
  998. let onLocationChangeInterval = setInterval(() => {
  999. let href = top.location.pathname;
  1000. if (href.indexOf(url) === -1) {
  1001. handler();
  1002. clearInterval(onLocationChangeInterval);
  1003. } else {
  1004. url = href;
  1005. }
  1006. }, settings.getElementTimes);
  1007. }
  1008. function onFirstLoad(doFunction) {
  1009. if (document.readyState === "complete") {
  1010. if (doFunction) {
  1011. doFunction();
  1012. }
  1013. } else {
  1014. setTimeout(() => {
  1015. onFirstLoad(doFunction);
  1016. }, settings.getElementTimes);
  1017. }
  1018. }
  1019. function searchToJSON(search) {
  1020. if (search) {
  1021. return JSON.parse("{\"" + decodeURIComponent(search.substring(1)
  1022. .replace(/"/g, '\\"')
  1023. .replace(/&/g, '","')
  1024. .replace(/=/g, '":"')) + "\"}");
  1025. } else {
  1026. return null;
  1027. }
  1028. }
  1029. }
  1030. function showTip(msg, style = "") {
  1031. // 该函数需要在top内运行,否则可能显示异常
  1032. if (window === top) {
  1033. let tip = document.querySelector(":root>tip");
  1034. if (tip && tip.nodeType === 1) {
  1035. // 防止中途新的showTip事件创建多个tip造成卡顿
  1036. root.removeChild(tip);
  1037. }
  1038. tip = document.createElement("tip");
  1039. // pointer-events: none; 禁用鼠标事件,input标签使用 disabled='disabled' 禁用input标签
  1040. tip.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;";
  1041. tip.innerHTML = "<style>@keyframes showTip {0%{opacity: 0;} 33.34%{opacity: 1;} 66.67%{opacity: 1;} 100%{opacity: 0;}}</style>\n" + msg;
  1042. let time = msg.replace(/\s/, "").length / 2; // TODO 2个字/秒
  1043. // cubic-bezier(起始点, 起始点偏移量, 结束点偏移量, 结束点),这里的 cubic-bezier函数 表示动画速度的变化规律
  1044. 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";
  1045. root.appendChild(tip);
  1046. setTimeout(() => {
  1047. try {
  1048. root.removeChild(tip);
  1049. } catch (e) {
  1050. // 排除root没有找到tip
  1051. }
  1052. }, time * 1000);
  1053. } else {
  1054. top.postMessage(key.ENCRYPT("宝塔镇河妖\x00函数\x00showTip('" + msg + "')", settings.k1, settings.k2), "*");
  1055. }
  1056. }
  1057. function xmlHttpRequest(settings) {
  1058. let request = new XMLHttpRequest();
  1059. if (settings.success) {
  1060. request.onload = event => {
  1061. // 加载成功
  1062. settings.success(request, event);
  1063. }
  1064. }
  1065. if (settings.error) {
  1066. request.onerror = event => {
  1067. // 加载失败
  1068. settings.error(request, event);
  1069. }
  1070. }
  1071. if (settings.loadend) {
  1072. request.onloadend = event => {
  1073. // 加载结束
  1074. settings.loadend(request, event);
  1075. }
  1076. }
  1077. if (settings.timeout) {
  1078. request.ontimeout = event => {
  1079. // 加载超时
  1080. settings.timeout(request, event);
  1081. }
  1082. }
  1083. request.open(settings.method ? settings.method : "GET", settings.url ? settings.url : location.href, settings.async ? settings.async : true, settings.username ? settings.username : null, settings.password ? settings.password : null);
  1084. if (settings.headers) {
  1085. for (let header in settings.headers) {
  1086. request.setRequestHeader(header, settings[header]);
  1087. }
  1088. }
  1089. if (settings.dataType) {
  1090. request.responseType = settings.dataType;
  1091. }
  1092. if (settings.data) {
  1093. let data = "";
  1094. for (let key in settings.data) {
  1095. data += key + "=" + settings.data[key] + "&";
  1096. }
  1097. data = data.substr(0, data.length - 1);
  1098. request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  1099. request.send(data);
  1100. } else {
  1101. request.send();
  1102. }
  1103. return request;
  1104. }

QingJ © 2025

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