Skip to content

Commit

Permalink
Merge pull request #5 from damianmgarcia/bug-no-tab-id-error
Browse files Browse the repository at this point in the history
Hide n' Seek 4.1.1
  • Loading branch information
damianmgarcia authored Feb 25, 2023
2 parents bbe40db + e13cfc6 commit 8e4bb84
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 15 deletions.
30 changes: 21 additions & 9 deletions extension/background/js/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,14 @@ class Utilities {
)
).join("");
}

static async safeAwait(functionToAwait, ...args) {
try {
return await functionToAwait(...args);
} catch (error) {
console.log(error);
}
}
}

class JobBoards {
Expand Down Expand Up @@ -199,18 +207,20 @@ const updateBadgeTextAndTitle = async (jobBoardId) => {
contentScriptStatusesOfJobBoardIdTabs.forEach(
({ tab, contentScriptStatus }) => {
if (!contentScriptStatus.hasHideNSeekUI) {
chrome.action.setTitle({
Utilities.safeAwait(chrome.action.setTitle, {
tabId: tab.id,
title: "Hide n' Seek",
});

return chrome.action.setBadgeText({
Utilities.safeAwait(chrome.action.setBadgeText, {
tabId: tab.id,
text: "",
});

return;
}

chrome.action.setTitle({
Utilities.safeAwait(chrome.action.setTitle, {
tabId: tab.id,
title: `Hide n' Seek
Expand All @@ -225,12 +235,12 @@ ${jobBoardName}:
`,
});

chrome.action.setBadgeBackgroundColor({
Utilities.safeAwait(chrome.action.setBadgeBackgroundColor, {
tabId: tab.id,
color: [255, 128, 128, 255],
});

chrome.action.setBadgeText({
Utilities.safeAwait(chrome.action.setBadgeText, {
tabId: tab.id,
text: `${numberOfBlockedJobAttributes}`,
});
Expand All @@ -246,7 +256,9 @@ chrome.runtime.onInstalled.addListener(async () => {
const tabsWithJobBoardId = await JobBoards.getTabsWithJobBoardId();

tabsWithJobBoardId.forEach((tabWithJobBoardId) =>
chrome.tabs.reload(tabWithJobBoardId.id, { bypassCache: true })
Utilities.safeAwait(chrome.tabs.reload, tabWithJobBoardId.id, {
bypassCache: true,
})
);
});

Expand All @@ -266,7 +278,7 @@ chrome.tabs.onUpdated.addListener((tabId, tabChanges, tab) => {

if (!jobBoardId) return;

chrome.scripting.executeScript({
Utilities.safeAwait(chrome.scripting.executeScript, {
target: { tabId },
files: ["/content-script/js/content-script.js"],
});
Expand All @@ -288,11 +300,11 @@ chrome.storage.local.onChanged.addListener((storageChanges) => {
});
});

chrome.runtime.onMessage.addListener(async (message, sender) => {
chrome.runtime.onMessage.addListener((message, sender) => {
if (!message.to.includes("background script")) return;

if (message.from === "content script" && message.body === "inject css") {
chrome.scripting.insertCSS({
Utilities.safeAwait(chrome.scripting.insertCSS, {
target: { tabId: sender.tab.id },
files: ["/content-script/css/content-script.css"],
});
Expand Down
2 changes: 1 addition & 1 deletion extension/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifest_version": 3,
"name": "Hide n' Seek",
"description": "View the jobs you seek. Hide the ones you don't.",
"version": "4.1.0",
"version": "4.1.1",
"icons": {
"16": "/images/hide-n-seek-icon-16.png",
"32": "/images/hide-n-seek-icon-32.png",
Expand Down
7 changes: 3 additions & 4 deletions extension/popup/js/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -796,7 +796,7 @@
}
}

chrome.runtime.onMessage.addListener(async (message, sender) => {
chrome.runtime.onMessage.addListener((message, sender) => {
if (!message.to.includes("popup script")) return;

if (
Expand All @@ -809,11 +809,10 @@

if (!messageFromActiveTabInCurrentWindow) return;

const storage = await chrome.storage.local.get();
if (message.hasHideNSeekUI === true) {
ApplicableTabPopup.start(message.jobBoardId, storage);
ApplicableTabPopup.start(message.jobBoardId);
} else if (message.hasHideNSeekUI === false) {
InapplicableTabPopup.start(activeTabInCurrentWindow, storage);
InapplicableTabPopup.start(activeTabInCurrentWindow);
}
}
});
Expand Down
2 changes: 1 addition & 1 deletion other-manifests/firefox/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifest_version": 3,
"name": "Hide n' Seek",
"description": "View the jobs you seek. Hide the ones you don't.",
"version": "4.1.0",
"version": "4.1.1",
"icons": {
"16": "/images/hide-n-seek-icon-16.png",
"32": "/images/hide-n-seek-icon-32.png",
Expand Down

0 comments on commit 8e4bb84

Please sign in to comment.