油猴与http 修改请求
我正在研究编写一些篡改 HTTP POST 请求和响应的 JavaScript 代码。由于我想要编写的代码主要是概念验证,因此我认为 Firefox 扩展太多了(而且我宁愿不处理所有包装和 over SSL 限制)。当时我想知道是否可以将其编写为 Greasemonkey 脚本。因此我的问题是:
你可以在 Greasemonkey 下使用 Mozilla 的事件观察器(http-on-modify-request 等)吗?
请记住,我 10 分钟前了解了 JavaScript 是什么,但我在该领域没有任何经验。然而,我相信这在我的能力范围内,只要进行一些研究和顽固,我就可以实现它。尽管我担心尝试以不可能的方式完成某些事情。
谢谢!
乔治.
I'm researching on writing some JavaScript code that tampers with HTTP POST requests and responses. Since the code I want to write is largely a proof-of-concept, a Firefox extension is too much I think (plus I would prefer to not deal with all that wrapping and over-SSL restrictions). I wondered then if I could write it as a Greasemonkey script. My question therefore is this:
Can you use Mozilla's event observers (http-on-modify-request etc) under Greasemonkey ?
Please have in mind that I learned what JavaScript is 10 minutes ago and I don't have any experience in that domain. However I believe this is within my skills and with a little research and stubbornness I can implement it. Though I worry about trying to make something work in an impossible way.
Thanks!
George.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不可以,Greasemonkey 脚本无法访问 XPCOM 组件。除了 GM_ 函数之外,Greasemonkey 脚本只能执行普通 JavaScript 的操作。
您通常可以通过覆盖
XMLHttpRequest()
来拦截AJAX调用——请参阅问题629671。请注意,页面可能使用的 JS 库可能会产生干扰。No, Greasemonkey scripts do not have access to XPCOM components. With the exception of the GM_ functions, Greasemonkey scripts can only do what ordinary JavaScript does.
You can usually intercept AJAX calls by overwriting
XMLHttpRequest()
-- see question 629671. Beware that there may be interference from JS libraries that the page may use.