//【登録場所】レス表示
//【ラベル】ランダムで開く
//【コマンド】${SCRIPT:S} random.js
//【内容】 スレ一覧からランダムにスレ開く
//【スクリプト】
var mes = "";
function getRandom()
{
if (!v2c.online) { return; }
var bd = v2c.context.thread.board;
v2c.openURL(bd.url);
if (v2c.interrupted) { return; }
var bs = bd.url + 'subject.txt';
var ss = v2c.readURL(bs);
if (v2c.interrupted) { return; }
if (!ss) { mes = bs+'の取得に失敗'; return; }
var lines = ss.split('\n');
var count = lines.length;
while (count) {
var idx = Math.floor(Math.random() * count);
var key = /^(\d+)\.dat<>.+ \(\d+\)/.exec(lines[idx])[1];
var th = bd.getThread(key);
if (th.localResCount == 0) {
th.open();
return;
}
lines.splice(idx, 1);
count--;
}
mes = "ランダムで開くための未取得スレッドがありませんでした。";
}
getRandom();
if (mes != "") { v2c.context.setStatusBarText(mes); }
Ly/jgJDnmbvpjLLloLTmiYDjgJHjg6zjgrnooajnpLoKLy/jgJDjg6njg5njg6vjgJHjg6njg7Pjg4Djg6DjgafplovjgY8KLy/jgJDjgrPjg57jg7Pjg4njgJEke1NDUklQVDpTfSByYW5kb20uanMgCi8v44CQ5YaF5a6544CRIOOCueODrOS4gOimp+OBi+OCieODqeODs+ODgOODoOOBq+OCueODrOmWi+OBjwovL+OAkOOCueOCr+ODquODl+ODiOOAkQp2YXIgbWVzID0gIiI7CmZ1bmN0aW9uIGdldFJhbmRvbSgpCnsKICAgIGlmICghdjJjLm9ubGluZSkgeyByZXR1cm47IH0KCQoJdmFyIGJkID0gdjJjLmNvbnRleHQudGhyZWFkLmJvYXJkOwoJdjJjLm9wZW5VUkwoYmQudXJsKTsKCWlmICh2MmMuaW50ZXJydXB0ZWQpIHsgcmV0dXJuOyB9CgkKCXZhciBicyA9IGJkLnVybCArICdzdWJqZWN0LnR4dCc7Cgl2YXIgc3MgPSB2MmMucmVhZFVSTChicyk7CglpZiAodjJjLmludGVycnVwdGVkKSB7IHJldHVybjsgfQoJaWYgKCFzcykgeyBtZXMgPSB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