// ==UserScript==
// @name ex tags
// @namespace http://t...content-available-to-author-only...y.net/
// @version 0.54
// @description 顯示搜索的參數
// @author You
// @include https://e...content-available-to-author-only...i.org/*
// @grant none
// @grant GM.xmlHttpRequest
// @grant GM.getValue
// @grant GM.setValue
// ==/UserScript==
var list = [];
var port;
function posttext()
{
let xhr = new XMLHttpRequest();
xhr.open("POST", "http://127.0.0.1:" + port);
xhr.setRequestHeader("Accept", "application/x-www-form-urlencoded", false);
xhr.onload = function() {
if(xhr.status != 200) {
posttext();
}
}
xhr.send(list);
// console.log(list);
}
function gettag(pdom)
{
if(typeof pdom !== "undefined") {
for(let next = pdom.firstChild; next != null ; next = next.nextSibling) {
//let tag_title = next.getElementsByTagName("td")[0];
let tags = function(dom) {
dom = dom.getElementsByTagName("td")[1];
for(let next = dom.firstChild; next != null ; next = next.nextSibling) {
list.push(next.getAttribute('title') + ",,");
}
}(next);
}
}
}
function tags(doc)
{
let x = doc.getElementsByClassName("itg glte")[0].getElementsByTagName("tbody")[0];
for(let next = x.firstChild; next != null ; next = next.nextSibling) {
//標題
let title = next.getElementsByClassName("glink")[0];
//console.log(title);
list.push(title.innerHTML + ",,");
//tags
gettag(next.getElementsByTagName("tbody")[0]);
//console.log(next.getElementsByTagName("tbody")[0]);
}
posttext();
//console.log(x);
}
function sleep(milliseconds) {
var start = new Date().getTime();
for (var i = 0; i < 1e7; i++) {
if ((new Date().getTime() - start) > milliseconds){
break;
}
}
}
function page(count, max)
{
var xhr = new XMLHttpRequest();
xhr.onload = function() {
if(xhr.status!= 200) {
sleep(5000);
page(count, max);
}
console.log(count);
tags(this.responseXML)
if(count < max) {
sleep(5000);
page(++count, max);
}
//console.log(this.responseXML.getElementsByClassName("itg glte")[0].getElementsByTagName("tbody")[0]);
}
if(count == 1) {
xhr.open("GET", "https://e...content-available-to-author-only...i.org/");
}
else {
xhr.open("GET", "https://e...content-available-to-author-only...i.org/?page=" + (count - 1));
}
xhr.responseType = "document";
xhr.send();
}
let min = prompt("min");
let max = prompt("max");
port = prompt("port");
page(min, max);