您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Adds a bootstrap function for easier startup of wmeSdk, WazeWrap, and ScriptUpdateMonitor.
当前为
此脚本不应直接安装。它是供其他脚本使用的外部库,要使用该库请加入元指令 // @require https://update.greatest.deepsurf.us/scripts/509664/1455340/WME%20Utils%20-%20Bootstrap.js
// ==UserScript== // @name WME Utils - Bootstrap // @namespace WazeDev // @version 2024.09.27.001 // @description Adds a bootstrap function for easier startup of wmeSdk, WazeWrap, and ScriptUpdateMonitor. // @author MapOMatic, WazeDev group // @include /^https:\/\/(www|beta)\.waze\.com\/(?!user\/)(.{2,6}\/)?editor\/?.*$/ // @license GNU GPLv3 // ==/UserScript== /* global WazeWrap */ /* global getWmeSdk */ /* global SDK_INITIALIZED */ // Using var here to allow scripts to override with their own bootstrap, if needed, // without having to remove the @require line for this code. // eslint-disable-next-line no-unused-vars, func-names, no-var var bootstrap = (function() { 'use strict'; let wmeSdk; function wmeReady(scriptName, scriptId) { wmeSdk = getWmeSdk({ scriptName, scriptId }); return new Promise(resolve => { if (wmeSdk.State.isReady()) resolve(); wmeSdk.Events.once('wme-ready').then(resolve); }); } function wazeWrapReady(scriptName) { return new Promise(resolve => { (function checkWazeWrapReady(tries = 0) { if (WazeWrap.Ready) { resolve(); } else if (tries < 1000) { setTimeout(checkWazeWrapReady, 200, ++tries); } else { console.error(`${scriptName}: WazeWrap took too long to load.`); } })(); }); } function loadScriptUpdateMonitor(scriptName, scriptVersion, downloadUrl, metaUrl, metaRegExp) { let updateMonitor; try { if (!GM_xmlhttpRequest) { throw new Error('GM_xmlhttpRequest is required for WazeWrap.Alerts.ScriptUpdateMonitor'); } updateMonitor = new WazeWrap.Alerts.ScriptUpdateMonitor(scriptName, scriptVersion, downloadUrl, GM_xmlhttpRequest, metaUrl, metaRegExp); updateMonitor.start(); } catch (ex) { // Report, but don't stop if ScriptUpdateMonitor fails. console.error(`${scriptName}:`, ex); } } async function bootstrapFunc(args) { await SDK_INITIALIZED; await wmeReady(args.scriptName, args.scriptId); if (args.useWazeWrap || args.scriptUpdateMonitor) await wazeWrapReady(args); if (args.scriptUpdateMonitor) { loadScriptUpdateMonitor( args.scriptName, args.scriptUpdateMonitor.scriptVersion, args.scriptUpdateMonitor.downloadUrl, args.scriptUpdateMonitor.metaUrl, args.scriptUpdateMonitor.metaRegExp ); } return wmeSdk; } return bootstrapFunc; })();