// ==UserScript== // @name A better search // @namespace http://tampermonkey.net/ // @version 0.2.1 // @description Completely strips the original search engine and replaces it with a more fleshed out version where you can use filters and see more info. // @author Lemson // @match https://www.geoguessr.com/search // @match https://www.geoguessr.com/ // @icon https://www.clipartmax.com/png/full/15-150759_search-icon-search-icon-png-blue.png // @grant GM_addStyle // @license MIT // @downloadURL none // ==/UserScript== //Removes the old search, and keeps it gone. const observer = new MutationObserver(() => { setTimeout(() => { document.querySelectorAll('[class*="quick-search_wrapper__"], [class*="search_center__"]').forEach((element) => { if (element.parentNode) element.parentNode.remove(); }); }, 200); }); observer.observe(document.documentElement, { childList: true, subtree: true }); if (window.location.href === "https://www.geoguessr.com/") { function newStartPageCSS() { const inputCSS = ` .quicksearch-input{ background-color: rgba(0,0,0,0); border: none; padding-left: 1.3rem; color: white; } `; GM_addStyle(inputCSS); const searchButtonCSS = ` .slanted-button-container{ display: inline-block; scale: .95; transition: .2s; } .slanted-button-container:hover{ transition: .2s; } .slanted-wrapper-root{ position: relative; z-index: 0; } .slanted-wrapper_variantGrayTransparent{ } .slanted-wrapper-start{ left: 0; } .slanted-wrapper-right{ bottom: 0; overflow: hidden; position: absolute; top: 0; width: 50%; z-index: -1; } .slanted-wrapper-right:before{ transform-origin: bottom; border-radius: 0.25rem 0 0 0.25rem; transform: skewX(-12deg); left: 0; padding-right: .0625rem; width: 100%; background: var(--ds-color-black-40); bottom: 0; content: ""; position: absolute; top: 0; z-index: -1; } .slanted-button_root{ --skew-angle: -10deg; --content-skew-angle: 0; --variant-background-color: var(--ds-color-black-20); --border-radius: 0.25rem; --content-color: var(--ds-color-white); --content-padding: 0.6rem 1rem; } .slanted-button_button{ background: none; border: initial; cursor: pointer; margin: 0; min-height: 3rem; padding: 0; display: flex; flex-direction: row-reverse; align-items: center; } .slanted-button_content{ color: var(--content-color); padding: var(--content-padding); } .slanted-button_contentSizeLarge{ --content-padding: 0.6rem 1rem; } .search-button-root{ background-color: transparent; border: unset; cursor: pointer; display: flex; flex: 0 0 3rem; justify-content: center; position: relative; z-index: 1; } .slanted-wrapper-end{ left: 50%; } .slanted-wrapper_right{ bottom: 0; overflow: hidden; position: absolute; top: 0; width: 50%; z-index: -1; } .slanted-wrapper_right:before{ transform-origin: top; border-radius: 0 0.25rem 0.25rem 0; transform: skewX(-12deg); padding-left: .0625rem; right: 0; width: 100%; background: var(--ds-color-black-40); bottom: 0; content: ""; position: absolute; top: 0; z-index: -1; } `; GM_addStyle(searchButtonCSS); } const createNewSearchButton = () => { const baseHTML = `
`; const header = document.querySelector('div[class^="header_context__"]'); const diver = document.createElement("div"); diver.innerHTML = baseHTML; header.insertBefore(diver, document.querySelector(".slanted-button_container__6JmyZ")); return diver; }; const openSearch = () => { if (!searchOpen) { const input = document.createElement("div"); input.innerHTML = ` `; document.querySelector(".slanted-button_root").append(input); searchOpen = true; } }; const createEventListeners = () => { //Search button searchButton.addEventListener("click", openSearch); //Search input document.addEventListener("keydown", function (event) { if (event.key === "Enter" && document.activeElement == document.querySelector(".quicksearch-input")) { const input = document.querySelector(".quicksearch-input"); localStorage.setItem("searchTerm", input.value); window.location.href = "https://www.geoguessr.com/search"; } }); }; //Definitions let searchOpen = false; //Create the new button. const searchButton = createNewSearchButton(); //All new CSS newStartPageCSS(); createEventListeners(); } //Search page \/ if (window.location.href === "https://www.geoguessr.com/search") { function newSearchPageCSS() { const CSS = ` .main-search-div{ height: 100%; } .search-page-main{ width: 100vw; height: 100%; display: flex; align-items: center; justify-content: center; flex-direction: column; } .input-main-container{ width: 100vw; height: 100%; display: flex; justify-content: center; align-items: center; } .search-container{ width: 40%; display: flex; justify-content: center; align-items: center; } .search-input{ width: 100%; background-color: rgb(255 255 255 / 5%); border: 1px solid black; border-radius: 10rem; color: white; font-size: 1.2rem; padding-left: 1.5rem; } .search-results{ } .search-item{ display: flex; flex-direction: row; justify-content: center; gap: 1rem; margin-top: 2rem; padding-bottom: 1rem; border-bottom: 1px solid rgba(0,0,0,0.5); transition: .2s; } .search-item:hover{ transition: .2s; scale: 1.01; } .author-map-name{ width: 20rem; } .map-name{ font-size:1.5rem; } .map-avatar{ width: 4rem; border-radius: .5rem; } .stat-view{ width: 5rem; margin-right: 4rem; display:flex; align-items: center; justify-content: center; flex-direction: column; gap: .2rem; } .dropdown{ width: 40%; display: flex; justify-content: center; align-items: center; flex-direction: column; } .filter-btn { color: white; font-size: 1rem; border: none; cursor: pointer; } .filter-window{ width: 100%; display: flex; justify-content: space-around; } .filter-category-container{ display: flex; flex-direction: column; align-items: center; margin-top: 1rem; margin-bottom: .5rem; } .min-input{ background-color: rgba(0,0,0,0.1); border: 1px solid #6b6b6b; border-radius: .7rem; color: white; width: 8rem; margin-top: .1rem; } .hide{ display: none; } .official-toggle-buttons>*{ color: white; border: 1px solid white; padding: 1rem; padding-top: .4rem; padding-bottom: .4rem; } .selectionmode-toggle-buttons>*{ color: white; border: 1px solid white; padding: 1rem; padding-top: .4rem; padding-bottom: .4rem; } .active-button{ background-color: #563b9a; } .apply-button{ width: 5rem; height: 2.5rem; background-color: transparent; margin-top: 10%; color: white; border: 1px solid white; border-radius: 2rem; margin-left: 35%; } .apply-button:active{ transition: .05s; background-color: rgba(255,255,255,0.2); } `; GM_addStyle(CSS); } const createNewSearchbar = () => { const searchHTML = `Minimum likes
Minimum locations
Minimum games played
Minimum average score
Official
Selection mode
${a.averageScore}