Skip to content

Instantly share code, notes, and snippets.

@vjk2005
Created October 1, 2012 16:27
Show Gist options
  • Save vjk2005/3812832 to your computer and use it in GitHub Desktop.
Save vjk2005/3812832 to your computer and use it in GitHub Desktop.
Deep Load
/*
DeepLoad:
Fetch any number of pages via AJAX for infinite scroll-like functionality.
First visit the site you want and put this into your browser console.
ToDo:
2. resume a broken DeepLoad. Find if DOM has been modified by a previous DeepLoad run and start resuming from where the previous run left off
3. remove jquery dependency
4. convert it into a bookmarklet
5. make a youtube video tutorial and spread word about DeepLoad around
*/
var s = document.createElement( 'script' );
s.src = 'http://code.jquery.com/jquery-1.8.0.min.js';
document.body.appendChild( s ); // load jQuery
document.getElementsByTagName('head')[0].innerHTML += document.getElementsByTagName("head")[0].innerHTML+ '<style type="text/css">
#deepLoad { padding:4px 15px; z-index:9999; background-color:#FFF; border-radius:3px; position:fixed; top:20px; right:20px; box-shadow: 0px 1px 3px 0px rgba(90, 90, 90, .1); font-size:12px; color:#A7A7A7; text-align:center; border:#E7E7E7 1px solid; }
#deepLoad a { margin:0 7px; border-bottom:1px #318CD6 solid; text-decoration:none; }
</style>'; // inject CSS needed for the Deep Load UI
var g = window.location.toString(), i = 0;
$( 'body' ).append(
'<div id="deepLoad">' + g.replace( /(\d+)/g,
function( match ) {
i++;
return '<span id=dl_a_' + i + '>' + match + '</span>';
});) + '</div>'
);
$( '#deepLoad' ).on( 'click', 'a', function() {
console.log( $( this ).attr( 'id' );
return false;
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment