1
|
/**
|
2
|
* Hachette main background script
|
3
|
*
|
4
|
* Copyright (C) 2021 Wojtek Kosior
|
5
|
* Redistribution terms are gathered in the `copyright' file.
|
6
|
*/
|
7
|
|
8
|
/*
|
9
|
* IMPORTS_START
|
10
|
* IMPORT TYPE_PREFIX
|
11
|
* IMPORT get_storage
|
12
|
* IMPORT start_storage_server
|
13
|
* IMPORT start_page_actions_server
|
14
|
* IMPORT start_policy_injector
|
15
|
* IMPORT browser
|
16
|
* IMPORTS_END
|
17
|
*/
|
18
|
|
19
|
start_storage_server();
|
20
|
start_page_actions_server();
|
21
|
start_policy_injector();
|
22
|
|
23
|
async function init_ext(install_details)
|
24
|
{
|
25
|
console.log("details:", install_details);
|
26
|
if (install_details.reason != "install")
|
27
|
return;
|
28
|
|
29
|
let storage = await get_storage();
|
30
|
|
31
|
await storage.clear();
|
32
|
|
33
|
/*
|
34
|
* Below we add sample settings to the extension.
|
35
|
*/
|
36
|
|
37
|
for (let setting of // The next line is replaced with the contents of /default_settings.json by the build script
|
38
|
`DEFAULT SETTINGS`
|
39
|
) {
|
40
|
let [key, value] = Object.entries(setting)[0];
|
41
|
storage.set(key[0], key.substring(1), value);
|
42
|
}
|
43
|
}
|
44
|
|
45
|
browser.runtime.onInstalled.addListener(init_ext);
|
46
|
|
47
|
console.log("hello, hachette");
|