Loop through each provided entry
This commit is contained in:
parent
aca048f3d6
commit
c6f1249c44
1 changed files with 23 additions and 16 deletions
|
@ -48,29 +48,36 @@ export default class BackgroundImporter {
|
||||||
delete configuration[`OOBE`];
|
delete configuration[`OOBE`];
|
||||||
|
|
||||||
// Replace local URLs of filters to corresponding chrome extension pages.
|
// Replace local URLs of filters to corresponding chrome extension pages.
|
||||||
if (((typeof configuration[`settings`][`filters`]).includes(`obj`) && configuration[`settings`][`filters`]) ? Object.keys(configuration[`settings`][`filters`]).length : false) {
|
const checkURL = async () => {
|
||||||
for (let FILTER_NUMBER = 0; FILTER_NUMBER < Object.keys(configuration[`settings`][`filters`]).length; FILTER_NUMBER++) {
|
if (((typeof configuration[`settings`][`filters`]).includes(`obj`) && configuration[`settings`][`filters`]) ? Object.keys(configuration[`settings`][`filters`]).length : false) {
|
||||||
let SOURCE = (Object.keys(configuration[`settings`][`filters`]))[FILTER_NUMBER];
|
let FILTERS = {};
|
||||||
|
FILTERS[`current`] = configuration[`settings`][`filters`];
|
||||||
|
FILTERS[`updated`] = {};
|
||||||
|
|
||||||
// Check if the URL is invalid.
|
for (let FILTER_NUMBER = 0; FILTER_NUMBER < Object.keys(FILTERS[`current`]).length; FILTER_NUMBER++) {
|
||||||
|
let SOURCE = Object.keys(FILTERS[`current`])[FILTER_NUMBER];
|
||||||
if (!(URLs.test(SOURCE))) {
|
|
||||||
// Set the URL.
|
|
||||||
let ORIGIN = {"raw": SOURCE};
|
|
||||||
|
|
||||||
// If it is, it's most likely located within the extension.
|
// Check if the URL is invalid.
|
||||||
ORIGIN[`local`] = chrome.runtime.getURL(`config/filters/`.concat(ORIGIN[`raw`]));
|
if (!(URLs.test(SOURCE))) {
|
||||||
|
// Set the URL.
|
||||||
|
let ORIGIN = {"raw": SOURCE};
|
||||||
|
|
||||||
// Attempt to verify the existence of the file.
|
// If it is, it's most likely located within the extension.
|
||||||
if (await net.download(ORIGIN[`local`], `json`, true)) {
|
ORIGIN[`local`] = chrome.runtime.getURL(`config/filters/`.concat(ORIGIN[`raw`]));
|
||||||
configuration[`settings`][`filters`][ORIGIN[`local`]] = configuration[`settings`][`filters`][ORIGIN[`raw`]];
|
|
||||||
|
// Attempt to verify the existence of the file.
|
||||||
|
if (await net.download(ORIGIN[`local`], `json`, true)) {
|
||||||
|
FILTERS[`updated`][ORIGIN[`local`]] = FILTERS[`current`][ORIGIN[`raw`]];
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
FILTERS[`updated`][SOURCE] = FILTERS[`current`][SOURCE];
|
||||||
};
|
};
|
||||||
|
|
||||||
// Delete the illegal URLs.
|
|
||||||
delete configuration[`settings`][`filters`][ORIGIN[`raw`]];
|
|
||||||
};
|
};
|
||||||
|
configuration[`settings`][`filters`] = FILTERS[`updated`];
|
||||||
|
return(FILTERS[`updated`]);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
await checkURL();
|
||||||
|
|
||||||
// Set the template.
|
// Set the template.
|
||||||
template.set(configuration);
|
template.set(configuration);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue