如何用本地 Javascript 替换生产网站的 Javascript? [英] How to replace Javascript of production website with local Javascript?

查看:74
本文介绍了如何用本地 Javascript 替换生产网站的 Javascript?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的生产网站上,我已经编译了 Javascript.

On my production website, I have compiled Javascript.

<script src="/js/mycode.min.js"></script>

如果我可以让我的浏览器将其替换为调试将非常方便

It would be very convient for debugging if I could make my browser replace that with

<script src="http://localhost/js/mycode1.js"></script>
<script src="http://localhost/js/mycode2.js"></script>
...

我知道我可以使用 Greasemonkey 用户脚本之类的东西来操作 DOM,但是我想不出一个可以阻止mycode.min.js"执行的解决方案.

I know I could manipulate the DOM using something like Greasemonkey userscripts, but I couldn't come up with a solution which would prevent the execution of "mycode.min.js".

有什么想法吗?

推荐答案

我的做法:

  1. 如果您使用的是 Windows,请下载并安装 Fiddler.
  2. 启用它以捕获 http 流量 [IE/Chrome 默认情况下会这样做,Firefox - 通过安装的附加项启用它]
  3. 加载相关页面.
  4. 在左侧的http流量列表中找到要替换的文件,点击即可.
  5. 右侧有一个 AutoResponder 选项卡.点击它.
  6. 点击复选框以启用自动回复"
  7. 点击添加...按钮
  8. 在右侧的第二个下拉菜单中,选择查找文件"选项
  9. 在对话框中找到文件并点击保存
  10. 重复步骤 4-9,直到替换所有要替换的文件
  11. 刷新浏览器窗口,您的新 js 文件正在运行

代替替换js文件,你可以替换html文件,改变页面上的js链接.

Instead of replacing the js file, you can replace the html file and change the js links on the page.

如果您使用的是 mac/linux,您可以安装 Charles.(非免费,有试用) 步骤类似,但不一样.

You can install Charles if you are on a mac/linux. (not free, has trial) Steps are similar, but not the same.

如果你使用 Google Closure 来压缩文件,你可以安装他们的插件来做源映射.

If you are using Google Closure to compress files, you can install their plug-in to do the source mapping.

这篇关于如何用本地 Javascript 替换生产网站的 Javascript?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆