diff --git a/manifest.json b/manifest.json index c4ee64a5..22ead839 100644 --- a/manifest.json +++ b/manifest.json @@ -25,5 +25,5 @@ "128": "src/assets/os-icons/os-icon-128.png" }, "host_permissions": [""], - "permissions": ["storage","webRequest"] + "permissions": ["storage","webRequest", "activeTab", "tabs"] } diff --git a/src/content-scripts/profileScreen.ts b/src/content-scripts/profileScreen.ts index acde284f..495f2a15 100644 --- a/src/content-scripts/profileScreen.ts +++ b/src/content-scripts/profileScreen.ts @@ -11,4 +11,11 @@ if (username != null) { else injectInviteToOpenSauced(username); } }; -processProfilePage(); + +chrome.runtime.onMessage.addListener((request) => { + if (request.message === "GITHUB_URL_CHANGED") { + processProfilePage(); + } +}); + +processProfilePage(); \ No newline at end of file diff --git a/src/worker/background.ts b/src/worker/background.ts index 3e9f8919..fc06844c 100644 --- a/src/worker/background.ts +++ b/src/worker/background.ts @@ -1,8 +1,14 @@ -import { SUPABASE_LOGOUT_URL, OPEN_SAUCED_AUTH_TOKEN_KEY } from "../constants"; +import { SUPABASE_LOGOUT_URL, OPEN_SAUCED_AUTH_TOKEN_KEY } from "../constants"; chrome.webRequest.onCompleted.addListener( - (details) => { - chrome.storage.sync.remove(OPEN_SAUCED_AUTH_TOKEN_KEY); - }, - { urls: [SUPABASE_LOGOUT_URL] } - ); \ No newline at end of file + (details) => { + chrome.storage.sync.remove(OPEN_SAUCED_AUTH_TOKEN_KEY); + }, + { urls: [SUPABASE_LOGOUT_URL] } +); + +chrome.tabs.onUpdated.addListener(function (tabId, changeInfo) { + if (changeInfo.url?.includes("github.com")) { + chrome.tabs.sendMessage(tabId, { message: "GITHUB_URL_CHANGED" }); + } +});