{"record":{"id":"d12ffc8ec4b1b931","repo":"maboloshi/github-chinese","slug":"github-locals-js-d12ffc","errorCode":null,"errorMessage":"[GitHub 中文化插件] 词库文件 locals.js 未加载","messagePattern":"\\[GitHub 中文化插件\\] 词库文件 locals\\.js 未加载","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"main.user.js","lineNumber":143,"sourceCode":"        // 当前运行时状态\n        pageConfig: null,        // 当前页面配置（null 表示无有效页面）\n        currentURL: window.location.href, // 当前页面URL\n        transEngine: 'iflyrec',  // 当前翻译引擎\n        mutationObserver: null,  // DOM变化观察器\n        urlChangeHandler: null,  // 存储URL变化处理器\n        dynamicMenus: {},        // 动态菜单ID记录\n        initDone: false,\n    };\n\n    /* =========================== 安全检查 =========================== */\n\n    /**\n     * 检查词库文件是否加载 — 未加载则抛出错误阻止继续执行\n     */\n    function checkI18NLoaded() {\n        if (typeof I18N === 'undefined') {\n            alert('GitHub 汉化插件：词库文件 locals.js 未加载，脚本无法运行！');\n            throw new Error('[GitHub 中文化插件] 词库文件 locals.js 未加载');\n        }\n    }\n\n    /**\n     * 错误边界 — 包装函数，捕获异常避免阻断页面正常使用\n     * @param {Function} fn - 要执行的函数\n     * @param {string} label - 错误标签\n     * @returns {Function} 包装后的函数\n     */\n    function safe(fn, label) {\n        return function (...args) {\n            try {\n                return fn.apply(this, args);\n            } catch (e) {\n                console.error(`[GitHub 中文化插件] ${label} 出错:`, e);\n            }\n        };\n    }","sourceCodeStart":125,"sourceCodeEnd":161,"githubUrl":"https://github.com/maboloshi/github-chinese/blob/1db777260aeaeba52b39ebc37e1097e0c7053198/main.user.js#L125-L161","documentation":"Same checkI18NLoaded() guard as the other variants, but this build (main.user.js) sources its vocabulary from GitHub's raw.githubusercontent.com gh-pages branch via // @require .../locals.js?v1.9.4.4-2026-08-04. The throw fires when that require did not define the global I18N before the IIFE runs, so the plugin halts rather than translating with an empty dictionary.","triggerScenarios":"The @require of https://raw.githubusercontent.com/mabolashi/github-chinese/gh-pages/locals.js?v... returns a 404 (the gh-pages file was removed/renamed or the version tag in the URL no longer matches a published file), or raw.githubusercontent.com is blocked/unreachable from the user's network, or the manager did not fetch @require resources — leaving I18N undefined at line 165.","commonSituations":"raw.githubusercontent.com blocked behind the GFW or a corporate proxy; a stale @require version string pointing at a not-yet-published or renamed gh-pages artifact; gh-pages branch HEAD moved but the cache-busting ?v=... is pinned to a missing path; manager network/@require disabled.","solutions":["Visit the exact @require URL in a browser; a 404 means the gh-pages version mismatch — update the @require URL to the currently published locals.js path/version.","If raw.githubusercontent.com is blocked, switch to the NJU mirror build (main(nju.edu).user.js) whose @require points at mirror.nju.edu.cn.","Re-enable 'download @require resources' and force the manager to re-fetch (reinstall or edit+save the metadata).","As a last resort, download locals.js locally and switch the @require to a file:/// URL with local-file access enabled."],"exampleFix":"// before\n// @require      https://raw.githubusercontent.com/mabolashi/github-chinese/gh-pages/locals.js?v1.9.4.4-2026-08-04\n// after — fix a 404 by aligning the version with the actually published gh-pages file\n// @require      https://raw.githubusercontent.com/mabolashi/github-chinese/gh-pages/locals.js?v1.9.4.4","handlingStrategy":"validation","validationCode":"// After @require should have run, before init():\nif (typeof I18N === 'undefined' || typeof I18N.t !== 'function' && typeof I18N !== 'object') {\n    console.error('[github-chinese] gh-pages locals.js missing — skipping');\n    return;\n}","typeGuard":"function isI18NPresent(v: unknown): v is Record<string, unknown> {\n    return typeof v === 'object' && v !== null;\n}","tryCatchPattern":"try {\n    checkI18NLoaded();\n    init();\n} catch (e) {\n    console.warn('[github-chinese] skipped:', e instanceof Error ? e.message : e);\n}","preventionTips":["Verify the @require URL resolves to a JS file before installing.","Keep the @require version string in sync with the published gh-pages artifact.","Have a fallback mirror URL ready for networks that block raw.githubusercontent.com.","Ensure the manager fetches @require resources on install/upgrade."],"tags":["userscript","i18n","runtime-guard","require","raw-github"],"backgroundTag":null,"analyzedSha":"1db777260aeaeba52b39ebc37e1097e0c7053198","analyzedAt":"2026-08-13T05:58:27.900Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}