Run tampermonkey userscript on non existing page?

27 Views Asked by At

I want to run a tampermonkey script on a non existing page in firefox ("Page not found" - default page). The typical method I use to inject a payload like this does not work:

window.addEventListener('load', function()
{
  setTimeout(init, 2000);
});

Of course, the load event might never be triggered, even if the firefox shows a default page "Server not found". I mean there is HTML content on it, so I figured it might be possible, as it is sort of a page. I tried to only use setTimeout(init, 2000);, but this also did not run the code. I tried both individually:

// @match        http://not.existing.yahoo.com/
// @match        https://not.existing.yahoo.com/

Although the URL bar shows http://not.existing.yahoo.com/, it does not execute my code. The syntax is okay - it is just a console.log for reference. The page is a different one actually but for data protection I used this to hide the actual "userspace". I run it on my companys domain, which I do not want to reveal. I mean, yahoo.com would propably return some page, But this is not what I want.

I do not want to create a webserver to run javascript, that I regularly want to run. If find it however very sketchy to load an actually existing page and overwrite the page, just to run a local javascript. And yes, I have a usecase, where a notejs server or similar is not an option. I actually need to run it directly in this browser window. I am using firefox for reference.

Just for reference, this is my init function:

async function init()
{
  console.log("TEST");
}

Did anyone ever pull this off - running a userscript in tampermonkey without an actually existing page?

0

There are 0 best solutions below