Discussions » Creation Requests

Auto open URLs on certain pages

§
Posted: 2019-07-01

Auto open URLs on certain pages

Hi -- I am looking for a script that will result in opening all URLs on a page from a specific site in new tabs or windows (doesn't matter). I have found the script below but it doesn't seem to work. Is Chrome not allowing this kind of behavior?

Thanks for your help!

// ==UserScript== // @name Open links in background window // @author Lex1 // @version 1.4 // @description Sets links in a page to open in new background window. // @include https://www.testpage123xyz.com/* // @exclude http://mail.google.com/* // @exclude https://mail.google.com/* // ==/UserScript==

function clickujsenabled(e) { var a = e.srcElement; while (a.nodeName != 'A' && a.nodeName != 'HTML') { a = a.parentNode; } if (a.href && a.protocol != 'javascript:' && a.getAttribute('href')[0] != '#') { window.open(a.href, 'blank').blur() e.stopPropagation(); e.preventDefault(); } };

document.addEventListener('click', click_ujsenabled, false);

FFW
§
Posted: 2019-07-12

Yes, I think Chrome doesn't allow that, you'll need to call the function the is built in your scripts manager "GM_openInTab" instead of "window.open".

FFW
§
Posted: 2019-07-12

Assuming that this script is working but not opening tabs in background, instead it opens and focuses the tab.

§
Posted: 2019-09-02

Yeah, discord doesn't allow this due to it may be dangerous.

Post reply

Sign in to post a reply.