如何使用 Firefox 扩展注入 Javascript

发布于 2024-07-22 04:10:51 字数 795 浏览 2 评论 0原文

我正在构建一个 Firefox 扩展,并且已经取得了很大的进展。 我的扩展的其中一个部分是在页面底部显示一个 DIV,并且我想将广告放入该 div 中,但由于某种原因,每次这样做时,它都会完全重定向到另一个页面,并显示广告它。 所以看起来它不允许我将下面的代码插入到位于底部的 div 中。 有机会有人可以帮忙吗?

这段代码当然会调用“ad_display.js”文件,这就是它执行重定向的地方。 有什么办法可以做到这一点还是我被困在水里了?

谢谢!!!

    <!-- Beginning of Project Wonderful ad code: -->
<!-- Ad box ID: 38154 -->
<script type="text/javascript">
<!--
var pw_d=document;
pw_d.projectwonderful_adbox_id = "38154";
pw_d.projectwonderful_adbox_type = "2";
pw_d.projectwonderful_foreground_color = "";
pw_d.projectwonderful_background_color = "";
//-->
</script>
<script type="text/javascript" src="http://www.projectwonderful.com/ad_display.js"></script>
<!-- End of Project Wonderful ad code. -->

I am building a Firefox extension and have come a long way. One of the parts of my extension is where I display a DIV at the bottom of the page and I want to put an ad into the div, but for some reason every time it does so, it redirects to another page entirely with the ad on it. So it looks like its not allowing me to insert this code below into the div that sits at the bottom. Any chance anyone can help?

This code of course calls the "ad_display.js" file and thats where it does the redirect. Any way I can do this or am I stuck in the water?

Thanks!!!

    <!-- Beginning of Project Wonderful ad code: -->
<!-- Ad box ID: 38154 -->
<script type="text/javascript">
<!--
var pw_d=document;
pw_d.projectwonderful_adbox_id = "38154";
pw_d.projectwonderful_adbox_type = "2";
pw_d.projectwonderful_foreground_color = "";
pw_d.projectwonderful_background_color = "";
//-->
</script>
<script type="text/javascript" src="http://www.projectwonderful.com/ad_display.js"></script>
<!-- End of Project Wonderful ad code. -->

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

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

发布评论

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

评论(1

热情消退 2024-07-29 04:10:52

两种解决方案:

  • 要么复制该 ad_display 脚本的功能,要么将“document.write(pw_s)”更改为更理智的内容,例如“document.getElementById('mydivwithanad').innerHTML=pw_s”
  • 您可以在页面中插入 iframe 而不是 div,然后将该代码注入 iframe 中。

Two solutions:

  • Either you replicate the functionality of that ad_display script, change "document.write(pw_s)" to something a little saner like "document.getElementById('mydivwithanad').innerHTML=pw_s"
  • Ether you use insert an iframe in the page rather than a div, and you inject that code in the iframe.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文