Skip to content

Commit

Permalink
feat: gh-page-update-listener
Browse files Browse the repository at this point in the history
  • Loading branch information
Anush008 committed Apr 26, 2023
1 parent 1c337c2 commit 4aa584c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@
"128": "src/assets/os-icons/os-icon-128.png"
},
"host_permissions": ["<all_urls>"],
"permissions": ["storage","webRequest"]
"permissions": ["storage","webRequest", "activeTab", "tabs"]
}
9 changes: 8 additions & 1 deletion src/content-scripts/profileScreen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,11 @@ if (username != null) {
else injectInviteToOpenSauced(username);
}
};
processProfilePage();

chrome.runtime.onMessage.addListener((request) => {
if (request.message === "GITHUB_URL_CHANGED") {
processProfilePage();
}
});

processProfilePage();
18 changes: 12 additions & 6 deletions src/worker/background.ts
Original file line number Diff line number Diff line change
@@ -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] }
);
(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" });
}
});

0 comments on commit 4aa584c

Please sign in to comment.