我有一个从列表重定向到随机站点的用户脚本。(参考:如何重定向到给定的一组网站?)
如何让脚本添加随机后缀来选择站点,例如 wallbase.cc?
到目前为止,这是我的脚本:
// ==UserScript==
// @name Multipage, MultiSite slideshow of sorts
// @match http://*.breaktaker.com/*
// @match http://*.imageshack.us/*
// @match http://static.tumblr.com/*
// @match http://withfriendship.com/images/*
// @match http://failjudge.com/*
// @match http://wallbase.cc/*
// ==/UserScript==
var urlsToLoad = [
'http://www.breaktaker.com/albums/pictures/animals/BigCat.jpg'
, 'http://img375.imageshack.us/img375/8105/bigcats34ye4.jpg'
, 'http://withfriendship.com/images/g/33769/1.jpg'
, 'http://static.tumblr.com/yd0wcto/LXQlx109d/bigcats.jpg'
, 'http://failjudge.com/'
, 'http://wallbase.cc/wallpaper/ + [random number suffix from 1- 10000000000]'
];
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];
}