特定页面集的 Javascript 页面加载延迟

标签 javascript greasemonkey

我想使用一个小的 greasemonkey 脚本延迟一组特定的网页。基本上,如果正在加载的网站是一组页面的一部分,那么我想延迟加载页面所需的时间。例如如果正在加载的页面是“http://www.a.com/”、“http://www.a.com/b”等,那么我想将加载延迟 30 秒。

最佳答案

假设 Dushara 的评论是正确的:

"See xkcd.com/862 for what the poster wants. (Hover the mouse over the image to see the reasoning). In fact, I found this question while googling for exactly the same thing."

那么这在 Greasemonkey 中是不可能的。原因是 GM 在页面加载后触发(任何缓慢的图片或 AJAX 调用除外)。所以用户会看到该页面,然后它会闪烁空白 30 秒......但是,只有在快速眼球看到太多之后。 ;)

更新:现在这在 Greasemonkey 中是可能的(使用 @run-at document-start 指令——2011 年 8 月添加)。参见 this answer for an example .


请注意,XKCD 的创建者使用良好的老式意志力来实现他的“简单的 30 秒延迟”。来自 his blog entry :

"Lots of people have asked me for the system I used to implement the restriction in the alt-text of today’s comic.
...
I made it a rule that as soon as I finished any task, or got bored with it, I had to power off my computer."

另请参阅:"Browser extension (or other software) to delay page load" -- 现在有指向人们为此创建的适当扩展的链接。

关于特定页面集的 Javascript 页面加载延迟,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5043263/

相关文章:

javascript - GreaseMonkey + YouTube + .click()

javascript - Greasemonkey 脚本自动选择并单击值/选择器中包含非英文字符的特定按钮?

javascript - 幻灯片之间具有固定元素的 Fullpage.js

javascript - 我想通过单击 ID 为 ="add_city"的按钮来激活该功能,到目前为止,按下 Enter 时会激活该功能

javascript - 在 WSL 上运行 Cypress

javascript - 在用户脚本中使用谷歌翻译 API

javascript - 如何维护页面之间的 WebSockets 连接?

javascript - 使用 JQuery 隐藏一个 div

javascript - 无法更改 div 中的文本

javascript - 懒网 : Need javascript that removes li elements based on visited class of a element