-
Notifications
You must be signed in to change notification settings - Fork 2
/
background.js
31 lines (28 loc) · 964 Bytes
/
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
//This sets the initial state of the features to enabled
chrome.runtime.onInstalled.addListener(function(details) {
// Set default settings upon installation
chrome.storage.sync.get(['tagErrorHighlighter', 'tagId'], function(result) {
// Check if settings already exist, if not set default values
if (result.tagErrorHighlighter === undefined) {
chrome.storage.sync.set({tagErrorHighlighter: true});
}
if (result.tagId === undefined) {
chrome.storage.sync.set({tagId: true});
}
});
});
chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) {
if (changeInfo.status === 'complete' && tab.url.includes("tagmanager.google.com")) {
enableTagID(tabId);
}
});
function enableTagID(tabId) {
chrome.scripting.executeScript({
target: {tabId: tabId},
files: ['tagID.js']
}, () => {
chrome.tabs.sendMessage(tabId, {
action: "setupTagIDInjection"
});
});
}