MCPcopy Index your code
hub / github.com/hoothin/UserScripts / openInNewTab

Method openInNewTab

Pagetual/pagetual.user.js:7317–7334  ·  view source on GitHub ↗
(eles)

Source from the content-addressed store, hash-verified

7315 }
7316
7317 openInNewTab(eles) {
7318 if (openInNewTab) {
7319 [].forEach.call(eles, ele => {
7320 if (compareNodeName(ele, ["a"]) && ele.href && !/^(mailto:|javascript:)|#/.test(ele.href)) {
7321 ele.setAttribute('target', openInNewTab == 1 ? '_blank' : '_self');
7322 } else {
7323 [].forEach.call(ele.querySelectorAll('a[href]:not([href^="mailto:"]):not([href^="javascript:"]):not([href^="#"])'), a => {
7324 if (openInNewTab == 1) {
7325 a.setAttribute('target', '_blank');
7326 if (a.getAttribute('onclick') == 'atarget(this)') {
7327 a.removeAttribute('onclick');
7328 }
7329 } else a.setAttribute('target', '_self');
7330 });
7331 }
7332 });
7333 }
7334 }
7335
7336 lazyImgAction(eles, doc) {
7337 if (!eles || eles.length == 0) return;

Callers 2

getPageElementMethod · 0.95
pageActionMethod · 0.95

Calls 1

compareNodeNameFunction · 0.85

Tested by

no test coverage detected