diff --git a/media/config.icons.json b/media/config.icons.json new file mode 100644 index 0000000..2160538 --- /dev/null +++ b/media/config.icons.json @@ -0,0 +1,18 @@ +{ + "default": { + "512": "media/icons/logo_tiny.png", + "1024": "media/icons/logo.png" + }, + "disabled": { + "512": "media/icons/logo_no_tiny.png", + "1024": "media/icons/logo_no.png" + }, + "good": { + "512": "media/icons/good_tiny.png", + "1024": "media/icons/good.png" + }, + "bad": { + "512": "media/icons/bad_tiny.png", + "1024": "media/icons/bad.png" + } +} \ No newline at end of file diff --git a/scripts/strings/image.js b/scripts/strings/image.js new file mode 100644 index 0000000..7ab9426 --- /dev/null +++ b/scripts/strings/image.js @@ -0,0 +1,23 @@ + +const CONFIG = chrome.runtime.getURL("media/config.icons.json"); + +class Image { + /* Get the appropriate image path from the configuration. + + @param {string} name The name of the image. + */ + static get(name, size) { + return (fetch(CONFIG) + .then((response) => response.json()) + .then((jsonData) => { + let image = {'raw': jsonData[name]}; + image[`filtered`] = (image[`raw`] && size) ? image[`raw`][String(size)] : image[`raw`]; + return image[`filtered`]; + }) + .catch((error) => { + console.error(error); + })); + }; +} + +export {Image as default}; \ No newline at end of file