加多重buff的广告拦截脚本(改)
// ==UserScript==
// @name 加多重buff的广告拦截脚本(改)
// @author ChatGPT
// @description 去广告脚本,可能有误杀,可以在脚本菜单禁用当前域名拦截,二改,优化了标识符替换和元素拦截,删除部分规则,尽量只做悬浮元素移除。
// @version 12.4
// @grant GM_registerMenuCommand
// @grant GM_setValue
// @grant GM_getValue
// @grant GM_addStyle
// @match *://*/*
// @exclude *://*.10000read.com/*
// @exclude *://*.10010.com/*
// @exclude *://*.10086.cn/*
// @exclude *://*.10jqka.com.cn/*
// @exclude *://*.12371.cn/*
// @exclude *://*.163.com/*
// @exclude *://*.17173.com/*
// @exclude *://*.17k.com/*
// @exclude *://*.1905.com/*
// @exclude *://*.19lou.com/*
// @exclude *://*.1kkk.com/*
// @exclude *://*.1ting.com/*
// @exclude *://*.360.cn/*
// @exclude *://*.360doc.com/*
// @exclude *://*.3g.cn/*
// @exclude *://*.3gsc.com.cn/*
// @exclude *://*.4399dmw.com/*
// @exclude *://*.4yt.net/*
// @exclude *://*.51changdu.cn/*
// @exclude *://*.56.com/*
// @exclude *://*.5nd.com/*
// @exclude *://*.5ydj.com/*
// @exclude *://*.6.cn/*
// @exclude *://*.61.com/*
// @exclude *://*.71.cn/*
// @exclude *://*.78dm.net/*
// @exclude *://*.7m.cn/*
// @exclude *://*.81.cn/*
// @exclude *://*.9ku.com/*
// @exclude *://*.9sky.com/*
// @exclude *://*.9xiu.com/*
// @exclude *://*.a8.com/*
// @exclude *://*.acfun.cn/*
// @exclude *://*.ahtv.cn/*
// @exclude *://*.aipai.com/*
// @exclude *://*.aisixiang.com/*
// @exclude *://*.amazon.cn/*
// @exclude *://*.anhuinews.cc/*
// @exclude *://*.baidu.com/*
// @exclude *://*.baike.com/*
// @exclude *://*.bale.cn/*
// @exclude *://*.banyuetan.org/*
// @exclude *://*.baofeng.com/*
// @exclude *://*.baomihua.com/*
// @exclude *://*.bayueju.com/*
// @exclude *://*.besgold.com/*
// @exclude *://*.bilibili.com/*
// @exclude *://*.bing.com/*
// @exclude *://*.bjnews.com.cn/*
// @exclude *://*.blogchina.com/*
// @exclude *://*.bokee.com/*
// @exclude *://*.brtn.cn/*
// @exclude *://*.buka.cn/*
// @exclude *://*.bymanhua.com/*
// @exclude *://*.cac.gov.cn/*
// @exclude *://*.caixin.com/*
// @exclude *://*.cankaoxiaoxi.com/*
// @exclude *://*.cb.com.cn/*
// @exclude *://*.cba.net.cn/*
// @exclude *://*.ccshao.com/*
// @exclude *://*.cctv.com/*
// @exclude *://*.ce.cn/*
// @exclude *://*.cfi.cn/*
// @exclude *://*.changba.com/*
// @exclude *://*.china.com.cn/*
// @exclude *://*.china.com/*
// @exclude *://*.chinadaily.com.cn/*
// @exclude *://*.chinanews.com.cn/*
// @exclude *://*.chinanews.com/*
// @exclude *://*.chinavalue.net/*
// @exclude *://*.chinaventure.com.cn/*
// @exclude *://*.chjak.cn/*
// @exclude *://*.chnews.net/*
// @exclude *://*.ciweimao.com/*
// @exclude *://*.cmread.com/*
// @exclude *://*.cnautonews.com/*
// @exclude *://*.cnblogs.com/*
// @exclude *://*.cngold.org/*
// @exclude *://*.cnhubei.com/*
// @exclude *://*.cnmo.com/*
// @exclude *://*.cnn.com/*
// @exclude *://*.cnnb.com/*
// @exclude *://*.cnr.cn/*
// @exclude *://*.cnstock.com/*
// @exclude *://*.cntv.cn/*
// @exclude *://*.cpd.com.cn/*
// @exclude *://*.cqnews.net/*
// @exclude *://*.cqwb.com.cn/*
// @exclude *://*.cri.cn/*
// @exclude *://*.crntt.com/*
// @exclude *://*.cuctv.com/*
// @exclude *://*.cyol.com/*
// @exclude *://*.cyol.net/*
// @exclude *://*.dahe.cn/*
// @exclude *://*.dangdang.com/*
// @exclude *://*.dayoo.com/*
// @exclude *://*.dbw.cn/*
// @exclude *://*.diyidan.com/*
// @exclude *://*.dj97.com/*
// @exclude *://*.djkk.com/*
// @exclude *://*.djye.com/*
// @exclude *://*.dm5.com/*
// @exclude *://*.dmkb.net/*
// @exclude *://*.docin.com/*
// @exclude *://*.dongmanmanhua.cn/*
// @exclude *://*.douban.com/*
// @exclude *://*.douban.fm/*
// @exclude *://*.douyu.com/*
// @exclude *://*.duitang.com/*
// @exclude *://*.duokan.com/*
// @exclude *://*.dzwww.com/*
// @exclude *://*.eastday.com/*
// @exclude *://*.eastmoney.com/*
// @exclude *://*.ebusinessreview.cn/*
// @exclude *://*.eeo.com.cn/*
// @exclude *://*.faloo.com/*
// @exclude *://*.fbook.net/*
// @exclude *://*.feng.com/*
// @exclude *://*.fjsen.com/*
// @exclude *://*.fmx.cn/*
// @exclude *://*.fx678.com/*
// @exclude *://*.gdtv.cn/*
// @exclude *://*.gdtv.com.cn/*
// @exclude *://*.gfan.com/*
// @exclude *://*.github.com/*
// @exclude *://*.gmw.cn/*
// @exclude *://*.google.*/*
// @exclude *://*.gooooal.com/*
// @exclude *://*.guancha.cn/*
// @exclude *://*.guandian.cn/*
// @exclude *://*.guokr.com/*
// @exclude *://*.guqu.net/*
// @exclude *://*.gxnews.com.cn/*
// @exclude *://*.haiwainet.cn/*
// @exclude *://*.hao123.com/*
// @exclude *://*.hbooker.com/*
// @exclude *://*.hefei.cc/*
// @exclude *://*.heiyan.com/*
// @exclude *://*.hexun.com/*
// @exclude *://*.hnquxing.com/*
// @exclude *://*.hongshu.com/*
// @exclude *://*.hongxiu.com/*
// @exclude *://*.hsw.cn/*
// @exclude *://*.huajiao.com/*
// @exclude *://*.hualongxiang.com/*
// @exclude *://*.huanqiu.com/*
// @exclude *://*.huomao.com/*
// @exclude *://*.hupu.com/*
// @exclude *://*.huxiu.com/*
// @exclude *://*.huya.com/*
// @exclude *://*.iceo.com.cn/*
// @exclude *://*.ifeng.com/*
// @exclude *://*.ifengweekly.com/*
// @exclude *://*.iheima.com/*
// @exclude *://*.ihuaben.com/*
// @exclude *://*.ik123.com/*
// @exclude *://*.imobile.com.cn/*
// @exclude *://*.inewsweek.cn/*
// @exclude *://*.infzm.com/*
// @exclude *://*.ip138.com/*
// @exclude *://*.iqilu.com/*
// @exclude *://*.iqiyi.com/*
// @exclude *://*.isamanhua.com/*
// @exclude *://*.it168.com/*
// @exclude *://*.ixigua.com/*
// @exclude *://*.iyouman.com/*
// @exclude *://*.iyunyue.com/*
// @exclude *://*.jcrb.com/*
// @exclude *://*.jianshu.com/*
// @exclude *://*.jjckb.cn/*
// @exclude *://*.jjwxc.net/*
// @exclude *://*.jstv.com/*
// @exclude *://*.k618.cn/*
// @exclude *://*.kaimanhua.com/*
// @exclude *://*.kaixin001.com/*
// @exclude *://*.kankan.com/*
// @exclude *://*.kankanews.com/*
// @exclude *://*.kanman.com/*
// @exclude *://*.kanshu.com/*
// @exclude *://*.kaolafm.com/*
// @exclude *://*.kdnet.net/*
// @exclude *://*.km.com/*
// @exclude *://*.ku6.com/*
// @exclude *://*.kuaikanmanhua.com/*
// @exclude *://*.kugou.com/*
// @exclude *://*.kujiang.com/*
// @exclude *://*.kumanhua.net/*
// @exclude *://*.kumi.cn/*
// @exclude *://*.kuwo.cn/*
// @exclude *://*.laikan.com/*
// @exclude *://*.lcread.com/*
// @exclude *://*.le.com/*
// @exclude *://*.legaldaily.com.cn/*
// @exclude *://*.leisu.com/*
// @exclude *://*.leju.com/*
// @exclude *://*.letv.com/*
// @exclude *://*.liba.com/*
// @exclude *://*.lifeweek.com.cn/*
// @exclude *://*.lingyun5.com/*
// @exclude *://*.lkong.net/*
// @exclude *://*.lofter.com/*
// @exclude *://*.longzhu.com/*
// @exclude *://*.lottery.gov.cn/*
// @exclude *://*.lrts.me/*
// @exclude *://*.ltaaa.com/*
// @exclude *://*.luochen.com/*
// @exclude *://*.luochu.com/*
// @exclude *://*.m.fun.tv/*
// @exclude *://*.m1905.com/*
// @exclude *://*.m4.cn/*
// @exclude *://*.manben.com/*
// @exclude *://*.manhuadao.cn/*
// @exclude *://*.manhuatai.com/*
// @exclude *://*.manmanapp.com/*
// @exclude *://*.manmankan.com/*
// @exclude *://*.meipai.com/*
// @exclude *://*.mgtv.com/*
// @exclude *://*.miercn.com/*
// @exclude *://*.migu.cn/*
// @exclude *://*.mingqingxiaoshuo.com/*
// @exclude *://*.mkzhan.com/*
// @exclude *://*.moofeel.com/*
// @exclude *://*.mop.com/*
// @exclude *://*.motie.com/*
// @exclude *://*.mtime.com/*
// @exclude *://*.mtv123.com/*
// @exclude *://*.musicool.cn/*
// @exclude *://*.muyewx.com/*
// @exclude *://*.mvbox.cn/*
// @exclude *://*.myfcomic.com/*
// @exclude *://*.nba.com/*
// @exclude *://*.nbd.com.cn/*
// @exclude *://*.news.cn/*
// @exclude *://*.newsmth.net/*
// @exclude *://*.nfcmag.com/*
// @exclude *://*.nipic.com/*
// @exclude *://*.nlc.cn/*
// @exclude *://*.nowscore.com/*
// @exclude *://*.npc.gov.cn/*
// @exclude *://*.oeeee.com/*
// @exclude *://*.oneniceapp.com/*
// @exclude *://*.paidai.com/*
// @exclude *://*.pconline.com.cn/*
// @exclude *://*.pcpop.com/*
// @exclude *://*.people.com.cn/*
// @exclude *://*.pingshu8.com/*
// @exclude *://*.pps.tv/*
// @exclude *://*.pptv.com/*
// @exclude *://*.qdaily.com/*
// @exclude *://*.qdmm.com/*
// @exclude *://*.qidian.com/*
// @exclude *://*.qimao.com/*
// @exclude *://*.qingdaonews.com/*
// @exclude *://*.qingoo.cn/*
// @exclude *://*.qingting.fm/*
// @exclude *://*.qiremanhua.com/*
// @exclude *://*.qiushibaike.com/*
// @exclude *://*.qq.com/*
// @exclude *://*.qrxs.cn/*
// @exclude *://*.qwsy.com/*
// @exclude *://*.rain8.com/*
// @exclude *://*.readnovel.com/*
// @exclude *://*.rednet.cn/*
// @exclude *://*.renhe.cn/*
// @exclude *://*.renren.com/*
// @exclude *://*.ruochu.com/*
// @exclude *://*.sfacg.com/*
// @exclude *://*.sh.cn/*
// @exclude *://*.shenchuang.com/*
// @exclude *://*.shenglifubang.cn/*
// @exclude *://*.shenmantang.com/*
// @exclude *://*.shucong.com/*
// @exclude *://*.shuhai.com/*
// @exclude *://*.shuqi.com/*
// @exclude *://*.sina.cn/*
// @exclude *://*.sina.com.cn/*
// @exclude *://*.sinovision.net/*
// @exclude *://*.so.com/*
// @exclude *://*.sohu.com/*
// @exclude *://*.soudongman.com/*
// @exclude *://*.southcn.com/*
// @exclude *://*.sport.gov.cn/*
// @exclude *://*.stnn.cc/*
// @exclude *://*.storychina.cn/*
// @exclude *://*.sxcnw.net/*
// @exclude *://*.sxrb.com/*
// @exclude *://*.sznews.com/*
// @exclude *://*.tadu.com/*
// @exclude *://*.taihe.com/*
// @exclude *://*.takungpao.com/*
// @exclude *://*.tan8.com/*
// @exclude *://*.taobao.com/*
// @exclude *://*.taomanhua.com/*
// @exclude *://*.thecfa.cn/*
// @exclude *://*.thepaper.cn/*
// @exclude *://*.tiandizw.com/*
// @exclude *://*.tianya.cn/*
// @exclude *://*.tiexue.net/*
// @exclude *://*.tingbook.com/*
// @exclude *://*.titan24.com/*
// @exclude *://*.trueme.net/*
// @exclude *://*.tudou.com/*
// @exclude *://*.tvb.com/*
// @exclude *://*.tvmao.com/*
// @exclude *://*.tvsou.com/*
// @exclude *://*.txtbook.com.cn/*
// @exclude *://*.u17.com/*
// @exclude *://*.un.org/*
// @exclude *://*.v.qq.com/*
// @exclude *://*.v1.cn/*
// @exclude *://*.vmovier.com/*
// @exclude *://*.voc.com.cn/*
// @exclude *://*.vvvdj.com/*
// @exclude *://*.wasu.cn/*
// @exclude *://*.weibo.com/*
// @exclude *://*.wenming.cn/*
// @exclude *://*.wenweipo.com/*
// @exclude *://*.win001.com.cn/*
// @exclude *://*.winshang.com/*
// @exclude *://*.www.fun.tv/*
// @exclude *://*.www.gov.cn/*
// @exclude *://*.xfrb.com.cn/*
// @exclude *://*.xiami.com/*
// @exclude *://*.xiang5.com/*
// @exclude *://*.xiaomi.cn/*
// @exclude *://*.xici.net/*
// @exclude *://*.xilu.com/*
// @exclude *://*.ximalaya.com/*
// @exclude *://*.xinhuanet.com/*
// @exclude *://*.xinmanhua.net/*
// @exclude *://*.xmfish.com/*
// @exclude *://*.xmkanshu.com/*
// @exclude *://*.xs8.cn/*
// @exclude *://*.xxsy.net/*
// @exclude *://*.y2002.com/*
// @exclude *://*.yangtse.com/*
// @exclude *://*.ycwb.com/*
// @exclude *://*.yicai.com/*
// @exclude *://*.yidianzixun.com/*
// @exclude *://*.yinyuetai.com/*
// @exclude *://*.yizhibo.com/*
// @exclude *://*.yizhikan.com/*
// @exclude *://*.youth.cn/*
// @exclude *://*.yue365.com/*
// @exclude *://*.yy.com/*
// @exclude *://*.yy8844.cn/*
// @exclude *://*.yymp3.com/*
// @exclude *://*.zgjrjw.com/*
// @exclude *://*.zhangwen.cn/*
// @exclude *://*.zhangyue.com/*
// @exclude *://*.zhibo8.cc/*
// @exclude *://*.zhihu.com/*
// @exclude *://*.zhiyin.cn/*
// @exclude *://*.zhulang.com/*
// @exclude *://*.zjol.com.cn/*
// @exclude *://*.zjstv.com/*
// @exclude *://*.znds.com/*
// @exclude *://*.zol.com.cn/*
// @exclude *://*.zongheng.com/*
// @exclude *://*.zuitang.com/*
// @exclude *://*.zuowen.com/*
// @exclude *://*.zymk.cn/*
// @exclude *://github.com/*
// @exclude *://greasyfork.org/*
// @exclude *://rebang.today/*
// @exclude *://scriptcat.org/*
// @exclude *://twitter.com/*
// @exclude *://www.colamanhua.com/*
// @exclude *://x.com/*
// @run-at document-start
// @namespace https://greasyfork.org/users/452911
// ==/UserScript==
(function() {
'use strict';
// 获取当前网站URL,并根据其生成一个唯一的存储键
var storageKey = window.location.hostname;
// 根据存储键获取已保存的设置(如果存在)
var isEnabled = GM_getValue(storageKey, true);
function showAlert() {
(function() {
var g_times = 0,
itids = [],
timer;
function myfun() {
//隐藏元素
itids.push(
setTimeout(function() {
var styleTag = document.createElement('style');
styleTag.innerHTML = `
.hidden-element {
display: none !important;
visibility: hidden;
opacity: 0;
z-index: -999;
width: 0;
height: 0;
pointer-events: none;
position: absolute;
left: -9999px;
top: -9999px;
}
`;
document.head.appendChild(styleTag);
var elements = document.querySelectorAll("[style*='background-image:url(data:image/'],[id][class][classname],[ontouchstar],[class*='_'][id*='_']");
for (var i = 0; i < elements.length; i++) {
var zIndex = parseInt(elements[i].style.zIndex);
if (zIndex > 600) {
elements[i].classList.add('hidden-element');
}
}
}, 350)
);
if (g_times >= 6) {
window.clearInterval(timer);
}
g_times++;
}
itids.push(
setTimeout(function() {
//主循环计时器
timer = setInterval(myfun, 500);
itids.push(timer);
myfun();
}, 500)
);
})();
//通用规则
// 假定的输入字符串,分为三部分
const input1 = `##[style*='width: 100vw; background: url'][style$='no-repeat; position: fixed;'][style*='0px 0px / 100vw ']
##[style="position:absolute !important;padding:0px !important;margin:0px !important;width:100% !important;font-size:0px !important;line-height:0px !important;"]
##[style*="background-image:url(data:image/"]
##[class][style*="px; top: 0px; left: 0px; z-index"][style$="width: 100vw; position: relative;"]
##body > [style$="background-size: 407px 101px !important;"]
##body > [style$="background-size: 407px 104px !important;"]
##body > [style$="background-size: 407px 127.188px !important;"]
##body > [style$="background-size: 407px 127px !important;"]
##body > [style$="background-size: 407px 128px !important;"]
##body > [style$="background-size: 407px 129px !important;"]
##body > [style$="background-size: 407px 130px !important;"]
##body > [style$="background-size: 407px 132px !important;"]
##body > [style$="background-size: 407px 135px !important;"]
##body > [style$="background-size: 407px 95px !important;"]
##body > [style$="width:9.6vw;height:8.5vw;background: #000;opacity:0.01;"]
##body > [style$="width:9.6vw;height:8.5vw;background:#000;opacity:0.01;"]
##body > [style*="background"][style*="#000"][style$="opacity:0.01;"]
##body > [style*="position:fixed; bottom:0vw; left:0vw; z-index:"]
##body > [style="display: block; z-index: 2147483646; width: 14px; position: fixed; height: 14px; left: 1px; bottom: 129px; box-sizing: content-box;"]
##body > [style="display: block; z-index: 2147483646; width: 14px; position: fixed; height: 14px; left: 1px; top: 129px; box-sizing: content-box;"]
##body > [style^="display: block; z-index: 2147483647; width: 10%;"][style$="!important;"]
##body > [style^="display: block;"][style*="129px;"]
##body > [style^="position: fixed; z-index: 100; display: block; left: 0px; width: 36px;"]
##body > div#dontfoid
##body > div#fixedban
##body > div.demo-wrapper[style="display:none;"] + div[id][class]
##body > div[class$="c"][style="bottom: 135px;"]
##body > div[class$="h"][style="bottom: 135px;"]
##body > div[class$="m"][style="display: block; width: 100%; height: 135px;"]
##body > div[class="swiper swiper-initialized swiper-horizontal swiper-ios swiper-backface-hidden"]
##body > div[class][style="bottom: 104px;"]
##body > div[class][style="bottom: 129px;"]
##body > div[class][style="bottom: 135px;"]
##body > div[class][style="display: block; width: 100%; height: 129px;"]
##body > div[class][style="display: block; width: 100%; height: 135px;"]
##body > div[class][style="display: block; width: 100%; left: 0px; position: fixed; z-index: 2147483646; height: 95px; top: 101px;"]
##body > div[class][style="top: 104px;"]
##body > div[class][style="top: 129px;"]
##body > div[class][style="top: 135px;"]
##body > div[class][style^="display: block; width: 100%; left: 0px; position: fixed; z-index: 2147"][style$="top: 135px;"]
##body > div[class][style^="display: block; width: 100%; left: 0px; position: fixed; z-index: 21474"]
##body > div[id^="a17"] > div[id^="u17"]
##body > div[style$="background: #000;opacity:0.01;"]
##body > div[style^="position: fixed; inset: 0px; z-index: 2147483647; background: black; opacity: 0.01;"]
##body > embed[id][src*="://"][src$="="]
##body > embed[id][src^="https:///"]
##body > span[style*="bottom:"][style*="30vh"][style*="position"][style*="fixed"]
##div[class^="is_"] > a > img[referrerpolicy="no-referrer"]
##div[class][style$="0vh; width: 0vw; bottom: 0px; left: 0px;"]
##div[class][style$="background-size: 393px 131px !important;"]
##div[class][style*="100vw"][style*="no-repeat"][style*="background:"][style*="0px"]
##div[class][style*="9.6vw;"][style$="background: #000;opacity:0.01;"],div[class][style*="9.6vw;"][style$="background:#000;opacity:0.01;"],div[class][style*="131px"][style*="bottom"],div[style*="bottom:0vw;"][style*="9.6vw;"][style$="background: #000;opacity:0.01;"],div[style*="bottom:0vw;"][style*="9.6vw;"][style$="background:#000;opacity:0.01;"]
##div[class][style*="bottom: 0px; left: 0px; animation: 1.5s ease 0.2s infinite normal none running shakegwegs; z-index:"][style$="width: 100vw; position: fixed;"]
##div[class][style*="bottom: 0px; left: 0px; z-index:"][style*="0px 0px"][style*="no-repeat"]
##div[class][style*="display: block;"][style*="131px;"],div[class][style*="width: 100%;"][style*="131px;"],div[class][style*="z-index: 2147483646;"][style*="131px"],div[class][style*="position: fixed;"][style*="131px"],div[class][style*="z-index:"][style*="display: block;"][style$="98px;"]
##div[class][style*="top: 0px; left: 0px; animation: 1.5s ease 0.2s infinite normal none running shakegwegs; z-index:"][style*="100vw;"]
##div[class][style*="z-index:"][style*="0px 0px / 100vw"][style*="no-repeat"]
##div[class][style="display: block; width: 100%; height: 100%; left: 0px; bottom: 0px; position: fixed; z-index: 2147483646;"]
##div[class][style^="line-height:"][style*="/"][style*="100vw"][style*="0px"][style*="animation"][style*="infinite"][style*="background:"]
`;
const input2 = `##div[class][style*="9.6vw;"][style$="background: #000;opacity:0.01;"],div[class][style*="9.6vw;"][style$="background:#000;opacity:0.01;"],div[class][style*="131px"][style*="bottom"],div[style*="bottom:0vw;"][style*="9.6vw;"][style$="background: #000;opacity:0.01;"],div[style*="bottom:0vw;"][style*="9.6vw;"][style$="background:#000;opacity:0.01;"]`;
// 函数用来处理单个输入字符串并添加样式
function addCustomStyle(input) {
// 移除前两个字符 ('##'),拼接它们为CSS选择器
const selector = input.split('\n').map(line => line.slice(2)).join(',');
// 定义CSS规则
const cssRule = `${selector} {display: none !important;visibility: hidden; opacity: 0; z-index: -999; width: 0; height: 0; pointer-events: none; position: absolute; left: -9999px; top: -9999px;}`;
// 如果 GM_addStyle 函数存在,则应用样式
if (typeof GM_addStyle === 'function') {
GM_addStyle(cssRule);
} else {
console.error('GM_addStyle is not available. Ensure you are running this script in a userscript manager environment like Tampermonkey or Greasemonkey.');
}
}
// 对每一个输入执行函数
addCustomStyle(input1); // 为第一部分的选择器应用样式
addCustomStyle(input2); // 为第二部分的选择器应用样式
(function() {
const FAKE_PLATFORM = 'Mac';
const spoofNavigator = new Proxy(navigator, {
get(target, prop) {
return prop === 'platform' ? FAKE_PLATFORM : Reflect.get(target, prop);
},
getOwnPropertyDescriptor(target, prop) {
if (prop === 'platform') {
return {
value: FAKE_PLATFORM,
writable: false,
configurable: true,
enumerable: true
};
}
return Object.getOwnPropertyDescriptor(target, prop);
}
});
try {
const descriptor = Object.getOwnPropertyDescriptor(navigator, 'platform');
if (descriptor?.configurable) {
Object.defineProperty(navigator, 'platform', {
get: () => FAKE_PLATFORM,
configurable: true,
enumerable: true
});
} else if (navigator.__defineGetter__) {
navigator.__defineGetter__('platform', () => FAKE_PLATFORM);
}
Object.defineProperty(window, 'navigator', {
value: spoofNavigator,
writable: false,
configurable: true
});
const protoDescriptor = Object.getOwnPropertyDescriptor(Navigator.prototype, 'platform');
if (protoDescriptor?.configurable) {
Object.defineProperty(Navigator.prototype, 'platform', {
get: () => FAKE_PLATFORM,
configurable: true,
enumerable: true
});
}
const originalIndexOf = String.prototype.indexOf;
String.prototype.indexOf = function(searchString) {
if (this === FAKE_PLATFORM) {
if (searchString === 'Win' || searchString === 'Linux' || searchString === 'X11') return -1;
if (searchString === 'Mac') return 0;
}
return originalIndexOf.call(this, searchString);
};
} catch (e) {
console.warn('Platform spoofing fallback:', e);
window.navigator = spoofNavigator;
}
Object.freeze(window.navigator);
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', () => {
if (navigator.platform !== FAKE_PLATFORM) {
Object.defineProperty(window, 'navigator', {
value: spoofNavigator,
writable: false,
configurable: true
});
Object.freeze(window.navigator);
}
}, {
once: true
});
}
})();
}
// 根据保存的设置来启用或禁用弹出提示框功能
if (isEnabled) {
showAlert();
}
// 创建油猴菜单项,在菜单中添加“启用”和“禁用”选项
GM_registerMenuCommand(isEnabled ? '禁用buff拦截' : '启用buff拦截', function() {
isEnabled = !isEnabled;
GM_setValue(storageKey, isEnabled);
if (isEnabled) {
showAlert();
}
});
})();