Skip to content

Instantly share code, notes, and snippets.

@juliend2
Created September 29, 2010 14:27
Show Gist options
  • Save juliend2/602837 to your computer and use it in GitHub Desktop.
Save juliend2/602837 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name passwordsafe formatting
// @namespace jdesrosiers
// @description newlines to BR tags
// @include https://www.passwordsafe.com/secure/main.html
// ==/UserScript==
var nl2br = function(value) {
return value.replace(/\n/g, "<br />");
}
var $;
// Add jQuery
(function(){
if (typeof unsafeWindow.jQuery == 'undefined') {
var GM_Head = document.getElementsByTagName('head')[0] || document.documentElement,
GM_JQ = document.createElement('script');
GM_JQ.src = 'http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js';
GM_JQ.type = 'text/javascript';
GM_JQ.async = true;
GM_Head.insertBefore(GM_JQ, GM_Head.firstChild);
}
GM_wait();
})();
// Check if jQuery's loaded
function GM_wait() {
if (typeof unsafeWindow.jQuery == 'undefined') {
window.setTimeout(GM_wait, 100);
} else {
$ = unsafeWindow.jQuery.noConflict(true);
letsJQuery();
}
}
// All your GM code must be inside this function
function letsJQuery() {
var $tr = $('table[cellpadding="1"] table[cellpadding="1"]>tbody tr:has(td[colspan="3"])');
$tr.each(function(){
var $td = $(this).find('td[colspan="3"]');
if ( $td.length != 0 ) {
var $font = $td.find('font');
var nouveau_content = nl2br($font.html());
$font.html( nouveau_content );
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment