Project

General

Profile

Download (1.02 KB) Statistics
| Branch: | Tag: | Revision:

haketilo / background / main.js @ 2059fab6

1
/**
2
 * Myext 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_myext(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_myext);
46

    
47
console.log("hello, myext");
(1-1/7)