Browse Source

Fix variables declarations

Brendan Abolivier 6 years ago
parent
commit
61182139b8
Signed by: Brendan Abolivier <contact@brendanabolivier.com> GPG key ID: 8EF1500759F70623
2 changed files with 11 additions and 9 deletions
  1. 4
    4
      backgroundPage.js
  2. 7
    5
      index.js

+ 4
- 4
backgroundPage.js View File

1
-sites_url = "https://raw.githubusercontent.com/RSF-RWB/collateralfreedom/master/sites.json"
2
-sites = {}
3
-domain_regexp = /:\/\/(www\.)?([^\/]+)\//
1
+var sites_url = "https://raw.githubusercontent.com/RSF-RWB/collateralfreedom/master/sites.json"
2
+var sites = {}
3
+var domain_regexp = /:\/\/(www\.)?([^\/]+)\//
4
 
4
 
5
 // Retrieve the list of mirrors
5
 // Retrieve the list of mirrors
6
 function getSitesAndMirrors() {
6
 function getSitesAndMirrors() {
30
 			sites = sites.sites
30
 			sites = sites.sites
31
 			if(url.match(domain_regexp)) {
31
 			if(url.match(domain_regexp)) {
32
 				// Skipping detection for about:* pages
32
 				// Skipping detection for about:* pages
33
-				domain = url.match(domain_regexp).slice(-1)[0]
33
+				let domain = url.match(domain_regexp).slice(-1)[0]
34
 				if(domain in sites) {
34
 				if(domain in sites) {
35
 					chrome.browserAction.setIcon({path: 'rsc/icon-red.png'})
35
 					chrome.browserAction.setIcon({path: 'rsc/icon-red.png'})
36
 				}
36
 				}

+ 7
- 5
index.js View File

21
 
21
 
22
 // Redirect to mirror url
22
 // Redirect to mirror url
23
 function takeMeTo(url) {
23
 function takeMeTo(url) {
24
-	updateProperties = {
24
+	let updateProperties = {
25
 			url: "https://" + url
25
 			url: "https://" + url
26
 	}
26
 	}
27
 	chrome.tabs.update(updateProperties=updateProperties)
27
 	chrome.tabs.update(updateProperties=updateProperties)
33
 	// about it and the button to redirect to a random mirror (if there's more than
33
 	// about it and the button to redirect to a random mirror (if there's more than
34
 	// one).
34
 	// one).
35
 	getCurrentTabUrl(function(url) {
35
 	getCurrentTabUrl(function(url) {
36
-		chrome.storage.local.get("sites", function(sites){
37
-			sites = sites.sites
36
+		chrome.storage.local.get("sites", function(localSites){
37
+			sites = localSites.sites
38
 			// Grab the domain part of the URL
38
 			// Grab the domain part of the URL
39
-			domain = url.match(/:\/\/(www\.)?([^\/]+)\//).slice(-1)[0]
39
+			let domain = url.match(/:\/\/(www\.)?([^\/]+)\//).slice(-1)[0]
40
+			console.log(domain);
41
+			console.log(sites);
40
 			if(domain in sites) {
42
 			if(domain in sites) {
41
-				proxies = sites[domain]
43
+				let proxies = sites[domain]
42
 				// Offer the user to redirect them to a mirror
44
 				// Offer the user to redirect them to a mirror
43
 				$("#mirror").css("display", "block")
45
 				$("#mirror").css("display", "block")
44
 				$("#nomirror").css("display", "none")
46
 				$("#nomirror").css("display", "none")