// ==UserScript== // @name Xchina disable popup // @namespace http://tampermonkey.net/ // @version 1.4 // @description 绕过xChina弹窗检测 // @author Aloazny && Grok // @license MIT // @run-at document-start // @match *://*.1909.me/* // @match *://*.8se.me/* // @match *://*.crxs.me/* // @match *://*.litu100.xyz/* // @match *://*.shise.me/* // @match *://*.xbbs.me/* // @match *://*.xbookcn.org/* // @match *://*.xchina-cn.com/* // @match *://xchina-cn.com/* // @match *://*.xchina.biz/* // @match *://*.xchina.co/* // @match *://*.xchina.com/* // @match *://*.xchina.fun/* // @match *://*.xchina.pro/* // @match *://*.xchina.store/* // @match *://*.xchina.tv/* // @match *://*.xchina.site/* // @grant unsafeWindow // @grant GM_addStyle // @grant GM_cookie // ==/UserScript== (function () { 'use strict'; const w = typeof unsafeWindow !== 'undefined' ? unsafeWindow : window; const d = document; function setCookie(name, value) { const domain = '.' + location.hostname.split('.').slice(-2).join('.'); const secure = location.protocol === 'https:' ? '; secure' : ''; const expires = new Date(Date.now() + 31536e6).toUTCString(); d.cookie = `${name}=${value}; expires=${expires}; path=/; domain=${domain}${secure}`; } const cookieFix = /showed_adscarat_shuffle_box=0|clicked_modal=0/g; setCookie('showed_adscarat_shuffle_box', '1'); setCookie('clicked_modal', '1'); if (typeof GM_cookie === 'object') { ['showed_adscarat_shuffle_box', 'clicked_modal'].forEach(c => GM_cookie.set({ name: c, value: '1', url: location.href, expirationDate: ~~(Date.now() / 1e3) + 31536e6 }) ); } const cookieDesc = Object.getOwnPropertyDescriptor(Document.prototype, 'cookie'); if (cookieDesc) { Object.defineProperty(d, 'cookie', { get: function () { return cookieDesc.get.call(this).replace(cookieFix, '$&'.replace(/=0/g, '=1')); }, set: function (v) { v = v.replace(cookieFix, '$&'.replace(/=0/g, '=1')); cookieDesc.set.call(this, v); }, configurable: true }); } w.googleAdsInstance = { initGoogleTag: () => { w.googletag = { cmd: [] }; }, initAdSense: () => { w.adsbygoogle = []; } }; w.googleAdsInstance.initGoogleTag(); w.googleAdsInstance.initAdSense(); const realFetch = w.fetch; w.fetch = function(url, opts) { if (url && url.includes && url.includes('6888.site/v2.php')) { const res = { ok: true }; return Promise.resolve(res); } return realFetch.apply(this, arguments); }; Object.defineProperty(w, 'googleAdsInstance', { value: w.googleAdsInstance, writable: false }); w.adConfigInstance = { active: true }; w.adsSystemLoaded = w.AD_SCRIPT_LOADED = true; w.google_ad_client = 'ca-pub-2085856493428967'; const noop = { fire: () => {}, show: () => {}, hide: () => {}, close: () => {}, showModal: () => {}, setContent: () => noop }; ['Swal', 'sweetAlert', 'layer', 'artDialog', 'dialog', 'modal', 'Modal', 'ModalAlert'].forEach(name => Object.defineProperty(w, name, { value: noop, writable: false, configurable: false }) ); const blockRegex = /Swal|modal_alert|请关闭广告拦截|isBlocked/i; const realSetTimeout = w.setTimeout; w.setTimeout = new Proxy(w.setTimeout, { apply: (t, _, a) => blockRegex.test(a[0] + '') ? 0 : t(...a) }); w.setInterval = new Proxy(w.setInterval, { apply: (t, _, a) => blockRegex.test(a[0] + '') ? 0 : t(...a) }); d.addEventListener('beforescriptexecute', e => { if (blockRegex.test(e.target.textContent)) { e.preventDefault(); e.stopPropagation(); e.target.remove(); } }, true); const baseCSS = '.modal-alert,.block-overlay,.adblock-overlay{display:none!important}'; typeof GM_addStyle === 'function' ? GM_addStyle(baseCSS) : (d.head || d.documentElement).appendChild(Object.assign(d.createElement('style'), { textContent: baseCSS })); const hideCSS = ` [src^="https://xchina.click/"], a[clickmode="cpt"][target="_blank"][rel="nofollow noopener"] > img[src*="xchina"], a[href*="/xchina.fun/redirect/ad"], a[href*="xchina.click/prepare."], a[href^="https://xchina.app"], a[href^="https://xchina.click/"], div[linkurl^="https://xchina.click/"], div[url^="https://xchina.click/"], iframe[width="728"][height="90"], ins.adsbygoogle[data-ad-slot], script[src$="/ad-provider.js"] + ins, .google-adsbygoogle, .a-media.ex-728-90, .push-bottom-container[clickmode="cpt"], .push-bottom-container[key] > .push-bottom, .push-top-container > .push-top[key], .push-slider[key^="clicked_cpt"], a[clickmode="ad"], a[clickmode="cpt"], a[href*="//go.mnaspm.com"], iframe[src*=".magsrv.com/"], div.ex-300-250, div.item > div.a-media, div.media > a > img[src*="xchina"], div.recommendation_widget, div[class*="jquery-modal"], div[class*="modalAd"], div[style*="width: 300px;"][style*="height: 455px;"], .ad, .push-top, .media, .slider-ad, .push-bottom, .exoclick_300x250, .exoclick_300x500, [adid], [class*="exoclick_"], [class*="fa-ban"], [class^="photoMask"], [class^="playerMask"], [href="#"]:not([data-page]), .outer-banner, .photos > div.item > div > a[target="_blank"], .photos > div.item > div[class^="exoclick_"], div > div:only-child > .media img[src*="/ad/"], div[class^="item photo zone"] {display:none!important} `.trim(); typeof GM_addStyle === 'function' ? GM_addStyle(hideCSS) : (d.head || d.documentElement).appendChild(Object.assign(d.createElement('style'), { textContent: hideCSS })); // 适配Webview105以下 const imgCSS = ` div.media > a > img[src^="https://upload.xchina.biz/ad/"] {display:none!important} div.media > a > img[src^="https://upload.xchina.biz/ad/"] ~ .. {display:none!important} `.trim(); typeof GM_addStyle === 'function' ? GM_addStyle(imgCSS) : (d.head || d.documentElement).appendChild(Object.assign(d.createElement('style'), { textContent: imgCSS })); d.addEventListener('DOMContentLoaded', () => { document.querySelectorAll('[class$="article"]').forEach(el => { if (el.querySelector('.media > a > img[src^="https://upload.xchina.biz/ad/"]')) el.style.display = 'none'; }); document.querySelectorAll('div.item').forEach(el => { if (el.querySelector('div.a-media')) el.style.display = 'none'; }); document.querySelectorAll('div.media').forEach(el => { if (el.querySelector('a > img[src*="xchina"]')) el.style.display = 'none'; }); document.querySelectorAll('.photos > div.item').forEach(el => { if (el.querySelector('div > a[target="_blank"]') || el.querySelector('div[class^="exoclick_"]')) { el.style.display = 'none'; } }); document.querySelectorAll('div').forEach(el => { const child = el.firstElementChild; if (child && child === el.lastElementChild && child.querySelector && child.querySelector('.media img[src*="/ad/"]')) { el.style.display = 'none'; } }); }, false); })();