我使用Greasemonkey对页面进行一些更改。
我有一个网页,它使用了SomeFunction()
。
SomeFunction()
放在javascript文件中。
我忽略了一些附加组件的javascript文件。
但我需要自己重写SomeFunction()
。
但是当我在GM脚本中定义SomeFunction()
时,我得到了“SomeFunction()
未定义”。
我也在我的GM脚本中添加了run-at document-start
,但它没有解决我的问题。
所以我将SomeFunction()
保存在一个文件中,并在GM和document.getElementsByTagName('head')[0].appendChild(js);
的页面上写了这个,但它也没有解决我的问题。
请帮助我如何重写直接在页面中调用的Somefunction()
?
谢谢
答案 0 :(得分:0)
请考虑阅读exportFunction
和所有其他有关unsafeWindow
的内容。
基本上:
exportFunction(SomeFunction, unsafeWindow, {defineAs: "SomeFunction"});