Skip to content

Commit

Permalink
Merge branch 'ft-firefox_support'
Browse files Browse the repository at this point in the history
* ft-firefox_support:
  Added notes for Firefox
  Added notes for Firefox
  Added notes for Firefox
  Increased version number
  Lessened the delay for phishing check
  Issue #26 - Added logic to enable Firefox support
  • Loading branch information
Harry Denley committed Jul 15, 2017
2 parents a4a9314 + 68ae357 commit 745f79b
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 67 deletions.
17 changes: 14 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,33 @@ Automatically adds links to strings that look like Ethereum addresses so you can
block explorer. It also prevents you from interacting with known phishing domains by wiping the DOM and displaying text
notifying you.

Ether/ERC20 donation address: [`0x661b5dc032bedb210f225df4b1aa2bdd669b38bc`](https://etherscan.io/address/0x661b5dc032bedb210f225df4b1aa2bdd669b38bc) (donations aren't required to run the extension. Each Friday, I will send 50% of the donations to MEW)
Ether/ERC20 donation address: [`0x661b5dc032bedb210f225df4b1aa2bdd669b38bc`](https://etherscan.io/address/0x661b5dc032bedb210f225df4b1aa2bdd669b38bc) (Each Friday, I will send 50% of the donations from the week to MEW)

##### Read: http://harrydenley.com/ethaddresslookup-chrome-extension-release/

## Installations

### Chrome Extension

The `master` branch is bundled on every release 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 & Firefox 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)

### Manual Installation

#### Chrome
* Clone/download [the repo](https://github.com/409H/EtherAddressLookup).
* Go to [chrome://extensions](chrome://extensions) in Chrome.
* Go to [chrome://extensions](chrome://extensions) in Chrome
* Turn on developer mode.
* Load the `manifest.json` file by dragging and dropping.

#### Firefox
* Clone/download [the repo](https://github.com/409H/EtherAddressLookup).
* Go to [about:debugging](about:debugging) in Firefox
* Click "Load Temporary Add-on"
* Browse to the downloaded repo, and double click `manifest.json`

(Note that this will **not** have automatic updates)

## Blacklisted Domains
Expand All @@ -50,6 +57,10 @@ a [pull request](https://github.com/409H/EtherAddressLookup/compare) with the ch

## Changelog

### v1.4

* Added support for Firefox.

### v1.3

* Due to the recent phishing campaigns going on, we have decided to start a [domain blacklist](https://github.com/409H/EtherAddressLookup/blob/master/blacklists/domains.json), and
Expand Down
107 changes: 47 additions & 60 deletions js/DomManipulator.js
Original file line number Diff line number Diff line change
@@ -1,47 +1,50 @@
let objBrowser = chrome ? chrome : browser;

class EtherAddressLookup {

constructor()
{
console.log("Init");
this.setDefaultExtensionSettings();
this.init();
}

levenshtein(a, b) {
if(a.length == 0) return b.length;
if(b.length == 0) return a.length;

// swap to save some memory O(min(a,b)) instead of O(a)
if(a.length > b.length) {
var tmp = a;
a = b;
b = tmp;
}

var row = [];
// init the row
for(var i = 0; i <= a.length; i++){
row[i] = i;
}

// fill in the rest
for(var i = 1; i <= b.length; i++){
var prev = i;
for(var j = 1; j <= a.length; j++){
var val;
if(b.charAt(i-1) == a.charAt(j-1)){
val = row[j-1]; // match
} else {
val = Math.min(row[j-1] + 1, // substitution
prev + 1, // insertion
row[j] + 1); // deletion
}
row[j - 1] = prev;
prev = val;
if(a.length == 0) return b.length;
if(b.length == 0) return a.length;

// swap to save some memory O(min(a,b)) instead of O(a)
if(a.length > b.length) {
var tmp = a;
a = b;
b = tmp;
}

var row = [];
// init the row
for(var i = 0; i <= a.length; i++){
row[i] = i;
}

// fill in the rest
for(var i = 1; i <= b.length; i++){
var prev = i;
for(var j = 1; j <= a.length; j++){
var val;
if(b.charAt(i-1) == a.charAt(j-1)){
val = row[j-1]; // match
} else {
val = Math.min(row[j-1] + 1, // substitution
prev + 1, // insertion
row[j] + 1); // deletion
}
row[j - 1] = prev;
prev = val;
}
row[a.length] = prev;
}
row[a.length] = prev;
}

return row[a.length];
return row[a.length];
}

setDefaultExtensionSettings()
Expand All @@ -57,22 +60,23 @@ class EtherAddressLookup {
//Gets extension settings and then converts addresses to links
init()
{
let objBrowser = chrome ? chrome : browser;
//Get the highlight option for the user
chrome.runtime.sendMessage({func: "highlight_option"}, function(objResponse) {
objBrowser.runtime.sendMessage({func: "highlight_option"}, function(objResponse) {
if(objResponse && objResponse.hasOwnProperty("resp")) {
this.blHighlight = (objResponse.resp == 1 ? true : false);
}
++this.intSettingsCount;
}.bind(this));

//Get the blockchain explorer for the user
chrome.runtime.sendMessage({func: "blockchain_explorer"}, function(objResponse) {
objBrowser.runtime.sendMessage({func: "blockchain_explorer"}, function(objResponse) {
this.strBlockchainExplorer = objResponse.resp;
++this.intSettingsCount;
}.bind(this));

//Get the blacklist domains option for the user
chrome.runtime.sendMessage({func: "blacklist_domains"}, function(objResponse) {
objBrowser.runtime.sendMessage({func: "blacklist_domains"}, function(objResponse) {
if(objResponse && objResponse.hasOwnProperty("resp")) {
this.blBlacklistDomains = (objResponse.resp == 1 ? true : false);
}
Expand All @@ -81,13 +85,13 @@ class EtherAddressLookup {

//Update the DOM once all settings have been received...
setTimeout(function() {
if(this.intSettingsCount === this.intSettingsTotalCount) {
if(true || this.intSettingsCount === this.intSettingsTotalCount) {
if(this.blBlacklistDomains) {
this.blacklistedDomainCheck();
}
this.convertAddressToLink();
}
}.bind(this), 1)
}.bind(this), 10)
}

//Finds Ethereum addresses and converts to a link to a block explorer
Expand Down Expand Up @@ -141,16 +145,17 @@ class EtherAddressLookup {
//Detects if the current tab is in the blacklisted domains file
blacklistedDomainCheck()
{
let objBrowser = chrome ? chrome : browser;
var self = this;
var arrBlacklistedDomains = [];
var arrWhitelistedDomains = ["www.myetherwallet.com", "myetherwallet.com"];
chrome.runtime.sendMessage({func: "blacklist_domain_list"}, function(objResponse) {
objBrowser.runtime.sendMessage({func: "blacklist_domain_list"}, function(objResponse) {
if(objResponse && objResponse.hasOwnProperty("resp")) {
arrBlacklistedDomains = objResponse.resp;
}
}.bind(arrBlacklistedDomains));

chrome.runtime.sendMessage({func: "whitelist_domain_list"}, function(objResponse) {
objBrowser.runtime.sendMessage({func: "whitelist_domain_list"}, function(objResponse) {
if(objResponse && objResponse.hasOwnProperty("resp")) {
arrWhitelistedDomains = objResponse.resp;
}
Expand All @@ -174,25 +179,7 @@ class EtherAddressLookup {
var blHolisticStatus = (intHolisticMetric > 0 && intHolisticMetric < intHolisticLimit) ? true : false;

if (isBlacklisted || blHolisticStatus ) {
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;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 = "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;color:#fff'>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);
window.location.href = "https://harrydenley.com/EtherAddressLookup/phishing.html";
}
}
}.bind(arrBlacklistedDomains), 500)
Expand All @@ -204,7 +191,7 @@ window.addEventListener("load", function() {
});

//Send message from the extension to here.
chrome.runtime.onMessage.addListener(
objBrowser.runtime.onMessage.addListener(
function(request, sender, sendResponse) {
let objEtherAddressLookup = new EtherAddressLookup();
if(typeof request.func !== "undefined") {
Expand Down
5 changes: 3 additions & 2 deletions js/options.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
let objBrowser = chrome ? chrome : browser;
(function() {
//Toggle the highlight option and set it in LocalStorage
var objOptionAddHighlight = document.getElementById('ext-etheraddresslookup-show_style');
Expand All @@ -18,7 +19,7 @@
}

//Get the extension version
var objManifest = chrome.runtime.getManifest();
var objManifest = objBrowser.runtime.getManifest();
var objManifestVersion = document.getElementById('ext-manifest_version');
if(objManifestVersion) {
objManifestVersion.innerHTML = objManifest.version;
Expand All @@ -38,7 +39,7 @@
}, 180000);
})();

chrome.runtime.onMessage.addListener(
objBrowser.runtime.onMessage.addListener(
function(request, sender, sendResponse) {
var strOption = request.func;
var strResponse = "";
Expand Down
3 changes: 1 addition & 2 deletions 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.7",
"version": "1.4.0",

"browser_action": {
"default_icon": "images/icon.png",
Expand All @@ -13,7 +13,6 @@
},

"permissions": [
"https://etherscan.io/",
"activeTab"
],

Expand Down

0 comments on commit 745f79b

Please sign in to comment.