blob: d0ae54b3dd570d858a271e9fd1a7292ed0744008 (
plain)
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
|
const port = browser.runtime.connectNative("browser");
async function apiCall(message) {
const { type, since, removalOptions, dataTypes } = message;
switch (type) {
case "clear-downloads":
await browser.browsingData.removeDownloads({ since });
break;
case "clear-form-data":
await browser.browsingData.removeFormData({ since });
break;
case "clear-history":
await browser.browsingData.removeHistory({ since });
break;
case "clear-passwords":
await browser.browsingData.removePasswords({ since });
break;
case "clear":
await browser.browsingData.remove(removalOptions, dataTypes);
break;
case "get-settings":
return browser.browsingData.settings();
}
return null;
}
port.onMessage.addListener(async message => {
const { uuid } = message;
try {
const result = await apiCall(message);
port.postMessage({
type: "response",
result,
uuid,
});
} catch (exception) {
const { message } = exception;
port.postMessage({
type: "error",
error: message,
uuid,
});
}
});
|