From 5cc233e4349c02104feaf293cc9bdf1a87000854 Mon Sep 17 00:00:00 2001 From: Harry Denley Date: Sun, 9 Jul 2017 02:29:33 +0100 Subject: [PATCH 1/9] Added styling for blacklist stats --- css/app.css | 63 +++++++++++++++++++++++++++++------------------------ 1 file changed, 35 insertions(+), 28 deletions(-) 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 From 63e997e58f4d7474b4bb711c9aaab2663c9ce643 Mon Sep 17 00:00:00 2001 From: Harry Denley Date: Sun, 9 Jul 2017 02:30:23 +0100 Subject: [PATCH 2/9] Added logic to fetch the blacklisted domains that are cached and cleared the dom before I append to it --- js/DomManipulator.js | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) 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) } } From a836b7aeacbecb1b9f23d73fb623a9ea70717033 Mon Sep 17 00:00:00 2001 From: Harry Denley Date: Sun, 9 Jul 2017 02:30:47 +0100 Subject: [PATCH 3/9] Added logic to show you how many domains are blacklisted and when your last cache was --- js/app/toggleBlacklistDomains.js | 37 +++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) 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 From a32f805e656251bc9a7e331dec8f533dde0dee16 Mon Sep 17 00:00:00 2001 From: Harry Denley Date: Sun, 9 Jul 2017 02:31:03 +0100 Subject: [PATCH 4/9] Added text to show blacklisted domain stats --- options.html | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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 +
-
+