使用滑脂猴替换javascript函数 [英] Replace javascript function using greasemonkey
本文介绍了使用滑脂猴替换javascript函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用滑脂猴子更改脚本.但这是行不通的.请帮忙;
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>
现在,我想更改功能abc作为我的要求.我尝试了以下方法,但无济于事.
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
}
推荐答案
您将在此处找到一个很好的示例/教程: @ document-start示例:劫持页面脚本
You will find a good example/tutorial here: @document-start Example: hijack page scripts
N.B. 此脚本中使用的'beforescriptexecute'事件是HTML5规范的一部分,目前仅基于Gecko的浏览器(Firefox)支持.
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.
这篇关于使用滑脂猴替换javascript函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文