如何使用本地 javascript 文件使用 firebug(或 Chrome)在实时站点上进行测试?

发布于 2024-11-29 10:05:58 字数 184 浏览 1 评论 0原文

我有一些自定义 JS,希望将其部署到实时站点上,但我想先对其进行测试。

我是目标站点管理者的第三方顾问,并且不参与他们的构建过程,因此我无法在他们的测试环境中进行部署。由于它是一个 DOM 遍历库,因此非常具体。

我想知道是否有人知道如何让我的本地 javascript 文件自动插入特定域或主机。

谢谢!

I've got some custom JS that i'm looking to deploy on a live site, but I want to test it out first.

I'm a third-party consultant to the target site managers, and am not part of their build process, so I can't deploy in their test environments. Since it's a DOM traversal library, it's pretty specific.

I was wondering if anyone knew how to get my local javascript files to auto-insert for a particular domain or host.

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

猛虎独行 2024-12-06 10:05:58

为什么不直接在 firebug 的控制台中注入您正在处理的脚本:

var script = document.createElement('script');
script.src = 'url to local file';
document.appendChild(script);

或者如果您有 jQuery

$.getScript('url to script file.js');

Why not just inject the script you're working on in firebug's console:

var script = document.createElement('script');
script.src = 'url to local file';
document.appendChild(script);

Or if you have jQuery

$.getScript('url to script file.js');
娇纵 2024-12-06 10:05:58

安装适用于 Firefox 的 Greasemonkey 插件

此附加组件可以为某些 URL 与注入的 JS 文件中给出的正则表达式匹配的页面注入 Javascript。

如果您想了解其他人如何编写 Greasemonkey 脚本,请搜索以“BetterXYZ”开头的 FF 附加组件,例如 BetterGmail、BetterFacebook、BetterGoogle ...
Greasemonkey-Skripts 实际上是带有特殊初始 JS 注释和特殊文件扩展名“*.user.js”的 Javascript 文件。

Install Greasemonkey Add-On for Firefox.

This Add-On can inject Javascript for pages with certain URLs matching a regex given in the injected JS-file.

If you want to learn how others are writing their Greasemonkey-Scripts then search for FF Add-Ons that start with "BetterXYZ" like BetterGmail, BetterFacebook, BetterGoogle ...
Greasemonkey-Skripts are in fact Javascript-Files with special initial JS-Comment and a special file extension "*.user.js".

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文