// ==UserScript== // @name bilinovel反检测 // @namespace https://viayoo.com/zt6kh2 // @version 1.1 // @description 移除www.bilinovel.com和www.linovelib.com的Adblock检测,移除复制限制。 // @author Aloazny // @match http*://*.bilinovel.*/* // @match https://www.bilinovel.com/* // @match https://www.linovelib.com/* // @icon https://www.bilinovel.com/favicon.ico // @run-at document-start // @license MIT // @grant none // ==/UserScript== (function() { 'use strict'; (function() { const adsbygoogle = window.adsbygoogle = window.adsbygoogle || []; adsbygoogle.loaded = true; adsbygoogle.push = function() {}; const originalError = window.onerror; window.onerror = function(msg, src) { if (src && src.includes('googlesyndication.com')) return true; if (originalError) return originalError.apply(this, arguments); }; })(); const protectWithShadow = (originalNode) => { if (!originalNode || originalNode.dataset.protected) return; const host = document.createElement('div'); host.id = 'shadow-content-protector'; host.style.cssText = 'position: relative !important; width: 100% !important; display: block !important; z-index: 999999 !important; background: inherit !important;'; const shadow = host.attachShadow({mode: 'closed'}); document.querySelectorAll('link[rel="stylesheet"], style').forEach(css => { shadow.appendChild(css.cloneNode(true)); }); const contentClone = originalNode.cloneNode(true); contentClone.removeAttribute('style'); const style = document.createElement('style'); style.textContent = ` :host { display: block; color: inherit; font-size: inherit; background: transparent !important; } #acontent, .contente, #TextContent { display: block !important; position: static !important; transform: none !important; visibility: visible !important; opacity: 1 !important; width: auto !important; height: auto !important; } .csgo, .co, ins, script, [href*="whitelist"], div[style*="flex"] > a[href*="whitelist"] { display: none !important; } p { margin: 1em 0; line-height: 1.8; } `; shadow.appendChild(style); shadow.appendChild(contentClone); originalNode.dataset.protected = 'true'; originalNode.style.setProperty('display', 'none', 'important'); originalNode.style.setProperty('position', 'absolute', 'important'); originalNode.style.setProperty('top', '-9999px', 'important'); originalNode.parentNode.insertBefore(host, originalNode); }; (function() { const interceptors = { eval: function(original) { return function(code) { if (typeof code === 'string') { const test = code.toLowerCase(); if (test.includes('debugger') && test.includes('about:blank')) return; } return original.apply(this, arguments); }; }, setInterval: function(original) { return function(fn, delay) { if (typeof fn === 'function') { const str = Function.prototype.toString.call(fn); if (str.includes('adBlockCheck') || str.includes('checkAdBlock')) return 0; } return original.apply(this, arguments); }; } }; Object.keys(interceptors).forEach(key => { if (window[key]) { window[key] = interceptors[key](window[key]); } }); })(); const domProtector = new MutationObserver(mutations => { mutations.forEach(({addedNodes}) => { addedNodes.forEach(node => { if (node.nodeType !== 1) return; if (node.querySelector?.('a[href*="whitelist"]') || node.matches?.('div[style*="z-index:9999"], .hairlie-top')) { node.remove(); return; } if (node.id === 'acontent' || node.id === 'TextContent') { protectWithShadow(node); } if (node.tagName === 'STYLE') { const content = node.textContent || ''; if (content.includes('AdGuard') && content.includes(':before')) { node.remove(); } } }); }); }); const restoreCopy = () => { const events = ['copy', 'select', 'selectstart', 'contextmenu', 'beforecopy']; events.forEach(e => document.addEventListener(e, e => e.stopImmediatePropagation(), true)); Object.defineProperty(document, 'oncopy', { get: () => null, configurable: true }); Object.defineProperty(document, 'onselectstart', { get: () => null, configurable: true }); }; const init = () => { domProtector.observe(document, { childList: true, subtree: true, attributes: true, attributeFilter: ['style'] }); restoreCopy(); const checkContent = () => { const targets = document.querySelectorAll('#acontent:not([data-protected]), #TextContent:not([data-protected])'); targets.forEach(el => protectWithShadow(el)); document.querySelectorAll('a[href*="whitelist"]').forEach(el => { const parent = el.closest('div'); if (parent) parent.remove(); }); }; setInterval(checkContent, 800); document.addEventListener('DOMContentLoaded', checkContent); }; if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', init); } else { setTimeout(init, 0); } Object.defineProperty(window, 'anra', { value: () => {}, writable: false }); document.writeln = new Proxy(document.writeln, { apply: function(target, thisArg, args) { if (args[0]?.includes?.('hairlie-top') || args[0]?.includes?.('whitelist')) return; return target.apply(thisArg, args); } }); })();