Firefox userChrome.js greasemonkeyスクリプトスレ16

このエントリーをはてなブックマークに追加
418名無しさん@お腹いっぱい。
// ==UserScript==
// @name      GM_Example_Timer
// @namespace   http://hibari.2ch.net/test/read.cgi/software/1308891336/418
// @description  GreaseMonkeyで1秒後に処理をさせるスクリプト
// @include    http://*
// ==/UserScript==
(function(){

    //■test関数
    function test(){
        //●アラートを表示
        alert();

        //●エラーコンソールのメッセージへ日時を出力
        // greasemonkey.mozdev.org/authoring.html
        //GM_log(Date());
    }

    //●1秒後に1回だけtest関数を呼び出し
    // www.openspc2.org/JavaScript/ref/timer/setT.htm
    //timerID = setTimeout(function(){ test(); }, 1000);

    //●1秒間隔で繰り返しtest関数を呼び出し
    // www.openspc2.org/JavaScript/ref/timer/setInt.htm
    timerID = setInterval(function(){ test(); }, 1000);

    //○setIntervalをクリア
    // www.openspc2.org/JavaScript/ref/timer/clearInt.htm
    //clearInterval(timerID)

})();