(function(scripts, callback, errorback) { if (typeof errorback != 'function') errorback = function(url) { alert('jsloader load error: ' + url) }; var cssRegexp = /.css$/; var load = function(url) { if (cssRegexp.test(url)) { var link = document.createElement('link'); link.href = url; link.type = 'text/css'; link.rel = 'stylesheet'; (document.getElementsByTagName('head')[0] || document.body).appendChild(link); if (scripts.length) { load(scripts.shift()); } else { callback(); } } else { var script = document.createElement('script'); script.type = 'text/javascript'; script.charset = 'utf-8'; var current_callback; if (scripts.length) { var u = scripts.shift(); current_callback = function() { load(u) } } else { current_callback = callback; } if (window.ActiveXObject) { // IE script.onreadystatechange = function() { if (script.readyState == 'complete' || script.readyState == 'loaded') { current_callback(); } } } else { script.onload = current_callback; script.onerror = function() { errorback(url) }; } script.src = url; document.body.appendChild(script); } } load(scripts.shift()); })(["http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js","http://momentjs.com/downloads/moment.js"], function() { // ==UserScript== // @title spot_search // @name spot_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 // @require http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js // @require http://momentjs.com/downloads/moment.js // ==/UserScript== var result6 = document.evaluate('//ul[@class="nav_list"]', document, null, 7, null); result6.snapshotItem(0).insertAdjacentHTML('afterbegin', ''); 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', "
"); } else { result2.snapshotItem(i).insertAdjacentHTML('beforeend', " "); } } 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); } } } } result6.snapshotItem(0).insertAdjacentHTML('afterbegin', ' '); var result7 = document.evaluate('id("pref_name")', document, null, 7, null); result7.snapshotItem(0).addEventListener('change', function () { var selectedValue = $("#pref_name").val(); location.href = "https://travel.spot-app.jp/category/" + selectedValue + "/"; }); result6.snapshotItem(0).insertAdjacentHTML('beforeend', ''); var result8 = document.evaluate('id("last_visit")', document, null, 7, null); result8.snapshotItem(0).addEventListener('click', function () { var now = moment(); if (!('last_visit' in localStorage)) { localStorage.setItem('last_visit', now); alert("現在の時刻をローカルストレージに書き込みました"); } else { if (now.diff(localStorage.getItem('last_visit'), 'days') != 0) { alert(now.diff(localStorage.getItem('last_visit'), 'days') + "日前に訪れています"); localStorage.setItem('last_visit', now); } else { alert("今日訪れました"); localStorage.setItem('last_visit', now); } } }); });