// ==UserScript== // @name 工单自动更新 // @namespace http://tampermonkey.net/ // @license MIT // @version 2026-07-21-19 // @description 运盟工单的自动化操作,协助工作人员简单化操作 // @author FNG666 // @match https://gongdan.yonmen.com:17040/index.html* // @match https://dolphin.yonmen.com/web/ // @icon https://www.google.com/s2/favicons?sz=64&domain=yonmen.com // @grant GM_addStyle // @grant GM_setValue // @grant GM_getValue // @grant window.close // ==/UserScript== (function() { 'use strict'; // ========================================================================= // CONFIG — all tunable values in one place // ========================================================================= const CONFIG = { refresh: { minInterval: 3000, maxInterval: 5000, }, toast: { defaultDuration: 4000, stickyDuration: 0, // 0 = stays until replaced }, monitor: { queryDelay: 500, retryBaseDelay: 2000, retryMaxDelay: 15000, dropdownPollInterval: 100, dropdownTimeout: 5000, }, router: { fallbackPollMs: 5000, // long-interval fallback if events fail }, log: { level: 'info', // 'debug' | 'info' | 'warn' | 'error' | 'none' }, selectors: { // These are FALLBACKS — primary queries use text/label/placeholder matching searchButtonClass: 'search-button', queryButtonText: '查询', licensePlateLabel: '车头号牌:', licensePlateInput: '请输入车牌号', dropdownItem: '.k-select-item', }, storage: { autoRefresh: 'autoRefreshActive', licensePlate: 'licensePlate', shouldAutoQuery: 'shouldAutoQuery', }, hotkey: { ctrl: true, alt: true, key: 'e' }, }; // ========================================================================= // LOGGER — level-based, can mute in production // ========================================================================= const LOG = (() => { const levels = { debug: 0, info: 1, warn: 2, error: 3, none: 99 }; const current = levels[CONFIG.log.level] ?? levels.info; const prefix = '[工单助手]'; return { debug: (...a) => current <= 0 && console.debug(prefix, ...a), info: (...a) => current <= 1 && console.log(prefix, ...a), warn: (...a) => current <= 2 && console.warn(prefix, ...a), error: (...a) => current <= 3 && console.error(prefix, ...a), }; })(); // ========================================================================= // DOM UTILITIES — semantic queries that survive UI-framework upgrades // ========================================================================= /** * Find a button whose visible text matches `text` exactly or by inclusion. * Returns the `