Created
October 28, 2011 07:36
-
-
Save hughsk/1321817 to your computer and use it in GitHub Desktop.
Pick up compiled LESS code using a bookmarklet!
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
//Bookmarklet Code | |
$('head style').each(function() {if ($(this).attr('id') && $(this).attr('id').indexOf('less:') > -1) {var lesscode = $(document.createElement('div'));lesscode.html($(this).text().replace(/\/\*.*?\*\//g,' ').replace(/[ ]{2,100}/g,' '));lesscode.css('padding','20px').css('font-size','10px').css('background-color','#ddd').css('font-family','monospace');$('body:last-child').append(lesscode);} }); | |
//Legible version | |
$('head style').each(function() { | |
if ($(this).attr('id') && $(this).attr('id').indexOf('less:') > -1) { | |
var lesscode = $(document.createElement('div')); | |
//Clean up a lot of comments and white space... | |
lesscode.html($(this).text(). | |
replace(/\/\*.*?\*\//g,' '). | |
replace(/[ ]{2,100}/g,' ')); | |
//Format the box | |
lesscode.css('padding','20px'). | |
css('font-size','10px'). | |
css('background-color','#ddd'). | |
css('font-family','monospace'); | |
//Place the box at the end of the body | |
$('body:last-child').append(lesscode); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment