Skip to content

Commit

Permalink
Merge branch 'hf-22'
Browse files Browse the repository at this point in the history
* hf-22:
  Adjusted text
  Removed debug
  Added styling for the attention view
  Increased version number
  Added more thanks
  Issue #22 - Added more logic to fix syncing issues, especially on initial install
  Issue #22 - Enabled blocking blacklisted domains by default
  Sets the default explorer to etherscan for initial install
  Added thanks
  Issue #22 - Added logic to fetch/check for updates on init of the extension. This should fix the syncing issues
  • Loading branch information
Harry Denley committed Jul 11, 2017
2 parents 8c8b520 + bec9bad commit 79e62a9
Show file tree
Hide file tree
Showing 10 changed files with 94 additions and 53 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Ether/ERC20 donation address: [`0x661b5dc032bedb210f225df4b1aa2bdd669b38bc`](htt

### Chrome Extension

`master` is bundled and pushed to the Chrome Extension store, you can view/download it
The `master` branch is bundled on every release and pushed to the Chrome Extension store, you can view/download it
here: [https://chrome.google.com/webstore/detail/etheraddresslookup/pdknmigbbbhmllnmgdfalmedcmcefdfn](https://chrome.google.com/webstore/detail/etheraddresslookup/pdknmigbbbhmllnmgdfalmedcmcefdfn)

(Note that this will have automatic updates)
Expand All @@ -34,6 +34,11 @@ blacklist, please [open an issue](https://github.com/409H/EtherAddressLookup/iss
a [pull request](https://github.com/409H/EtherAddressLookup/compare) with the changes. Make sure you give some
details on why the changes are needed.

## Special Thanks

* Thanks to the team at MyEtherWallet for helping keep the domain blacklist up-to-date!
* Thanks to the team at [Crypto Minded](https://cryptominded.com/) for the store graphics!

----

## Changelog
Expand Down
Binary file added images/screenshots/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/screenshots/2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions images/screenshots/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#### Thanks!

These images were gifted to us by the guys over at [CRYPTOMINDED](http://cryptominded.com/).
Binary file added images/screenshots/tile.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 12 additions & 8 deletions js/DomManipulator.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,17 +115,21 @@ class EtherAddressLookup {
var strCurrentTab = window.location.hostname;
if (arrBlacklistedDomains.includes(strCurrentTab)) {
document.body.innerHTML = ""; //Clear the DOM.
document.body.cssText = "margin:0;padding:0;border:0;font-size:100%;font:inherit;vertical-align:baseline;font-family:arial,sans-serif";
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;"
objBlacklistedDomain.style.cssText = "position:absolute;top:0%;left:0%;width:100%;height:100%;background:#00c2c1;color:#fff;text-align:center;font-size:100%;"

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>";
objBlacklistedDomainText.style.cssText = "margin-left:auto;margin-right:auto;width:50%;padding:5%;margin-top:5%;";
objBlacklistedDomainText.innerHTML = "<img src='https://github.com/409H/EtherAddressLookup/raw/master/images/icon.png?raw=true' style='margin-left:auto;margin-right:auto;margin-bottom:1.5em'/>" +
"<br /><h3 style='font-size:130%;font-weight:800;'>ATTENTION</h3>We have detected this domain to have malicious " +
"intent and have prevented you from interacting with it.<br /><br /><br />" +
"<div style='margin-left:auto;margin-right:auto;width:50%'>" +
"<span style='font-size:10pt;'>This is because you have enabled <em>'Warn of blacklisted domains'</em> setting on EtherAddressLookup Chrome " +
"Extension. You can turn this setting off to interact with this site but it's advised not to." +
"<br /><br />We blacklisted it for a reason.</span></div>";
objBlacklistedDomainText.innerHTML += "<br /><span style='font-size:10pt;'>You can donate to the developers " +
"address if you want to: 0x661b5dc032bedb210f225df4b1aa2bdd669b38bc</span>";

objBlacklistedDomain.appendChild(objBlacklistedDomainText);
document.body.appendChild(objBlacklistedDomain);
Expand Down
55 changes: 30 additions & 25 deletions js/app/chooseBlockchain.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,31 @@
//On page load it selects the default blockchain explorer
(function() {
refreshBlockchainExplorer();
})();

//Sets the local storage to remember their match favourite blockchain explorer
function toggleBlockchainExplorer() {
var objBlockchainExplorer = document.getElementById("ext-etheraddresslookup-choose_blockchain");
localStorage.setItem("ext-etheraddresslookup-blockchain_explorer", objBlockchainExplorer.options[objBlockchainExplorer.selectedIndex].value);
refreshBlockchainExplorer();
}

function refreshBlockchainExplorer() {
var strBlockchainExplorer = localStorage.getItem("ext-etheraddresslookup-blockchain_explorer");
document.getElementById("ext-etheraddresslookup-choose_blockchain").value = strBlockchainExplorer;

//Notify the tab to do a class method
var strMethod = "changeBlockchainExplorer";
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
chrome.tabs.sendMessage(tabs[0].id, {
"func":strMethod
}, function(response) {
console.log(response);
});
});
//On page load it selects the default blockchain explorer
(function() {
refreshBlockchainExplorer();
})();

//Sets the local storage to remember their match favourite blockchain explorer
function toggleBlockchainExplorer() {
var objBlockchainExplorer = document.getElementById("ext-etheraddresslookup-choose_blockchain");
localStorage.setItem("ext-etheraddresslookup-blockchain_explorer", objBlockchainExplorer.options[objBlockchainExplorer.selectedIndex].value);
refreshBlockchainExplorer();
}

function refreshBlockchainExplorer() {
var strBlockchainExplorer = localStorage.getItem("ext-etheraddresslookup-blockchain_explorer");

if(strBlockchainExplorer === null) {
document.getElementById("ext-etheraddresslookup-choose_blockchain").value = "https://etherscan.io/address";
} else {
document.getElementById("ext-etheraddresslookup-choose_blockchain").value = strBlockchainExplorer;
}

//Notify the tab to do a class method
var strMethod = "changeBlockchainExplorer";
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
chrome.tabs.sendMessage(tabs[0].id, {
"func":strMethod
}, function(response) {
console.log(response);
});
});
}
7 changes: 6 additions & 1 deletion js/app/toggleBlacklistDomains.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@ function refreshBlacklistDomains()
});

var intBlacklistDomains = localStorage.getItem("ext-etheraddresslookup-blacklist_domains");
document.getElementById("ext-etheraddresslookup-blacklist_domains").checked = (intBlacklistDomains == 1 ? true : false);

if(intBlacklistDomains === null) {
document.getElementById("ext-etheraddresslookup-blacklist_domains").checked = true;
} else {
document.getElementById("ext-etheraddresslookup-blacklist_domains").checked = (intBlacklistDomains == 1 ? true : false);
}
}

function getBlacklistStats()
Expand Down
53 changes: 36 additions & 17 deletions js/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@
if(objManifestVersion) {
objManifestVersion.innerHTML = objManifest.version;
}

//init getting blacklisted domains
getBlacklistedDomains();
setInterval(function() {
console.log("Re-caching domains");
getBlacklistedDomains();
}, 180000);

})();

chrome.runtime.onMessage.addListener(
Expand All @@ -38,26 +46,16 @@ chrome.runtime.onMessage.addListener(
strResponse = localStorage.getItem("ext-etheraddresslookup-blockchain_explorer");
break;
case 'blacklist_domains' :
strResponse = localStorage.getItem("ext-etheraddresslookup-blacklist_domains");
//This option is enabled by default
if(localStorage.getItem("ext-etheraddresslookup-blacklist_domains") === null) {
strResponse = 1;
} else {
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;
strResponse = getBlacklistedDomains();
break;
default:
strResponse = "unsupported";
Expand All @@ -68,8 +66,29 @@ chrome.runtime.onMessage.addListener(
}
);

function getBlacklistedDomains()
{
var objBlacklistedDomains = {"timestamp":0,"domains":[]};
//See if we need to get the blacklisted domains - ie: do we have them cached?
if(localStorage.getItem("ext-etheraddresslookup-blacklist_domains_list") === null) {
objBlacklistedDomains = getBlacklistedDomainsFromSource();
} else {
var objBlacklistedDomains = localStorage.getItem("ext-etheraddresslookup-blacklist_domains_list");
//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();
}
}

return objBlacklistedDomains.domains;
}

function getBlacklistedDomainsFromSource()
{
console.log("Getting blacklist from GitHub now");
var objAjax = new XMLHttpRequest();
objAjax.open("GET", "https://raw.githubusercontent.com/409H/EtherAddressLookup/master/blacklists/domains.json", true);
objAjax.send();
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.3",
"version": "1.3.5",

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

0 comments on commit 79e62a9

Please sign in to comment.