1
0
mirror of https://github.com/koloml/furbooru-tagging-assistant.git synced 2025-12-23 23:02:58 +00:00

Merge pull request #128 from koloml/bugfix/ignore-duplicated-modules

Firefox: Fixed an error message appearing when single chunk is trying to execute multiple times
This commit is contained in:
2025-08-13 16:42:16 +04:00
committed by GitHub

View File

@@ -2,7 +2,21 @@ import { amdLite } from "amd-lite";
const originalDefine = amdLite.define;
/**
* Set of already defined modules. Used for deduplication.
*/
const definedModules = new Set<string>();
amdLite.define = (name, dependencies, originalCallback) => {
// Chrome doesn't run the same content script multiple times, while Firefox does. Since each content script and their
// chunks are intended to be run only once, we should just ignore any attempts of running the same module more than
// once. Names of the modules are assumed to be unique.
if (definedModules.has(name)) {
return;
}
definedModules.add(name);
return originalDefine(name, dependencies, function () {
const callbackResult = originalCallback(...arguments);