如何使用 Greasemonkey 替换整个页面?
有没有办法使用 Greasemonkey 替换整个网页?
基本上是重定向,但地址栏仍然显示原始地址。
我希望显示原始地址,但我想在没有人知道的情况下从我的硬盘加载修改后的网页。
Is there a way to replace a whole web page using Greasemonkey?
Basically a redirection but the address bar still shows the original address.
I want the original address to show, but I want to load a modified web page from my hard drive without anyone knowing.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
嗯...这应该会改变页面内容
要获取您可以依赖的内容
GM_xmlhttpRequest()
这里真正的问题是在什么时间触发greasemonkey;也就是说:对于用户不注意到发生的事情来说为时已晚。
我不确定你想在这里实现什么目标。
这是恶作剧,还是实验室用户访问方案?
无论如何,为了让用户没有注意到,您最终需要执行以下两项操作之一:
mh... this should change page contents
To get those contents you could rely upon
GM_xmlhttpRequest()
The real problem here is at what time greasemonkey is triggered; that is: too late for the user not to notice what happened.
I'm not sure about what you're trying to achieve here.
Is it a prank, or a lab user access scheme?
Anyway for the user not to notice you'll eventually need to do one of those two:
是的,你也许可以这样做。它的难度在很大程度上取决于源页面和目标页面的复杂程度。如果它们都是简单的 html,那就很容易了。如果其中一个或两者都有很多奇特的样式和脚本,这可能会有点棘手,但这是可能的。
一种简单的方法可能是创建一个填充整个页面的 iframe?
或者,循环遍历 html 的“body”标签的所有子级并删除它们;然后插入iframe,或者插入其他页面的内容作为innerHTML。
Yes, you could probably do this. How hard it will be depends a lot on how complicated the source and destination pages are. If they're both simple html, it will be easy. If one or the other or both have a lot of fancy styling and scripting, it could be a bit tricky, but it'd be possible.
One easy way might be to create an iframe that fills the whole page?
Or, loop over all of the children of the "body" tag of the html and delete them; then insert the iframe, or insert the contents of the other page as innerHTML.
我认为执行此操作的最简单方法是删除正文的内容,插入 iframe (100%x100%),并将其源设置为您选择的路径。
The easiest way I could see doing this would be to remove the contents of the body, insert an iframe (100%x100%), and set its source to the path of your choosing.