How to alter this javascript with Greasemonkey?

后端 未结 1 1088
走了就别回头了
走了就别回头了 2020-12-01 23:01

Here is the script:



        
相关标签:
1条回答
  • 2020-12-02 00:03

    Since all those scriptData values seem liable to change from page load to page load, what you'd want to do is intercept that <script> node on the fly, clone it and only change 'auto' to true, using RegEx.

    On Firefox Greasemonkey, you can do that with the stupefyingly brilliant (^_^) checkForBadJavascripts utility. Like so:

    // ==UserScript==
    // @name     _Modify JS as it's loaded
    // @include  http://YOUR_SERVER.COM/YOUR_PATH/*
    // @require  https://gist.github.com/raw/2620135/checkForBadJavascripts.js
    // @run-at   document-start
    // @grant    GM_addStyle
    // ==/UserScript==
    /*- The @grant directive is needed to work around a design change
        introduced in GM 1.0.   It restores the sandbox.
    */
    
    function replaceTargetJavascript (scriptNode) {
        var scriptSrc   = scriptNode.textContent;
        scriptSrc       = scriptSrc.replace (
            /'auto'\s+\:\s+false/,
            "'auto'      : true"
        );
    
        addJS_Node (scriptSrc);
    }
    
    checkForBadJavascripts ( [
        [false, /'auto'\s+\:\s+false/, replaceTargetJavascript]
    ] );
    
    0 讨论(0)
提交回复
热议问题