pear-devs/pear-desktop · warning · Error

Duplicated Userscript Calling

Error message

Duplicated Userscript Calling

What it means

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.

Source

Thrown at src/plugins/performance-improvement/scripts/cpu-tamer/cpu-tamer-by-dom-mutation.js:36

IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

*/

/* oxlint-disable */

export const injectCpuTamerByDomMutation = ((__CONTEXT__) => {
  'use strict';

  const win = this instanceof Window ? this : window;

  // Create a unique key for the script and check if it is already running
  const hkey_script = 'nzsxclvflluv';
  if (win[hkey_script]) throw new Error('Duplicated Userscript Calling'); // avoid duplicated scripting
  win[hkey_script] = true;

  /** @type {globalThis.PromiseConstructor} */
  const Promise = (async () => { })().constructor; // hacks Promise in WaterFox Classic and "Promise.resolve(0)" nevers resolve.
  const PromiseExternal = ((resolve_, reject_) => {
    const h = (resolve, reject) => { resolve_ = resolve; reject_ = reject };
    return class PromiseExternal extends Promise {
      constructor(cb = h) {
        super(cb);
        if (cb === h) {
          /** @type {(value: any) => void} */
          this.resolve = resolve_;
          /** @type {(reason?: any) => void} */
          this.reject = reject_;
        }
      }
    };
  })();

View on GitHub (pinned to 1e2aac5706)

Solutions

  1. Enable only ONE of the two CPU tamer variants (they share the singleton flag)
  2. Disable any standalone userscript copy if the plugin injects the script
  3. Reload the page after changing plugin configuration
  4. Guard injection with a check of window.nzsxclvflluv

Example fix

// before
inject(cpuTamerDomMutation); inject(cpuTamerAnimationFrame); // second one throws

// after
if (!(window as any).nzsxclvflluv) inject(cpuTamerDomMutation);
Defensive patterns

Strategy: try-catch

Validate before calling

if (!(window as any).nzsxclvflluv) inject(cpuTamerDomMutation);

Try / catch

inject(cpuTamerDomMutation).catch((e) => { if (!/Duplicated Userscript/.test(e.message)) throw e; });

Prevention

When it happens

Trigger: 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.

Common situations: Enabling both CPU tamer variants in the performance-improvement plugin; userscript-manager duplication; hot-reload during development leaving the flag set.

Related errors


AI-assisted analysis of pear-devs/pear-desktop@1e2aac5706 (2026-08-27). Data as JSON: /api/errors/2b14da0aeea5a3c8. Report an issue: GitHub.