在网页上运行任何内联脚本之前,如何运行用户脚本? [英] How can I run a user script before any inline scripts run on a webpage?

查看:216
本文介绍了在网页上运行任何内联脚本之前,如何运行用户脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为firefox制作一个grepmonkey类型的脚本,它在页面上的脚本之前运行。 Greasemonkey脚本在页面上的脚本之后运行,所以不起作用。我需要这个的原因是因为我想编辑页面上的一个脚本。具体来说,我想删除一个强制页面加载框架的脚本,因为有一个框架内的页面中断F5(按F5使页面跳回到首页,而不是重新加载当前页面)。另外,我不想通过AJAX代理加载页面,切换到铬/歌剧也不是一个选项。我想也许Jetpack的附加工作,但它似乎只有与greasemonkey使用,DOMContentLoaded相同的事件。任何想法?

解决方案

[edit 2013]使用 page-mod 附加组件的模块,内容为 contentScriptWhen = 开始。





正确的,只有更新的Firefox版本(目前3.7版本,稍后可能会添加到3.6.x)支持在内容指定的脚本之前运行自定义脚本。我写了一个原型Jetpack-SDK模块新的通知的好处。

它是一个< script src>或一个内联脚本?在前一种情况下,可以通过内容政策(adblock-like)来阻止。


I want to make a greasemonkey type script for firefox that runs before the scripts on the page. Greasemonkey scripts run after scripts on the page, so that won't work. The reason I need this is because I want to edit one of the scripts on the page. Specifically, I want to delete a script that forces the page to load inside a frame since having the page inside a frame breaks F5 (Pressing F5 makes the page jump back to the front page instead of reloading the current page). Also, I don't want to load the page through a proxy with AJAX and switching to chrome/opera is not an option either. I was thinking maybe the Jetpack add-on would work but it seems to only have the same event that greasemonkey uses, DOMContentLoaded. Any ideas?

解决方案

[edit 2013] Use the page-mod module of the Add-on SDK with contentScriptWhen = start.


older: Right, only newer Firefox builds (currently 3.7 nighlies, may later be added to 3.6.x) have support for running custom scripts before content-specified scripts. I wrote a prototype Jetpack-SDK module to take advantage of the new notification.

Is it a <script src> or an inline script? In the former case it can be blocked with a content policy (something adblock-like).

这篇关于在网页上运行任何内联脚本之前,如何运行用户脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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