// ==UserScript==
// @title spot_author_search
// @name spot_author_search
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://travel.spot-app.jp/*
// @grant none
// ==/UserScript==
var result6 = document.evaluate('//ul[@class="nav_list"]', document, null, 7, null);
result6.snapshotItem(0).insertAdjacentHTML('afterbegin', '<input type="text" id="sub_search" value="">');
document.getElementById("sub_search").addEventListener('change', function () {
location.href = "https://travel.spot-app.jp/?s=" + document.getElementById("sub_search").value;
});
if (!(/\/tag\//g.test(location.href)) && !(/\/category\//g.test(location.href))) {
var result = document.evaluate('//div[@class="author-name"]/a/text()', document, null, 7, null);
var result2 = document.evaluate('//div[@class="loop-meta"]/div', document, null, 7, null);
for (var i = 0; i < result.snapshotLength; i++) {
var sp = " ";
var reg2 = new RegExp(sp);
if (reg2.test(result.snapshotItem(i).nodeValue)) {
result2.snapshotItem(i).insertAdjacentHTML('beforeend', "<div class=n_author><a></a></div>");
} else {
result2.snapshotItem(i).insertAdjacentHTML('beforeend', "<div class=n_author><a href=https://travel.spot-app.jp/tag/" + result.snapshotItem(i).nodeValue + "/#dummy>" + result.snapshotItem(i).nodeValue + "</a></div>");
}
}
var result3 = document.evaluate('//div[@class="cover"]', document, null, 7, null);
for (var j = 0; j < result3.snapshotLength; j++) {
result3.snapshotItem(j).remove();
}
} else if (/#dummy/g.test(location.href)) {
var result5 = document.evaluate('//span[@class="title"]/text()', document, null, 7, null);
var t1 = result5.snapshotItem(0).nodeValue;
var er = "ERROR"
var reg = new RegExp(er);
if (reg.test(t1)) {
alert("authorページが確認できません。\n元のページに戻ります");
history.back();
} else {
var result4 = document.evaluate('//div[@class="author-name"]/a', document, null, 7, null);
for (var k = 0; k < result4.snapshotLength; k++) {
if (result4.snapshotItem(k).href == result4.snapshotItem(k + 1).href) {
location.replace(result4.snapshotItem(k).href);
}
}
}
}