From 85b4683a66395cad926d21afdff752a5f8273496 Mon Sep 17 00:00:00 2001 From: Index Date: Tue, 2 Jul 2024 13:35:04 -0500 Subject: [PATCH] feat: add redirects for old Polytoria site paths --- js/site-redirects.js | 37 +++++++++++++++++++++++++++++++++++++ manifest.json | 5 +++++ 2 files changed, 42 insertions(+) create mode 100644 js/site-redirects.js diff --git a/js/site-redirects.js b/js/site-redirects.js new file mode 100644 index 0000000..b1d026e --- /dev/null +++ b/js/site-redirects.js @@ -0,0 +1,37 @@ +const URLs = [ + { + Old: "/games/", + New: "/places/" + }, + + { + Old: "/shop/", + New: "/store/" + }, + + { + Old: "/my/referrals", + New: "/my/settings/referrals" + }, + + { + Old: "/create/?t=", + New: "/create/" + }, + + { + Old: "/user/", + New: "/users/" + }, + + { + Old: "/library/", + New: "/models/" + } +] + +let Matches = URLs.filter((x) => window.location.pathname.startsWith(x.Old)) +if (Matches.length > 0) { + let Match = Matches[0] + window.location.pathname = window.location.pathname.replace(Match.Old, Match.New) +} \ No newline at end of file diff --git a/manifest.json b/manifest.json index bcc750d..8d643ac 100644 --- a/manifest.json +++ b/manifest.json @@ -118,6 +118,11 @@ "js": ["/js/library-download.js"] }, + { + "matches": ["https://polytoria.com/games/*", "https://polytoria.com/shop/*", "https://polytoria.com/my/referrals", "https://polytoria.com/create/?t=*", "https://polytoria.com/user/*", "https://polytoria.com/library/*"], + "js": ["/js/site-redirects.js"] + }, + { "matches": ["https://polytoria.com/places/**", "https://polytoria.com/u/**"], "js": ["the-great-divide.js"]