diff --git a/scripts/filters.js b/scripts/filters.js index 78b44d3..9dca170 100644 --- a/scripts/filters.js +++ b/scripts/filters.js @@ -53,15 +53,15 @@ export default class filters { @param {string} URL the URL to update @return {boolean} the state */ - async update(URL) { + async update(location) { // Create a queue of the filters. let filters = new Queue(); - if (URL) { + if (location) { // Check if the URL is in a valid protocol - if (URL.includes(`://`)) { + if (location.includes(`://`)) { // Append that to the queue. - filters.enqueue(URL); + filters.enqueue(new URL(location)); } } else { // Add every item to the queue based on what was loaded first. @@ -81,7 +81,7 @@ export default class filters { let filter_URL = filters.dequeue(); // Inform the user of download state. - new logging (texts.localized(`settings_filters_update_status`, null, [filter_URL])); + new logging (texts.localized(`settings_filters_update_status`), filter_URL); // Create promise of downloading. let filter_download = net.download(filter_URL, `JSON`, false, true); @@ -91,15 +91,17 @@ export default class filters { if (result) { // Write the filter to storage. await global.write(["filters", filter_URL], result, -1, {"silent": true}); - new logging(texts.localized(`settings_filters_update_status_complete`,null,[filter_URL])); - + // Add the filter to the sync list. if ((await global.read(["settings", `filters`])) ? !((Object.keys(await global.read(["settings", `filters`]))).includes(filter_URL)) : true) { global.write(["settings", `filters`, filter_URL], true, 1, {"silent": true}); - } + }; + + // Notify that the update is completed. + new logging(texts.localized(`settings_filters_update_status_complete`),filter_URL); } }) - .catch(async function(error) { + .catch((error) => { // Inform the user of the download failure. logging.error(error.name, texts.localized(`settings_filters_update_status_failure`, null, [error.name, filter_URL]), error.stack); }); diff --git a/scripts/logging.js b/scripts/logging.js index 691119d..70087d3 100644 --- a/scripts/logging.js +++ b/scripts/logging.js @@ -72,7 +72,7 @@ export default class logging { */ static async error(ERROR_CODE, ERROR_MESSAGE, ERROR_STACK, critical = true) { // Display the error message. - console.error('%c%s%c%s%c%s%c\n%s%c', `font-weight: bold;`, ERROR_CODE, ``, `:`, ``, ERROR_MESSAGE, `font-family: monospace;`, ERROR_STACK, ``); + console.error('%c%s%c%s%c%s%c\n%s%c', `font-weight: bold;`, ERROR_CODE, ``, `: `, ``, ERROR_MESSAGE, `font-family: monospace;`, ERROR_STACK, ``); try { (critical) ? alert(texts.localized(`error_msg_GUI`, false, [String(ERROR_CODE), ERROR_MESSAGE])) : M.toast({ text: ERROR_MESSAGE }); diff --git a/scripts/secretariat.js b/scripts/secretariat.js index fab0486..12e678a 100644 --- a/scripts/secretariat.js +++ b/scripts/secretariat.js @@ -167,7 +167,7 @@ class global { DATA_CHECK[`state`] = await compare([...NAME], DATA); (!DATA_CHECK[`state`]) - ? logging.error((new texts(`error_msg_save_failed`)).localized, NAME.join(`→`), JSON.stringify(DATA)) + ? logging.error((new texts(`error_msg_save_failed`)).localized, NAME.join(` → `), JSON.stringify(DATA)) : ((((typeof OPTIONS).includes(`obj`) && OPTIONS != null) ? (!(!!OPTIONS[`silent`])) : true) ? new logging (new texts(`saving_done`).localized) : false); @@ -203,7 +203,7 @@ class global { // Write! chrome.storage[(CLOUD > 0) ? `sync` : `local`].set(DATA_INJECTED); - return (verify(DATA_NAME, data)); + return ((OPTIONS[`verify`] != null ? (OPTIONS[`verify`]) : true) ? verify(DATA_NAME, data) : true); } /* @@ -239,7 +239,7 @@ class global { return(global.read([...PATH], cloud).then(async (DATA) => { return((DATA != null) // Then erase the data. - ? await global.write(PATH, null, cloud, {"strict": true}) + ? await global.write(PATH, null, cloud, {"strict": true, "verify": false}) : true); })); };