您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Greasy Fork is available in English.
全站通用型页内增强脚本,Bing兼容,bili兼容.添加kook按钮排除
当前为
// ==UserScript== // // @name 当页开链 // @version 3.9 // @description 全站通用型页内增强脚本,Bing兼容,bili兼容.添加kook按钮排除 // @author none // @match *://*/* // @grant unsafeWindow // @run-at document-body // @namespace // @exclude-match *://www.gamer520.com/* // // @namespace // ==/UserScript== (function() { 'use strict'; function setFormTargetSelf() { document.querySelectorAll('form').forEach(form => { form.setAttribute('target', '_self'); }); new MutationObserver(mutations => { mutations.forEach(({ addedNodes }) => { addedNodes.forEach(node => { if (node.nodeName === 'FORM') { node.setAttribute('target', '_self'); } if (node.querySelectorAll) { node.querySelectorAll('form').forEach(newForm => { newForm.setAttribute('target', '_self'); }); } }); }); }).observe(document.body, { childList: true, subtree: true }); } const shouldExcludeElement = (target) => { const EXCLUDE_SELECTORS = [ '.nav-content', '.views', '.presentation', '.pay-box', '[target="_self"]', '[role="group"]', '#ks', '.bpx-player-ending-related-item-cover', '#qs_searchBox', '.actions', '#b_header' ]; return EXCLUDE_SELECTORS.some(selector => target.closest(selector)); }; // 合并后的唯一click监听器 document.addEventListener('click', function(event) { const path = event.composedPath(); let target = path[0] || event.target; if (shouldExcludeElement(target) || target.closest('form')) { return true; } let link = target.closest('a'); if (!link) { link = target; while (link && link.tagName !== 'A') { link = link.parentElement; } } if (link && link.tagName === 'A') { event.preventDefault(); window.location.href = link.href; } }, true); // 保留捕获阶段 const main = () => { if (window.self !== window.top) return; // 保持window.open劫持 unsafeWindow.open = function(url) { window.location.href = url; }; setFormTargetSelf(); }; document.readyState === 'complete' ? main() : document.addEventListener('DOMContentLoaded', main); })();