aboutsummaryrefslogtreecommitdiff
path: root/background/main.js
blob: 2fcdda3270f13469b6549097fdf31c73cfe7411a (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
/**
 * Myext 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 browser
 * IMPORTS_END
 */

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

async function init_myext(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_myext);

console.log("hello, myext");