您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Open links in new tab. Ctrl-click or Middle-click loads it in background, Alt-click opens normally
当前为
- // ==UserScript==
- // @name Open links in new tab
- // @description Open links in new tab. Ctrl-click or Middle-click loads it in background, Alt-click opens normally
- // @include *
- // @namespace wOxxOm.scripts
- // @author wOxxOm
- // @version 2.0.2
- // @license MIT License
- // @grant GM_openInTab
- // @run-at document-start
- // ==/UserScript==
- var suppressing;
- window.addEventListener('mousedown', function(e) {
- if (e.button > 1 || e.altKey)
- return;
- var link = e.target.closest('a');
- if (!link ||
- (link.getAttribute('href') || '').match(/^(javascript|#|$)/) ||
- link.href.replace(/#.*/, '') == location.href.replace(/#.*/, '')
- )
- return;
- GM_openInTab(link.href, e.button || e.ctrlKey);
- suppressing = true;
- prevent(e);
- }, true);
- window.addEventListener('click', prevent, true);
- window.addEventListener('mouseup', prevent, true);
- window.addEventListener('auxclick', prevent, true);
- function prevent(e) {
- if (!suppressing)
- return;
- e.preventDefault();
- e.stopPropagation();
- e.stopImmediatePropagation();
- if (e.type == 'mouseup') {
- setTimeout(function() {
- suppressing = false;
- }, 100);
- }
- }