Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save hisasann/76bb6cea6950dd3110f86ea669633652 to your computer and use it in GitHub Desktop.
Save hisasann/76bb6cea6950dd3110f86ea669633652 to your computer and use it in GitHub Desktop.
amazonホームだけ検索窓に勝手にフォーカスするスクリプト
// ==UserScript==
// @name amazonホームだけ検索窓に勝手にフォーカスするスクリプト
// @namespace http://hisasann.dev/
// @version 0.1
// @description nameのまま
// @author hisasann
// @match https://www.amazon.co.jp/
// @icon https://www.google.com/s2/favicons?sz=64&domain=amazon.co.jp
// @grant none
// ==/UserScript==
(function() {
'use strict';
const regex1 = new RegExp('https?:\/\/(www)?.amazon.co.jp\/?', 'g');
const regex2 = new RegExp('https?:\/\/(www)?.amazon.co.jp/ref=nav_logo', 'g');
if (
regex1.test(location.href) ||
regex2.test(location.href)
) {
document.querySelector('#twotabsearchtextbox').focus();
console.log('focus amazon searchbox!')
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment