├── .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 | ![Capture](https://user-images.githubusercontent.com/82938580/118751662-56b51f00-b87f-11eb-806c-3ab09c849777.PNG) 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 | 23 | 24 | 25 | 26 | 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)}
    ` 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)}
    ` 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 = `` 287 | } 288 | if (yt_re.test(i.link)) { 289 | special_stuff = `` 290 | } 291 | return `
  • ${_$.escapeHTML(i.title)}${info_icon}${history_icon}

    ${_$.escapeHTML((new URL(i.link)).hostname)}

    ${_$.escapeHTML(i.snippet.replace(/(\W)\1+/g, "$1")).linkify()}${special_stuff}
  • ` 292 | }).join("\n"); 293 | _$.each(document.querySelectorAll("ul#results > li"), (li) => { 294 | let non_listen = ["definition", "math_eval", "wolfram"] 295 | if (!(non_listen.includes(li.classList[0]))) { 296 | li.onmousedown = () => { 297 | clicktime = Date.now(); 298 | } 299 | li.onmouseup = () => { 300 | if (Date.now() - clicktime < 200) { 301 | window.open(li.querySelector("a#url").href, "_blank") 302 | } 303 | } 304 | li.querySelector("#text").onmouseup = (e) => { 305 | e.stopPropagation(); 306 | } 307 | li.querySelector("a").onmouseup = (e) => { 308 | e.stopPropagation(); 309 | } 310 | tippy(li.querySelector("a"), { 311 | content: li.querySelector("a").href, 312 | theme: document.documentElement.classList.contains("dark-mode") ? "dark" : "light" 313 | }) 314 | li.querySelector("#archive_icon").onmouseup = (e) => { 315 | e.stopPropagation(); 316 | window.open(`http://web.archive.org/web/${li.querySelector("a").href}`, "_blank") 317 | } 318 | tippy(li.querySelector("#archive_icon"), { 319 | content: "View archived version", 320 | theme: document.documentElement.classList.contains("dark-mode") ? "dark" : "light" 321 | }) 322 | li.querySelector("#info_icon").onmouseup = (e) => { 323 | console.log("Fetching info for URL in question.") 324 | e.stopPropagation(); 325 | fetch(`https://apis.explosionscratc.repl.co/link-preview?q=${escape(li.querySelector("a").href)}`).then(res => res.json()).then(json => { 326 | alert({ 327 | title: `` + _$.escapeHTML(json.title) || "No info", 328 | text: (json.images.length > 0 ? `` : "") + _$.escapeHTML(json.description || li.querySelector("#text").innerText) 329 | }) 330 | }) 331 | } 332 | tippy(li.querySelector("#info_icon"), { 333 | content: "Info", 334 | theme: document.documentElement.classList.contains("dark-mode") ? "dark" : "light" 335 | }) 336 | } 337 | }) 338 | localStorage.setItem("cache", JSON.stringify(cache)) 339 | } 340 | })(); 341 | } 342 | window.onkeyup = (e) => { 343 | if (document.activeElement !== inp && e.key !== "A" && e.key !== "B") { 344 | inp.focus(); 345 | inp.value += e.key.length > 1 ? "" : e.key; 346 | } 347 | } 348 | async function settings(){ 349 | await alert({ 350 | title: "Settings:", 351 | text: `


    `, 352 | buttontext: "Save" 353 | }); 354 | updateHistory(); 355 | } 356 | function key(e) { 357 | return (e.key.length !== 1 || e.ctrlKey || e.altKey) && e.key !== "Enter" && e.key !== "Backspace" 358 | } 359 | inp.onkeyup = _$.debounce((e) => { 360 | if (key(e)) return; 361 | ftch(`https://apis.explosionscratc.repl.co/google?q=${escape(inp.value)}`); 362 | }, 1000) 363 | document.querySelector("button").onclick = _$.debounce(() => { 364 | ftch(`https://apis.explosionscratc.repl.co/google?q=${escape(inp.value)}`); 365 | }, 500) 366 | if (!String.linkify) { 367 | String.prototype.linkify = function() { 368 | var urlPattern = /\b(?:https?|ftp):\/\/[a-z0-9-+&@#\/%?=~_|!:,.;]*[a-z0-9-+&@#\/%=~_|]/gim; 369 | var pseudoUrlPattern = /(^|[^\/])(www\.[\S]+(\b|$))/gim; 370 | var emailAddressPattern = /[\w.]+@[a-zA-Z_-]+?(?:\.[a-zA-Z]{2,6})+/gim; 371 | return this.replace(urlPattern, '$&').replace(pseudoUrlPattern, '$1$2').replace(emailAddressPattern, '$&'); 372 | }; 373 | } 374 | async function didYouMean(text) { 375 | let dym_html = await _$.getHTML(`https://cors.explosionscratc.repl.co/google.com/search?q=${escape(text)}`, () => {}); 376 | let el = dym("Did you mean:") || dym("Showing results for"); 377 | let dym_mode = dym("Did you mean:") ? "dym" : dym("Showing results for") ? "results_for" : "original" 378 | if (!el) { 379 | return { 380 | mode: "original", 381 | suggestion: text 382 | } 383 | }; 384 | return { 385 | suggestion: el.parentElement.querySelector("a").innerText, 386 | mode: dym_mode 387 | } 388 | 389 | function dym(t) { 390 | let els = dym_html.querySelectorAll("*"); 391 | for (let i = 0; i < els.length; i++) { 392 | if (els[i].innerText === (t)) return els[i] 393 | } 394 | } 395 | } 396 | } -------------------------------------------------------------------------------- /style.css: -------------------------------------------------------------------------------- 1 | @import url('https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap'); 2 | :root { 3 | --selection-color: rgb(223, 37, 74, .5); 4 | --primary: rgb(220, 20, 203); 5 | --secondary: #f93; 6 | --light-secondary: #fb5; 7 | --box-shadow: #0001; 8 | --light-primary: rgb(238, 42, 81); 9 | --dark-mode-light-primary: rgb(245, 107, 134); 10 | } 11 | .cool-mode * { 12 | --selection-color: rgba(37, 186, 223, 0.5); 13 | --primary: rgb(8, 196, 155); 14 | --secondary: rgb(66, 214, 123); 15 | --light-secondary: rgb(93, 233, 147); 16 | --box-shadow: #0001; 17 | --light-primary: rgb(47, 218, 181); 18 | --dark-mode-light-primary: rgb(131, 255, 234); 19 | } 20 | * { 21 | font-family: "Montserrat", sans-serif !important; 22 | } 23 | *:focus { 24 | outline: none; 25 | } 26 | #dym { 27 | padding: 5px; 28 | } 29 | ul#results::-webkit-scrollbar { 30 | width: 3px; 31 | } 32 | ul#results::-webkit-scrollbar-thumb { 33 | background: linear-gradient(var(--primary), var(--secondary)); 34 | border-radius: 1000px; 35 | } 36 | ::selection { 37 | background: var(--selection-color) 38 | } 39 | .top { 40 | display: block; 41 | position: absolute; 42 | top: 0; 43 | width: 0vw; 44 | background: linear-gradient(to right, var(--primary), var(--secondary)); 45 | height: 5px; 46 | margin: 0; 47 | padding: 0; 48 | left: 0; 49 | transition: width .2s ease; 50 | } 51 | html { 52 | background: white; 53 | color: #111; 54 | display: flex; 55 | justify-content: center; 56 | align-items: center; 57 | height: 100vh; 58 | } 59 | 60 | body { 61 | width: 80vw; 62 | max-width: 700px; 63 | height: 100vh; 64 | font-family: "Montserrat", sans-serif 65 | } 66 | ul { 67 | height: fit-content; 68 | max-height: 70vh; 69 | overflow: scroll; 70 | } 71 | ul > i { 72 | display: block; 73 | margin: 0 auto; 74 | text-align: center; 75 | } 76 | ul > i > svg { 77 | animation: rotate .5s ease infinite; 78 | } 79 | input { 80 | border-radius: 20px 0 0 20px; 81 | padding: 20px; 82 | box-shadow: 3px 3px 10px 2px var(--box-shadow); 83 | border: none; 84 | transition: box-shadow .1s ease; 85 | margin: 10px 0 10px 10px; 86 | } 87 | .inputs button { 88 | cursor: pointer; 89 | color: white; 90 | display: inline-block; 91 | padding: 20px; 92 | border-radius: 0 20px 20px 0; 93 | background: linear-gradient(var(--primary), var(--secondary)); 94 | border: none; 95 | position: relative; 96 | box-shadow: 3px 3px 10px 2px var(--box-shadow); 97 | } 98 | button:active { 99 | background: linear-gradient(var(--light-primary), var(--light-secondary)); 100 | outline: none; 101 | } 102 | a { 103 | color: var(--primary); 104 | padding: 3px; 105 | background-size: 200%; 106 | background-position: -0% 0; 107 | background-image: linear-gradient(to right, rgba(255,255,255,0) 50%, var(--primary) 50%, var(--light-secondary) 100%); 108 | transition: background-position 0.3s ease; 109 | border-radius: 3px; 110 | } 111 | a:hover { 112 | background-position: -100% 0; 113 | color: white; 114 | } 115 | @keyframes rotate { 116 | 0% { 117 | transform: rotate(0deg); 118 | } 119 | 100% { 120 | transform: rotate(360deg) 121 | } 122 | } 123 | 124 | input:focus { 125 | outline: none; 126 | box-shadow: 4px 4px 15px 3px var(--box-shadow); 127 | } 128 | .inputs:focus-within button { 129 | box-shadow: 4px 4px 15px 3px var(--box-shadow); 130 | } 131 | ul > li { 132 | cursor: pointer; 133 | list-style: none; 134 | padding: 30px; 135 | border-radius: 5px; 136 | width: 80%; 137 | display: block; 138 | margin: 0 auto; 139 | margin-bottom: 10px; 140 | box-shadow: 2px 2px 10px 1px #00000015; 141 | transition: background-color .3s ease; 142 | } 143 | ul > li > #text{ 144 | cursor: auto; 145 | display: block; 146 | } 147 | ul li:hover { 148 | background: #00000005; 149 | box-shadow: 2px 2px 10px 1px #0002; 150 | } 151 | .inputs * { 152 | box-sizing: border-box; 153 | } 154 | body { 155 | display: flex; 156 | justify-content: center; 157 | align-items: center; 158 | flex-direction: column; 159 | } 160 | .inputs { 161 | width: calc(fit-content + 10px); 162 | } 163 | .inputs * { 164 | display: inline-block; 165 | } 166 | .inputs input { 167 | width: 40vw; 168 | min-width: 90px; 169 | } 170 | .inputs button { 171 | width: 5vw; 172 | min-width: 60px; 173 | margin-right: 10px; 174 | } 175 | 176 | #results { 177 | padding: 10px; 178 | margin: 0; 179 | } 180 | #icon { 181 | width: 15px; 182 | position: relative; 183 | top: 2px; 184 | margin-right: 7px; 185 | } 186 | .dark-mode #icon { 187 | filter: invert(100%) hue-rotate(180deg); 188 | } 189 | #popup { 190 | --button-bg: linear-gradient(45deg, var(--primary), var(--secondary)); 191 | --button-bg-transparent: var(--secondary)4; 192 | --button-bg-hover: linear-gradient(45deg, var(--light-primary), var(--light-secondary)); 193 | } 194 | #popup { 195 | width: 60vw !important; 196 | max-width: 500px; 197 | } 198 | #info_image { 199 | border-radius: 20px 0 20px 0; 200 | border: 2px solid var(--secondary); 201 | max-width: 30%; 202 | margin-right: 10px; 203 | display: block; 204 | float: left; 205 | object-fit: cover; 206 | min-width: 50px; 207 | } 208 | #popup-text { 209 | max-height: 75%; 210 | } 211 | #info_icon, #archive_icon { 212 | position: absolute; 213 | right: 15px; 214 | top: 15px; 215 | font-size: 22px; 216 | } 217 | #archive_icon { 218 | position: absolute; 219 | right: 45px; 220 | } 221 | ul#results > li { 222 | position: relative; 223 | } 224 | 225 | .dark-mode *, .dark-mode { 226 | background-color: #111 !important; 227 | color: white; 228 | overflow-x: hidden; 229 | } 230 | .dark-mode:focus-within button { 231 | box-shadow: 2px 2px 10px #fff2; 232 | } 233 | .dark-mode input, .dark-mode button { 234 | box-shadow: 2px 2px 6px #fff2; 235 | } 236 | .dark-mode button .iconify { 237 | background: transparent; 238 | } 239 | #dark-mode { 240 | box-shadow: none; 241 | } 242 | .dark-mode ul > li { 243 | transition: box-shadow .3s ease; 244 | box-shadow: 0px 0px 5px #fff5; 245 | margin-bottom: 10px; 246 | } 247 | .dark-mode a { 248 | color: var(--dark-mode-light-primary); 249 | } 250 | .dark-mode a:hover { 251 | color: white; 252 | } 253 | .dark-mode #popup-bg { 254 | background-color: transparent; 255 | } 256 | .dark-mode ul#results > li:hover { 257 | box-shadow: 0px 0px 10px #fff5; 258 | } 259 | button#dark-mode { 260 | position: fixed; 261 | top: 15px; 262 | right: 15px; 263 | background: transparent; 264 | border: none; 265 | padding: 10px; 266 | } 267 | button .iconify { 268 | background: transparent !important; 269 | } 270 | #popup-bg { 271 | background: transparent !important; 272 | } 273 | .inputs { 274 | display: block; 275 | top: 20px; 276 | z-index: 1; 277 | width: fit-content; 278 | } 279 | .inputs input { 280 | width: 40vw; 281 | max-width: 600px; 282 | } 283 | .inputs button { 284 | width: 5vw; 285 | max-width: 60px; 286 | } 287 | @media screen and (max-width: 650px) { 288 | .inputs > button { 289 | display: none !important; 290 | } 291 | .inputs input { 292 | border-radius: 20px; 293 | width: 70vw !important; 294 | margin: 0; 295 | } 296 | } 297 | [data-tippy-root] { 298 | word-wrap: break-word; 299 | } 300 | .dark-mode [data-tippy-root], .dark-mode [data-tippy-root] * { 301 | background: #333 !important; 302 | border-radius: 3px; 303 | } 304 | input:-webkit-autofill, 305 | input:-webkit-autofill:hover, 306 | input:-webkit-autofill:focus, 307 | textarea:-webkit-autofill, 308 | textarea:-webkit-autofill:hover, 309 | textarea:-webkit-autofill:focus, 310 | select:-webkit-autofill, 311 | select:-webkit-autofill:hover, 312 | select:-webkit-autofill:focus { 313 | border: 1px solid #222; 314 | -webkit-text-fill-color: white; 315 | -webkit-box-shadow: 0 0 0px 1000px #0000 inset; 316 | transition: background-color 5000s ease-in-out 0s; 317 | } 318 | iframe { 319 | border-radius: 10px; 320 | box-shadow: 2px 2px 5px var(--box-shadow); 321 | border: 3px solid var(--primary); 322 | display: block; 323 | margin: 10px auto; 324 | width: 95%; 325 | } 326 | #img { 327 | width: 300px; 328 | height: 200px; 329 | object-fit: cover; 330 | } 331 | select { 332 | display: none; 333 | } 334 | .switch-field { 335 | display: flex; 336 | overflow: hidden; 337 | margin-top: 6px; 338 | margin-bottom: 6px; 339 | } 340 | 341 | .switch-field input { 342 | position: absolute !important; 343 | clip: rect(0, 0, 0, 0); 344 | height: 1px; 345 | width: 1px; 346 | border: 0; 347 | overflow: hidden; 348 | } 349 | 350 | .switch-field label { 351 | background-color: #ccc1; 352 | color: rgba(0, 0, 0, 0.6); 353 | font-size: 14px; 354 | line-height: 1; 355 | text-align: center; 356 | padding: 8px 16px; 357 | margin-right: -1px; 358 | border: 2px solid rgba(0, 0, 0, 0.2); 359 | transition: all 0.3s ease-in-out; 360 | } 361 | .dark-mode .switch-field label { 362 | border: 2px solid rgba(255, 255, 255, 0.2); 363 | } 364 | .switch-field label:hover { 365 | cursor: pointer; 366 | } 367 | 368 | .switch-field input:checked + label { 369 | background: var(--primary) !important; 370 | color: white; 371 | box-shadow: none; 372 | } 373 | .dark-mode .switch-field label { 374 | color: white !important; 375 | } 376 | .switch-field label:first-of-type { 377 | border-radius: 4px 0 0 4px; 378 | } 379 | 380 | .switch-field label:last-of-type { 381 | border-radius: 0 4px 4px 0; 382 | } 383 | audio { 384 | width: 100%; 385 | } 386 | .inputs { 387 | margin-top: 20px; 388 | } 389 | body { 390 | overflow-x: visible; 391 | } 392 | .inputs, .inputs * { 393 | overflow: hidden;; 394 | } 395 | #img.error { 396 | display: none; 397 | } 398 | #img { 399 | opacity: 0; 400 | transition-duration: .5s; 401 | margin: 0 auto; 402 | transition-property: opacity, transform, width, height, top, left; 403 | } 404 | #img.loaded:hover { 405 | cursor: zoom-in; 406 | } 407 | #img.clicked { 408 | width: 80vw; 409 | height: 80vh; 410 | top: 50%; 411 | left: 50%; 412 | transform: translate(-50%, -50%); 413 | position: fixed; 414 | z-index: 10000; 415 | } 416 | #img.loaded.entered { 417 | opacity: 1; 418 | } -------------------------------------------------------------------------------- /sw.js: -------------------------------------------------------------------------------- 1 | const staticCacheName = 'site-static-v1'; 2 | const assets = [ 3 | '/', 4 | '/index.html', 5 | "/manifest.json", 6 | "/pwa.js", 7 | "/high-res.png", 8 | 'https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap', 9 | '/script.js', 10 | '/style.css', 11 | '/favicon.png', 12 | "https://cdn.jsdelivr.net/gh/explosion-scratch/popup@v1.0.2/popup.js", 13 | "https://cdn.jsdelivr.net/npm/bijou.js@v7.1.2", 14 | "https://cdn.jsdelivr.net/gh/explosion-scratch/popup@v1.0.2/popup.css", 15 | "https://unpkg.com/mathjs/lib/browser/math.js", 16 | "https://cdn.jsdelivr.net/npm/vanilla-lazyload@17.3.1/dist/lazyload.min.js", 17 | "https://code.iconify.design/1/1.0.7/iconify.min.js", 18 | "https://unpkg.com/@popperjs/core@2", 19 | "https://unpkg.com/tippy.js@6/themes/light.css", 20 | "https://unpkg.com/tippy.js@6" 21 | ]; 22 | // install event 23 | self.addEventListener('install', evt => { 24 | evt.waitUntil( 25 | caches.open(staticCacheName).then((cache) => { 26 | console.log('caching shell assets'); 27 | cache.addAll(assets); 28 | }) 29 | ); 30 | }); 31 | // activate event 32 | self.addEventListener('activate', evt => { 33 | evt.waitUntil( 34 | caches.keys().then(keys => { 35 | return Promise.all(keys 36 | .filter(key => key !== staticCacheName) 37 | .map(key => caches.delete(key)) 38 | ); 39 | }) 40 | ); 41 | }); 42 | // fetch event 43 | self.addEventListener('fetch', evt => { 44 | evt.respondWith( 45 | caches.match(evt.request).then(cacheRes => { 46 | return cacheRes || fetch(evt.request); 47 | }) 48 | ); 49 | }); --------------------------------------------------------------------------------