Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save chriscorwin/9956893 to your computer and use it in GitHub Desktop.
Save chriscorwin/9956893 to your computer and use it in GitHub Desktop.
Copy nodes of body to the clipboard.
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);
})();
@cmcculloh
Copy link

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment