Project

General

Profile

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

haketilo / background / main.js @ 6b12a034

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 start_page_info_server
16
 * IMPORT browser
17
 * IMPORTS_END
18
 */
19

    
20
start_storage_server();
21
start_page_actions_server();
22
start_policy_injector();
23
start_page_info_server();
24

    
25
async function init_ext(install_details)
26
{
27
    console.log("details:", install_details);
28
    if (install_details.reason != "install")
29
	return;
30

    
31
    let storage = await get_storage();
32

    
33
    await storage.clear();
34

    
35
    /*
36
     * Below we add sample settings to the extension.
37
     */
38

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

    
47
browser.runtime.onInstalled.addListener(init_ext);
48

    
49
console.log("hello, hachette");
(1-1/8)