Skip to content

Commit

Permalink
Added Identicons / Ether Blockies
Browse files Browse the repository at this point in the history
Resolves #91

This commit contains functionality for auto scaling blockie images to be inserted infront of any ethereum address
  • Loading branch information
Samyoul committed Nov 8, 2017
1 parent 9f525f6 commit 6c1c9c6
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 2 deletions.
11 changes: 11 additions & 0 deletions css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,15 @@
margin-top: 5%;
padding: 15px 5%;
background: #e4e4e4;
}

.ext-etheraddresslookup-blockie {
width: 1em;
height: 1em;
background-size: cover;
background-repeat: no-repeat;
border-radius: 50%;
box-shadow: inset rgba(255, 255, 255, 0.6) 0 2px 2px, inset rgba(0, 0, 0, 0.3) 0 -2px 6px;
display: inline-block;
margin-bottom: -0.2em;
}
19 changes: 18 additions & 1 deletion js/DomManipulator.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ class EtherAddressLookup {
'$1<a title="See this address on the blockchain explorer" ' +
'href="' + this.strBlockchainExplorer + '/$2" ' +
'class="ext-etheraddresslookup-link" ' +
'target="'+ this.target +'">$2</a>$3',
'target="'+ this.target +'">' +
'<div class="ext-etheraddresslookup-blockie" data-ether-address="$2" ></div> $2' +
'</a>$3',

// ENS Address Replace
'<a title="See this address on the blockchain explorer" ' +
Expand Down Expand Up @@ -148,6 +150,7 @@ class EtherAddressLookup {
}

this.tidyUpSlots();
this.addBlockies();

if(this.blHighlight) {
this.addHighlightStyle();
Expand Down Expand Up @@ -240,6 +243,20 @@ class EtherAddressLookup {
}
}

addBlockies()
{
var blockieDivs = document.querySelectorAll("div.ext-etheraddresslookup-blockie");
for(var i = 0; i < blockieDivs.length; i++){

blockieDivs[i].style.backgroundImage = 'url(' + blockies.create({
// toLowerCase is used because standard blockies are based on none-checksum Ethereum addresses
seed:blockieDivs[i].getAttribute('data-ether-address').toLowerCase(),
size: 8,
scale: 16
}).toDataURL() +')';
}
}

//Removes the highlight style from Ethereum addresses
removeHighlightStyle()
{
Expand Down
1 change: 1 addition & 0 deletions js/app/lib/blockies.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@
"content_scripts":[{
"run_at": "document_start",
"matches": ["http://*/*", "https://*/*"],
"js": ["js/app/lib/punycode.min.js", "js/DomainBlacklist.js"]
"js": [
"js/app/lib/punycode.min.js",
"js/app/lib/blockies.min.js",
"js/DomainBlacklist.js"
]
},{
"run_at": "document_end",
"matches": ["http://*/*", "https://*/*"],
Expand Down

0 comments on commit 6c1c9c6

Please sign in to comment.