Geoguessr Styles Scan

Provides utility functions to make your geoguessr scripts independent of arbitrary changes to class name suffixes

Questo script non dovrebbe essere installato direttamente. È una libreria per altri script da includere con la chiave // @require https://updategf.qytechs.cn/scripts/460322/1408713/Geoguessr%20Styles%20Scan.js

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

You will need to install an extension such as Tampermonkey to install this script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

Autore
victheturtle
Versione
1.0.1
Creato il
19/02/2023
Aggiornato il
10/07/2024
Dimensione
1,39 KB
Licenza
MIT

Geoguessr sometimes updates its stylesheets, changing its class names, which can break user scripts despite no visible changes to the UI. These minor changes involve the last 5 characters of a class name, which always follow 2 underscores. For example, "status_section__8uP8o" is the class name for a section in the purple info bar at the top right of the screen in classic games.

This library provides utility functions to make your scripts independent of random changes to these last 5 characters, by letting you define class names by their prefix (underscores included: "status_section__") rather than the full name.

  • async function scanStyles() fetches full class names from Geoguessr stylesheets listed in the <head> block. Note that it is possible that not all styles you need are there at the moment when you're calling scanStyles, therefore you might want to call it several times. Calling it "too many times" should never be a performance issue as fetching a stylesheet uses cache beyond the first fetch.

  • function cn(string) outputs the geoguessr class name corresponding to the prefix. For example, cn("status_section__") evaluates to "status_section__8uP8o". Make sure you called scanStyles at least once before using cn. If the function fails to find the full name, it will simply output undefined.

  • function checkAllStylesFound(list) outputs a boolean to let you check whether all class name prefixes inside list are ready for use by cn.

  • async function requireClassName(string) does the same thing as cn if the full class name is found the first time, otherwise it will call scanStyles and then try to call cn a second time.