Greasemonkey script to remove . So the page redirects before GM executes the script. – Rohith Jan 23 '14 at 07:09

  • If you have set `@run-at document-start`, as in the linked answers, the solutions work fine. Beware that this is Firefox only (as is Greasemonkey). Link to the target page if you still can't get it to work. ... Edit: that's the very first line of the whole HTML file? The solutions should still work, but I don't remember testing that scenario. I'll give it a look-see. – Brock Adams Jan 23 '14 at 07:25
  • 1
    Just tested the answers against an HTML file with just `` inside. The answers still work flawlessly. (FF 26 + GM 1.14). Be sure to set a `@grant` other than `none`. – Brock Adams Jan 23 '14 at 07:48
  • There is NoScript Firefox plugin. – Basilevs Jan 23 '14 at 03:54
  • 2 Answers2

    -1

    Greasemonkey lets you add JavaScript code (called "user scripts") to any web page, which will run when its HTML code has loaded. So when user scripts stat running ,the <script> have already run,maybe it is a little hard to do that.

    Or use $ wget url_you_want_to_visitand remove the fist <script>.

    Maybe you should install wget in your Windows OS.

    Creat a file a.bat,and the content of it is like

    wget url -O index.html&&perl remove_first_script.pl&&start  index.html;
    

    and then use it in cmdlike

    a.bat the_url
    
    orange
    • 116
    • 1
    • 7
    • How can I automate this? 1. $wget url 2. remove script(its easy) 3. render the output code in the browser. .. Do you have any idea? – Rohith Jan 23 '14 at 06:44
    -2

    We can do it with a very simple line of jquery.

    // ==UserScript==
    // @name        NameForScript
    // @include     http://example.com/*
    // @require     http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.js
    // @run-at      document-start
    // @grant       GM_addStyle
    // ==/UserScript==
    
    
        $($('script')[0]).html("alert('okay');");
    

    Don't forget to add @run-at document-start. It will help to execute your GM script before execution of any js from the original page.

    Rohith
    • 1,301
    • 3
    • 21
    • 31
    • 3
      I believe that it is just luck that/if this works. It depends on winning a very precise race condition. Better to use one of the event-driven methods in the linked answers. – Brock Adams Jan 24 '14 at 03:03