From 04660635b5cf26c0009bb6f2e5b8dd78b288783b Mon Sep 17 00:00:00 2001 From: Haku Date: Wed, 24 Nov 2021 21:46:30 -0500 Subject: [PATCH] links are now fixed on ajax2 pages --- build/manifest.json | 6 ++++++ src/ajax.ts | 9 +++++++++ 2 files changed, 15 insertions(+) create mode 100644 src/ajax.ts diff --git a/build/manifest.json b/build/manifest.json index c792180..65ddf14 100644 --- a/build/manifest.json +++ b/build/manifest.json @@ -31,6 +31,12 @@ "exclude_matches": ["https://forum.nationstates.net/*"], "run_at": "document_idle", "js": ["scripts/settings.js"] + }, + { + "matches": ["https://www.nationstates.net/page=ajax2/*"], + "exclude_matches": ["https://forum.nationstates.net/*"], + "run_at": "document_idle", + "js": ["scripts/ajax.js"] } ] } \ No newline at end of file diff --git a/src/ajax.ts b/src/ajax.ts new file mode 100644 index 0000000..003c4ae --- /dev/null +++ b/src/ajax.ts @@ -0,0 +1,9 @@ +const links: NodeList = document.querySelectorAll('a'); +for (let i = 0; i < links.length; i++) { + const link: HTMLAnchorElement = links[i] as HTMLAnchorElement; + const linkParams = getUrlParameters(link.href); + if (linkParams['nation']) + link.href = `/template-overall=none/nation=${linkParams['nation']}`; + else if (linkParams['region']) + link.href = `/template-overall=none/region=${linkParams['region']}`; +} \ No newline at end of file