新月の開発

e3967852 :Anonymous 2017-09-23 13:23
moonlightと同じような動作するブックマークレット作った。先頭にjavascirpt:付ければ動くよ
# 元ソース
(async()=>{
let res=await fetch("/gateway.cgi/csv/recent/title,size");
let text=await res.text();
let list=text.split("\n").map(p=>p.split(",")).filter(x=>x.length===2).filter(x=>x[1]==="0\r").map(x=>x[0]);
console.log(list.length);
for(let name of list){
await fetch("/thread.cgi/"+encodeURIComponent(name)+"?search_new_file=yes");
}
})()
# babelトランスパイル版
"use strict";

(function _callee() {
var res, text, list, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, name;

return regeneratorRuntime.async(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.next = 2;
return regeneratorRuntime.awrap(fetch("/gateway.cgi/csv/recent/title,size"));

case 2:
res = _context.sent;
_context.next = 5;
return regeneratorRuntime.awrap(res.text());

case 5:
text = _context.sent;
list = text.split("\n").map(function (p) {
return p.split(",");
}).filter(function (x) {
return x.length === 2;
}).filter(function (x) {
return x[1] === "0\r";
}).map(function (x) {
return x[0];
});

console.log(list.length);
_iteratorNormalCompletion = true;
_didIteratorError = false;
_iteratorError = undefined;
_context.prev = 11;
_iterator = list[Symbol.iterator]();

case 13:
if (_iteratorNormalCompletion = (_step = _iterator.next()).done) {
_context.next = 20;
break;
}

name = _step.value;
_context.next = 17;
return regeneratorRuntime.awrap(fetch("/thread.cgi/" + encodeURIComponent(name) + "?search_new_file=yes"));

case 17:
_iteratorNormalCompletion = true;
_context.next = 13;
break;

case 20:
_context.next = 26;
break;

case 22:
_context.prev = 22;
_context.t0 = _context["catch"](11);
_didIteratorError = true;
_iteratorError = _context.t0;

case 26:
_context.prev = 26;
_context.prev = 27;

if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}

case 29:
_context.prev = 29;

if (!_didIteratorError) {
_context.next = 32;
break;
}

throw _iteratorError;

case 32:
return _context.finish(29);

case 33:
return _context.finish(26);

case 34:
case "end":
return _context.stop();
}
}
}, null, undefined, [[11, 22, 26, 34], [27,, 29, 33]]);
})();
Powered by shinGETsu.