[英]Modify script loaded from page
Lets say a website was loading this script:假设一个网站正在加载这个脚本:
<script src="https://example.com/scripts/main.js"></script>
Assuming I had access to it, I could modify the script.假设我可以访问它,我可以修改脚本。 Though, in this scenario, I don't have access.
但是,在这种情况下,我无权访问。
Would it be possible to some how "replace" the contents of that script, without changing the URL?是否有可能在不更改 URL 的情况下“替换”该脚本的内容?
For example, the original script is:例如,原始脚本是:
alert("Hello, World!");
But my modified version is:但我的修改版本是:
alert("Hello!");
However, the URL (to the script) would stay the same.但是,URL(脚本)将保持不变。
I know this might sound complicated but, hypothetically, is this possible?我知道这听起来可能很复杂,但假设这可能吗? At least client-side?
至少是客户端?
You can edit the script (clint only) by using a userscript manager like TamperMonkey .您可以使用 TamperMonkey 之类的用户脚本管理器来编辑脚本(仅限clint )。
This is not going to change the loaded script, but you can load your custom script.这不会更改加载的脚本,但您可以加载自定义脚本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.