Loop through each provided entry

This commit is contained in:
buzz-lightsnack-2007 2024-06-08 17:36:41 +08:00
parent aca048f3d6
commit c6f1249c44

View file

@ -48,12 +48,16 @@ export default class BackgroundImporter {
delete configuration[`OOBE`];
// Replace local URLs of filters to corresponding chrome extension pages.
const checkURL = async () => {
if (((typeof configuration[`settings`][`filters`]).includes(`obj`) && configuration[`settings`][`filters`]) ? Object.keys(configuration[`settings`][`filters`]).length : false) {
for (let FILTER_NUMBER = 0; FILTER_NUMBER < Object.keys(configuration[`settings`][`filters`]).length; FILTER_NUMBER++) {
let SOURCE = (Object.keys(configuration[`settings`][`filters`]))[FILTER_NUMBER];
let FILTERS = {};
FILTERS[`current`] = configuration[`settings`][`filters`];
FILTERS[`updated`] = {};
for (let FILTER_NUMBER = 0; FILTER_NUMBER < Object.keys(FILTERS[`current`]).length; FILTER_NUMBER++) {
let SOURCE = Object.keys(FILTERS[`current`])[FILTER_NUMBER];
// Check if the URL is invalid.
if (!(URLs.test(SOURCE))) {
// Set the URL.
let ORIGIN = {"raw": SOURCE};
@ -63,14 +67,17 @@ export default class BackgroundImporter {
// Attempt to verify the existence of the file.
if (await net.download(ORIGIN[`local`], `json`, true)) {
configuration[`settings`][`filters`][ORIGIN[`local`]] = configuration[`settings`][`filters`][ORIGIN[`raw`]];
FILTERS[`updated`][ORIGIN[`local`]] = FILTERS[`current`][ORIGIN[`raw`]];
};
// Delete the illegal URLs.
delete configuration[`settings`][`filters`][ORIGIN[`raw`]];
} else {
FILTERS[`updated`][SOURCE] = FILTERS[`current`][SOURCE];
};
};
configuration[`settings`][`filters`] = FILTERS[`updated`];
return(FILTERS[`updated`]);
};
};
await checkURL();
// Set the template.
template.set(configuration);