-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.js
66 lines (54 loc) · 1.93 KB
/
index.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
const URLS = [
'*://*.instagram.com/api/graphql',
'*://*.instagram.com/graphql/query',
'*://*.facebook.com/api/graphql/',
]
const isNodeEnv = typeof exports !== 'undefined'
// Chrome support: `browser` should fallback to `chrome`
// since Chrome doesn't fully support WebExtensions
if (typeof browser === 'undefined' && !isNodeEnv) {
browser = chrome
}
let isEnabled = true;
browser.storage.local.get('enabled', function (data) {
isEnabled = data.enabled !== false;
});
browser.storage.onChanged.addListener((changes, area) => {
if (area === 'local' && 'enabled' in changes) {
isEnabled = changes.enabled.newValue;
}
});
const handleRequest = (details) => {
if (!isEnabled) {
return { cancel: false };
}
if (details.method == "POST") {
let formData = details.requestBody.formData;
let cancel = false;
if (formData) {
if (
formData.hasOwnProperty("fb_api_req_friendly_name")
&& (
formData.fb_api_req_friendly_name.includes("PolarisAPIReelSeenMutation")
|| formData.fb_api_req_friendly_name.includes("PolarisAPIReelSeenDirectMutation")
|| formData.fb_api_req_friendly_name.includes("storiesUpdateSeenStateMutation")
|| formData.fb_api_req_friendly_name.includes("usePolarisStoriesV3SeenMutation")
|| formData.fb_api_req_friendly_name.includes("PolarisStoriesV3SeenMutation")
|| formData.fb_api_req_friendly_name.includes("PolarisStoriesV3SeenDirectMutation")
)
) {
cancel = true;
}
}
return { cancel: cancel };
}
return { cancel: false };
}
const listenToRequests = () => {
browser.webRequest.onBeforeRequest.addListener(
handleRequest,
{ urls: URLS },
['blocking', 'requestBody']
);
}
listenToRequests();