zjqmh
小狐狸
小狐狸
  • UID6156
  • 注册日期2005-05-19
  • 最后登录2019-05-01
  • 发帖数10
  • 经验14枚
  • 威望0点
  • 贡献值8点
  • 好评度0点
阅读:797回复:0

怎么把油猴user.js脚本改成uc.js脚本

楼主#
更多 发布于:2019-03-19 16:24
求助,把如下新标签打链接油猴脚本改成UC脚本,非常感谢

// ==UserScript==
// @Name         新标签页打开链接
// @description  Open links in new tab
// @include      *
// @namespace    wOxxOm.scripts
// @author       wOxxOm
// @version      2.0.5
// @license      MIT License
// @Grant        GM_openInTab
// @run-at       document-start
// ==/UserScript==

var suppressing, clickedElement;

window.addEventListener('mousedown', function(e) {
   clickedElement = e.target;
}, true);

window.addEventListener('mouseup', function(e) {
   if (e.button > 1 || e.target != clickedElement)
       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, {
       active: true,
       setParent: true,
       insert: true,
   });
   suppressing = true;
   setTimeout(function() {
       window.dispatchEvent(new MouseEvent('mouseup', {bubbles: true}));
   });
   prevent(e);
}, true);

window.addEventListener('click', prevent, true);
window.addEventListener('auxclick', prevent, true);

function prevent(e) {
   if (!suppressing)
       return;
   e.preventDefault();
   e.stopPropagation();
   e.stopImmediatePropagation();
   setTimeout(function() {
       suppressing = false;
   }, 100);
}
游客

返回顶部