您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Provides utility functions to make your geoguessr scripts independent of arbitrary changes to class name suffixes
当前为
此脚本不应直接安装。它是供其他脚本使用的外部库,要使用该库请加入元指令 // @require https://update.cn-greasyfork.org/scripts/460322/1151666/Geoguessr%20Styles%20Scan.js
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.
function cn(string)
outputs the geoguessr class name corresponding to the prefix. For example, cn("status_section__")
evaluates to "status_section__8uP8o"
. If the full name can't be found, the function will simply output the input string.
async function scanStyles()
fetches Geoguessr class names from stylesheets listed in the <head>
block. You must use scanStyles
before being able to use cn
. 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 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.