// ==UserScript== // @name 粤语屋 小宝影院 看剧吧 剧集屋去视频内嵌广告 // @name:zh-CN 粤语屋 小宝影院 看剧吧 剧集屋去视频内嵌广告 // @name:zh-TW 粤语屋 小宝影院 看剧吧 剧集屋去视频内嵌广告 // @name:zh-HK 粤语屋 小宝影院 看剧吧 剧集屋去视频内嵌广告 // @namespace https://bbs.tampermonkey.net.cn/ // @version 2.0.0 // @description 去除粤语屋 小宝影院 看剧吧 剧集屋视频里嵌入的广告 // @description:zh-CN 去除粤语屋 小宝影院 看剧吧 剧集屋视频里的嵌入的广告 // @description:zh-TW 去除粤语屋 小宝影院 看剧吧 剧集屋视频里的嵌入的广告 // @description:zh-HK 去除粤语屋 小宝影院 看剧吧 剧集屋视频里的嵌入的广告 // @author hua // @grant unsafeWindow // @license MIT // @include https://m3u8.yueyuwu.cc/player/* // @include https://xbyy.app/player/* // @include https://kandaju.net/js/player/* // @include https://ffzyplayer.com/* // @run-at document-start // @downloadURL none // ==/UserScript== //粤语屋 小宝影院 看剧吧 剧集屋 const config_infos = { 'yyw': { 'm3u8_file_flag': /mixed\.m3u8$/, }, 'xbyy': { 'm3u8_file_flag': /\.m3u8$/, }, "kjb": { 'm3u8_file_flag': /mixed\.m3u8$/, }, "jjw": { 'm3u8_file_flag': /mixed\.m3u8$/, } }; (function () { let href = document.location.href; const page_type = get_page_type(); const origin_console = console; const log = origin_console.log; if (page_type === 'unknown') { log('unknown page type'); return; } let config_info = config_infos[page_type]; init_hook(); log('脚本注入成功!'); function init_hook() { unsafeWindow.XMLHttpRequest = class extends unsafeWindow.XMLHttpRequest { get xhrResponseValue() { const xhr = this; if (xhr.readyState === XMLHttpRequest.DONE && xhr.status === 200) { const url = xhr.responseURL; if (url.match(config_info.m3u8_file_flag)) { try { return process_m3u8(super.response); } catch (error) { log('m3u8处理异常!', error); } } } return super.response; } get responseText() { return this.xhrResponseValue; } get response() { return this.xhrResponseValue; } }; } function process_m3u8(file) { if (['yyw', 'kjb','jjw'].includes(page_type)) { return yyw(file); } else if (page_type === 'xbyy') { return xbyy(file); } function xbyy(file) { let lines = file.split('\n'); let processed_lines = []; let pre_name; for (let line of lines) { if (line.endsWith('.ts')) { pre_name = line.match(/^.*\//)[0]; break; } } for (let line of lines) { if (line.endsWith('.ts')) { if (!line.startsWith(pre_name)) { processed_lines.pop(); if (processed_lines[processed_lines.length - 1] == '#EXT-X-DISCONTINUITY') { processed_lines.pop(); } log('删除', line); continue; } } processed_lines.push(line); } return processed_lines.join('\n'); } function yyw(file) { let lines = file.split('\n'); let processed_lines = []; let index = 0; let name_len; let pre_name; let next_name; for (let line of lines) { if (line.endsWith('.ts')) { if (!next_name) { pre_name = line.split('.ts')[0]; name_len = pre_name.length; index++; const str_index = String(index); next_name = `${pre_name.substring(0, name_len - str_index.length)}${str_index}.ts`; } else { if (next_name != line) { processed_lines.pop(); if (processed_lines[processed_lines.length - 1] == '#EXT-X-DISCONTINUITY') { processed_lines.pop(); } console.log(`删除${line}`); continue; } else { index++; const str_index = String(index); next_name = `${pre_name.substring(0, name_len - str_index.length)}${str_index}.ts`; } } } processed_lines.push(line); } let processed_file = processed_lines.join('\n'); return processed_file; } } function get_page_type() { if (href.includes('m3u8.yueyuwu.cc')) return 'yyw'; else if (href.includes('xbyy.app')) return 'xbyy'; else if (href.includes('kandaju.net')) return 'kjb'; else if (href.includes('ffzyplayer.com')) return 'jjw'; else return 'unknown'; } })();