jQuerify

Discussion in 'Extensions (Userscripts)' started by Bluscream, Jun 24, 2016.

Tags:
  1. Bluscream

    Bluscream Beta Tester

    Joined:
    May 19, 2016
    Messages:
    29
    If found a little userscript to inject jQuery on every website. To make it work in AdGuard and load first i modified it a bit.

    PHP:
    // ==UserScript==
    // @name            0 jQuerify
    // @namespace       http://tkassembled.com/ns/jQuerify
    // @include         *
    // @version         1.0.0
    // @author            Modified by Bluscream
    // @run-at            document-end
    // ==/UserScript==

    var scripts document.getElementsByTagName("script");
    var 
    script null;

    var 
    found false;

    for (var 
    0scripts.lengthi++) {
        
    script scripts[i];
        if (/^
    jQuery.*\.js$/i.test(script.src)) {
            
    found true;
            break;
        }
    }

    if (!
    found) {
        try {
            $ || 
    jQuery || $ === jQuery;
            
    found true;
        } catch (
    err) {
           
        }
    }

    if (!
    found) {
        
    script document.createElement("script");
        
    script.type "text/javascript";
       
        var 
    protocol = /^https:/i.test(document.location) ? "https" "http";
        
    script.src protocol "://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0/jquery.min.js";
            var 
    heads document.getElementsByTagName("body");
        if (
    bodies.length 0) {
            
    bodies[0].appendChild(script);
        } else {
            
    document.documentElement.appendChild(script);
        }
    }
    try { $(); }catch(
    err){ console.warn('jQuery does not respond on: $ ('+err+')'); }
    try { 
    jQuery(); }catch(err){ console.warn('jQuery does not respond on: jQuery ('+err+')'); }
    My Question is, does AdGuard handle @require's? If yes, how? (Are they cached, how long are they cached, Does ".../3.0.0/jquery.min.js" in cache overwrite ".../2.0.0/jquery.min.js"?)

    Do i have to remove the jQuery require manually from every script on every update?
     
    Last edited: Jun 24, 2016
  2. avatar

    avatar Administrator Staff Member Administrator

    Joined:
    Oct 26, 2010
    Messages:
    13,144
    When userscript is installed or updated AG downloads all required scripts and saves along with the userscript.

    I don't get the question though as there are no @require tags in the userscript you've posted. How exactly do you want to use it?