-
-
Save raulb/1091554 to your computer and use it in GitHub Desktop.
Color Picker bookmarklet for Dribbble.com
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript: void((function() { | |
var colors = []; | |
var title = document.title.replace(/Dribbble - /g, ''); | |
var li = document.getElementsByClassName('color'); | |
if (li.length > 0) { | |
for (var i = 0; i < li.length; i++) { | |
var c = li[i].getElementsByTagName('a')[0].getAttribute('title'); | |
colors.push('<li><div style="display:inline-block; width:20px; height:20px;background:' + c + '"></div> ' + c + '</li>'); | |
} | |
var d = document.getElementById('colorPicker'); | |
if (d != null) { | |
document.body.removeChild(d); | |
} | |
var picker = document.createElement("div"); | |
picker.id = "colorPicker"; | |
picker.innerHTML = '<a href="#" style="float:right;width:1.5em;height:1.5em;padding-left:1px;background-color:#ea4c88;color:#fff;font-size:11px;line-height:14px;text-align:center;-webkit-border-radius: 1em;-moz-border-radius: 1em;border-radius: 1em;" onclick="var d=document.getElementById(\'colorPicker\'); document.body.removeChild(d);">×</a><strong>Colors for: ' + title + '</strong><br /><br /><ul id="colors">' + colors.join(" ") + '</ul>'; | |
document.body.appendChild(picker); | |
var sheet = document.createElement('style'); | |
sheet.innerHTML = "#colorPicker {position:absolute; margin-left:-200px; width:400px; padding:15px 15px 20px 15px; background:#fff; font-size:14px; z-index:1000; left:50%; top:50px; -webkit-border-radius: 5px;-moz-border-radius: 5px;border-radius: 5px; -webkit-box-shadow: 1px 1px 1px rgba(0,0,0,.2);-moz-box-shadow: 1px 1px 1px rgba(0,0,0,.2);box-shadow: 1px 1px 1px rgba(0,0,0,.2);}"; | |
document.body.appendChild(sheet); | |
} else { | |
alert("Are you in dribbble.com?"); | |
} | |
})()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment