Answer the question
In order to leave comments, you need to log in
How to enable greasemonkey script on 404 page?
Hi all. How to make greasemonkey script work on 404 page? Even just trying to display an alert, it does not work, although if you click on the extension icon, it will show that the script is working on this page
Answer the question
In order to leave comments, you need to log in
If you look for such solutions, then the majority rests on the search for the string "not found" and / or "404".
I would prefer the re-request option.
For a specific site, specify // include http://site.com/*
To process all 404 pages // include *
It is also important to specify// @run-at document-start
// ==UserScript==
// @name page404handler
// @namespace page404handler
// @version 0.0.1
// @include *
// @grant none
// @run-at document-start
// ==/UserScript==
var url = document.location.href;
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (xhr.readyState == 4 && xhr.status === 404) {
console.log('Page not found');
// do something
}
}
xhr.open('GET', url, true);
xhr.send();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question