summaryrefslogtreecommitdiff
path: root/background/main.js
blob: ffa814e46c76619ea4efe9742ab00a8f9545f75f (about) (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
45
46
47
48
49
/**
 * Hachette main background script
 *
 * Copyright (C) 2021 Wojtek Kosior
 * Redistribution terms are gathered in the `copyright' file.
 */

/*
 * IMPORTS_START
 * IMPORT TYPE_PREFIX
 * IMPORT get_storage
 * IMPORT start_storage_server
 * IMPORT start_page_actions_server
 * IMPORT start_policy_injector
 * IMPORT start_page_info_server
 * IMPORT browser
 * IMPORTS_END
 */

start_storage_server();
start_page_actions_server();
start_policy_injector();
start_page_info_server();

async function init_ext(install_details)
{
    console.log("details:", install_details);
    if (install_details.reason != "install")
	return;

    let storage = await get_storage();

    await storage.clear();

    /*
     * Below we add sample settings to the extension.
     */

    for (let setting of // The next line is replaced with the contents of /default_settings.json by the build script
        `DEFAULT SETTINGS`
    ) {
	let [key, value] = Object.entries(setting)[0];
	storage.set(key[0], key.substring(1), value);
    }
}

browser.runtime.onInstalled.addListener(init_ext);

console.log("hello, hachette");