我创建了一个用户脚本以重定向到指定的多个站点中的一个:
I created a userscript to redirect to one out of the specified multiple sites:
// ==UserScript== // @id fvhfy464 // @name [udit]redirector to yahoo or google // @version 1.0 // @namespace // @author // @description // @include yahoo // @include google // @include bing // @run-at document-end // ==/UserScript== setTimeout(function() { window.location.href("yahoo","google","bing") }, 4000);但这是行不通的.
(来自评论:) 我想以4秒的时间间隔随机地在一个选项卡中一个接一个地打开多个站点.就像网站的屏幕保护程序.
(From comments:) I want to open multiple sites in a single tab, one after another, in a random way with a time interval of 4 seconds. It's like a screensaver of sites.
它可以永远消失.要停止,我只需要关闭选项卡.而且,我将只在我希望此脚本运行的 @include 中设置这些站点.就像是照片的屏幕保护程序.
It can go forever. To stop, I just have to close the tab. And, I'll only set those sites in the @include which I want this script to work on. It's like a screensaver of photos etc.
推荐答案将要显示的站点列表放入数组中.然后,您可以关闭当前页面,然后按顺序转到下一页,或者随机选择下一页.
Put the list of sites, you want to display, into an array. Then you can key off the current page and either go to the next one in order, or pick a random next one.
例如,这是一个有序的幻灯片放映:
For example, here is an ordered slide-show:
// ==UserScript== // @name Multipage, MultiSite slideshow of sorts // @match *.breaktaker/* // @match *.imageshack.us/* // @match static.tumblr/* // @match withfriendship/images/* // ==/UserScript== var urlsToLoad = [ 'www.breaktaker/albums/pictures/animals/BigCat.jpg' , 'img375.imageshack.us/img375/8105/bigcats34ye4.jpg' , 'withfriendship/images/g/33769/1.jpg' , 'static.tumblr/yd0wcto/LXQlx109d/bigcats.jpg' ]; setTimeout (GotoNextURL, 4000); function GotoNextURL () { var numUrls = urlsToLoad.length; var urlIdx = urlsToLoad.indexOf (location.href); urlIdx++; if (urlIdx >= numUrls) urlIdx = 0; location.href = urlsToLoad[urlIdx]; }以下是随机提供相同网站的网站:
Here's the same sites served up randomly:
// ==UserScript== // @name Multipage, MultiSite slideshow of sorts // @match *.breaktaker/* // @match *.imageshack.us/* // @match static.tumblr/* // @match withfriendship/images/* // ==/UserScript== var urlsToLoad = [ 'www.breaktaker/albums/pictures/animals/BigCat.jpg' , 'img375.imageshack.us/img375/8105/bigcats34ye4.jpg' , 'withfriendship/images/g/33769/1.jpg' , 'static.tumblr/yd0wcto/LXQlx109d/bigcats.jpg' ]; setTimeout (GotoRandomURL, 4000); function GotoRandomURL () { var numUrls = urlsToLoad.length; var urlIdx = urlsToLoad.indexOf (location.href); if (urlIdx >= 0) { urlsToLoad.splice (urlIdx, 1); numUrls--; } urlIdx = Math.floor (Math.random () * numUrls); location.href = urlsToLoad[urlIdx]; }更多推荐
如何重定向到给定站点集中的一个?
发布评论