Skip to content

Instantly share code, notes, and snippets.

@mkhl
Created August 22, 2009 14:07
Show Gist options
  • Save mkhl/172793 to your computer and use it in GitHub Desktop.
Save mkhl/172793 to your computer and use it in GitHub Desktop.
Userscript for Chroma-Hash password visualization.
// ==UserScript==
// @name Chroma-Hash password visualization
// @namespace http://purl.org/net/mkhl
// @description Add Chroma-Hash visualization to all password field inputs. Compatible with Greasemonkey and GreaseKit.
// @include *
// ==/UserScript==
// Many thanks to Henrik Nyh and Mattt Thompson for doing all the hard work!
(function() {
// -----------------------------------------------------------------
// Greasemonkey/GreaseKit compatibility
// -----------------------------------------------------------------
if (typeof(unsafeWindow) === 'undefined') {
unsafeWindow = window;
}
// -----------------------------------------------------------------
// Script loading
// -----------------------------------------------------------------
function require(src, cont){
var script = document.createElement('script');
script.src = src;
script.type = 'text/javascript';
script.addEventListener('load', cont, false);
document.getElementsByTagName('head')[0].appendChild(script);
}
// -----------------------------------------------------------------
// jQuery, Chroma-Hash
// -----------------------------------------------------------------
var jq_url = 'http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.js';
var ch_url = 'http://mattt.github.com/Chroma-Hash/chroma-hash.js';
function loadChromaHash() {
require(ch_url, function() {
unsafeWindow.jQuery('input:password').chromaHash({bars: 3});
});
}
if (typeof(unsafeWindow.jQuery) === 'undefined') {
require(jq_url, function() {
unsafeWindow.jQuery.noConflict();
loadChromaHash();
});
} else {
loadChromaHash();
}
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment