-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackground.js
More file actions
31 lines (25 loc) · 814 Bytes
/
Copy pathbackground.js
File metadata and controls
31 lines (25 loc) · 814 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
let currentTab;
// Invoked when tabs are updated
chrome.tabs.onUpdated.addListener((tabId, changeInfo, tab) => {
currentTab = tab;
TriggerRepaint();
});
// Invoked when we change tab
chrome.tabs.onActivated.addListener((activeInfo) => {
GetCurrentTab((tab) => currentTab = tab);
});
// Invoked when we receive a message
chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
if (message.greeting = "trigger-repaint")
TriggerRepaint();
sendResponse();
});
function TriggerRepaint() {
if (currentTab && currentTab.url.includes("itch.io/dashboard"))
chrome.tabs.sendMessage(currentTab.id, { type: "Repaint" });
}
async function GetCurrentTab(onResult) {
let queryOptions = { active: true, currentWindow: true };
let [tab] = await chrome.tabs.query(queryOptions);
onResult(tab);
}