-
Notifications
You must be signed in to change notification settings - Fork 0
/
background.js
39 lines (35 loc) · 1.05 KB
/
background.js
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
32
33
34
35
36
37
38
39
const url = "https://www.icloud.com.cn/notes";
chrome.runtime.onInstalled.addListener(() => {
chrome.action.setBadgeText({
text: "OFF",
});
});
chrome.action.onClicked.addListener(async (tab) => {
if (tab.url.startsWith(url)) {
const prevState = await chrome.action.getBadgeText({
tabId: tab.id
});
const nextState = prevState === "OFF" ? "ON" : "OFF";
await chrome.action.setBadgeText({
text: nextState,
tabId: tab.id
});
if(nextState === "ON") {
await chrome.scripting.insertCSS({
files: ["hide-left-sidebar.css"],
target: {
allFrames: true,
tabId: tab.id
}
});
}else if (nextState === "OFF") {
await chrome.scripting.removeCSS({
files: ["hide-left-sidebar.css"],
target: {
allFrames: true,
tabId: tab.id
}
});
}
}
});