diff --git a/css/app.css b/css/app.css index 1e9b8d70..47c11cb2 100644 --- a/css/app.css +++ b/css/app.css @@ -1,28 +1,35 @@ -.ext-etheraddresslookup-link-highlight { - padding: 2px; - background: #F2EAAC; - color: #000; - border: 1px solid #C7BC67; -} - -.ext-etheraddresslookup-link-no_highlight { - padding: 0px; - background: transparent; - border: 1px solid transparent; - color: inherit; -} - -#ext-etheraddresslookup-popup { - margin: 0; - padding: 0px; - font-family: "Arial"; - font-size: 12pt; - width: 300px; -} -#ext-etheraddresslookup-popup #content { - padding: 15px; - margin-top: 15px; -} -#ext-etheraddresslookup-popup #content #footer { - font-size: 70%; -} +.ext-etheraddresslookup-link-highlight { + padding: 2px; + background: #F2EAAC; + color: #000; + border: 1px solid #C7BC67; +} + +.ext-etheraddresslookup-link-no_highlight { + padding: 0px; + background: transparent; + border: 1px solid transparent; + color: inherit; +} + +#ext-etheraddresslookup-popup { + margin: 0; + padding: 0px; + font-family: "Arial"; + font-size: 12pt; + width: 300px; +} +#ext-etheraddresslookup-popup #content { + padding: 15px; + margin-top: 15px; +} +#ext-etheraddresslookup-popup #content #footer { + font-size: 70%; +} + +#ext-etheraddresslookup-blacklist_domains_stats { + font-size: 10pt; + color: #c2c6c7; + line-height: 10pt; + padding-left: 3.5em; +} \ No newline at end of file diff --git a/images/ether-128x128.png b/images/ether-128x128.png new file mode 100644 index 00000000..0d9b6ec7 Binary files /dev/null and b/images/ether-128x128.png differ diff --git a/images/ether-16x16.png b/images/ether-16x16.png new file mode 100644 index 00000000..4b1e05ea Binary files /dev/null and b/images/ether-16x16.png differ diff --git a/images/ether-32x32.png b/images/ether-32x32.png new file mode 100644 index 00000000..18084fa9 Binary files /dev/null and b/images/ether-32x32.png differ diff --git a/images/ether-48x48.png b/images/ether-48x48.png new file mode 100644 index 00000000..3a94b633 Binary files /dev/null and b/images/ether-48x48.png differ diff --git a/images/ether-64x64.png b/images/ether-64x64.png new file mode 100644 index 00000000..3943a13a Binary files /dev/null and b/images/ether-64x64.png differ diff --git a/js/DomManipulator.js b/js/DomManipulator.js index c12651fe..96588904 100644 --- a/js/DomManipulator.js +++ b/js/DomManipulator.js @@ -55,7 +55,7 @@ class EtherAddressLookup { //Finds Ethereum addresses and converts to a link to a block explorer convertAddressToLink() { - var arrWhitelistedTags = new Array("code", "span", "p", "td", "li"); + var arrWhitelistedTags = new Array("code", "span", "p", "td", "li", "em", "i", "b", "strong"); var strRegex = /(^|\s|:|-)((?:0x)?[0-9a-fA-F]{40})(?:\s|$)/gi; //Get the whitelisted nodes @@ -63,7 +63,7 @@ class EtherAddressLookup { var objNodes = document.getElementsByTagName(arrWhitelistedTags[i]); //Loop through the whitelisted content for(var x=0; x 0) { + var strCurrentTab = window.location.hostname; if (arrBlacklistedDomains.includes(strCurrentTab)) { + document.body.innerHTML = ""; //Clear the DOM. var objBlacklistedDomain = document.createElement("div"); objBlacklistedDomain.style.cssText = "position:absolute;z-index:999999999;top:0%;left:0%;width:100%;height:100%;background:#fff;color:#000;text-align:center;" @@ -129,7 +131,7 @@ class EtherAddressLookup { document.body.appendChild(objBlacklistedDomain); } } - } + }.bind(arrBlacklistedDomains), 500) } } diff --git a/js/app/toggleBlacklistDomains.js b/js/app/toggleBlacklistDomains.js index d714a220..e74892c6 100644 --- a/js/app/toggleBlacklistDomains.js +++ b/js/app/toggleBlacklistDomains.js @@ -1,10 +1,15 @@ //On page load it checks/unchecks the checkbox -(function() { +(function() +{ refreshBlacklistDomains(); + + getBlacklistStats(); + setInterval(function() {getBlacklistStats()}, 3000); })(); //Sets the local storage to remember their match blacklist settings -function toggleBlacklistDomains() { +function toggleBlacklistDomains() +{ var objBlacklistDomains = document.getElementById("ext-etheraddresslookup-blacklist_domains"); var intBlacklistDomains = objBlacklistDomains.checked ? 1 : 0; localStorage.setItem("ext-etheraddresslookup-blacklist_domains", intBlacklistDomains); @@ -12,7 +17,33 @@ function toggleBlacklistDomains() { refreshBlacklistDomains(); } -function refreshBlacklistDomains() { +function refreshBlacklistDomains() +{ + chrome.runtime.sendMessage({func: "blacklist_domain_list"}, function(objResponse) { + console.log("BDL-001"); + }); + var intBlacklistDomains = localStorage.getItem("ext-etheraddresslookup-blacklist_domains"); document.getElementById("ext-etheraddresslookup-blacklist_domains").checked = (intBlacklistDomains == 1 ? true : false); +} + +function getBlacklistStats() +{ + var objLastUpdatedText = document.getElementById("ext-etheraddresslookup-blacklist_domains_last_updated"); + var objTotalCountText = document.getElementById("ext-etheraddresslookup-blacklist_domains_total_count"); + var objBlacklistedDomains = localStorage.getItem("ext-etheraddresslookup-blacklist_domains_list"); + objBlacklistedDomains = JSON.parse(objBlacklistedDomains); + var intLastUpdated = objBlacklistedDomains.timestamp; + + objLastUpdatedText.innerText = timeDifference(Math.floor(Date.now()/1000), intLastUpdated); + objTotalCountText.innerText = new Intl.NumberFormat().format(objBlacklistedDomains.domains.length); +} + +function timeDifference(current, previous) +{ + var elapsed = parseInt(current) - parseInt(previous); + if(elapsed > 59) { + return Math.floor(elapsed / 60) + ' minutes ago'; + } + return Math.round(elapsed) + ' seconds ago'; } \ No newline at end of file diff --git a/js/options.js b/js/options.js index c35650a4..ba9932d2 100644 --- a/js/options.js +++ b/js/options.js @@ -40,6 +40,25 @@ chrome.runtime.onMessage.addListener( case 'blacklist_domains' : strResponse = localStorage.getItem("ext-etheraddresslookup-blacklist_domains"); break; + case 'blacklist_domain_list' : + console.log("Getting domain list"); + var objBlacklistedDomains = localStorage.getItem("ext-etheraddresslookup-blacklist_domains_list"); + if(objBlacklistedDomains === null) { + //We haven't cached the blacklisted domains yet, let's do it. + console.log("Fetching new domain list"); + objBlacklistedDomains = getBlacklistedDomainsFromSource(); + strResponse = objBlacklistedDomains.domains; + } else { + //Check to see if the cache is older than 5 minutes, if so re-cache it. + objBlacklistedDomains = JSON.parse(objBlacklistedDomains); + console.log("Domains last fetched: "+ (Math.floor(Date.now() / 1000) - objBlacklistedDomains.timestamp) +" seconds ago"); + if( (Math.floor(Date.now() / 1000) - objBlacklistedDomains.timestamp) > 180 ) { + console.log("Caching blacklisted domains again."); + objBlacklistedDomains = getBlacklistedDomainsFromSource(); + } + } + strResponse = objBlacklistedDomains.domains; + break; default: strResponse = "unsupported"; break; @@ -47,4 +66,22 @@ chrome.runtime.onMessage.addListener( sendResponse({resp:strResponse}); } -); \ No newline at end of file +); + +function getBlacklistedDomainsFromSource() +{ + var objAjax = new XMLHttpRequest(); + objAjax.open("GET", "https://raw.githubusercontent.com/409H/EtherAddressLookup/master/blacklists/domains.json", true); + objAjax.send(); + objAjax.onreadystatechange = function () { + if (objAjax.readyState === 4) { + var arrBlacklistedDomains = JSON.parse(objAjax.responseText); + var objBlacklist = {}; + objBlacklist.timestamp = Math.floor(Date.now() / 1000); + objBlacklist.domains = arrBlacklistedDomains; + localStorage.setItem("ext-etheraddresslookup-blacklist_domains_list", JSON.stringify(objBlacklist)); + return objBlacklist; + } + } + return {"timestamp":0,"domains":[]}; +} \ No newline at end of file diff --git a/manifest.json b/manifest.json index b0b93163..6cc87e0e 100644 --- a/manifest.json +++ b/manifest.json @@ -3,8 +3,8 @@ "name": "EtherAddressLookup", "short_name": "EtherAddressLookup", - "description": "Adds links to strings that look like Ethereum addresses to your favorite blockchain explorer.", - "version": "1.3.1", + "description": "Adds links to strings that look like Ethereum addresses to your favorite blockchain explorer. It also attempts to protect you from phishing sites stealing your private keys.", + "version": "1.3.3", "browser_action": { "default_icon": "images/icon.png", @@ -26,5 +26,11 @@ "background": { "scripts": ["js/options.js"] + }, + + "icons": { + "16": "images/ether-16x16.png", + "48": "images/ether-48x48.png", + "128": "images/ether-128x128.png" } } \ No newline at end of file diff --git a/options.html b/options.html index aed8af37..a1e74584 100644 --- a/options.html +++ b/options.html @@ -23,8 +23,12 @@

EtherAddressLookup

Warn of blacklisted domains +
+ Last updated: N/A
+ Domains Blacklisted: 0 +
-
+