@duckduckgo/autoconsent 4.4.0 → 5.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +32 -0
- package/build.sh +28 -0
- package/data/coverage.json +853 -906
- package/dist/addon-firefox/background.bundle.js +295 -291
- package/dist/addon-firefox/content.bundle.js +1928 -1881
- package/dist/addon-firefox/manifest.json +1 -1
- package/dist/addon-firefox/rules.json +62 -1
- package/dist/addon-mv3/background.bundle.js +295 -291
- package/dist/addon-mv3/content.bundle.js +1928 -1881
- package/dist/addon-mv3/devtools/panel.js +130 -136
- package/dist/addon-mv3/manifest.json +1 -1
- package/dist/addon-mv3/popup.bundle.js +160 -171
- package/dist/addon-mv3/rules.json +62 -1
- package/dist/autoconsent.cjs.js +2032 -1
- package/dist/autoconsent.esm.js +2005 -1
- package/dist/autoconsent.playwright.js +1 -1
- package/lib/types.ts +1 -0
- package/lib/web.ts +16 -8
- package/package.json +6 -9
- package/rules/autoconsent/burpee-com.json +1 -1
- package/rules/autoconsent/cookie-manager-popup.json +42 -0
- package/rules/rules.json +62 -1
- package/tests/burpee-com.spec.ts +2 -1
- package/tests/cookie-manager-popup.spec.ts +8 -0
- package/rollup.config.js +0 -103
|
@@ -1,148 +1,142 @@
|
|
|
1
|
-
(
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
Object.assign(storage, obj);
|
|
10
|
-
return;
|
|
11
|
-
}
|
|
12
|
-
return chrome.storage.local.set(obj);
|
|
13
|
-
}
|
|
14
|
-
async function storageGet(key) {
|
|
15
|
-
if (key === null) {
|
|
16
|
-
if (manifestVersion === 2) {
|
|
17
|
-
return storage;
|
|
18
|
-
}
|
|
19
|
-
return await chrome.storage.local.get(null);
|
|
20
|
-
}
|
|
21
|
-
if (manifestVersion === 2) {
|
|
22
|
-
return storage[key];
|
|
23
|
-
}
|
|
24
|
-
return (await chrome.storage.local.get(key))?.[key];
|
|
1
|
+
(() => {
|
|
2
|
+
// addon/mv-compat.ts
|
|
3
|
+
var manifestVersion = chrome.runtime.getManifest().manifest_version;
|
|
4
|
+
var storage = {};
|
|
5
|
+
async function storageSet(obj) {
|
|
6
|
+
if (manifestVersion === 2) {
|
|
7
|
+
Object.assign(storage, obj);
|
|
8
|
+
return;
|
|
25
9
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
10
|
+
return chrome.storage.local.set(obj);
|
|
11
|
+
}
|
|
12
|
+
async function storageGet(key) {
|
|
13
|
+
if (key === null) {
|
|
14
|
+
if (manifestVersion === 2) {
|
|
15
|
+
return storage;
|
|
16
|
+
}
|
|
17
|
+
return await chrome.storage.local.get(null);
|
|
30
18
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
if (document.getElementById(rowId) !== null) {
|
|
34
|
-
// update existing row
|
|
35
|
-
const td = document.getElementById(rowId).querySelectorAll("td");
|
|
36
|
-
return td;
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
const template = document.querySelector("#row");
|
|
40
|
-
const table = document.querySelector("tbody");
|
|
41
|
-
const clone = template.content.cloneNode(true);
|
|
42
|
-
const td = clone.querySelectorAll("td");
|
|
43
|
-
table.appendChild(clone);
|
|
44
|
-
table.lastElementChild.id = rowId;
|
|
45
|
-
return td;
|
|
46
|
-
}
|
|
19
|
+
if (manifestVersion === 2) {
|
|
20
|
+
return storage[key];
|
|
47
21
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
.getElementById(`instance-${message.instanceId}`)
|
|
70
|
-
?.classList.add("dead");
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
backgroundPageConnection.onDisconnect.addListener(() => {
|
|
74
|
-
reconnect();
|
|
75
|
-
});
|
|
76
|
-
return backgroundPageConnection;
|
|
22
|
+
return (await chrome.storage.local.get(key))?.[key];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// addon/devtools/panel.ts
|
|
26
|
+
var backgroundPageConnection;
|
|
27
|
+
function sendBackgroundMessage(msg) {
|
|
28
|
+
backgroundPageConnection.postMessage(msg);
|
|
29
|
+
}
|
|
30
|
+
function getRowForInstance(instanceId) {
|
|
31
|
+
const rowId = `instance-${instanceId}`;
|
|
32
|
+
if (document.getElementById(rowId) !== null) {
|
|
33
|
+
const td = document.getElementById(rowId).querySelectorAll("td");
|
|
34
|
+
return td;
|
|
35
|
+
} else {
|
|
36
|
+
const template = document.querySelector("#row");
|
|
37
|
+
const table = document.querySelector("tbody");
|
|
38
|
+
const clone = template.content.cloneNode(true);
|
|
39
|
+
const td = clone.querySelectorAll("td");
|
|
40
|
+
table.appendChild(clone);
|
|
41
|
+
table.lastElementChild.id = rowId;
|
|
42
|
+
return td;
|
|
77
43
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
tbody.removeChild(tbody.firstChild);
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
document.getElementById("clear").addEventListener("click", clearPanel);
|
|
86
|
-
document.getElementById("reload").addEventListener("click", async () => {
|
|
87
|
-
if (clearStorageCheckbox.checked) {
|
|
88
|
-
const tab = await chrome.tabs.get(chrome.devtools.inspectedWindow.tabId);
|
|
89
|
-
const url = new URL(tab.url);
|
|
90
|
-
await chrome.browsingData.remove({
|
|
91
|
-
origins: [url.origin],
|
|
92
|
-
}, {
|
|
93
|
-
cookies: true,
|
|
94
|
-
localStorage: true,
|
|
95
|
-
indexedDB: true,
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
clearPanel();
|
|
99
|
-
chrome.devtools.inspectedWindow.reload({});
|
|
44
|
+
}
|
|
45
|
+
function reconnect() {
|
|
46
|
+
backgroundPageConnection = chrome.runtime.connect({
|
|
47
|
+
name: "devtools-panel"
|
|
100
48
|
});
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
.querySelector("#mode > option:checked")
|
|
105
|
-
.getAttribute("data-autoaction");
|
|
106
|
-
if (autoAction === "null") {
|
|
107
|
-
autoAction = null;
|
|
108
|
-
}
|
|
109
|
-
storedConfig.autoAction = autoAction;
|
|
110
|
-
storageSet({
|
|
111
|
-
config: storedConfig,
|
|
112
|
-
});
|
|
49
|
+
sendBackgroundMessage({
|
|
50
|
+
type: "init",
|
|
51
|
+
tabId: chrome.devtools.inspectedWindow.tabId
|
|
113
52
|
});
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
}
|
|
53
|
+
backgroundPageConnection.onMessage.addListener(function(message) {
|
|
54
|
+
if (message.type === "report") {
|
|
55
|
+
const td = getRowForInstance(message.instanceId);
|
|
56
|
+
td[0].innerText = `${message.frameId}`;
|
|
57
|
+
td[1].innerText = message.url;
|
|
58
|
+
td[2].innerText = message.state.lifecycle;
|
|
59
|
+
td[3].innerText = message.state.prehideOn ? "yes" : "no";
|
|
60
|
+
td[4].innerText = `${message.state.findCmpAttempts}`;
|
|
61
|
+
td[5].innerText = message.state.detectedCmps.join(", ");
|
|
62
|
+
td[6].innerText = message.state.detectedPopups.join(", ");
|
|
63
|
+
} else if (message.type === "instanceTerminated") {
|
|
64
|
+
document.getElementById(`instance-${message.instanceId}`)?.classList.add("dead");
|
|
65
|
+
}
|
|
118
66
|
});
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
type: "optOut",
|
|
122
|
-
});
|
|
67
|
+
backgroundPageConnection.onDisconnect.addListener(() => {
|
|
68
|
+
reconnect();
|
|
123
69
|
});
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
modeOptions[2].selected = true;
|
|
132
|
-
break;
|
|
133
|
-
default:
|
|
134
|
-
modeOptions[0].selected = true;
|
|
135
|
-
}
|
|
70
|
+
return backgroundPageConnection;
|
|
71
|
+
}
|
|
72
|
+
var clearStorageCheckbox = document.querySelector("#clear-storage");
|
|
73
|
+
var clearPanel = () => {
|
|
74
|
+
const tbody = document.querySelector("tbody");
|
|
75
|
+
while (tbody.firstChild) {
|
|
76
|
+
tbody.removeChild(tbody.firstChild);
|
|
136
77
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
78
|
+
};
|
|
79
|
+
document.getElementById("clear").addEventListener("click", clearPanel);
|
|
80
|
+
document.getElementById("reload").addEventListener("click", async () => {
|
|
81
|
+
if (clearStorageCheckbox.checked) {
|
|
82
|
+
const tab = await chrome.tabs.get(chrome.devtools.inspectedWindow.tabId);
|
|
83
|
+
const url = new URL(tab.url);
|
|
84
|
+
await chrome.browsingData.remove(
|
|
85
|
+
{
|
|
86
|
+
origins: [url.origin]
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
cookies: true,
|
|
90
|
+
localStorage: true,
|
|
91
|
+
indexedDB: true
|
|
140
92
|
}
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
clearPanel();
|
|
96
|
+
chrome.devtools.inspectedWindow.reload({});
|
|
97
|
+
});
|
|
98
|
+
document.getElementById("mode").addEventListener("change", async () => {
|
|
99
|
+
const storedConfig = await storageGet("config");
|
|
100
|
+
let autoAction = document.querySelector("#mode > option:checked").getAttribute("data-autoaction");
|
|
101
|
+
if (autoAction === "null") {
|
|
102
|
+
autoAction = null;
|
|
103
|
+
}
|
|
104
|
+
storedConfig.autoAction = autoAction;
|
|
105
|
+
storageSet({
|
|
106
|
+
config: storedConfig
|
|
141
107
|
});
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
108
|
+
});
|
|
109
|
+
document.getElementById("optin").addEventListener("click", () => {
|
|
110
|
+
chrome.tabs.sendMessage(chrome.devtools.inspectedWindow.tabId, {
|
|
111
|
+
type: "optIn"
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
document.getElementById("optout").addEventListener("click", () => {
|
|
115
|
+
chrome.tabs.sendMessage(chrome.devtools.inspectedWindow.tabId, {
|
|
116
|
+
type: "optOut"
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
function onConfigUpdated(config) {
|
|
120
|
+
const modeOptions = document.querySelectorAll("#mode > option");
|
|
121
|
+
switch (config.autoAction) {
|
|
122
|
+
case "optIn":
|
|
123
|
+
modeOptions[1].selected = true;
|
|
124
|
+
break;
|
|
125
|
+
case "optOut":
|
|
126
|
+
modeOptions[2].selected = true;
|
|
127
|
+
break;
|
|
128
|
+
default:
|
|
129
|
+
modeOptions[0].selected = true;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
chrome.storage.local.onChanged.addListener((changes) => {
|
|
133
|
+
if (changes.config) {
|
|
134
|
+
onConfigUpdated(changes.config.newValue);
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
(async () => {
|
|
138
|
+
const config = await storageGet("config");
|
|
139
|
+
onConfigUpdated(config);
|
|
140
|
+
})();
|
|
141
|
+
reconnect();
|
|
148
142
|
})();
|
|
@@ -1,180 +1,169 @@
|
|
|
1
|
-
(
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
(() => {
|
|
2
|
+
// addon/mv-compat.ts
|
|
3
|
+
var manifestVersion = chrome.runtime.getManifest().manifest_version;
|
|
4
|
+
var storage = {};
|
|
5
|
+
async function storageSet(obj) {
|
|
6
|
+
if (manifestVersion === 2) {
|
|
7
|
+
Object.assign(storage, obj);
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
return chrome.storage.local.set(obj);
|
|
11
|
+
}
|
|
12
|
+
async function storageGet(key) {
|
|
13
|
+
if (key === null) {
|
|
14
|
+
if (manifestVersion === 2) {
|
|
15
|
+
return storage;
|
|
16
|
+
}
|
|
17
|
+
return await chrome.storage.local.get(null);
|
|
13
18
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
if (manifestVersion === 2) {
|
|
17
|
-
return storage;
|
|
18
|
-
}
|
|
19
|
-
return await chrome.storage.local.get(null);
|
|
20
|
-
}
|
|
21
|
-
if (manifestVersion === 2) {
|
|
22
|
-
return storage[key];
|
|
23
|
-
}
|
|
24
|
-
return (await chrome.storage.local.get(key))?.[key];
|
|
19
|
+
if (manifestVersion === 2) {
|
|
20
|
+
return storage[key];
|
|
25
21
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
22
|
+
return (await chrome.storage.local.get(key))?.[key];
|
|
23
|
+
}
|
|
24
|
+
async function storageRemove(key) {
|
|
25
|
+
if (manifestVersion === 2) {
|
|
26
|
+
delete storage[key];
|
|
27
|
+
return;
|
|
32
28
|
}
|
|
29
|
+
return chrome.storage.local.remove(key);
|
|
30
|
+
}
|
|
33
31
|
|
|
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
|
-
await action.setTitle({
|
|
66
|
-
tabId,
|
|
67
|
-
title,
|
|
68
|
-
});
|
|
69
|
-
await action.setIcon({
|
|
70
|
-
tabId,
|
|
71
|
-
path: icon,
|
|
72
|
-
});
|
|
32
|
+
// lib/config.ts
|
|
33
|
+
var enableLogs = false;
|
|
34
|
+
|
|
35
|
+
// addon/utils.ts
|
|
36
|
+
async function showOptOutStatus(tabId, status, cmp = "") {
|
|
37
|
+
let title = "";
|
|
38
|
+
let icon = "icons/cookie-idle.png";
|
|
39
|
+
if (status === "success") {
|
|
40
|
+
title = `Opt out successful! (${cmp})`;
|
|
41
|
+
icon = "icons/party.png";
|
|
42
|
+
} else if (status === "complete") {
|
|
43
|
+
title = `Opt out complete! (${cmp})`;
|
|
44
|
+
icon = "icons/tick.png";
|
|
45
|
+
} else if (status === "working") {
|
|
46
|
+
title = `Processing... (${cmp})`;
|
|
47
|
+
icon = "icons/cog.png";
|
|
48
|
+
} else if (status === "verified") {
|
|
49
|
+
title = `Verified (${cmp})`;
|
|
50
|
+
icon = "icons/verified.png";
|
|
51
|
+
} else if (status === "idle") {
|
|
52
|
+
title = "Idle";
|
|
53
|
+
icon = "icons/cookie-idle.png";
|
|
54
|
+
} else if (status === "available") {
|
|
55
|
+
title = `Click to opt out (${cmp})`;
|
|
56
|
+
icon = "icons/cookie.png";
|
|
57
|
+
}
|
|
58
|
+
enableLogs && console.log("Setting action state to", status);
|
|
59
|
+
const action = chrome.action || chrome.pageAction;
|
|
60
|
+
if (chrome.pageAction) {
|
|
61
|
+
chrome.pageAction.show(tabId);
|
|
73
62
|
}
|
|
63
|
+
await action.setTitle({
|
|
64
|
+
tabId,
|
|
65
|
+
title
|
|
66
|
+
});
|
|
67
|
+
await action.setIcon({
|
|
68
|
+
tabId,
|
|
69
|
+
path: icon
|
|
70
|
+
});
|
|
71
|
+
}
|
|
74
72
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
});
|
|
106
|
-
proceedButton.remove();
|
|
107
|
-
window.close();
|
|
108
|
-
});
|
|
109
|
-
document.body.prepend(proceedButton);
|
|
110
|
-
}
|
|
111
|
-
// set form initial values
|
|
112
|
-
enabledCheckbox.checked = autoconsentConfig.enabled;
|
|
113
|
-
retriesInput.value = autoconsentConfig.detectRetries.toString();
|
|
114
|
-
if (autoconsentConfig.autoAction === 'optIn') {
|
|
115
|
-
optInRadio.checked = true;
|
|
116
|
-
}
|
|
117
|
-
else if (autoconsentConfig.autoAction === 'optOut') {
|
|
118
|
-
optOutRadio.checked = true;
|
|
119
|
-
}
|
|
120
|
-
else {
|
|
121
|
-
promptRadio.checked = true;
|
|
122
|
-
}
|
|
123
|
-
if (autoconsentConfig.enablePrehide) {
|
|
124
|
-
prehideOnRadio.checked = true;
|
|
125
|
-
}
|
|
126
|
-
else {
|
|
127
|
-
prehideOffRadio.checked = true;
|
|
128
|
-
}
|
|
129
|
-
if (autoconsentConfig.enableCosmeticRules) {
|
|
130
|
-
cosmeticOnRadio.checked = true;
|
|
131
|
-
}
|
|
132
|
-
else {
|
|
133
|
-
cosmeticOffRadio.checked = true;
|
|
134
|
-
}
|
|
135
|
-
// set form event listeners
|
|
136
|
-
enabledCheckbox.addEventListener('change', () => {
|
|
137
|
-
autoconsentConfig.enabled = enabledCheckbox.checked;
|
|
138
|
-
storageSet({ config: autoconsentConfig });
|
|
139
|
-
});
|
|
140
|
-
retriesInput.addEventListener('change', () => {
|
|
141
|
-
autoconsentConfig.detectRetries = parseInt(retriesInput.value, 10);
|
|
142
|
-
storageSet({ config: autoconsentConfig });
|
|
143
|
-
});
|
|
144
|
-
function modeChange() {
|
|
145
|
-
if (optInRadio.checked) {
|
|
146
|
-
autoconsentConfig.autoAction = 'optIn';
|
|
147
|
-
}
|
|
148
|
-
else if (optOutRadio.checked) {
|
|
149
|
-
autoconsentConfig.autoAction = 'optOut';
|
|
150
|
-
}
|
|
151
|
-
else {
|
|
152
|
-
autoconsentConfig.autoAction = null;
|
|
153
|
-
}
|
|
154
|
-
storageSet({ config: autoconsentConfig });
|
|
155
|
-
}
|
|
156
|
-
optInRadio.addEventListener('change', modeChange);
|
|
157
|
-
optOutRadio.addEventListener('change', modeChange);
|
|
158
|
-
promptRadio.addEventListener('change', modeChange);
|
|
159
|
-
function prehideChange() {
|
|
160
|
-
autoconsentConfig.enablePrehide = prehideOnRadio.checked;
|
|
161
|
-
storageSet({ config: autoconsentConfig });
|
|
162
|
-
}
|
|
163
|
-
prehideOnRadio.addEventListener('change', prehideChange);
|
|
164
|
-
prehideOffRadio.addEventListener('change', prehideChange);
|
|
165
|
-
function cosmeticChange() {
|
|
166
|
-
autoconsentConfig.enableCosmeticRules = cosmeticOnRadio.checked;
|
|
167
|
-
storageSet({ config: autoconsentConfig });
|
|
168
|
-
}
|
|
169
|
-
cosmeticOnRadio.addEventListener('change', cosmeticChange);
|
|
170
|
-
cosmeticOffRadio.addEventListener('change', cosmeticChange);
|
|
171
|
-
ruleReloadButton.addEventListener('click', async () => {
|
|
172
|
-
const res = await fetch("./rules.json");
|
|
173
|
-
storageSet({
|
|
174
|
-
rules: await res.json(),
|
|
175
|
-
});
|
|
73
|
+
// addon/popup.ts
|
|
74
|
+
async function init() {
|
|
75
|
+
const autoconsentConfig = await storageGet("config");
|
|
76
|
+
const enabledCheckbox = document.querySelector("input#enabled");
|
|
77
|
+
const optOutRadio = document.querySelector("input#optout");
|
|
78
|
+
const optInRadio = document.querySelector("input#optin");
|
|
79
|
+
const promptRadio = document.querySelector("input#prompt");
|
|
80
|
+
const prehideOnRadio = document.querySelector("input#prehide-on");
|
|
81
|
+
const prehideOffRadio = document.querySelector("input#prehide-off");
|
|
82
|
+
const cosmeticOnRadio = document.querySelector("input#cosmetic-on");
|
|
83
|
+
const cosmeticOffRadio = document.querySelector("input#cosmetic-off");
|
|
84
|
+
const retriesInput = document.querySelector("input#retries");
|
|
85
|
+
const ruleReloadButton = document.querySelector("#reload");
|
|
86
|
+
const [currentTab] = await chrome.tabs.query({ active: true, lastFocusedWindow: true });
|
|
87
|
+
const tabId = currentTab.id;
|
|
88
|
+
const detectedKey = `detected${tabId}`;
|
|
89
|
+
console.log("detectedKey", detectedKey);
|
|
90
|
+
const frameId = await storageGet(detectedKey);
|
|
91
|
+
console.log("frameId", frameId, typeof frameId);
|
|
92
|
+
if (typeof frameId === "number") {
|
|
93
|
+
const proceedButton = document.createElement("button");
|
|
94
|
+
proceedButton.innerText = "Manage popup";
|
|
95
|
+
proceedButton.id = "proceed";
|
|
96
|
+
proceedButton.addEventListener("click", () => {
|
|
97
|
+
storageRemove(detectedKey);
|
|
98
|
+
showOptOutStatus(tabId, "working");
|
|
99
|
+
chrome.tabs.sendMessage(tabId, {
|
|
100
|
+
type: "optOut"
|
|
101
|
+
}, {
|
|
102
|
+
frameId
|
|
176
103
|
});
|
|
104
|
+
proceedButton.remove();
|
|
105
|
+
window.close();
|
|
106
|
+
});
|
|
107
|
+
document.body.prepend(proceedButton);
|
|
177
108
|
}
|
|
178
|
-
|
|
179
|
-
|
|
109
|
+
enabledCheckbox.checked = autoconsentConfig.enabled;
|
|
110
|
+
retriesInput.value = autoconsentConfig.detectRetries.toString();
|
|
111
|
+
if (autoconsentConfig.autoAction === "optIn") {
|
|
112
|
+
optInRadio.checked = true;
|
|
113
|
+
} else if (autoconsentConfig.autoAction === "optOut") {
|
|
114
|
+
optOutRadio.checked = true;
|
|
115
|
+
} else {
|
|
116
|
+
promptRadio.checked = true;
|
|
117
|
+
}
|
|
118
|
+
if (autoconsentConfig.enablePrehide) {
|
|
119
|
+
prehideOnRadio.checked = true;
|
|
120
|
+
} else {
|
|
121
|
+
prehideOffRadio.checked = true;
|
|
122
|
+
}
|
|
123
|
+
if (autoconsentConfig.enableCosmeticRules) {
|
|
124
|
+
cosmeticOnRadio.checked = true;
|
|
125
|
+
} else {
|
|
126
|
+
cosmeticOffRadio.checked = true;
|
|
127
|
+
}
|
|
128
|
+
enabledCheckbox.addEventListener("change", () => {
|
|
129
|
+
autoconsentConfig.enabled = enabledCheckbox.checked;
|
|
130
|
+
storageSet({ config: autoconsentConfig });
|
|
131
|
+
});
|
|
132
|
+
retriesInput.addEventListener("change", () => {
|
|
133
|
+
autoconsentConfig.detectRetries = parseInt(retriesInput.value, 10);
|
|
134
|
+
storageSet({ config: autoconsentConfig });
|
|
135
|
+
});
|
|
136
|
+
function modeChange() {
|
|
137
|
+
if (optInRadio.checked) {
|
|
138
|
+
autoconsentConfig.autoAction = "optIn";
|
|
139
|
+
} else if (optOutRadio.checked) {
|
|
140
|
+
autoconsentConfig.autoAction = "optOut";
|
|
141
|
+
} else {
|
|
142
|
+
autoconsentConfig.autoAction = null;
|
|
143
|
+
}
|
|
144
|
+
storageSet({ config: autoconsentConfig });
|
|
145
|
+
}
|
|
146
|
+
optInRadio.addEventListener("change", modeChange);
|
|
147
|
+
optOutRadio.addEventListener("change", modeChange);
|
|
148
|
+
promptRadio.addEventListener("change", modeChange);
|
|
149
|
+
function prehideChange() {
|
|
150
|
+
autoconsentConfig.enablePrehide = prehideOnRadio.checked;
|
|
151
|
+
storageSet({ config: autoconsentConfig });
|
|
152
|
+
}
|
|
153
|
+
prehideOnRadio.addEventListener("change", prehideChange);
|
|
154
|
+
prehideOffRadio.addEventListener("change", prehideChange);
|
|
155
|
+
function cosmeticChange() {
|
|
156
|
+
autoconsentConfig.enableCosmeticRules = cosmeticOnRadio.checked;
|
|
157
|
+
storageSet({ config: autoconsentConfig });
|
|
158
|
+
}
|
|
159
|
+
cosmeticOnRadio.addEventListener("change", cosmeticChange);
|
|
160
|
+
cosmeticOffRadio.addEventListener("change", cosmeticChange);
|
|
161
|
+
ruleReloadButton.addEventListener("click", async () => {
|
|
162
|
+
const res = await fetch("./rules.json");
|
|
163
|
+
storageSet({
|
|
164
|
+
rules: await res.json()
|
|
165
|
+
});
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
init();
|
|
180
169
|
})();
|