Brendan Abolivier 8 years ago
parent
commit
0d8853cc78
3 changed files with 17 additions and 3 deletions
  1. 10
    1
      eventPage.js
  2. 4
    0
      jquery.js
  3. 3
    2
      manifest.json

+ 10
- 1
eventPage.js View File

1
+sites_url = "sites.json"
2
+sites = {}
3
+
4
+function getSitesAndMirrors() {
5
+    $.getJSON("http://host.brendanabolivier.com/files/56bf24564ab24.json")
6
+                                    .done(function(data) { sites = data })
7
+}
8
+
1
 function getCurrentTabUrl(callback) {
9
 function getCurrentTabUrl(callback) {
2
   // Query filter to be passed to chrome.tabs.query - see
10
   // Query filter to be passed to chrome.tabs.query - see
3
   // https://developer.chrome.com/extensions/tabs#method-query
11
   // https://developer.chrome.com/extensions/tabs#method-query
39
 
47
 
40
 function updateTab() {
48
 function updateTab() {
41
     getCurrentTabUrl(function(url) {
49
     getCurrentTabUrl(function(url) {
42
-        if(url.match(/:\/\/(.+)\//)[1] == "www.ijavn.org") {
50
+        if(url.match(/:\/\/(.+)\//)[1] in sites) {
43
             chrome.browserAction.setIcon({path: 'icon-red.png'})
51
             chrome.browserAction.setIcon({path: 'icon-red.png'})
44
         }
52
         }
45
         else {
53
         else {
48
     })
56
     })
49
 }
57
 }
50
 
58
 
59
+chrome.runtime.onStartup.addListener(getSitesAndMirrors)
51
 chrome.tabs.onActivated.addListener(updateTab)
60
 chrome.tabs.onActivated.addListener(updateTab)
52
 chrome.tabs.onUpdated.addListener(updateTab)
61
 chrome.tabs.onUpdated.addListener(updateTab)

+ 4
- 0
jquery.js
File diff suppressed because it is too large
View File


+ 3
- 2
manifest.json View File

11
     },
11
     },
12
     "permissions": [
12
     "permissions": [
13
         "tabs",
13
         "tabs",
14
-        "https://ajax.googleapis.com/"
14
+        "https://ajax.googleapis.com/",
15
+        "http://host.brendanabolivier.com/"
15
     ],
16
     ],
16
 
17
 
17
     "background": {
18
     "background": {
18
-        "scripts": ["eventPage.js"],
19
+        "scripts": ["jquery.js", "eventPage.js"],
19
         "persistent": false
20
         "persistent": false
20
     }
21
     }
21
 }
22
 }