{"record":{"id":"2b14da0aeea5a3c8","repo":"pear-devs/pear-desktop","slug":"duplicated-userscript-calling-2b14da","errorCode":null,"errorMessage":"Duplicated Userscript Calling","messagePattern":"Duplicated Userscript Calling","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"src/plugins/performance-improvement/scripts/cpu-tamer/cpu-tamer-by-dom-mutation.js","lineNumber":36,"sourceCode":"IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n\n*/\n\n/* oxlint-disable */\n\nexport const injectCpuTamerByDomMutation = ((__CONTEXT__) => {\n  'use strict';\n\n  const win = this instanceof Window ? this : window;\n\n  // Create a unique key for the script and check if it is already running\n  const hkey_script = 'nzsxclvflluv';\n  if (win[hkey_script]) throw new Error('Duplicated Userscript Calling'); // avoid duplicated scripting\n  win[hkey_script] = true;\n\n  /** @type {globalThis.PromiseConstructor} */\n  const Promise = (async () => { })().constructor; // hacks Promise in WaterFox Classic and \"Promise.resolve(0)\" nevers resolve.\n  const PromiseExternal = ((resolve_, reject_) => {\n    const h = (resolve, reject) => { resolve_ = resolve; reject_ = reject };\n    return class PromiseExternal extends Promise {\n      constructor(cb = h) {\n        super(cb);\n        if (cb === h) {\n          /** @type {(value: any) => void} */\n          this.resolve = resolve_;\n          /** @type {(reason?: any) => void} */\n          this.reject = reject_;\n        }\n      }\n    };\n  })();","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/pear-devs/pear-desktop/blob/1e2aac5706c870c93ed74ba8727ae8390d3b0fa5/src/plugins/performance-improvement/scripts/cpu-tamer/cpu-tamer-by-dom-mutation.js#L18-L54","documentation":"This userscript (CPU Tamer by DOM Mutation) shares the same singleton flag ('nzsxclvflluv') as its AnimationFrame sibling. If that flag is already set on the window — because either script already ran in this page — it throws 'Duplicated Userscript Calling' to prevent double patching of timers/observers.","triggerScenarios":"Both cpu-tamer-by-animationframe.js and cpu-tamer-by-dom-mutation.js being injected into the same page; re-injection after plugin re-enable without a page reload; a manually installed copy plus the plugin's copy.","commonSituations":"Enabling both CPU tamer variants in the performance-improvement plugin; userscript-manager duplication; hot-reload during development leaving the flag set.","solutions":["Enable only ONE of the two CPU tamer variants (they share the singleton flag)","Disable any standalone userscript copy if the plugin injects the script","Reload the page after changing plugin configuration","Guard injection with a check of window.nzsxclvflluv"],"exampleFix":"// before\ninject(cpuTamerDomMutation); inject(cpuTamerAnimationFrame); // second one throws\n\n// after\nif (!(window as any).nzsxclvflluv) inject(cpuTamerDomMutation);","handlingStrategy":"try-catch","validationCode":"if (!(window as any).nzsxclvflluv) inject(cpuTamerDomMutation);","typeGuard":null,"tryCatchPattern":"inject(cpuTamerDomMutation).catch((e) => { if (!/Duplicated Userscript/.test(e.message)) throw e; });","preventionTips":["Enable only ONE cpu-tamer variant — they share the 'nzsxclvflluv' flag","Avoid installing the userscript manually while the plugin is active","Reload after configuration changes"],"tags":["userscript","duplicate-injection","cpu-tamer","singleton-guard","performance-improvement"],"backgroundTag":"duplicate-script-injection","analyzedSha":"1e2aac5706c870c93ed74ba8727ae8390d3b0fa5","analyzedAt":"2026-08-27T20:01:08.614Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}