Nei*_*cer 8 firefox greasemonkey javascript
我是 Greasemonkey 和 javascript 的新手,但发现下面的脚本每 5 分钟重新加载一次页面。
// ==UserScript==
// @name Auto Reload Protopage
// @namespace http://blog.monstuff.com/archives/cat_greasemonkey.html
// @description Reload pages every 5 minutes
// @include http://ww.bbc.co.uk
// @grant none
// ==/UserScript==
// based on code by Julien Couvreur
// and included here with his gracious permission
var numMinutes = 5;
window.setTimeout("document.location.reload();", numMinutes*60*1000);
Run Code Online (Sandbox Code Playgroud)
这有效,但它每 5 分钟重新加载所有打开的选项卡,而不仅仅是 @include 语句中指定的选项卡。
有没有办法做到这一点?
该代码具有损坏的元数据块,空格对于该块至关重要,行首的额外空格可能会破坏它 - 导致脚本为所有页面触发(默认行为)。
更新: 损坏块的出现可能只是 SuperUser 上的一个显示错误。待会儿调查。
更新程序:损坏的块是真实的,OP 的代码由制表符和空格的混合缩进,这欺骗了 SU 的原始帖子编辑器,但不是最终显示。
此外,该@include指令指定了一个不存在的网页。ww., 与www.. 该行应该是:
// @include http://www.bbc.co.uk/
Run Code Online (Sandbox Code Playgroud)
或者可能:
// @include http://www.bbc.co.uk/*
Run Code Online (Sandbox Code Playgroud)
如果您想要的不仅仅是主页的影响。
将它们放在一起并setTimeout以推荐的方式使用(避免使用“auto eval()”):
// ==UserScript==
// @name Auto Reload Protopage
// @namespace http://blog.monstuff.com/archives/cat_greasemonkey.html
// @description Reload pages every 5 minutes
// @include http://www.bbc.co.uk/
// @grant none
// ==/UserScript==
// based on code by Julien Couvreur
// and included here with his gracious permission
var numMinutes = 5;
setTimeout (location.reload, numMinutes*60*1000);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
11868 次 |
| 最近记录: |