diff --git a/js/index.js b/js/index.js index 3bd6c2e..374fabb 100644 --- a/js/index.js +++ b/js/index.js @@ -3,10 +3,12 @@ function restore_options() { console.log("Loading Settings", result) var quads = document.getElementsByClassName("quadrant") var style = document.createElement("style") - if (!(typeof result === 'undefined')) { - if (!(typeof result.links)) result.links = [] - if (!(typeof result.colors)) result.colors = [] - if (!(typeof result.mode)) result.mode = "light" + if (!(typeof result === "undefined")) { + if (!(typeof result.links === "object")) result.links = [] + if (!Array.isArray(result.links)) result.links = [] + if (!(typeof result.colors === "object")) result.colors = [] + if (!Array.isArray(result.colors)) result.colors = [] + if (!(typeof result.mode) === "string") result.mode = "light" for (i = 0; i < quads.length; i++) { if (i < result.links.length) { var link = result.links[i] diff --git a/js/options.js b/js/options.js index a7b7cfe..62a7b0e 100644 --- a/js/options.js +++ b/js/options.js @@ -22,9 +22,11 @@ function restore_options() { var input_links = document.querySelectorAll('input[type="text"]') var input_colors = document.querySelectorAll('input[type="color"]') if (!(typeof result === 'undefined')) { - if (!(typeof result.links)) result.links = [] - if (!(typeof result.colors)) result.colors = [] - if (!(typeof result.mode)) result.mode = "light" + if (!(typeof result.links === "object")) result.links = [] + if (!Array.isArray(result.links)) result.links = [] + if (!(typeof result.colors === "object")) result.colors = [] + if (!Array.isArray(result.colors)) result.colors = [] + if (!(typeof result.mode) === "string") result.mode = "light" for (i = 0; i < input_links.length; i++) { if (i < result.links.length) { input_links[i].value = result.links[i]