Running jQuery on the console on a page that does not have jQuery

3

JQuery is often very useful for taking some page statistics and other things , just make a $('.elemento').each(callback) and you can start to know what is happening on the page.

The problem is that this relies on the page doing the load of jQuery; if not, there is no way, it has to be pure JS.

Is there any way to force the loading of jQ on any page, eg Google?

    
asked by anonymous 12.10.2014 / 19:19

1 answer

4

a>.

Just do paste of the code in the console and jQuery will be loaded. We can then use it freely on the console. Slightly adapted:

var jq = document.createElement('script');
jq.src = "//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js";
document.getElementsByTagName('head')[0].appendChild(jq);
// ... dar um tempinho pro script carregar
setTimeout( function(){
    jQuery.noConflict();
    $=jQuery;
    console.log('Carregado jQuery v' + $.fn.jquery);
}, 3000);

To make it easier to use the snippet we can save it as a ... snippet !, within Chrome Developer Tools itself:


    
12.10.2014 / 19:19