diff --git a/README.md b/README.md index 14efb16b..51a0b71d 100644 --- a/README.md +++ b/README.md @@ -82,6 +82,18 @@ a [pull request](https://github.com/409H/EtherAddressLookup/compare) with the ch ## Changelog +### v1.8 + +* Improved Levenshtien edit distance check for MyEtherWallet and punycode domains. + +### v1.7 + +* Added the ability for EAL to check your browser history to see if you have been on a domain that has since been blacklisted. + +### v1.6 + +* Added the ability to bookmark up to 6 domains with their favicon showing. + ### v1.5 * Added report domain button. diff --git a/js/DomainBlacklist.js b/js/DomainBlacklist.js index e1755ef7..1af5148e 100644 --- a/js/DomainBlacklist.js +++ b/js/DomainBlacklist.js @@ -38,13 +38,19 @@ return; } - //Levenshtein - @sogoiii var strCurrentTab = strCurrentTab.replace(/www\./g,''); var isBlacklisted = arrBlacklistedDomains.includes(strCurrentTab); - var source = strCurrentTab.replace(/\./g,''); - var intHolisticMetric = levenshtein(source, 'myetherwallet'); - var intHolisticLimit = 7 // How different can the word be? - var blHolisticStatus = (intHolisticMetric > 0 && intHolisticMetric < intHolisticLimit) ? true : false; + + //Only do Levenshtein if it's not blacklisted + //Levenshtein - @sogoiii + var blHolisticStatus = false; + if(isBlacklisted === false) { + var strCurrentTab = punycode.toUnicode(strCurrentTab); + var source = strCurrentTab.replace(/\./g, ''); + var intHolisticMetric = levenshtein(source, 'myetherwallet'); + var intHolisticLimit = 7 // How different can the word be? + blHolisticStatus = (intHolisticMetric > 0 && intHolisticMetric < intHolisticLimit) ? true : false; + } if (isBlacklisted || blHolisticStatus ) { window.location.href = "https://harrydenley.com/EtherAddressLookup/phishing.html#"+ (window.location.href); diff --git a/js/app/lib/punycode.min.js b/js/app/lib/punycode.min.js new file mode 100644 index 00000000..c72d0c2f --- /dev/null +++ b/js/app/lib/punycode.min.js @@ -0,0 +1,2 @@ +/*! https://mths.be/punycode v1.4.1 by @mathias */ +!function(a){function b(a){throw new RangeError(E[a])}function c(a,b){for(var c=a.length,d=[];c--;)d[c]=b(a[c]);return d}function d(a,b){var d=a.split("@"),e="";d.length>1&&(e=d[0]+"@",a=d[1]),a=a.replace(D,".");var f=a.split("."),g=c(f,b).join(".");return e+g}function e(a){for(var b,c,d=[],e=0,f=a.length;f>e;)b=a.charCodeAt(e++),b>=55296&&56319>=b&&f>e?(c=a.charCodeAt(e++),56320==(64512&c)?d.push(((1023&b)<<10)+(1023&c)+65536):(d.push(b),e--)):d.push(b);return d}function f(a){return c(a,function(a){var b="";return a>65535&&(a-=65536,b+=H(a>>>10&1023|55296),a=56320|1023&a),b+=H(a)}).join("")}function g(a){return 10>a-48?a-22:26>a-65?a-65:26>a-97?a-97:t}function h(a,b){return a+22+75*(26>a)-((0!=b)<<5)}function i(a,b,c){var d=0;for(a=c?G(a/x):a>>1,a+=G(a/b);a>F*v>>1;d+=t)a=G(a/F);return G(d+(F+1)*a/(a+w))}function j(a){var c,d,e,h,j,k,l,m,n,o,p=[],q=a.length,r=0,w=z,x=y;for(d=a.lastIndexOf(A),0>d&&(d=0),e=0;d>e;++e)a.charCodeAt(e)>=128&&b("not-basic"),p.push(a.charCodeAt(e));for(h=d>0?d+1:0;q>h;){for(j=r,k=1,l=t;h>=q&&b("invalid-input"),m=g(a.charCodeAt(h++)),(m>=t||m>G((s-r)/k))&&b("overflow"),r+=m*k,n=x>=l?u:l>=x+v?v:l-x,!(n>m);l+=t)o=t-n,k>G(s/o)&&b("overflow"),k*=o;c=p.length+1,x=i(r-j,c,0==j),G(r/c)>s-w&&b("overflow"),w+=G(r/c),r%=c,p.splice(r++,0,w)}return f(p)}function k(a){var c,d,f,g,j,k,l,m,n,o,p,q,r,w,x,B=[];for(a=e(a),q=a.length,c=z,d=0,j=y,k=0;q>k;++k)p=a[k],128>p&&B.push(H(p));for(f=g=B.length,g&&B.push(A);q>f;){for(l=s,k=0;q>k;++k)p=a[k],p>=c&&l>p&&(l=p);for(r=f+1,l-c>G((s-d)/r)&&b("overflow"),d+=(l-c)*r,c=l,k=0;q>k;++k)if(p=a[k],c>p&&++d>s&&b("overflow"),p==c){for(m=d,n=t;o=j>=n?u:n>=j+v?v:n-j,!(o>m);n+=t)x=m-o,w=t-o,B.push(H(h(o+x%w,0))),m=G(x/w);B.push(H(h(m,0))),j=i(d,r,f==g),d=0,++f}++d,++c}return B.join("")}function l(a){return d(a,function(a){return B.test(a)?j(a.slice(4).toLowerCase()):a})}function m(a){return d(a,function(a){return C.test(a)?"xn--"+k(a):a})}var n="object"==typeof exports&&exports&&!exports.nodeType&&exports,o="object"==typeof module&&module&&!module.nodeType&&module,p="object"==typeof global&&global;(p.global===p||p.window===p||p.self===p)&&(a=p);var q,r,s=2147483647,t=36,u=1,v=26,w=38,x=700,y=72,z=128,A="-",B=/^xn--/,C=/[^\x20-\x7E]/,D=/[\x2E\u3002\uFF0E\uFF61]/g,E={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},F=t-u,G=Math.floor,H=String.fromCharCode;if(q={version:"1.4.1",ucs2:{decode:e,encode:f},decode:j,encode:k,toASCII:m,toUnicode:l},"function"==typeof define&&"object"==typeof define.amd&&define.amd)define("punycode",function(){return q});else if(n&&o)if(module.exports==n)o.exports=q;else for(r in q)q.hasOwnProperty(r)&&(n[r]=q[r]);else a.punycode=q}(this); \ No newline at end of file diff --git a/manifest.json b/manifest.json index 39be7468..068ee3f8 100644 --- a/manifest.json +++ b/manifest.json @@ -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.7.1", + "version": "1.8", "browser_action": { "default_icon": "images/icon.png", @@ -23,7 +23,7 @@ "content_scripts":[{ "run_at": "document_start", "matches": ["http://*/*", "https://*/*"], - "js": ["js/DomainBlacklist.js"] + "js": ["js/app/lib/punycode.min.js", "js/DomainBlacklist.js"] },{ "run_at": "document_end", "matches": ["http://*/*", "https://*/*"],