// ==UserScript==
// @name spot_search
// @description try to take over the world!
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js
// @require http://momentjs.com/downloads/moment.js
// ==/UserScript==
// ==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;
}
});