|
@@ -1,5 +1,6 @@
|
1
|
1
|
sites_url = "https://raw.githubusercontent.com/RSF-RWB/collateralfreedom/master/sites.json"
|
2
|
2
|
sites = {}
|
|
3
|
+domain_regexp = /:\/\/(www\.)?([^\/]+)\//
|
3
|
4
|
|
4
|
5
|
function getSitesAndMirrors() {
|
5
|
6
|
$.getJSON(sites_url).done(function(data) { chrome.storage.local.set({"sites": data}) })
|
|
@@ -26,18 +27,20 @@ function updateTab() {
|
26
|
27
|
getCurrentTabUrl(function(url) {
|
27
|
28
|
chrome.storage.local.get("sites", function(sites){
|
28
|
29
|
sites = sites.sites
|
29
|
|
- domain = url.match(/:\/\/(www\.)?([^\/]+)\//).slice(-1)[0]
|
30
|
|
- if(domain in sites) {
|
31
|
|
- chrome.browserAction.setIcon({path: 'rsc/icon-red.png'})
|
32
|
|
- }
|
33
|
|
- else {
|
34
|
|
- chrome.browserAction.setIcon({path: 'rsc/icon.png'})
|
|
30
|
+ if(url.match(domain_regexp)) {
|
|
31
|
+ // Skipping detection for about:* pages
|
|
32
|
+ domain = url.match(domain_regexp).slice(-1)[0]
|
|
33
|
+ if(domain in sites) {
|
|
34
|
+ chrome.browserAction.setIcon({path: 'rsc/icon-red.png'})
|
|
35
|
+ }
|
|
36
|
+ else {
|
|
37
|
+ chrome.browserAction.setIcon({path: 'rsc/icon.png'})
|
|
38
|
+ }
|
35
|
39
|
}
|
36
|
40
|
})
|
37
|
41
|
})
|
38
|
42
|
}
|
39
|
43
|
|
40
|
|
-chrome.runtime.onStartup.addListener(getSitesAndMirrors)
|
41
|
|
-chrome.runtime.onInstalled.addListener(getSitesAndMirrors)
|
42
|
44
|
chrome.tabs.onActivated.addListener(updateTab)
|
43
|
45
|
chrome.tabs.onUpdated.addListener(updateTab)
|
|
46
|
+getSitesAndMirrors()
|