-
Notifications
You must be signed in to change notification settings - Fork 2
/
background.js
49 lines (30 loc) · 1.3 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
44
45
46
47
48
49
console.log("+++++ ===== Chrome Extension background script running!")
let color = '#3aa757';
chrome.runtime.onInstalled.addListener(() => {
// console.log('Default background color set to %cgreen', `color: ${color}`);
});
/*
chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) {
console.log("request: ", request)
console.log("sender: ", sender)
console.log("sendResponse: ", sendResponse)
sendResponse({test:'test'})
})
chrome.browserAction.onClicked.addListener(function(tab) {
chrome.tabs.create({url: 'popup.html'})
chrome.runtime.openOptionsPage(()=>{console.log("Chrome Extension Open Options page")});
});
chrome.tabs.onActivated.addListener( (currentTab) => {
chrome.tabs.get(currentTab.tabId, ( currentTabInfo) => {
console.log("currentTabInfo: ", currentTabInfo.url);
const regex1 = /^https:\/\/club\.tgfcer\.com\/thread/;
const regex2 = /^https:\/\/wap.tgfcer.com\/index.php\?action=thread/;
console.log(regex1.test(currentTabInfo.url));
if (regex1.test(currentTabInfo.url) || regex2.test(currentTabInfo.url)) {
chrome.tabs.executeScript(null,{
file: "./content.js"
}, ()=> {console.log("Chrome Extension Script Inject Programmatically! ")});
}
})
})
*/