From c9558a811a268b0a8bd3e96d056260527ac11d2a Mon Sep 17 00:00:00 2001 From: buzz-lightsnack-2007 <73412182+buzz-lightsnack-2007@users.noreply.github.com> Date: Thu, 18 Apr 2024 22:36:55 +0800 Subject: [PATCH 1/3] read debugging from configuration file instead of being embedded --- scripts/GUI/windowman.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/scripts/GUI/windowman.js b/scripts/GUI/windowman.js index 3a28b0e..f3a5d56 100644 --- a/scripts/GUI/windowman.js +++ b/scripts/GUI/windowman.js @@ -4,9 +4,6 @@ Window and window content management */ import texts from "../strings/read.js"; import net from "../net.js"; -// MAKE SURE TO TURN THIS OFF DURING BUILD. -let DEBUG = true; - export default class windowman { static new(URL, height, width) { this.window = chrome.windows.create({url: (URL.includes(`://`)) ? URL : chrome.runtime.getURL(URL), type: "popup", width: width ? parseInt(width) : 600, height: height ? parseInt(height) : 600}); @@ -35,16 +32,17 @@ export default class windowman { metadata_element.setAttribute(`href`, source); document.querySelector(`head`).appendChild(metadata_element); } else { - throw new ReferenceError(new texts(`error_msg_fileNotFound`, [UI.CSS[index]])); + throw new ReferenceError((new texts(`error_msg_fileNotFound`, [source])).localized); } } catch(err) { + const secretariat = (await import(chrome.runtime.getURL(`/scripts/secretariat.js`))); const logging = (await import(chrome.runtime.getURL(`/scripts/logging.js`))).default; // Raise an alert. logging.error(err.name, err.message, err.stack, true, [source]); // Stop loading the page when an error has occured; it's not going to work! - if (!DEBUG) { + if ((await secretariat.read(`debug`, -1) != null) ? await secretariat.read(`debug`, -1) : true) { window.close(); }; }; From 7c4b4f84bf03e0325f6218b6f24e3aaad0f1d057 Mon Sep 17 00:00:00 2001 From: buzz-lightsnack-2007 <73412182+buzz-lightsnack-2007@users.noreply.github.com> Date: Thu, 18 Apr 2024 22:54:20 +0800 Subject: [PATCH 2/3] use import modules given its asynchronous import --- scripts/external/processor.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/external/processor.js b/scripts/external/processor.js index 4e1da1c..bee1f6b 100644 --- a/scripts/external/processor.js +++ b/scripts/external/processor.js @@ -2,9 +2,9 @@ Process the information on the website and display it on screen. */ -// const inject = ((await import(chrome.runtime.getURL("scripts/external/inject.js"))).default); -const scraper = (await import(chrome.runtime.getURL("scripts/external/scraper.js"))).default; -const product = (await import(chrome.runtime.getURL("scripts/product.js"))).default; +import scraper from "/scripts/external/scraper.js"; +import product from "/scripts/product.js"; +import injection from "/scripts/GUI/inject.js" export default class processor { #filter; From c27fe808fedc7842b32335d7f036737685c7fcbe Mon Sep 17 00:00:00 2001 From: buzz-lightsnack-2007 <73412182+buzz-lightsnack-2007@users.noreply.github.com> Date: Thu, 18 Apr 2024 22:55:32 +0800 Subject: [PATCH 3/3] add the injection module --- scripts/GUI/inject.js | 14 ++++++++++++++ scripts/external/inject.js | 0 2 files changed, 14 insertions(+) create mode 100644 scripts/GUI/inject.js delete mode 100644 scripts/external/inject.js diff --git a/scripts/GUI/inject.js b/scripts/GUI/inject.js new file mode 100644 index 0000000..eb88ccf --- /dev/null +++ b/scripts/GUI/inject.js @@ -0,0 +1,14 @@ +export default class injection { + constructor (parent, element, id, classes, options) { + let ELEMENTS = {}; + + ELEMENTS[`parents`] = ((typeof parent) != `object`) ? docuent.querySelectorAll(parent) : [...parent]; + + // must only run if there are elements to inject + if ((ELEMENTS[`parents`]).length > 0) { + + } + }; + + +} \ No newline at end of file diff --git a/scripts/external/inject.js b/scripts/external/inject.js deleted file mode 100644 index e69de29..0000000