├── .github
└── FUNDING.yml
├── LICENSE
├── README.md
├── favicon.png
├── high-res.png
├── icon-192x192.png
├── icon-256x256.png
├── icon-384x384.png
├── icon-512x512.png
├── index.html
├── manifest.json
├── pwa.js
├── script.js
├── style.css
└── sw.js
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | patreon: dopevog
2 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2021 Vedant Kothari
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Fakegooogle
2 | A working search engine!
3 | ## Use It [NOW](https://dopevog.github.io/fakegooogle/)
4 | 
5 |
6 |
7 | ## License
8 | This Project is [MIT Licensed](https://github.com/dopevog/fakegooogle/blob/main/LICENSE)
9 |
--------------------------------------------------------------------------------
/favicon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dopevog/fakegooogle/406d1660943995382e86ab6c110028cdacc27158/favicon.png
--------------------------------------------------------------------------------
/high-res.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dopevog/fakegooogle/406d1660943995382e86ab6c110028cdacc27158/high-res.png
--------------------------------------------------------------------------------
/icon-192x192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dopevog/fakegooogle/406d1660943995382e86ab6c110028cdacc27158/icon-192x192.png
--------------------------------------------------------------------------------
/icon-256x256.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dopevog/fakegooogle/406d1660943995382e86ab6c110028cdacc27158/icon-256x256.png
--------------------------------------------------------------------------------
/icon-384x384.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dopevog/fakegooogle/406d1660943995382e86ab6c110028cdacc27158/icon-384x384.png
--------------------------------------------------------------------------------
/icon-512x512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dopevog/fakegooogle/406d1660943995382e86ab6c110028cdacc27158/icon-512x512.png
--------------------------------------------------------------------------------
/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Fake Gooogle
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 | The web
23 |
24 | Images
25 |
26 | News
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
50 |
--------------------------------------------------------------------------------
/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "Fake Gooogle",
3 | "short_name": "Fake Gooogle",
4 | "start_url": "/?coolMode=true&incognito=trues",
5 | "orientation": "landscape",
6 | "scope": "./",
7 | "icons": [
8 | {
9 | "src": "/icon-192x192.png",
10 | "sizes": "192x192",
11 | "type": "image/png"
12 | },
13 | {
14 | "src": "/icon-256x256.png",
15 | "sizes": "256x256",
16 | "type": "image/png"
17 | },
18 | {
19 | "src": "/icon-384x384.png",
20 | "sizes": "384x384",
21 | "type": "image/png"
22 | },
23 | {
24 | "src": "/icon-512x512.png",
25 | "sizes": "512x512",
26 | "type": "image/png"
27 | }
28 | ],
29 | "theme_color": "#DC143C",
30 | "background_color": "#fff",
31 | "display": "minimal-ui"
32 | }
33 |
--------------------------------------------------------------------------------
/pwa.js:
--------------------------------------------------------------------------------
1 | if('serviceWorker' in navigator){
2 | navigator.serviceWorker.register('/sw.js')
3 | .then(reg => console.log('service worker registered'))
4 | .catch(err => console.log('service worker not registered', err));
5 | }
--------------------------------------------------------------------------------
/script.js:
--------------------------------------------------------------------------------
1 | import * as _$ from "https://cdn.jsdelivr.net/npm/bijou.js@v7.1.2";
2 | console.log((new URLSearchParams(window.location.search)).get("q"))
3 | _$.observeMutations(document.documentElement, () => {
4 | try {
5 | document.querySelector("#popup-bg").onclick = () => document.querySelector("#popup-bg").remove();
6 | } catch(e){
7 | //Eat it.
8 | }
9 | })
10 |
11 | if ((new URLSearchParams(window.location.search).get("q") || "").startsWith("!")) {
12 | console.log("Fetching first search result to quickly redirect to it.")
13 | _$.getHTML(`https://cors.explosionscratc.repl.co/www.google.com/search?q=${escape((new URLSearchParams(window.location.search)).get("q").replace(/^!/, ""))}&btnI=Im+Feeling+Lucky`, () => {}).then(html => {
14 | console.log("Quick-redirecting to 1st search result")
15 | window.location.href = html.querySelector("a").href;
16 | });
17 | } else {
18 | run();
19 | }
20 | function konami(callback) {
21 | console.log("Key pressed, caching.")
22 | let kkeys = [];
23 | // up,up,down,down,left,right,left,right,B,A
24 | const konami = '38,38,40,40,37,39,37,39,66,65';
25 | return event => {
26 | kkeys.push(event.keyCode);
27 | if (kkeys.toString().indexOf(konami) >= 0) {
28 | callback();
29 | kkeys = [];
30 | }
31 | };
32 | }
33 | function run() {
34 | window.addEventListener("keydown", konami(() => settings()))
35 | console.log("Main loop started.")
36 | if (new URLSearchParams(window.location.search).get("coolMode")) {
37 | console.log("Transitioning to cool due to url queries.")
38 | document.documentElement.classList.add("cool-mode");
39 | document.head.appendChild(_$.createElement(` `))
40 | } else {
41 | document.head.appendChild(_$.createElement(` `))
42 | }
43 | let inp = document.getElementById("input");
44 | let out = document.getElementById("results");
45 | let dym_a = document.querySelector("#dym");
46 | let urlMode = (new URLSearchParams(window.location.search)).get("mode") || "web";
47 | console.log("Set initial variables")
48 | document.querySelector("[data-value='web']").checked = urlMode === "web" ? true : false;
49 | document.querySelector("[data-value='images']").checked = urlMode === "images" ? true : false;
50 | document.querySelector("[data-value='news']").checked = urlMode === "news" ? true : false;
51 | console.log("Updating active radio fields")
52 | document.querySelector(".switch-field").onclick = () => {
53 | updateHistory();
54 | ftch(`https://apis.explosionscratc.repl.co/google?q=${escape(inp.value)}`)
55 | }
56 | var cache = JSON.parse(localStorage.getItem("cache")) || {};
57 | var wolframCache = JSON.parse(localStorage.getItem("wolfram_cache")) || {};
58 | var newsCache = JSON.parse(localStorage.getItem("news_cache")) || {};
59 | inp.value = (new URLSearchParams(window.location.search)).get("q") || localStorage.getItem("input") || "";
60 | if (inp.value === (new URLSearchParams(window.location.search)).get("q")) {
61 | console.log("Auto searching due to query.")
62 | ftch(`https://apis.explosionscratc.repl.co/google?q=${escape(inp.value)}`)
63 | }
64 | if ((new URLSearchParams(window.location.search)).get("darkMode") == 1) {
65 | console.log("Transitioning to dark mode")
66 | document.documentElement.classList.add("dark-mode");
67 | updateHistory();
68 | }
69 |
70 | function updateHistory() {
71 | if ((new URLSearchParams(window.location.search)).get("incognito")){
72 | console.log(`Would push to history but using incognito, mode: ${mode()}`);
73 | return;
74 | }
75 | console.log(`Pushing to history: ${mode()}`);
76 | document.title = inp.value ? `${inp.value} – Search` : "Search engine";
77 | history.pushState({}, `${inp.value} – Search`, `?q=${escape(inp.value)}&darkMode=${+document.documentElement.classList.contains("dark-mode")}&mode=${mode()}${document.documentElement.classList.contains("cool-mode") ? "&coolMode=1" : ""}`)
78 | }
79 | let phdrs = ["Search something!", "Type anything here to search!", "Try clicking the info button on search results!", "Made by Vedant!", "Do you like the search engine?", "Unlike other search engines this doesn't track you!", "You can share links to searches!"]
80 | setInterval(() => {
81 | console.log('Set new placeholder on search input.')
82 | inp.setAttribute("placeholder", phdrs[Math.floor(Math.random() * phdrs.length)])
83 | }, 3000);
84 | let dark_btn = document.querySelector("button#dark-mode")
85 | dark_btn.onclick = () => {
86 | console.log("Toggling dark mode")
87 | document.documentElement.classList.toggle("dark-mode");
88 | updateHistory();
89 | }
90 | var width = 0;
91 | var clicktime = Date.now();
92 | setInterval(() => {
93 | document.querySelector(".top").style.width = `${Math.floor(width)}vw`;
94 | }, 100)
95 | window.onpopstate = (e) => {
96 | console.log("Fetching due to popState.")
97 | inp.value = (new URLSearchParams(window.location.search)).get("q");
98 | ftch(`https://apis.explosionscratc.repl.co/google?q=${escape(inp.value)}`)
99 | }
100 | inp.addEventListener("keyup", (e) => {
101 | if (key(e) && e.key !== "Enter") return;
102 | if ((e.key === "Enter" && e.shiftKey)) {
103 | console.log("Shift + enter was pressed, fetching first search result to redirect to...")
104 | _$.getHTML(`https://cors.explosionscratc.repl.co/www.google.com/search?q=${escape(inp.value.replace(/^!/, ""))}&btnI=Im+Feeling+Lucky`, () => {}).then(html => {
105 | console.log("Opening new tab with 1st search result for " + inp.value)
106 | window.open(html.querySelector("a").href, "_blank")
107 | });
108 | return;
109 | }
110 | if (e.key === "Enter") {
111 | console.log('Fetching due to enter key.')
112 | ftch(`https://apis.explosionscratc.repl.co/google?q=${escape(inp.value)}`);
113 | }
114 | localStorage.setItem("input", inp.value)
115 | let html = ` Loading results `
116 | //if (out.innerHTML !== html) out.innerHTML = html
117 | })
118 |
119 | function mode() {
120 | return document.querySelector("[data-value='images']").checked ? "images" : document.querySelector("[data-value='web']").checked ? "web" : "news"
121 | }
122 | function ftch(url) {
123 | (async () => {
124 | dym_a.innerHTML = "";
125 | if (!inp.value.trim().length) {
126 | out.innerHTML = '';
127 | return
128 | };
129 | var mean = "No mean";
130 | try {
131 | console.log("Fetching did you mean");
132 | mean = await didYouMean(inp.value);
133 | } catch (e) {
134 | console.warn("Error:")
135 | console.info(e.stack)
136 | }
137 | console.log(`Did you mean fetched:`, mean)
138 | if (mean.mode !== "original") {
139 | console.log(`New: ${mean.suggestion}, type: ${mean.mode}`);
140 | dym_a.innerHTML = `${mean.mode === "dym" ? "Did you mean: " : mean.mode === "results_for" ? "Showing results for: " : ""} ${_$.escapeHTML(mean.suggestion)} `;
141 | } else {
142 | console.log('Original mode')
143 | }
144 | if (mean.mode === "results_for") {
145 | console.log("Setting input value")
146 | inp.value = mean.suggestion;
147 | }
148 | updateHistory();
149 | if (mode() == "images") {
150 | console.log("Images mode.")
151 | width = 0;
152 | if (cache[`https://apis.explosionscratc.repl.co/image-search?q=${escape(inp.value)}`.toLowerCase()]) {
153 | out.innerHTML = cache[`https://apis.explosionscratc.repl.co/image-search?q=${escape(inp.value)}`.toLowerCase()].map(i => {
154 | let color = _$.blendColors("#ffa126", "#f5587f", _$.random(0, 100));
155 | let placeholder = `src="https://via.placeholder.com/${Math.ceil(i.width / 10)}x${Math.ceil(i.height / 10)}/${color.replace("#", "")}/${_$.lightOrDark(color).lightOrDark === "light" ? "000000" : "FFFFFF"}/?text=%20"`;
156 | return ` `;
157 | }).join("\n");
158 | lazyLoadInstance.update();
159 | return;
160 | }
161 | let widthInt = setInterval(() => {
162 | width += (100 - width) / (Math.random() * 3 + 30);
163 | }, 500)
164 | fetch(`https://apis.explosionscratc.repl.co/image-search?q=${escape(inp.value)}`).then(res => res.json()).then(json => {
165 | cache[`https://apis.explosionscratc.repl.co/image-search?q=${escape(inp.value)}`.toLowerCase()] = json;
166 | out.innerHTML = json.map(i => {
167 | return ` `
168 | }).join("\n");
169 | lazyLoadInstance.update();
170 | width = 100;
171 | });
172 | return
173 | }
174 | if (mode() === "news") {
175 | width = 0;
176 | let widthInt = setInterval(() => {
177 | width += (100 - width) / (Math.random() * 3 + 30);
178 | }, 500)
179 | console.log("Fetching news.");
180 | let newsUrl = `https://apis.explosionscratc.repl.co/news-search?q=${escape(inp.value.trim())}`.toLowerCase();
181 | if (newsCache[newsUrl]) {
182 | out.innerHTML = newsCache[newsUrl].map((i) => {
183 | return ` ${i.abstract || "No title "}${_$.escapeHTML(new URL(i.web_url).hostname)} ${_$.escapeHTML(i.lead_paragraph)} `;
184 | width = 100
185 | }).join("\n");
186 | clearInterval(widthInt)
187 | return
188 | }
189 | fetch(newsUrl).then(res => res.json()).then(json => {
190 | newsCache[newsUrl] = json.response.docs;
191 | clearInterval(widthInt)
192 | width = 100;
193 | out.innerHTML = json.response.docs.map((i) => {
194 | return ` ${i.abstract || "No title "}${_$.escapeHTML(new URL(i.web_url).hostname)} ${_$.escapeHTML(i.lead_paragraph)} `
195 | }).join("\n");
196 | localStorage.setItem('news_cache', JSON.stringify(newsCache))
197 | })
198 | return;
199 | }
200 | width = 0;
201 | let widthInt = setInterval(() => {
202 | width += (100 - width) / (Math.random() * 3 + 30);
203 | }, 500)
204 | out.innerHTML = ""
205 | let wolframUrl = `https://apis.explosionscratc.repl.co/quick-answer?q=${escape(inp.value.trim().toLowerCase())}`;
206 | localStorage.setItem("wolfram_cache", JSON.stringify(wolframCache))
207 | if (!wolframCache[wolframUrl]) {
208 | console.info(`Fetching quick answer from wolfram`)
209 | fetch(wolframUrl).then(res => res.json()).then(answer => {
210 | wolframCache[wolframUrl] = answer;
211 | if (!answer.error && !document.querySelector(".wolfram")) {
212 | out.innerHTML = `${answer.text} Quick answer by Wolfram Alpha \n${out.innerHTML}`
213 | }
214 | })
215 | } else {
216 | console.info(`Getting wolfram quick answer from cache`)
217 | let answer = wolframCache[wolframUrl]
218 | if (!answer.error && !document.querySelector(".wolfram")) {
219 | out.innerHTML = `${answer.text} Quick answer by Wolfram Alpha \n${out.innerHTML}`
220 | }
221 | }
222 | if (inp.value.toLowerCase().startsWith("define ")) {
223 | if (!cache[`https://apis.explosionscratc.repl.co/dictionary?q=${escape(input.value.replace("define ", "").trim())}`.toLowerCase()]) {
224 | fetch(`https://apis.explosionscratc.repl.co/dictionary?q=${escape(input.value.replace("define ", "").trim())}`).then(res => res.json()).then(json => {
225 | out.innerHTML += `${_$.escapeHTML(json.word)} ${_$.escapeHTML(json.pronounciation)} • ${_$.escapeHTML(json.type.toLowerCase().replace(/^./, (i) => i.toUpperCase()))} ${_$.escapeHTML(json.meaning)} Your browser does not support audio! `
226 | })
227 | } else {
228 | let json = cache[`https://apis.explosionscratc.repl.co/dictionary?q=${escape(input.value.replace("define ", "").trim())}`.toLowerCase()]
229 | out.innerHTML += `${_$.escapeHTML(json.word)} ${_$.escapeHTML(json.pronounciation)} • ${_$.escapeHTML(json.type.toLowerCase().replace(/^./, (i) => i.toUpperCase()))} ${_$.escapeHTML(json.meaning)} Your browser does not support audio! `
230 | }
231 | }
232 | if (!cache[url.toLowerCase()]) {
233 | try {
234 | if (!navigator.onLine) {
235 | clearInterval(widthInt);
236 | width = 0;
237 | if (!document.querySelector("#popup")) {
238 | alert("No internet! 😩");
239 | }
240 | out.innerHTML = "";
241 | return
242 | }
243 | fetch(url).then(res => res.json()).then(json => {
244 | cache[url.toLowerCase()] = json;
245 | try {
246 | console.log(math.evaluate(inp.value))
247 | out.innerHTML += `${math.evaluate(inp.value)} `;
248 | } catch (e) {}
249 | update();
250 | });
251 | } catch (e) {
252 | clearInterval(widthInt);
253 | width = 0;
254 | console.error(e.stack);
255 | if (navigator.onLine) {
256 | alert("Error! Check console for details!");
257 | }
258 | out.innerHTML = "";
259 | }
260 | } else {
261 | try {
262 | console.log(math.evaluate(inp.value))
263 | out.innerHTML += `${math.evaluate(inp.value)} `;
264 | } catch (e) {}
265 | update();
266 | }
267 |
268 | function update() {
269 | clearInterval(widthInt);
270 | width = 100;
271 | let info_icon = ` `;
272 | let history_icon = ` `;
273 | out.innerHTML += cache[url.toLowerCase()].map(i => ({
274 | title: i.title || "No title",
275 | link: i.link || "",
276 | snippet: i.snippet || "No snippet available"
277 | })).map((i) => {
278 | let yt_re = /^.*(?:youtu.be\/|youtube(?:-nocookie)?.com\/(?:v\/|.*u\/\w\/|embed\/|.*v=))([\w-]{11}).*/i
279 | let scratch_re = /(?:http|https):\/\/scratch.mit.edu\/users\/([a-z0-9\-]+)/i
280 | let gist_re = /(?:http|https):\/\/gist.github.com\/([a-z0-9\-]+)\/([a-z0-9\-]+)/i
281 | let special_stuff = "";
282 | if (gist_re.test(i.link)){
283 | special_stuff = `