Replace javascript function with greasemonkey

I want to change the script using greasemonkey. But that will not work. Please, help;

original script

<script>
      function abc(){
          // SOME STUFF HERE
      }
      abc();
      window.onload = abc;
      .....
      // OTHER JAVASCRIPT TASK
      .....
</script>

Now I want to change the abc function as my requirement. I tried the following path but did not help.

// ==UserScript==
// @name        Test
// @namespace   UNIQUE_NAMESPACE
// @include     http://PATH_TO_DOMAIN/*
// @version     1
// @grant       unsafeWindow
// ==/UserScript==
unsafeWindow.abc= function () {
    //MY REQUIREMENT
}
+5
source share
1 answer

You will find a good example / tutorial here: @ document-start Example: hijack page scripts

NB The "beforescriptexecute" event used in this script, which is part of the HTML5 specifications, is only supported by Gecko (Firefox) -based browsers at this time.

0
source

Source: https://habr.com/ru/post/1539324/


All Articles