Ver código fonte

Fix variables declarations

Brendan Abolivier 6 anos atrás
pai
commit
61182139b8
Assinado por: Brendan Abolivier <contact@brendanabolivier.com> ID da chave GPG: 8EF1500759F70623
2 arquivos alterados com 11 adições e 9 exclusões
  1. 4
    4
      backgroundPage.js
  2. 7
    5
      index.js

+ 4
- 4
backgroundPage.js Ver arquivo

@@ -1,6 +1,6 @@
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 5
 // Retrieve the list of mirrors
6 6
 function getSitesAndMirrors() {
@@ -30,7 +30,7 @@ function updateTab() {
30 30
 			sites = sites.sites
31 31
 			if(url.match(domain_regexp)) {
32 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 34
 				if(domain in sites) {
35 35
 					chrome.browserAction.setIcon({path: 'rsc/icon-red.png'})
36 36
 				}

+ 7
- 5
index.js Ver arquivo

@@ -21,7 +21,7 @@ function getCurrentTabUrl(callback) {
21 21
 
22 22
 // Redirect to mirror url
23 23
 function takeMeTo(url) {
24
-	updateProperties = {
24
+	let updateProperties = {
25 25
 			url: "https://" + url
26 26
 	}
27 27
 	chrome.tabs.update(updateProperties=updateProperties)
@@ -33,12 +33,14 @@ jQuery(document).ready(function() {
33 33
 	// about it and the button to redirect to a random mirror (if there's more than
34 34
 	// one).
35 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 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 42
 			if(domain in sites) {
41
-				proxies = sites[domain]
43
+				let proxies = sites[domain]
42 44
 				// Offer the user to redirect them to a mirror
43 45
 				$("#mirror").css("display", "block")
44 46
 				$("#nomirror").css("display", "none")