Skip to content

Commit

Permalink
Merge branch 'en-35'
Browse files Browse the repository at this point in the history
* en-35:
  Increased version number
  ISsue #35 - If you are on your favourite blockchain explorer, links won't open in a new tab
  • Loading branch information
409H committed Aug 14, 2017
2 parents cc8cf4e + c5a1e37 commit 9eb6eac
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion js/DomManipulator.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ class EtherAddressLookup {
//Finds Ethereum addresses and converts to a link to a block explorer
convertAddressToLink()
{
//Put the blockchain explorer into a so we can parse it.
var objBlockchainExplorer = document.createElement("a");
objBlockchainExplorer.href = this.strBlockchainExplorer;

var arrWhitelistedTags = new Array("code", "span", "p", "td", "li", "em", "i", "b", "strong", "small");
var strRegex = /(^|\s|:|-)((?:0x)[0-9a-fA-F]{40})(?:\s|$)/gi;

Expand All @@ -60,9 +64,13 @@ class EtherAddressLookup {
for(var x=0; x<objNodes.length; x++) {
var strContent = objNodes[x].innerHTML;
if( /((?:0x)[0-9a-fA-F]{40})/gi.exec(strContent) !== null) {
//If we are on our favourite blockchain explorer, don't target blank.
objNodes[x].innerHTML = strContent.replace(
new RegExp(strRegex, "gi"),
'$1<a title="See this address on the blockchain explorer" href="'+ this.strBlockchainExplorer +'/$2" class="ext-etheraddresslookup-link" target="_blank">$2</a>'
'$1<a title="See this address on the blockchain explorer" ' +
'href="' + this.strBlockchainExplorer + '/$2" ' +
'class="ext-etheraddresslookup-link" ' +
'target="'+ (objBlockchainExplorer.hostname === window.location.hostname ? '_self' : '_blank') +'">$2</a>'
);
}
}
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.5.2",
"version": "1.5.3",

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

0 comments on commit 9eb6eac

Please sign in to comment.