// ==UserScript== // @name bilinovel反检测 // @namespace https://viayoo.com/zt6kh2 // @version 1.6 // @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'; const RECOVERY_STYLE = 'display:block!important;visibility:visible!important;opacity:1!important;position:static!important;transform:none!important;filter:none!important;clip:auto!important;clip-path:none!important;width:auto!important;height:auto!important;pointer-events:auto!important;'; const BLOCK_REGEX = /hairlie-top|whitelist|AdBlock|detect|屏蔽|检测到|浏览体验|内容无法显示|Guard\/AdBl/i; const TARGET_IDS = ['acontent', 'TextContent', 'volumes', 'volume-list']; const forceShow = (el) => { if (!el || el.dataset.shadowed) return; if (el.getAttribute('style') !== RECOVERY_STYLE) { domProtector.disconnect(); el.removeAttribute('style'); el.style.cssText = RECOVERY_STYLE; const prev = el.previousElementSibling; if (prev && !/atitle|section_title|h1|h2/i.test(prev.tagName + prev.className)) { prev.style.setProperty('display', 'none', 'important'); } startObserve(); } }; const protectWithShadow = (originalNode) => { if (!originalNode || originalNode.dataset.shadowed || originalNode.textContent.trim().length < 50) return; const host = document.createElement('div'); host.id = 'shadow-content-protector'; host.style.cssText = 'position:relative!important;display:block!important;width:100%!important;z-index:1!important;'; const shadow = host.attachShadow({mode: 'closed'}); document.querySelectorAll('link[rel="stylesheet"]').forEach(css => shadow.appendChild(css.cloneNode(true))); const contentClone = originalNode.cloneNode(true); contentClone.id = 'shadow-inner-content'; const innerStyle = document.createElement('style'); innerStyle.textContent = ` :host { display: block!important; } #shadow-inner-content { display: block!important; visibility: visible!important; position: static!important; transform: none!important; opacity: 1!important; } .csgo, .co, ins, script, [href*="whitelist"], .hairlie-top { display: none !important; height: 0 !important; } p { margin: 1em 0; line-height: 1.8; } `; shadow.appendChild(innerStyle); shadow.appendChild(contentClone); originalNode.dataset.shadowed = 'true'; originalNode.style.cssText = 'position:absolute!important;top:-9999px!important;visibility:hidden!important;pointer-events:none!important;'; originalNode.parentNode.insertBefore(host, originalNode); }; const checkAndBlock = (node) => { if (node && node.nodeType === 1) { if (BLOCK_REGEX.test(node.textContent) || BLOCK_REGEX.test(node.innerHTML) || BLOCK_REGEX.test(node.id + node.className)) { return true; } } return false; }; ['appendChild', 'insertBefore'].forEach(method => { const original = Node.prototype[method]; Node.prototype[method] = function(...args) { if (checkAndBlock(args[0])) return args[0]; return original.apply(this, args); }; }); Object.defineProperty(window, 'anra', { value: () => {}, writable: false }); document.writeln = new Proxy(document.writeln, { apply: (target, thisArg, args) => BLOCK_REGEX.test(args[0]) ? null : target.apply(thisArg, args) }); window.unlockScroll = function() { if (!document.body) return; if (!document.getElementById('scroll-unlocker-style')) { const style = document.createElement('style'); style.id = 'scroll-unlocker-style'; style.textContent = `html, body { overflow: auto!important; -webkit-overflow-scrolling: touch!important; position: relative!important; } body.no-scroll, body.modal-open, body.scroll-locked { overflow: auto!important; }.modal-backdrop, .van-overlay, .am-modal-mask { display: none!important; }`; (document.head || document.documentElement).appendChild(style); } document.documentElement.style.overflow = 'visible'; document.body.style.overflow = 'visible'; }; const restoreCopy = () => { const events = ['copy', 'selectstart', 'contextmenu', 'dragstart']; events.forEach(e => document.addEventListener(e, ev => ev.stopImmediatePropagation(), true)); events.forEach(e => { Object.defineProperty(document, 'on' + e, { get: () => null, configurable: true }); }); }; const domProtector = new MutationObserver(mutations => { for (const mutation of mutations) { mutation.addedNodes.forEach(node => { if (node.nodeType !== 1) return; if (TARGET_IDS.includes(node.id)) forceShow(node); if (node.tagName === 'STYLE' && BLOCK_REGEX.test(node.textContent)) node.remove(); if (BLOCK_REGEX.test(node.id + node.className)) node.style.display = 'none'; }); if (mutation.type === 'attributes' && TARGET_IDS.includes(mutation.target.id)) { const target = mutation.target; const style = window.getComputedStyle(target); if (style.display === 'none' || style.visibility === 'hidden' || target.offsetHeight < 10) { forceShow(target); if (target.offsetHeight < 10) protectWithShadow(target); } } } }); const startObserve = () => { domProtector.observe(document.documentElement, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); }; const init = () => { startObserve(); restoreCopy(); unlockScroll(); const baseStyle = document.createElement('style'); baseStyle.textContent = ` #acontent, #TextContent, #volumes, #volume-list { display: block!important; visibility: visible!important; transform: none!important; } .hairlie-top, .fc-ab-root, a[href*="whitelist"], .csgo, ins.adsbygoogle { display: none!important; } `; (document.head || document.documentElement).appendChild(baseStyle); setInterval(() => { unlockScroll(); TARGET_IDS.forEach(id => { const el = document.getElementById(id); if (el && !el.dataset.shadowed) { const rect = el.getBoundingClientRect(); if (rect.height < 10) protectWithShadow(el); else forceShow(el); } }); }, 1000); }; if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', init); } else { init(); } })();