This repository was archived by the owner on Aug 6, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackground.js
More file actions
63 lines (54 loc) · 1.98 KB
/
Copy pathbackground.js
File metadata and controls
63 lines (54 loc) · 1.98 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
function updateSeen(story, chat) { // TRUE = BLOCK / FALSE = ALLOW
chrome.declarativeNetRequest.updateDynamicRules({
removeRuleIds: [1],
addRules: [
{
id: 1,
condition: {
urlFilter: `https://www.instagram.com/api/v1/stories/reel/seen`,
resourceTypes: ['xmlhttprequest'],
},
action: { type: story?"block":"allow" },
}
],
});
chrome.declarativeNetRequest.updateDynamicRules({
removeRuleIds: [2],
addRules: [
{
id: 2,
condition: {
urlFilter: `https://www.instagram.com/api/v1/direct_v2/threads/*/items/*/seen/`,
resourceTypes: ['xmlhttprequest'],
},
action: { type: chat?"block":"allow" },
}
],
});
}
chrome.runtime.onInstalled.addListener(async () => {
chrome.storage.sync.set({ status: {story:true, chat:true} });
let url = chrome.runtime.getURL("index.html");
chrome.tabs.create({ url });
updateSeen(true, true);
});
chrome.windows.onCreated.addListener(function() {
let reciever = chrome.storage.sync.get("status");
reciever.then((storage) => {
let status = storage.status;
console.log(status)
updateSeen(status.story, status.chat);
if(status.story || status.chat) chrome.action.setIcon({path: "icons/Unseen128.png"});
else chrome.action.setIcon({path: "icons/Seen128.png"});
});
})
chrome.storage.onChanged.addListener((changes, areaname) => {
if(!changes.status) return;
let reciever = chrome.storage.sync.get("status");
reciever.then((storage) => {
let status = storage.status;
updateSeen(status.story, status.chat);
if(status.story || status.chat) chrome.action.setIcon({path: "icons/Unseen128.png"});
else chrome.action.setIcon({path: "icons/Seen128.png"});
});
});