2

指定された複数のサイトのうちの 1 つにリダイレクトするユーザー スクリプトを作成しました。

// ==UserScript==
// @id             fvhfy464
// @name           [udit]redirector to yahoo or google
// @version        1.0
// @namespace      
// @author         
// @description    
// @include        http://yahoo.com
// @include        http://google.com
// @include        http://bing.com
// @run-at         document-end
// ==/UserScript==

setTimeout(function() {
    window.location.href("http://yahoo.com","http://google.com","http://bing.com")
}, 4000);

しかし、うまくいきません。

(コメントから:)
1 つのタブで複数のサイトを 4 秒間隔でランダムに次々に開きたい。サイトのスクリーンセーバーのようなものです。

それは永遠に続くことができます。停止するには、タブを閉じるだけです。@includeそして、このスクリプトを実行したいサイトだけを設定します。写真などのスクリーンセーバーのようなものです。

4

1 に答える 1

2

表示したいサイトのリストを配列に入れます。次に、現在のページをキーオフして、次のページに順番に移動するか、次のページをランダムに選択できます。

たとえば、順序付けされたスライド ショーは次のとおりです。

// ==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/*
// ==/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'
];

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];
}


ランダムに配信された同じサイトは次のとおりです。

// ==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/*
// ==/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'
];

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];
}
于 2012-07-06T16:06:36.740 に答える