From b7a03830307198fa45c69d930712ebd463ae5583 Mon Sep 17 00:00:00 2001 From: dathbe Date: Tue, 15 Apr 2025 19:16:14 -0700 Subject: [PATCH 1/3] Add check for "(Log)" at end of module config file --- node_helper.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/node_helper.js b/node_helper.js index 4f0b984..23d4e3b 100644 --- a/node_helper.js +++ b/node_helper.js @@ -331,7 +331,11 @@ module.exports = NodeHelper.create({ try { fs.accessSync(filename, fs.F_OK); // Add new line at the beginning of the file (this is necessary for modules which are bundled) - const newContent = `const Log = console;const document = navigator = window = {};document.createElement = function() { return {}; };\n${fs.readFileSync(filename, "utf8")}`; + var fileContent = fs.readFileSync(filename, "utf8"); + if (fileContent.endsWith('}(Log);\n')) { + fileContent = fileContent.substring(0, fileContent.length - 7) + ';\n'; + } + const newContent = `const Log = console;const document = navigator = window = {};document.createElement = function() { return {}; };\n${fileContent}`; // Write the new content to the temporary file fs.writeFileSync(tempFilename, newContent, "utf8"); From 1a6cc65a09e3e681e40de8b319666e8fee201a7d Mon Sep 17 00:00:00 2001 From: dathbe Date: Mon, 21 Apr 2025 19:57:46 -0700 Subject: [PATCH 2/3] lint --- node_helper.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/node_helper.js b/node_helper.js index 23d4e3b..203c333 100644 --- a/node_helper.js +++ b/node_helper.js @@ -331,9 +331,9 @@ module.exports = NodeHelper.create({ try { fs.accessSync(filename, fs.F_OK); // Add new line at the beginning of the file (this is necessary for modules which are bundled) - var fileContent = fs.readFileSync(filename, "utf8"); - if (fileContent.endsWith('}(Log);\n')) { - fileContent = fileContent.substring(0, fileContent.length - 7) + ';\n'; + let fileContent = fs.readFileSync(filename, "utf8"); + if (fileContent.endsWith("}(Log);\n")) { + fileContent = `${fileContent.substring(0, fileContent.length - 7)};\n`; } const newContent = `const Log = console;const document = navigator = window = {};document.createElement = function() { return {}; };\n${fileContent}`; // Write the new content to the temporary file From 079a2d6a056f4d43d1f608cde840d0c98a399053 Mon Sep 17 00:00:00 2001 From: dathbe Date: Thu, 24 Apr 2025 08:48:21 -0700 Subject: [PATCH 3/3] Fix obtaining default configs from bundled modules --- node_helper.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/node_helper.js b/node_helper.js index 203c333..962bea4 100644 --- a/node_helper.js +++ b/node_helper.js @@ -332,9 +332,7 @@ module.exports = NodeHelper.create({ fs.accessSync(filename, fs.F_OK); // Add new line at the beginning of the file (this is necessary for modules which are bundled) let fileContent = fs.readFileSync(filename, "utf8"); - if (fileContent.endsWith("}(Log);\n")) { - fileContent = `${fileContent.substring(0, fileContent.length - 7)};\n`; - } + fileContent = `Module.register${fileContent.split("Module.register")[1].split(`}${fileContent.split("}")[fileContent.split("}").length - 1]}`)[0]}`; const newContent = `const Log = console;const document = navigator = window = {};document.createElement = function() { return {}; };\n${fileContent}`; // Write the new content to the temporary file fs.writeFileSync(tempFilename, newContent, "utf8");