有没有办法让一些 javascript(例如 Bookmarklet)在页面加载时自动运行?

发布于 2024-08-18 16:12:08 字数 96 浏览 5 评论 0原文

要执行小书签代码,小书签需要由用户操作。有没有办法让书签或者任何 javascript 在页面加载时自动运行?

或者附加组件是可行的方法吗?

谢谢

To execute bookmarklet code the bookmarklet needs to be actioned by the user. Is there any way to have a bookmarklet or indeed any javascript run automatically on page load?

Or is an Add-on the way to go?

Thanks

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

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

发布评论

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

评论(5

岛徒 2024-08-25 16:12:08

我认为不可能在页面加载时自动运行书签。这可能会被非常恶意地使用。

我认为插件是最好的方式。如果仅供个人使用,您应该查看 Firefox 版 grasemonkey

I don't think that it is possible to autorun a bookmarklet on pageload. This could be used very maliciously.

I think a plugin is the best way to go here. If only for personal use, you should check out greasemonkey for Firefox.

闻呓 2024-08-25 16:12:08

Chrome 上的 Greasemonkey 或 Tampermonkey 允许这样做......但他们需要您想要运行的脚本

,例如,如果某个网站总是发布某种类型的广告覆盖层,并且您可以找到或编写一个脚本来杀死它,那么您可以将该源输入 Tampermonkey,它将在全局加载的每个页面上运行,或者在您指定的任何站点/域/通配符表达式上运行,

或者如果您希望阻止某些脚本并希望自动化该过程,Chrome 版的 Notscript 将向您显示每个脚本当您访问某个站点时运行,并允许您指定在该站点或所有站点的后续访问中允许哪些行为,非常非常酷...这样您就不需要编写或查找脚本来阻止您不希望的行为就像

之前指出的那样,当你做这些事情时,你会严重破坏浏览器的安全性,所以要小心,不要设置任何旧脚本,除非你可以阅读它们或信任来源......

Greasemonkey, or Tampermonkey on Chrome allow this.... but they need the script you want to run

for example, if a certain site always puts up some type of an ad overlay and you can find or write a script to kill that, you can enter that source into Tampermonkey and it will run on each page load globally or at whatever site / domain/ wildcard expression you designate

alternatively if you are looking to block certain scripts and want to automate the process, Notscript for chrome will show you each script that ran when you visited a site and allow you to designate which you want to allow on subsequent visits at that site or all sites, very very cool... that way you need not write or find a script to block behaviors you don't like

as previously pointed out, when you do this stuff you are seriously screwing with browser security, so be careful and just don't set up any old script unless you can read them or trust the source....

一向肩并 2024-08-25 16:12:08

我认为 Opera 允许您将 js 自动注入到您指定“加载”的网站库中,无论所有权如何。

I think Opera allows you to auto inject js into a library of sites you specificy 'onload' regardless of ownership.

乙白 2024-08-25 16:12:08

好吧,任何 javascript 使用 onload 事件都会自动运行,如果这就是您所需要的?

Well, any javascript runs automatically using onload event, if thats what you need?

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