Last active
August 29, 2015 13:58
-
-
Save chriscorwin/9956893 to your computer and use it in GitHub Desktop.
Copy nodes of body to the clipboard.
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:(function() { | |
window.nodes; | |
window.timeoutLength = 200; | |
var po = document.createElement('script'); | |
po.type = 'text/javascript'; | |
po.async = true; | |
if (window.location.protocol !== 'https:') { | |
po.src = "http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"; | |
} else { | |
po.src = "https://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"; | |
window.timeoutLength = 600; | |
} | |
var s = document.getElementsByTagName('body')[0]; | |
s.parentNode.appendChild(po, s); | |
function copyToClipboard() { | |
window.prompt("Copy and paste this into console to get source:", "copy(nodes);"); | |
} | |
function runIt(){ | |
jQuery.noConflict(); | |
jQuery("div[id*='configured']").addClass('configured'); | |
jQuery("div[id*='visited']").addClass('visited'); | |
jQuery("div[id*='group']").addClass('group'); | |
jQuery("div[class!='group']").addClass('img'); | |
printHTML(); | |
}; | |
function printHTML() { | |
jQuery('div.img, div.group').each(function(i, e) { | |
$e = jQuery(e); | |
if ($e.hasClass('notdraggable')) { | |
$e.removeClass('draggable').removeClass('ui-draggable'); | |
} | |
if ($e.hasClass('drop-state-highlight')) { | |
$e.removeClass('drop-state-highlight'); | |
} | |
$e.css('display', 'block'); | |
}); | |
window.nodes = jQuery('body').html(); | |
console.group('Source:'); | |
console.log(window.nodes); | |
console.groupEnd(); | |
copyToClipboard(); | |
} | |
var timeoutID = window.setTimeout(runIt, window.timeoutLength); | |
})(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Awesome! Thanks man! It actually looks like you've got a whole bunch of stuff going on other than just the copy thing here. I basically just incorporated the concept thusly: https://github.com/cmcculloh/RPD/commit/8a81c0ce20c3526dc889b315222bc5815846cf44
(This is just an FYI for when you go to retrofit this into master)