// ==UserScript== // @name 爱壹帆 // @namespace http://tampermonkey.net/ // @description 去广告解除画中画等 // @version 0.1 // @author hua // @match https://*.iyf.tv* // @match https://*yfsp.tv* // @match https://*.wyav.tv* // @grant unsafeWindow // @grant GM_xmlhttpRequest // @grant GM_setValue // @grant GM_getValue // @require https://gcore.jsdelivr.net/gh/wuhua111/monkeyApi@main/quicklymodel.module.1.0.4.min.js // @run-at document-start // @license MIT // @noframes // ==/UserScript== const api = new QuicklyModelCore({ enable: ['setAttribute'], dev: true }); const logger = new api.utils.Logger({ moduleName: '爱壹帆' }); const $ = api.dom.query.$; const $$ = api.dom.query.$$; (function () { 'use strict'; const mobileWeb = location.href.startsWith('https://m.'); main(); async function main() { removeAD(); otherFun(); } function otherFun() { //允许移动端播放 api.utils.origin.hook('navigator.userAgent', { get: function () { return 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36'; } }); // 允许画中画 api.dom.setAttribute.subscribe((_, name) => { if (name === 'disablepictureinpicture') return false; }); // 双击离线看 进入画中画 const addDbClick = function () { let button = null; api.dom.waitElement($('body'), () => { return button = $('.iconlixianhuancun1')?.closest('button'); }, { type: 'none' }).then(() => { if (button.inject_adddbClick) return; button.inject_adddbClick = true; const video = $('video#video_player'); logger.info('hook到视频'); button = button.children[0]; api.event.dbClickAPI(button, () => { video.requestPictureInPicture(); }).start(); }); }; if (!mobileWeb) { if (location.href.includes('/play/')) { api.event.domContentLoaded.subscribe(() => { addDbClick(); }); } api.event.urlChange.subscribe((uri) => { logger.info('urlChange', uri); if (uri.includes('/play/')) { addDbClick(); } }); } } function removeAD() { const removeLeftSlideAd = function () { let container = null; api.dom.waitElement(document.documentElement, () => { return container = $('.ps.pggf'); }, { type: 'none' }).then(() => { container.querySelectorAll('.ng-star-inserted').forEach(item => item.remove()); }); }; if (mobileWeb) { api.net.xhr.response.text.subscribe(() => '{"ret": 304}', { condition: (_, url) => url.includes('getadsdatalist') }); } else { removeLeftSlideAd(); api.event.urlChange.subscribe((uri) => { logger.info('urlChange', uri); if (uri.includes('/play/')) { removeLeftSlideAd(); } }); } api.net.xhr.response.json.subscribe((json) => { logger.info('用户信息触发'); const rules = [ 'bigV=json(true)', 'vipLevel=num(3)', 'gid=num(3)', 'vipTypeName=啊哈', 'vipCategoryId=num(3)', 'endDays=num(1)', 'vipImage=royal-admin.png' ]; api.data.dataProcess.obj_process(json, rules, { traverse_all: true }); }, { condition: (_, url) => ['getuserinfo', 'validate', 'GetUserSetting'].some(item => url.includes(item)) }); let md5 = ''; api.utils.hookGlobalObjectPrototypeName('Md5', { get: function () { return md5; }, set: function (value) { if (!value) return; logger.info('Md5设置', value); const hashStr = value.hashStr; value.hashStr = function (str) { str = str.replace('gid=3', 'gid=0'); return hashStr.call(value, str); }; md5 = value; } }); api.net.xhr.request.open.subscribe((url) => { if (!url.startsWith('http')) return; const { uri, params } = api.utils.url.paramsParse(url); if (params.gid) { params.gid = '0'; return api.utils.url.paramsMerge(uri, params); } }); api.net.xhr.request.send.subscribe((body, url) => { if (!url.startsWith('http')) return; if (body?.includes('gid=3')) { body = body.replace('gid=3', 'gid=0'); return [body, url]; } }, { stopPropagation: false }); api.net.xhr.response.json.subscribe((json) => { // 去侧边栏广告 logger.info('侧边栏广告触发'); json.data.info.forEach(item => { item.extraList = []; }); }, { condition: (_, url) => url.includes('video/detail') }); api.net.xhr.response.json.subscribe((json) => { // 首页大banner logger.info('首页大banner'); json.data?.info?.reduceRight((_, item, index) => { if (item.adLevel > 0) { json.data.info.splice(index, 1); } }); }, { condition: (_, url) => url.includes('/home/getflashbanner') }); api.net.xhr.response.json.subscribe((json) => { logger.info('播放中广告触发'); json.data.info.forEach(item => { Object.assign(item, { pauseData: [], maxFrontAds: 0, isUserFilterAd: true, }); // 去播放中广告 item.flvPathList?.forEach(item => { delete item.dashResult; delete item.backup; delete item.rtmp; }); }); }, { condition: (_, url) => url.includes('video/play') }); // 广告 api.net.xhr.request.open.subscribe(() => '', { condition: (url) => url.includes('play/o?cinema') }); api.utils.defineProperty(unsafeWindow, 'isAdsBlocked', { get: function () { return false; } }); api.utils.defineProperty(unsafeWindow, 'injectJson', { get: function () { return {}; } }); api.net.fetch.request.subscribe(() => '', { condition: (url) => url.includes('adsbygoogle.js') }); } })();