forked from SEI-Pro/sei-pro
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackground.js
executable file
·42 lines (35 loc) · 1.65 KB
/
background.js
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
/******************************************************************************
SPro: Extensão para o Firefox e Chrome que adiciona ao Sistema Eletrônico de Informações (SEI) funções avançadas.
Autor: Pedro Henrique Soares ([email protected])
*******************************************************************************/
function handleInstalled(details) {
console.log(details.reason);
function onError(error) { console.log(`Error: ${error}`); }
function AbrirUrlSeiPro(item) {
// Ao instalar ou atualizar.
item.InstallOrUpdate = true;
browser.storage.local.set(item);
if (item.CheckTypes == undefined) {
browser.tabs.create({ url: "https://sei-pro.github.io/sei-pro/" });
} else if (item.CheckTypes.indexOf("hidemsgupdate") == -1) {
browser.tabs.create({ url: "https://sei-pro.github.io/sei-pro/pages/HISTORICO.html" });
}
}
if (isChrome) { /* Chrome: */
browser.storage.local.get("CheckTypes", AbrirUrlSeiPro);
} else {
var gettingItem = browser.storage.local.get("CheckTypes");
gettingItem.then(AbrirUrlSeiPro, onError);
}
}
/******************************************************************************
* Inicio *
******************************************************************************/
const isChrome = (typeof browser === "undefined"); /* Chrome: */
if (isChrome) { var browser = chrome; } /* Chrome: */
browser.runtime.onInstalled.addListener(handleInstalled);
if(!isChrome) {
browser.runtime.getBrowserInfo().then(function (info) {
browser.storage.local.set({version: info.version}).then(null, null);
});
}