-
Notifications
You must be signed in to change notification settings - Fork 1
/
background.js
43 lines (37 loc) · 1.1 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
43
chrome.runtime.onInstalled.addListener(function () {
chrome.contextMenus.create({
id: "editInfo",
title: "Edit Data",
contexts: ["browser_action"]
});
});
chrome.contextMenus.onClicked.addListener(function (info, tab) {
if (info.menuItemId === "editInfo") {
chrome.tabs.create({ url: 'Option/option.html' })
}
});
chrome.tabs.onUpdated.addListener((tabId, changeInfo, tab) => {
chrome.tabs.sendMessage(tabId, { url: tab.url, status: changeInfo.status });
});
chrome.runtime.onMessage.addListener((data, sender, sendResponse) => {
if (data.closeTab === 'yes') {
chrome.tabs.remove(sender.tab.id);
}
if (data.redirect && data.redirect === "yes") {
login();
}
if (data.removePopup && data.removePopup === 'yes') {
chrome.browserAction.setPopup({ popup: '' })
}
});
chrome.storage.local.get(null, (result) => {
if (!result.uname && !result.pword) {
chrome.browserAction.setPopup({ popup: 'Popup/popup.html' });
}
})
chrome.browserAction.onClicked.addListener((tab) => {
login();
});
function login() {
chrome.tabs.create({ url: "https://10.100.1.1:8090/" });
}