您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Utility methods for DOM and string parsing
当前为
此脚本不应直接安装,它是供其他脚本使用的外部库。如果您需要使用该库,请在脚本元属性加入:// @require https://update.gf.qytechs.cn/scripts/391979/746747/ParseUtil.js
// ==UserScript== // @name ParseUtil // @namespace hoehleg.userscripts.private // @version 0.3.1 // @description Utility methods for DOM and string parsing // @author Gerrit Höhle // @grant GM_xmlhttpRequest // ==/UserScript== /* jshint esnext: true */ const ParseUtil = { getPageAsync: (url, onSuccess, onError = () => {}) => { return GM_xmlhttpRequest({ method: 'GET', url: url, onload: (resp) => { resp.html = new DOMParser().parseFromString(resp.responseText || "", 'text/html'); switch (resp.status) { case 200: case 304: onSuccess(resp); return; default: onError(resp); return; } }, onerror: onError }); }, parseInt: (str, maxIntPlaces = 1, fallbackValue = null) => { let regex = "\\d"; if (maxIntPlaces > 1) { regex += "{1," + maxIntPlaces + "}"; } return Util.parseIntWithRegex(str, new RegExp(regex), fallbackValue); }, parseFloat: (str, maxIntPlaces = 1, maxDecPlaces = 0, fallbackValue = null) => { let regex = "\\d"; if (maxIntPlaces > 1) { regex += "{1," + maxIntPlaces + "}"; } if (maxDecPlaces > 0) { regex += "\\s?[,\.]?\\s?\\d{0," + maxDecPlaces + "}"; } return Util.parseFloatWithRegex(str, new RegExp(regex), fallbackValue); }, parseIntWithRegex: (str, regex, fallbackValue = null) => { const match = Util.parseStrWithRegex(str, regex); const value = parseInt(match); return Number.isNaN(value) ? fallbackValue : value; }, parseFloatWithRegex: (str, regex, fallbackValue = null) => { const match = Util.parseStrWithRegex(str, regex, "").replace(",","."); const value = parseFloat(match); return Number.isNaN(value) ? fallbackValue : value; }, parseStrWithRegex: (str, regex, fallbackValue = null) => { const match = regex.exec(str || ""); return (match && match.length >= 1) ? match[0] : fallbackValue; } };
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址