Update MediaWiki Redirects Fixer to 1.0.1

- Add wiki.archlinux.org, wiki.winehq.org, and wiki.archiveteam.org
- Fix handling !0 and !1 (example: https://wiki.archiveteam.org/index.php/Wiki_farms)
This commit is contained in:
blankie 2024-01-02 11:23:15 +11:00
parent 8d5abf9a30
commit ad095620d9
Signed by: blankie
GPG Key ID: CC15FC822C7F61F5
1 changed files with 11 additions and 2 deletions

View File

@ -2,8 +2,11 @@
// @name MediaWiki Redirects Fixer
// @namespace blankie-scripts
// @match https://*.wikipedia.org/*
// @match https://wiki.archlinux.org/*
// @match https://wiki.winehq.org/*
// @match https://wiki.archiveteam.org/*
// @grant none
// @version 1.0.0
// @version 1.0.1
// @author blankie
// @description Fixes redirects of pages with anchors on Wikipedia/MediaWiki instances when Javascript is disabled
// @inject-into content
@ -29,7 +32,13 @@ for (let script of document.querySelectorAll("script")) {
continue;
}
let rlconf = JSON.parse(match[1]);
// Handle things like "wgCSPNonce":!1
let rlconf = match[1].replaceAll(/(?<=[{,])("\w+":)!([01])(?=[,}])/g, function(_, p1, p2) {
let value = p2 == "0" ? "true" : "false";
return `${p1}${value}`;
});
rlconf = JSON.parse(rlconf);
if (rlconf.wgInternalRedirectTargetUrl) {
let url = new URL(rlconf.wgInternalRedirectTargetUrl, location);
let scrollTo = url.hash;