Skip to content

Commit

Permalink
Fixed bug that caused on to be off and off to be on, on block malicio…
Browse files Browse the repository at this point in the history
…us domains
  • Loading branch information
Harry Denley committed Jul 7, 2017
1 parent e610e0d commit 4a1b9cb
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 27 deletions.
1 change: 0 additions & 1 deletion blacklists/domains.json
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,6 @@
"myetherwallet.coffee",
"myetherwallet.college",
"myetherwallet.cologne",
"myetherwallet.com",
"myetherwallet.comcast",
"myetherwallet.commbank",
"myetherwallet.community",
Expand Down
47 changes: 22 additions & 25 deletions js/DomManipulator.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class EtherAddressLookup {
//Update the DOM once all settings have been received...
setTimeout(function() {
if(this.intSettingsCount === this.intSettingsTotalCount) {
if(this.blBlacklistDomains === false) {
if(this.blBlacklistDomains) {
this.blacklistedDomainCheck();
}
this.convertAddressToLink();
Expand All @@ -55,7 +55,6 @@ class EtherAddressLookup {
//Finds Ethereum addresses and converts to a link to a block explorer
convertAddressToLink()
{
console.log("converting");
var arrWhitelistedTags = new Array("code", "span", "p", "td", "li");
var strRegex = /(^|\s|:|-)((?:0x)?[0-9a-fA-F]{40})(?:\s|$)/gi;

Expand All @@ -65,7 +64,6 @@ class EtherAddressLookup {
//Loop through the whitelisted content
for(var x=0; x<objNodes.length; x++) {
var strContent = objNodes[x].innerText;
console.log(strContent);
if( /((?:0x)?[0-9a-fA-F]{40})/gi.exec(strContent) !== null) {
objNodes[x].innerHTML = strContent.replace(
new RegExp(strRegex, "gi"),
Expand Down Expand Up @@ -108,28 +106,27 @@ class EtherAddressLookup {
//@todo - check local storage and if within 5 minutes, don't send this request.
var objAjax = new XMLHttpRequest();
objAjax.open("GET", "https://raw.githubusercontent.com/409H/EtherAddressLookup/master/blacklists/domains.json", true);
if( objAjax.send() ) {
objAjax.onreadystatechange = function () {
if (objAjax.readyState === 4) {
var arrBlacklistedDomains = JSON.parse(objAjax.responseText);
var strCurrentTab = window.location.hostname;

if (arrBlacklistedDomains.includes(strCurrentTab)) {
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;"

var objBlacklistedDomainText = document.createElement("div");
objBlacklistedDomainText.style.cssText = "padding:5%;color:#57618F;";
objBlacklistedDomainText.innerHTML = "<img src='https://github.com/409H/EtherAddressLookup/raw/master/images/icon.png?raw=true' />" +
"<br /><h3>ATTENTION</h3>We have detected this domain to have malicious " +
"intent and have prevented you from interacting with it.<br /><br /><br /><small>This is " +
"because you have <br />enabled <em>'Warn of blacklisted domains'</em> setting <br />on EtherAddressLookup Chrome " +
"Extension. You <br />can turn this setting off to interact with this site <br />but it's advised not to." +
"<br /><br />We blacklisted it for a reason.</small>";

objBlacklistedDomain.appendChild(objBlacklistedDomainText);
document.body.appendChild(objBlacklistedDomain);
}
objAjax.send();
objAjax.onreadystatechange = function () {
if (objAjax.readyState === 4) {
var arrBlacklistedDomains = JSON.parse(objAjax.responseText);
var strCurrentTab = window.location.hostname;

if (arrBlacklistedDomains.includes(strCurrentTab)) {
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;"

var objBlacklistedDomainText = document.createElement("div");
objBlacklistedDomainText.style.cssText = "padding:5%;color:#57618F;";
objBlacklistedDomainText.innerHTML = "<img src='https://github.com/409H/EtherAddressLookup/raw/master/images/icon.png?raw=true' />" +
"<br /><h3>ATTENTION</h3>We have detected this domain to have malicious " +
"intent and have prevented you from interacting with it.<br /><br /><br /><small>This is " +
"because you have <br />enabled <em>'Warn of blacklisted domains'</em> setting <br />on EtherAddressLookup Chrome " +
"Extension. You <br />can turn this setting off to interact with this site <br />but it's advised not to." +
"<br /><br />We blacklisted it for a reason.</small>";

objBlacklistedDomain.appendChild(objBlacklistedDomainText);
document.body.appendChild(objBlacklistedDomain);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"name": "EtherAddressLookup",
"short_name": "EtherAddressLookup",
"description": "Adds links to strings that look like Ethereum addresses to your favorite blockchain explorer.",
"version": "1.3",
"version": "1.3.1",

"browser_action": {
"default_icon": "images/icon.png",
Expand Down

0 comments on commit 4a1b9cb

Please sign in to comment.