我想使用grease monkey进行客户端javascript调试。我想要使用的user.js是' checkForBadJavascript'。请看这个链接:https://gist.github.com/BrockA/2620593
例如,我想替换" http://jsbin.com/evilExternalJS/js"在下面的html页面中,另一个名为" http://code.jquery.com/jquery-1.11.1.min.js"的js,我应该怎么做的油脂猴的user.js?
<body onload="init()">
<script type="text/javascript" src="http://jsbin.com/evilExternalJS/js"></script>
<script type="text/javascript" language="javascript">
function init () {
var newParagraph = document.createElement ('p');
newParagraph.textContent = "I was added by the old, evil init() function!";
document.body.appendChild (newParagraph);
}
</script>
我试过这样的事情:
checkForBadJavascripts ( [
[false, /old, evil init()/, function () {addJS_Node (init);} ],
[true, /evilExternalJS/i, function(){addJS_Node(null,"http://code.jquery.com/jquery-1.11.1.min.js",null);} ]
]);
但是在Firebug中,它有类似的东西:
<script src="http://jsbin.com/evilExternalJS/js" type="text/javascript">
Reload the page to get source for: http://jsbin.com/evilExternalJS/js
</script>
有何评论?顺便说一句,为什么正常表达&#34; http://jsbin.com/evilExternalJS/js&#34;是&#39; / evilExternalJS / i&#39;? (这可以在&#39; checkForBadScripts&#39;的源代码中看到)。什么是&#39;我&#39;为?