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