-
Notifications
You must be signed in to change notification settings - Fork 0
/
background.js
36 lines (33 loc) · 1.29 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
/*******************************************************************************
*
* HTTPS Mixed Content Locator Background JS
* _________________________________________
* [2017] Pericror
* All Rights Reserved
* Use of this source code is governed by the license found in the LICENSE file.
*/
chrome.runtime.onMessage.addListener(function (msg, sender) {
if ((msg.from === 'popup') && (msg.subject === 'showLink')) {
chrome.tabs.create({
url : "https://www.pericror.com/"
});
}
});
chrome.tabs.onUpdated.addListener( function (tabId, changeInfo, tab) {
if (changeInfo.status == 'complete' && tab.active) {
chrome.tabs.sendMessage(tabId, {from: 'background', 'tabId': tabId,
subject: 'GetNumberOfMixedContentElements'}, updateBadge);
}
});
function updateBadge(response) {
if(response == undefined) {
return;
}
else if (response.mixedContentDetected == 0) {
chrome.browserAction.setBadgeText({'text' : '', 'tabId':response['tabId']});
} else {
chrome.browserAction.setBadgeText({'text' : response.mixedContentDetected.toString(),
'tabId': response.tabId});
chrome.browserAction.setBadgeBackgroundColor({'color' : '#CA2E0B', 'tabId' : response.tabId});
}
}