您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
2020-06-07 19:17:09
// ==UserScript== // @name 链接地址全在【当前/新建】标签页中打开 // @namespace Open in self/new tab. // @match *://*/* // @grant GM_registerMenuCommand // @grant GM_unregisterMenuCommand // @grant GM_getValue // @grant GM_setValue // @version 0.0.3 // @author 稻米鼠 // @description 2020-06-07 19:17:09 // ==/UserScript== /** 获取是否显示页面工具栏 **/ let isShowPageBar = GM_getValue('inNewPage', true); console.log(isShowPageBar) const menuNames = ['【当前】在当前标签打开链接', '【当前】在新标签打开链接'] const main = ()=>{ document.querySelectorAll('a').forEach(el=>{ if(isShowPageBar){ if(/^_blank$/i.test(el.target)) return el.target = '_blank' }else{ if(/^(_self)?$/i.test(el.target)) return el.target = '_self' } console.log(el.innerText) }) } const init = (caption, captionRemove)=>{ GM_unregisterMenuCommand(captionRemove) GM_registerMenuCommand(caption, ()=>{ isShowPageBar = !isShowPageBar GM_setValue('inNewPage', isShowPageBar) main() alert('当前页面立刻生效,其他页面刷新后生效。') }) } if(isShowPageBar){ init(menuNames[1], menuNames[0]) }else{ init(menuNames[0], menuNames[1]) } main() document.addEventListener('DOMNodeInserted', (e)=>{ main() }) window.addEventListener('load', ()=>{ main() })
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址