(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('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);
}
}
});
result6.snapshotItem(0).insertAdjacentHTML('beforeend', ' ');
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', '');
document.getElementById("sub_search").addEventListener('click', function () {
var s_word = window.prompt("検索ワードを入力してください", "");
if (s_word != null) {
location.href = "https://travel.spot-app.jp/?s=" + s_word;
}
});
});