Greasy Fork is available in English.

Discussions » Creation Requests

Auto open URLs on certain pages

§
Posted: 01.07.2019.

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 click_ujsenabled(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: 12.07.2019.

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: 12.07.2019.

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

§
Posted: 02.09.2019.

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

Post reply

Sign in to post a reply.