// ==UserScript== // @name PeCa List // @namespace http://peercast-theme.seesaa.net/ // @description The channel list of PeerCast. // @include http://localhost:*/html/ja/* // ==/UserScript== // LastUpdate: 2007/08/12 // ■■ 設定ここから ■■ /* チャンネルリスト更新時のタイムアウト(秒)を指定。デフォルトは30秒。 */ var nSetTimeout = 30; /* KPなどで配布している"差し替え用PeerCastHTML"を利用している場合、 「true」を指定とPeerCast各ページ左上にある「Yellow Pages」のリンクを チャンネル一覧ページへのリンクに変更します。 "差し替え用PeerCastHTML"を利用していない場合は「false」を指定。 */ var bUsedRebuildHTML = false; /* イエローページの短縮名とindex.txtのURLを指定 name:に短縮名、url:にURLを記述してください。 例:[{name:"▲", url:"http://△/index.txt"}, {name:"●", url:"http://○/index.txt"}]; IPアドレス:ポートや名前空間などを指定する場合、そのイエローページサーバーの 仕様に合わせてURLのパラメータを追記する必要があります。 (※ 使用ポートが7144で名前空間を指定しない場合は追記しなくて構いません。) 例1:url:"~index.txt?host=localhost:17144&ns=test" 例2:url:"~index.txt?ns=aaa|bbb|ccc" pcraw_proxy経由でindex.txtを取得する場合、URLの先頭に ”http://localhost:ポート/”を追記する必要があります。 ポートはpcraw_proxyを生成する際に指定したものを使用します。 例:url:"http://localhost:8080/http://あどれす/index.txt" */ var aYP = [ {name:"Ese", url:"http://アドレス/index.txt"}, {name:"KP", url:"http://アドレス/index.txt"}, {name:"UP", url:"http://アドレス/index.txt"}, {name:"XP", url:"http://localhost:pcrawポート/http://アドレス/index.txt"}, {name:"YP", url:"http://アドレス/index.txt"} ]; //この2行上(配列最終行)の行末にコンマ「,」は記入しないで下さい。 //上記の「アドレス」や「pcrawポート」の部分を書き換えて使用して下さい。 //(pcraw_proxyを使わない場合は該当する行を削除して下さい。) // ■■ 設定ここまで ■■ window.addEventListener('load', function() { var w = (typeof unsafeWindow == 'undefined') ? window : unsafeWindow; var sPageName = location.href.slice(location.href.lastIndexOf("/")+1); // ページ別に実行する内容を振り分ける if(sPageName == "pecalist.html") { // ★チャンネルリストを表示するpecalist.htmlでのみ以下を実行★ var nTimer = 0, nTimer2 = 0, nWait = 0, nTimeout = 0, nUp = 0, nLoaded = 0, nCheck = 0, sInt = "Z", sChk = ",."; var bTimeout = false, bOnLoad = false; var aYPname = []; var dNow = new Date(); //キーボードのキーを押したときの処理 var KeyDown = function(e) { keycode = e.which; var keychar = String.fromCharCode(keycode); var ctrl = typeof e.modifiers == 'undefined' ? e.ctrlKey : e.modifiers & Event.CONTROL_MASK; var shift = typeof e.modifiers == 'undefined' ? e.shiftKey : e.modifiers & Event.SHIFT_MASK; if(keycode == 116 || (keycode == 82 && ctrl)) { e.stopPropagation(); e.preventDefault(); dNow = new Date(); nUp = Number(GM_getValue("UpdateTime")); if((sChk.charCodeAt(0) + sChk.charCodeAt(1) == sInt.charCodeAt(0)) && (sInt.charCodeAt(0) < Math.ceil((dNow.getTime() - nUp) / 1000)) && ! w.bUpdating) { w.bUpdating = true; CheckUpdate(); } } } // 前回更新時から一定時間経過しているかチェック var CheckUpdate = function() { dNow = new Date(); nUp = Number(GM_getValue("UpdateTime")); while(isNaN(nUp) || nUp == undefined || nUp == null) { GM_setValue("UpdateTime", String(dNow.getTime())); nUp = Number(GM_getValue("UpdateTime")); } if(w.bPort) { var bModal = (document.getElementById("f").innerHTML.length > 40) ? true : false; if((dNow.getTime() - nUp > 1000 * sInt.charCodeAt(0)) && (sChk.charCodeAt(0) + sChk.charCodeAt(1) == sInt.charCodeAt(0))) { nWait = sInt.charCodeAt(0); w.bNowUpdate = true; Update(bModal); } else { nWait = sInt.charCodeAt(0) - Math.ceil((dNow.getTime() - nUp) / 1000); w.PopUp("Wait", bModal, nWait); dNow.setTime(nUp); setTimeout(function(){w.OnLoad(false);}, 10); clearInterval(nTimer); nTimer = setInterval(SetTimer,1000); } var nMo = dNow.getMonth(); var nDa = dNow.getDate(); var nHo = dNow.getHours(); var nMi = dNow.getMinutes(); w.sLastUpdate = ((nMo < 10) ? "0" + nMo : nMo) + "/" + ((nDa < 10) ? "0" + nDa : nDa) + " " + ((nHo < 10) ? "0" + nHo : nHo) + ":" + ((nMi < 10) ? "0" + nMi : nMi); } else { var sPort = window.location.host; sPort = sPort.slice(sPort.indexOf(":")+1); w.$("Main").innerHTML = '
PeerCastで使用するポートが開いていません!
TCP:' + sPort + ' を開けるようPCまたはルーターの設定を行って下さい。
'; } } // 更新OKまでのタイマー表示 var SetTimer = function() { nWait --; var str = "PeCa List - "; if(nWait > 0) { document.title = str + '(' + nWait + ')'; } else { clearInterval(nTimer); document.title = str + '更新OK'; setTimeout(function(){document.title = str + w.sLastUpdate.slice(w.sLastUpdate.lastIndexOf(" ")+1);}, 5000); } } // index.txtの読み込みタイムアウト処理 var SetTimeout = function() { if(nTimeout > nSetTimeout && ! bTimeout) { bTimeout = true; clearInterval(nTimer2); var bModal = (document.getElementById("f").innerHTML.length > 40) ? true : false; var aOriginal = w.swf("data").Index("Load"); for(var i=0; i