问题
I want to run a Greasemonkey script on Firefox network error pages, such as (but not limited to) this one:
Can I do this with chrome://
URLs? If so, what are they? If not, is there another way?
回答1:
Well, I was almost on the right track. Two things:
- Network error pages begin with
about:neterror
, notchrome://
. If you try to accessww.example.com
(missing a w) then you will be redirected toabout:neterror?e=dnsNotFound&u=http%3A//ww.example.com/&c=UTF-8&d=Firefox%20can%27t%20find%20the%20server%20at%20ww.example.com
- You cannot
// @include about:neterror*
.
But since we know the URL format, we can
// @include *
and check:
if (document.documentURI.search('about:neterror') != -1) {
doStuffOnNetError();
}
Thanks for the hints, Brock.
来源:https://stackoverflow.com/questions/3772777/greasemonkey-script-on-firefox-network-error-page