-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathsearch.js
More file actions
44 lines (39 loc) · 1.18 KB
/
search.js
File metadata and controls
44 lines (39 loc) · 1.18 KB
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
37
38
39
40
41
42
43
44
(function () {
const path = window.location.pathname.toLowerCase();
let cx;
let placeholder;
let title;
if (path.includes("/games/")) {
cx = "904ead0bae8c845f0";
placeholder = "Search for a game...";
title = "Game Search";
} else if (path.includes("/software/")) {
cx = "c288da2c020ec4091";
placeholder = "Search for software...";
title = "Software Search";
} else if (path.includes("/mobile/")) {
cx = "d175f6f92fc134b38";
placeholder = "Search For Android Apps...";
title = "Mobile/APK Search";
} else {
return;
}
const gcse = document.createElement("script");
gcse.type = "text/javascript";
gcse.async = true;
gcse.src = "https://cse.google.com/cse.js?cx=" + cx;
const s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(gcse, s);
function setSearchBox() {
const searchBox = document.getElementById("gsc-i-id1");
if (searchBox) {
searchBox.placeholder = placeholder;
searchBox.title = title;
return true;
}
return false;
}
const interval = setInterval(() => {
if (setSearchBox()) clearInterval(interval);
}, 1);
})();