-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenglish-search-button.user.js
36 lines (35 loc) · 1.37 KB
/
english-search-button.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// ==UserScript==
// @name English Search Button
// @namespace https://github.com/hideo54
// @version 0.1.2
// @description 日本語版 Google の検索結果画面に英語で検索ボタンを追加します
// @author hideo54
// @match https://www.google.com/search?*
// @grant none
// @updateUrl https://raw.githubusercontent.com/hideo54/userscripts/master/english-search-button.user.js
// @downloadUrl https://raw.githubusercontent.com/hideo54/userscripts/master/english-search-button.user.js
// ==/UserScript==
const div = document.querySelector('#hdtb-msb > div:nth-child(2)');
const searchEn = document.createElement('a');
if (location.href.includes('&lr=lang_en')) {
searchEn.href = location.href.replace('&lr=lang_en', '&lr=lang_ja');
searchEn.innerText = '日本語のページを検索';
} else if (location.href.includes('&lr=lang_ja')) {
searchEn.href = location.href.replace('&lr=lang_ja', '&lr=lang_en');
searchEn.innerText = '英語のページを検索';
} else {
searchEn.href = location.href + '&lr=lang_en';
searchEn.innerText = '英語のページを検索';
}
searchEn.className = 'GshZze';
const style = document.createElement('style');
style.innerText = `
a.GshZze {
color: #5f6368;
}
a.GshZze:visited {
color: #5f6368;
}
`;
div.appendChild(searchEn);
div.appendChild(style);