Replace javascript function using greasemonkey

荒凉一梦 提交于 2019-12-07 06:07:22

问题


I want to change the script using greasemonkey. But it doesn't 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 function abc as my requirement. I tried the following way but doesn't help.

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

回答1:


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

N.B. The 'beforescriptexecute' event used in this script, which is part of HTML5 specifications, is supported only by Gecko-based browsers (Firefox) at the moment.



来源:https://stackoverflow.com/questions/23479251/replace-javascript-function-using-greasemonkey

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!