Created
August 8, 2019 00:05
-
-
Save blogmonomono/5b1768f2c100581136e9076f4f5c6de1 to your computer and use it in GitHub Desktop.
tampermonkey用拡張コード。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name agodaサイトで最近できたホテルに絞り込む | |
// @namespace https://www.monomono-blog.com/ | |
// @version 1.0 | |
// @description 新しいホテルを目立つように表示します | |
// @author @BlogMonoMono | |
// @match https://www.agoda.com/* | |
// @grant none | |
// @require http://code.jquery.com/jquery-latest.js | |
// ==/UserScript== | |
(function () { | |
'use strict'; | |
// 読み込み時1度だけ実行 | |
initTinyUrlCSS(); | |
$(document).on("mouseenter", "ol.hotel-list-container > li", function () { | |
narrowDownNewBuild(); | |
}); | |
})(); | |
/** | |
* 「できたばかり」の宿泊先にクラスを追加する。 | |
*/ | |
function narrowDownNewBuild() { | |
$("ol.hotel-list-container > li").each(function (index, element) { | |
var dekitabakari = $(this).find(".Badge.Badge--NewlyBuilt.Badge--TopBadge").text(); | |
if (dekitabakari.match(/できたばかり$/)) { | |
$(this).addClass("NewBuild"); | |
$(this).removeClass("notNewBuild"); | |
} else { | |
$(this).addClass("notNewBuild"); | |
$(this).removeClass("NewBuild"); | |
} | |
}); | |
} | |
/** | |
* CSSを追加する。 | |
*/ | |
function initTinyUrlCSS() { | |
var css = "\ | |
li.NewBuild {\ | |
background: #3e3e3e;\ | |
}\ | |
li.notNewBuild {\ | |
opacity: 0.3; \ | |
height: 50px; \ | |
overflow: hidden; \ | |
}\ | |
#narrowDownNewBuildButton{\ | |
position: fixed; \ | |
right: 0px; \ | |
bottom: 0px; \ | |
z-index: 10000; \ | |
display: block; \ | |
margin: 10px; \ | |
padding: 10px; \ | |
background: #ffee23; \ | |
border: solid 3px; \ | |
}\ | |
"; | |
$('<style>').html(css).appendTo('head'); | |
// input:focus{outline:0;}でフォーカス時に青い枠が着くのを防いでいる。 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment