diff --git a/.eslintrc.json b/.eslintrc.json index 00d7d26a..f3f1c8e1 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -12,7 +12,7 @@ }, "rules": { "indent": ["error", 2], - "quotes": ["error", "double"], + "quotes": ["error", "single"], "semi": ["error", "always"] } } \ No newline at end of file diff --git a/public/backgrounds/background.js b/public/backgrounds/background.js index 5c3ea234..68490476 100644 --- a/public/backgrounds/background.js +++ b/public/backgrounds/background.js @@ -1,29 +1,29 @@ // Open the database const openDB = () => { return new Promise((resolve, reject) => { - const request = indexedDB.open("MyDatabase", 1); + const request = indexedDB.open('MyDatabase', 1); request.onerror = () => reject(request.error); request.onsuccess = () => resolve(request.result); request.onupgradeneeded = (event) => { const db = event.target.result; - db.createObjectStore("backgrounds", { keyPath: "id" }); + db.createObjectStore('backgrounds', { keyPath: 'id' }); }; }); }; // Modified Read Data from IndexedDB const readData = async () => { - const selectedBackground = localStorage.getItem("selectedBackground"); + const selectedBackground = localStorage.getItem('selectedBackground'); if (!selectedBackground) { - console.log("No selected background in local storage."); + console.log('No selected background in local storage.'); return null; } const db = await openDB(); - const tx = db.transaction("backgrounds", "readonly"); - const store = tx.objectStore("backgrounds"); + const tx = db.transaction('backgrounds', 'readonly'); + const store = tx.objectStore('backgrounds'); const request = store.get(selectedBackground); return await new Promise((resolve, reject) => { @@ -36,10 +36,10 @@ const updateBackground = async () => { try { const data = await readData(); if (!data) { - console.log("No data found in IndexedDB."); + console.log('No data found in IndexedDB.'); - const container = document.getElementById("media-container"); - const currentMedia = container.querySelector(".current-media"); + const container = document.getElementById('media-container'); + const currentMedia = container.querySelector('.current-media'); if (currentMedia) { currentMedia.remove(); } @@ -47,16 +47,16 @@ const updateBackground = async () => { } const url = URL.createObjectURL(data.blob); - const container = document.getElementById("media-container"); + const container = document.getElementById('media-container'); // Create new element and set properties let newElement; - if (data.type === "image") { - newElement = document.createElement("img"); + if (data.type === 'image') { + newElement = document.createElement('img'); newElement.src = url; - newElement.alt = "Uploaded content"; - } else if (data.type === "video") { - newElement = document.createElement("video"); + newElement.alt = 'Uploaded content'; + } else if (data.type === 'video') { + newElement = document.createElement('video'); newElement.src = url; newElement.autoplay = true; newElement.loop = true; @@ -64,25 +64,25 @@ const updateBackground = async () => { } // Mark the old element for removal - const oldElement = container.querySelector(".current-media"); + const oldElement = container.querySelector('.current-media'); if (oldElement) { - oldElement.classList.remove("current-media"); - oldElement.classList.add("old-media"); + oldElement.classList.remove('current-media'); + oldElement.classList.add('old-media'); } // Add the new element and mark it as current - newElement.classList.add("current-media"); + newElement.classList.add('current-media'); container.appendChild(newElement); // Delay removal of old element setTimeout(() => { - const oldMedia = container.querySelector(".old-media"); + const oldMedia = container.querySelector('.old-media'); if (oldMedia) { oldMedia.remove(); } }, 100); // 0.1 second delay } catch (error) { - console.error("An error occurred:", error); + console.error('An error occurred:', error); } }; @@ -91,12 +91,12 @@ const main = async () => { await updateBackground(); // Initial background update // Listen for changes to local storage - window.addEventListener("storage", async (event) => { - if (event.key === "selectedBackground") { + window.addEventListener('storage', async (event) => { + if (event.key === 'selectedBackground') { await updateBackground(); // Update background if 'selectedBackground' changes } }); }; // Run the main function when the document is ready -document.addEventListener("DOMContentLoaded", main); +document.addEventListener('DOMContentLoaded', main); diff --git a/public/purify.min.js b/public/purify.min.js index f1550f5a..32954ef5 100644 --- a/public/purify.min.js +++ b/public/purify.min.js @@ -1,14 +1,14 @@ /*! @license DOMPurify 3.0.3 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.0.3/LICENSE */ !(function (e, t) { - "object" == typeof exports && "undefined" != typeof module + 'object' == typeof exports && 'undefined' != typeof module ? (module.exports = t()) - : "function" == typeof define && define.amd - ? define(t) - : ((e = - "undefined" != typeof globalThis ? globalThis : e || self).DOMPurify = + : 'function' == typeof define && define.amd + ? define(t) + : ((e = + 'undefined' != typeof globalThis ? globalThis : e || self).DOMPurify = t()); })(this, function () { - "use strict"; + 'use strict'; const { entries: e, setPrototypeOf: t, @@ -17,20 +17,20 @@ getOwnPropertyDescriptor: r, } = Object; let { freeze: i, seal: a, create: l } = Object, - { apply: c, construct: s } = "undefined" != typeof Reflect && Reflect; + { apply: c, construct: s } = 'undefined' != typeof Reflect && Reflect; c || (c = function (e, t, n) { return e.apply(t, n); }), - i || + i || (i = function (e) { return e; }), - a || + a || (a = function (e) { return e; }), - s || + s || (s = function (e, t) { return new e(...t); }); @@ -69,7 +69,7 @@ let a = o.length; for (; a--; ) { let t = o[a]; - if ("string" == typeof t) { + if ('string' == typeof t) { const e = r(t); e !== t && (n(o) || (o[a] = e), (t = e)); } @@ -87,630 +87,630 @@ const n = r(e, t); if (n) { if (n.get) return b(n.get); - if ("function" == typeof n.value) return b(n.value); + if ('function' == typeof n.value) return b(n.value); } e = o(e); } return function (e) { - return console.warn("fallback value for", e), null; + return console.warn('fallback value for', e), null; }; } const w = i([ - "a", - "abbr", - "acronym", - "address", - "area", - "article", - "aside", - "audio", - "b", - "bdi", - "bdo", - "big", - "blink", - "blockquote", - "body", - "br", - "button", - "canvas", - "caption", - "center", - "cite", - "code", - "col", - "colgroup", - "content", - "data", - "datalist", - "dd", - "decorator", - "del", - "details", - "dfn", - "dialog", - "dir", - "div", - "dl", - "dt", - "element", - "em", - "fieldset", - "figcaption", - "figure", - "font", - "footer", - "form", - "h1", - "h2", - "h3", - "h4", - "h5", - "h6", - "head", - "header", - "hgroup", - "hr", - "html", - "i", - "img", - "input", - "ins", - "kbd", - "label", - "legend", - "li", - "main", - "map", - "mark", - "marquee", - "menu", - "menuitem", - "meter", - "nav", - "nobr", - "ol", - "optgroup", - "option", - "output", - "p", - "picture", - "pre", - "progress", - "q", - "rp", - "rt", - "ruby", - "s", - "samp", - "section", - "select", - "shadow", - "small", - "source", - "spacer", - "span", - "strike", - "strong", - "style", - "sub", - "summary", - "sup", - "table", - "tbody", - "td", - "template", - "textarea", - "tfoot", - "th", - "thead", - "time", - "tr", - "track", - "tt", - "u", - "ul", - "var", - "video", - "wbr", + 'a', + 'abbr', + 'acronym', + 'address', + 'area', + 'article', + 'aside', + 'audio', + 'b', + 'bdi', + 'bdo', + 'big', + 'blink', + 'blockquote', + 'body', + 'br', + 'button', + 'canvas', + 'caption', + 'center', + 'cite', + 'code', + 'col', + 'colgroup', + 'content', + 'data', + 'datalist', + 'dd', + 'decorator', + 'del', + 'details', + 'dfn', + 'dialog', + 'dir', + 'div', + 'dl', + 'dt', + 'element', + 'em', + 'fieldset', + 'figcaption', + 'figure', + 'font', + 'footer', + 'form', + 'h1', + 'h2', + 'h3', + 'h4', + 'h5', + 'h6', + 'head', + 'header', + 'hgroup', + 'hr', + 'html', + 'i', + 'img', + 'input', + 'ins', + 'kbd', + 'label', + 'legend', + 'li', + 'main', + 'map', + 'mark', + 'marquee', + 'menu', + 'menuitem', + 'meter', + 'nav', + 'nobr', + 'ol', + 'optgroup', + 'option', + 'output', + 'p', + 'picture', + 'pre', + 'progress', + 'q', + 'rp', + 'rt', + 'ruby', + 's', + 'samp', + 'section', + 'select', + 'shadow', + 'small', + 'source', + 'spacer', + 'span', + 'strike', + 'strong', + 'style', + 'sub', + 'summary', + 'sup', + 'table', + 'tbody', + 'td', + 'template', + 'textarea', + 'tfoot', + 'th', + 'thead', + 'time', + 'tr', + 'track', + 'tt', + 'u', + 'ul', + 'var', + 'video', + 'wbr', ]), D = i([ - "svg", - "a", - "altglyph", - "altglyphdef", - "altglyphitem", - "animatecolor", - "animatemotion", - "animatetransform", - "circle", - "clippath", - "defs", - "desc", - "ellipse", - "filter", - "font", - "g", - "glyph", - "glyphref", - "hkern", - "image", - "line", - "lineargradient", - "marker", - "mask", - "metadata", - "mpath", - "path", - "pattern", - "polygon", - "polyline", - "radialgradient", - "rect", - "stop", - "style", - "switch", - "symbol", - "text", - "textpath", - "title", - "tref", - "tspan", - "view", - "vkern", + 'svg', + 'a', + 'altglyph', + 'altglyphdef', + 'altglyphitem', + 'animatecolor', + 'animatemotion', + 'animatetransform', + 'circle', + 'clippath', + 'defs', + 'desc', + 'ellipse', + 'filter', + 'font', + 'g', + 'glyph', + 'glyphref', + 'hkern', + 'image', + 'line', + 'lineargradient', + 'marker', + 'mask', + 'metadata', + 'mpath', + 'path', + 'pattern', + 'polygon', + 'polyline', + 'radialgradient', + 'rect', + 'stop', + 'style', + 'switch', + 'symbol', + 'text', + 'textpath', + 'title', + 'tref', + 'tspan', + 'view', + 'vkern', ]), L = i([ - "feBlend", - "feColorMatrix", - "feComponentTransfer", - "feComposite", - "feConvolveMatrix", - "feDiffuseLighting", - "feDisplacementMap", - "feDistantLight", - "feDropShadow", - "feFlood", - "feFuncA", - "feFuncB", - "feFuncG", - "feFuncR", - "feGaussianBlur", - "feImage", - "feMerge", - "feMergeNode", - "feMorphology", - "feOffset", - "fePointLight", - "feSpecularLighting", - "feSpotLight", - "feTile", - "feTurbulence", + 'feBlend', + 'feColorMatrix', + 'feComponentTransfer', + 'feComposite', + 'feConvolveMatrix', + 'feDiffuseLighting', + 'feDisplacementMap', + 'feDistantLight', + 'feDropShadow', + 'feFlood', + 'feFuncA', + 'feFuncB', + 'feFuncG', + 'feFuncR', + 'feGaussianBlur', + 'feImage', + 'feMerge', + 'feMergeNode', + 'feMorphology', + 'feOffset', + 'fePointLight', + 'feSpecularLighting', + 'feSpotLight', + 'feTile', + 'feTurbulence', ]), v = i([ - "animate", - "color-profile", - "cursor", - "discard", - "font-face", - "font-face-format", - "font-face-name", - "font-face-src", - "font-face-uri", - "foreignobject", - "hatch", - "hatchpath", - "mesh", - "meshgradient", - "meshpatch", - "meshrow", - "missing-glyph", - "script", - "set", - "solidcolor", - "unknown", - "use", + 'animate', + 'color-profile', + 'cursor', + 'discard', + 'font-face', + 'font-face-format', + 'font-face-name', + 'font-face-src', + 'font-face-uri', + 'foreignobject', + 'hatch', + 'hatchpath', + 'mesh', + 'meshgradient', + 'meshpatch', + 'meshrow', + 'missing-glyph', + 'script', + 'set', + 'solidcolor', + 'unknown', + 'use', ]), x = i([ - "math", - "menclose", - "merror", - "mfenced", - "mfrac", - "mglyph", - "mi", - "mlabeledtr", - "mmultiscripts", - "mn", - "mo", - "mover", - "mpadded", - "mphantom", - "mroot", - "mrow", - "ms", - "mspace", - "msqrt", - "mstyle", - "msub", - "msup", - "msubsup", - "mtable", - "mtd", - "mtext", - "mtr", - "munder", - "munderover", - "mprescripts", + 'math', + 'menclose', + 'merror', + 'mfenced', + 'mfrac', + 'mglyph', + 'mi', + 'mlabeledtr', + 'mmultiscripts', + 'mn', + 'mo', + 'mover', + 'mpadded', + 'mphantom', + 'mroot', + 'mrow', + 'ms', + 'mspace', + 'msqrt', + 'mstyle', + 'msub', + 'msup', + 'msubsup', + 'mtable', + 'mtd', + 'mtext', + 'mtr', + 'munder', + 'munderover', + 'mprescripts', ]), C = i([ - "maction", - "maligngroup", - "malignmark", - "mlongdiv", - "mscarries", - "mscarry", - "msgroup", - "mstack", - "msline", - "msrow", - "semantics", - "annotation", - "annotation-xml", - "mprescripts", - "none", + 'maction', + 'maligngroup', + 'malignmark', + 'mlongdiv', + 'mscarries', + 'mscarry', + 'msgroup', + 'mstack', + 'msline', + 'msrow', + 'semantics', + 'annotation', + 'annotation-xml', + 'mprescripts', + 'none', ]), - k = i(["#text"]), + k = i(['#text']), O = i([ - "accept", - "action", - "align", - "alt", - "autocapitalize", - "autocomplete", - "autopictureinpicture", - "autoplay", - "background", - "bgcolor", - "border", - "capture", - "cellpadding", - "cellspacing", - "checked", - "cite", - "class", - "clear", - "color", - "cols", - "colspan", - "controls", - "controlslist", - "coords", - "crossorigin", - "datetime", - "decoding", - "default", - "dir", - "disabled", - "disablepictureinpicture", - "disableremoteplayback", - "download", - "draggable", - "enctype", - "enterkeyhint", - "face", - "for", - "headers", - "height", - "hidden", - "high", - "href", - "hreflang", - "id", - "inputmode", - "integrity", - "ismap", - "kind", - "label", - "lang", - "list", - "loading", - "loop", - "low", - "max", - "maxlength", - "media", - "method", - "min", - "minlength", - "multiple", - "muted", - "name", - "nonce", - "noshade", - "novalidate", - "nowrap", - "open", - "optimum", - "pattern", - "placeholder", - "playsinline", - "poster", - "preload", - "pubdate", - "radiogroup", - "readonly", - "rel", - "required", - "rev", - "reversed", - "role", - "rows", - "rowspan", - "spellcheck", - "scope", - "selected", - "shape", - "size", - "sizes", - "span", - "srclang", - "start", - "src", - "srcset", - "step", - "style", - "summary", - "tabindex", - "title", - "translate", - "type", - "usemap", - "valign", - "value", - "width", - "xmlns", - "slot", + 'accept', + 'action', + 'align', + 'alt', + 'autocapitalize', + 'autocomplete', + 'autopictureinpicture', + 'autoplay', + 'background', + 'bgcolor', + 'border', + 'capture', + 'cellpadding', + 'cellspacing', + 'checked', + 'cite', + 'class', + 'clear', + 'color', + 'cols', + 'colspan', + 'controls', + 'controlslist', + 'coords', + 'crossorigin', + 'datetime', + 'decoding', + 'default', + 'dir', + 'disabled', + 'disablepictureinpicture', + 'disableremoteplayback', + 'download', + 'draggable', + 'enctype', + 'enterkeyhint', + 'face', + 'for', + 'headers', + 'height', + 'hidden', + 'high', + 'href', + 'hreflang', + 'id', + 'inputmode', + 'integrity', + 'ismap', + 'kind', + 'label', + 'lang', + 'list', + 'loading', + 'loop', + 'low', + 'max', + 'maxlength', + 'media', + 'method', + 'min', + 'minlength', + 'multiple', + 'muted', + 'name', + 'nonce', + 'noshade', + 'novalidate', + 'nowrap', + 'open', + 'optimum', + 'pattern', + 'placeholder', + 'playsinline', + 'poster', + 'preload', + 'pubdate', + 'radiogroup', + 'readonly', + 'rel', + 'required', + 'rev', + 'reversed', + 'role', + 'rows', + 'rowspan', + 'spellcheck', + 'scope', + 'selected', + 'shape', + 'size', + 'sizes', + 'span', + 'srclang', + 'start', + 'src', + 'srcset', + 'step', + 'style', + 'summary', + 'tabindex', + 'title', + 'translate', + 'type', + 'usemap', + 'valign', + 'value', + 'width', + 'xmlns', + 'slot', ]), I = i([ - "accent-height", - "accumulate", - "additive", - "alignment-baseline", - "ascent", - "attributename", - "attributetype", - "azimuth", - "basefrequency", - "baseline-shift", - "begin", - "bias", - "by", - "class", - "clip", - "clippathunits", - "clip-path", - "clip-rule", - "color", - "color-interpolation", - "color-interpolation-filters", - "color-profile", - "color-rendering", - "cx", - "cy", - "d", - "dx", - "dy", - "diffuseconstant", - "direction", - "display", - "divisor", - "dur", - "edgemode", - "elevation", - "end", - "fill", - "fill-opacity", - "fill-rule", - "filter", - "filterunits", - "flood-color", - "flood-opacity", - "font-family", - "font-size", - "font-size-adjust", - "font-stretch", - "font-style", - "font-variant", - "font-weight", - "fx", - "fy", - "g1", - "g2", - "glyph-name", - "glyphref", - "gradientunits", - "gradienttransform", - "height", - "href", - "id", - "image-rendering", - "in", - "in2", - "k", - "k1", - "k2", - "k3", - "k4", - "kerning", - "keypoints", - "keysplines", - "keytimes", - "lang", - "lengthadjust", - "letter-spacing", - "kernelmatrix", - "kernelunitlength", - "lighting-color", - "local", - "marker-end", - "marker-mid", - "marker-start", - "markerheight", - "markerunits", - "markerwidth", - "maskcontentunits", - "maskunits", - "max", - "mask", - "media", - "method", - "mode", - "min", - "name", - "numoctaves", - "offset", - "operator", - "opacity", - "order", - "orient", - "orientation", - "origin", - "overflow", - "paint-order", - "path", - "pathlength", - "patterncontentunits", - "patterntransform", - "patternunits", - "points", - "preservealpha", - "preserveaspectratio", - "primitiveunits", - "r", - "rx", - "ry", - "radius", - "refx", - "refy", - "repeatcount", - "repeatdur", - "restart", - "result", - "rotate", - "scale", - "seed", - "shape-rendering", - "specularconstant", - "specularexponent", - "spreadmethod", - "startoffset", - "stddeviation", - "stitchtiles", - "stop-color", - "stop-opacity", - "stroke-dasharray", - "stroke-dashoffset", - "stroke-linecap", - "stroke-linejoin", - "stroke-miterlimit", - "stroke-opacity", - "stroke", - "stroke-width", - "style", - "surfacescale", - "systemlanguage", - "tabindex", - "targetx", - "targety", - "transform", - "transform-origin", - "text-anchor", - "text-decoration", - "text-rendering", - "textlength", - "type", - "u1", - "u2", - "unicode", - "values", - "viewbox", - "visibility", - "version", - "vert-adv-y", - "vert-origin-x", - "vert-origin-y", - "width", - "word-spacing", - "wrap", - "writing-mode", - "xchannelselector", - "ychannelselector", - "x", - "x1", - "x2", - "xmlns", - "y", - "y1", - "y2", - "z", - "zoomandpan", + 'accent-height', + 'accumulate', + 'additive', + 'alignment-baseline', + 'ascent', + 'attributename', + 'attributetype', + 'azimuth', + 'basefrequency', + 'baseline-shift', + 'begin', + 'bias', + 'by', + 'class', + 'clip', + 'clippathunits', + 'clip-path', + 'clip-rule', + 'color', + 'color-interpolation', + 'color-interpolation-filters', + 'color-profile', + 'color-rendering', + 'cx', + 'cy', + 'd', + 'dx', + 'dy', + 'diffuseconstant', + 'direction', + 'display', + 'divisor', + 'dur', + 'edgemode', + 'elevation', + 'end', + 'fill', + 'fill-opacity', + 'fill-rule', + 'filter', + 'filterunits', + 'flood-color', + 'flood-opacity', + 'font-family', + 'font-size', + 'font-size-adjust', + 'font-stretch', + 'font-style', + 'font-variant', + 'font-weight', + 'fx', + 'fy', + 'g1', + 'g2', + 'glyph-name', + 'glyphref', + 'gradientunits', + 'gradienttransform', + 'height', + 'href', + 'id', + 'image-rendering', + 'in', + 'in2', + 'k', + 'k1', + 'k2', + 'k3', + 'k4', + 'kerning', + 'keypoints', + 'keysplines', + 'keytimes', + 'lang', + 'lengthadjust', + 'letter-spacing', + 'kernelmatrix', + 'kernelunitlength', + 'lighting-color', + 'local', + 'marker-end', + 'marker-mid', + 'marker-start', + 'markerheight', + 'markerunits', + 'markerwidth', + 'maskcontentunits', + 'maskunits', + 'max', + 'mask', + 'media', + 'method', + 'mode', + 'min', + 'name', + 'numoctaves', + 'offset', + 'operator', + 'opacity', + 'order', + 'orient', + 'orientation', + 'origin', + 'overflow', + 'paint-order', + 'path', + 'pathlength', + 'patterncontentunits', + 'patterntransform', + 'patternunits', + 'points', + 'preservealpha', + 'preserveaspectratio', + 'primitiveunits', + 'r', + 'rx', + 'ry', + 'radius', + 'refx', + 'refy', + 'repeatcount', + 'repeatdur', + 'restart', + 'result', + 'rotate', + 'scale', + 'seed', + 'shape-rendering', + 'specularconstant', + 'specularexponent', + 'spreadmethod', + 'startoffset', + 'stddeviation', + 'stitchtiles', + 'stop-color', + 'stop-opacity', + 'stroke-dasharray', + 'stroke-dashoffset', + 'stroke-linecap', + 'stroke-linejoin', + 'stroke-miterlimit', + 'stroke-opacity', + 'stroke', + 'stroke-width', + 'style', + 'surfacescale', + 'systemlanguage', + 'tabindex', + 'targetx', + 'targety', + 'transform', + 'transform-origin', + 'text-anchor', + 'text-decoration', + 'text-rendering', + 'textlength', + 'type', + 'u1', + 'u2', + 'unicode', + 'values', + 'viewbox', + 'visibility', + 'version', + 'vert-adv-y', + 'vert-origin-x', + 'vert-origin-y', + 'width', + 'word-spacing', + 'wrap', + 'writing-mode', + 'xchannelselector', + 'ychannelselector', + 'x', + 'x1', + 'x2', + 'xmlns', + 'y', + 'y1', + 'y2', + 'z', + 'zoomandpan', ]), M = i([ - "accent", - "accentunder", - "align", - "bevelled", - "close", - "columnsalign", - "columnlines", - "columnspan", - "denomalign", - "depth", - "dir", - "display", - "displaystyle", - "encoding", - "fence", - "frame", - "height", - "href", - "id", - "largeop", - "length", - "linethickness", - "lspace", - "lquote", - "mathbackground", - "mathcolor", - "mathsize", - "mathvariant", - "maxsize", - "minsize", - "movablelimits", - "notation", - "numalign", - "open", - "rowalign", - "rowlines", - "rowspacing", - "rowspan", - "rspace", - "rquote", - "scriptlevel", - "scriptminsize", - "scriptsizemultiplier", - "selection", - "separator", - "separators", - "stretchy", - "subscriptshift", - "supscriptshift", - "symmetric", - "voffset", - "width", - "xmlns", + 'accent', + 'accentunder', + 'align', + 'bevelled', + 'close', + 'columnsalign', + 'columnlines', + 'columnspan', + 'denomalign', + 'depth', + 'dir', + 'display', + 'displaystyle', + 'encoding', + 'fence', + 'frame', + 'height', + 'href', + 'id', + 'largeop', + 'length', + 'linethickness', + 'lspace', + 'lquote', + 'mathbackground', + 'mathcolor', + 'mathsize', + 'mathvariant', + 'maxsize', + 'minsize', + 'movablelimits', + 'notation', + 'numalign', + 'open', + 'rowalign', + 'rowlines', + 'rowspacing', + 'rowspan', + 'rspace', + 'rquote', + 'scriptlevel', + 'scriptminsize', + 'scriptsizemultiplier', + 'selection', + 'separator', + 'separators', + 'stretchy', + 'subscriptshift', + 'supscriptshift', + 'symmetric', + 'voffset', + 'width', + 'xmlns', ]), - U = i(["xlink:href", "xml:id", "xlink:title", "xml:space", "xmlns:xlink"]), + U = i(['xlink:href', 'xml:id', 'xlink:title', 'xml:space', 'xmlns:xlink']), P = a(/\{\{[\w\W]*|[\w\W]*\}\}/gm), F = a(/<%[\w\W]*|[\w\W]*%>/gm), H = a(/\${[\w\W]*}/gm), @@ -734,14 +734,14 @@ ATTR_WHITESPACE: Y, DOCTYPE_NAME: j, }); - const X = () => ("undefined" == typeof window ? null : window), + const X = () => ('undefined' == typeof window ? null : window), K = function (e, t) { - if ("object" != typeof e || "function" != typeof e.createPolicy) + if ('object' != typeof e || 'function' != typeof e.createPolicy) return null; let n = null; - const o = "data-tt-policy-suffix"; + const o = 'data-tt-policy-suffix'; t && t.hasAttribute(o) && (n = t.getAttribute(o)); - const r = "dompurify" + (n ? "#" + n : ""); + const r = 'dompurify' + (n ? '#' + n : ''); try { return e.createPolicy(r, { createHTML: (e) => e, @@ -749,7 +749,7 @@ }); } catch (e) { return ( - console.warn("TrustedTypes policy " + r + " could not be created."), + console.warn('TrustedTypes policy ' + r + ' could not be created.'), null ); } @@ -759,7 +759,7 @@ arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : X(); const o = (e) => t(e); if ( - ((o.version = "3.0.3"), + ((o.version = '3.0.3'), (o.removed = []), !n || !n.document || 9 !== n.document.nodeType) ) @@ -779,16 +779,16 @@ trustedTypes: B, } = n, G = b.prototype, - Y = R(G, "cloneNode"), - V = R(G, "nextSibling"), - $ = R(G, "childNodes"), - Z = R(G, "parentNode"); - if ("function" == typeof s) { - const e = l.createElement("template"); + Y = R(G, 'cloneNode'), + V = R(G, 'nextSibling'), + $ = R(G, 'childNodes'), + Z = R(G, 'parentNode'); + if ('function' == typeof s) { + const e = l.createElement('template'); e.content && e.content.ownerDocument && (l = e.content.ownerDocument); } let J, - Q = ""; + Q = ''; const { implementation: ee, createNodeIterator: te, @@ -798,8 +798,8 @@ { importNode: re } = r; let ie = {}; o.isSupported = - "function" == typeof e && - "function" == typeof Z && + 'function' == typeof e && + 'function' == typeof Z && ee && void 0 !== ee.createHTMLDocument; const { @@ -853,99 +853,99 @@ Ce = !1, ke = !0, Oe = !1; - const Ie = "user-content-"; + const Ie = 'user-content-'; let Me = !0, Ue = !1, Pe = {}, Fe = null; const He = N({}, [ - "annotation-xml", - "audio", - "colgroup", - "desc", - "foreignobject", - "head", - "iframe", - "math", - "mi", - "mn", - "mo", - "ms", - "mtext", - "noembed", - "noframes", - "noscript", - "plaintext", - "script", - "style", - "svg", - "template", - "thead", - "title", - "video", - "xmp", + 'annotation-xml', + 'audio', + 'colgroup', + 'desc', + 'foreignobject', + 'head', + 'iframe', + 'math', + 'mi', + 'mn', + 'mo', + 'ms', + 'mtext', + 'noembed', + 'noframes', + 'noscript', + 'plaintext', + 'script', + 'style', + 'svg', + 'template', + 'thead', + 'title', + 'video', + 'xmp', ]); let ze = null; - const Be = N({}, ["audio", "video", "img", "source", "image", "track"]); + const Be = N({}, ['audio', 'video', 'img', 'source', 'image', 'track']); let We = null; const Ge = N({}, [ - "alt", - "class", - "for", - "id", - "label", - "name", - "pattern", - "placeholder", - "role", - "summary", - "title", - "value", - "style", - "xmlns", + 'alt', + 'class', + 'for', + 'id', + 'label', + 'name', + 'pattern', + 'placeholder', + 'role', + 'summary', + 'title', + 'value', + 'style', + 'xmlns', ]), - Ye = "http://www.w3.org/1998/Math/MathML", - je = "http://www.w3.org/2000/svg", - qe = "http://www.w3.org/1999/xhtml"; + Ye = 'http://www.w3.org/1998/Math/MathML', + je = 'http://www.w3.org/2000/svg', + qe = 'http://www.w3.org/1999/xhtml'; let Xe = qe, Ke = !1, Ve = null; const $e = N({}, [Ye, je, qe], d); let Ze; - const Je = ["application/xhtml+xml", "text/html"], - Qe = "text/html"; + const Je = ['application/xhtml+xml', 'text/html'], + Qe = 'text/html'; let et, tt = null; - const nt = l.createElement("form"), + const nt = l.createElement('form'), ot = function (e) { return e instanceof RegExp || e instanceof Function; }, rt = function (e) { if (!tt || tt !== e) { if ( - ((e && "object" == typeof e) || (e = {}), + ((e && 'object' == typeof e) || (e = {}), (e = S(e)), (Ze = Ze = -1 === Je.indexOf(e.PARSER_MEDIA_TYPE) ? Qe : e.PARSER_MEDIA_TYPE), - (et = "application/xhtml+xml" === Ze ? d : p), - (de = "ALLOWED_TAGS" in e ? N({}, e.ALLOWED_TAGS, et) : he), - (ge = "ALLOWED_ATTR" in e ? N({}, e.ALLOWED_ATTR, et) : Te), + (et = 'application/xhtml+xml' === Ze ? d : p), + (de = 'ALLOWED_TAGS' in e ? N({}, e.ALLOWED_TAGS, et) : he), + (ge = 'ALLOWED_ATTR' in e ? N({}, e.ALLOWED_ATTR, et) : Te), (Ve = - "ALLOWED_NAMESPACES" in e ? N({}, e.ALLOWED_NAMESPACES, d) : $e), + 'ALLOWED_NAMESPACES' in e ? N({}, e.ALLOWED_NAMESPACES, d) : $e), (We = - "ADD_URI_SAFE_ATTR" in e + 'ADD_URI_SAFE_ATTR' in e ? N(S(Ge), e.ADD_URI_SAFE_ATTR, et) : Ge), (ze = - "ADD_DATA_URI_TAGS" in e + 'ADD_DATA_URI_TAGS' in e ? N(S(Be), e.ADD_DATA_URI_TAGS, et) : Be), - (Fe = "FORBID_CONTENTS" in e ? N({}, e.FORBID_CONTENTS, et) : He), - (Ee = "FORBID_TAGS" in e ? N({}, e.FORBID_TAGS, et) : {}), - (Ae = "FORBID_ATTR" in e ? N({}, e.FORBID_ATTR, et) : {}), - (Pe = "USE_PROFILES" in e && e.USE_PROFILES), + (Fe = 'FORBID_CONTENTS' in e ? N({}, e.FORBID_CONTENTS, et) : He), + (Ee = 'FORBID_TAGS' in e ? N({}, e.FORBID_TAGS, et) : {}), + (Ae = 'FORBID_ATTR' in e ? N({}, e.FORBID_ATTR, et) : {}), + (Pe = 'USE_PROFILES' in e && e.USE_PROFILES), (_e = !1 !== e.ALLOW_ARIA_ATTR), (be = !1 !== e.ALLOW_DATA_ATTR), (Ne = e.ALLOW_UNKNOWN_PROTOCOLS || !1), @@ -971,7 +971,7 @@ (ye.attributeNameCheck = e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck), e.CUSTOM_ELEMENT_HANDLING && - "boolean" == + 'boolean' == typeof e.CUSTOM_ELEMENT_HANDLING .allowCustomizedBuiltInElements && (ye.allowCustomizedBuiltInElements = @@ -990,58 +990,58 @@ e.ADD_URI_SAFE_ATTR && N(We, e.ADD_URI_SAFE_ATTR, et), e.FORBID_CONTENTS && (Fe === He && (Fe = S(Fe)), N(Fe, e.FORBID_CONTENTS, et)), - Me && (de["#text"] = !0), - we && N(de, ["html", "head", "body"]), - de.table && (N(de, ["tbody"]), delete Ee.tbody), + Me && (de['#text'] = !0), + we && N(de, ['html', 'head', 'body']), + de.table && (N(de, ['tbody']), delete Ee.tbody), e.TRUSTED_TYPES_POLICY) ) { - if ("function" != typeof e.TRUSTED_TYPES_POLICY.createHTML) + if ('function' != typeof e.TRUSTED_TYPES_POLICY.createHTML) throw A( 'TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.', ); - if ("function" != typeof e.TRUSTED_TYPES_POLICY.createScriptURL) + if ('function' != typeof e.TRUSTED_TYPES_POLICY.createScriptURL) throw A( 'TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.', ); - (J = e.TRUSTED_TYPES_POLICY), (Q = J.createHTML("")); + (J = e.TRUSTED_TYPES_POLICY), (Q = J.createHTML('')); } else void 0 === J && (J = K(B, a)), - null !== J && "string" == typeof Q && (Q = J.createHTML("")); + null !== J && 'string' == typeof Q && (Q = J.createHTML('')); i && i(e), (tt = e); } }, - it = N({}, ["mi", "mo", "mn", "ms", "mtext"]), - at = N({}, ["foreignobject", "desc", "title", "annotation-xml"]), - lt = N({}, ["title", "style", "font", "a", "script"]), + it = N({}, ['mi', 'mo', 'mn', 'ms', 'mtext']), + at = N({}, ['foreignobject', 'desc', 'title', 'annotation-xml']), + lt = N({}, ['title', 'style', 'font', 'a', 'script']), ct = N({}, D); N(ct, L), N(ct, v); const st = N({}, x); N(st, C); const mt = function (e) { let t = Z(e); - (t && t.tagName) || (t = { namespaceURI: Xe, tagName: "template" }); + (t && t.tagName) || (t = { namespaceURI: Xe, tagName: 'template' }); const n = p(e.tagName), o = p(t.tagName); return ( !!Ve[e.namespaceURI] && (e.namespaceURI === je ? t.namespaceURI === qe - ? "svg" === n + ? 'svg' === n : t.namespaceURI === Ye - ? "svg" === n && ("annotation-xml" === o || it[o]) - : Boolean(ct[n]) + ? 'svg' === n && ('annotation-xml' === o || it[o]) + : Boolean(ct[n]) : e.namespaceURI === Ye - ? t.namespaceURI === qe - ? "math" === n - : t.namespaceURI === je - ? "math" === n && at[o] - : Boolean(st[n]) - : e.namespaceURI === qe - ? !(t.namespaceURI === je && !at[o]) && + ? t.namespaceURI === qe + ? 'math' === n + : t.namespaceURI === je + ? 'math' === n && at[o] + : Boolean(st[n]) + : e.namespaceURI === qe + ? !(t.namespaceURI === je && !at[o]) && !(t.namespaceURI === Ye && !it[o]) && !st[n] && (lt[n] || !ct[n]) - : !("application/xhtml+xml" !== Ze || !Ve[e.namespaceURI])) + : !('application/xhtml+xml' !== Ze || !Ve[e.namespaceURI])) ); }, ut = function (e) { @@ -1058,36 +1058,36 @@ } catch (e) { f(o.removed, { attribute: null, from: t }); } - if ((t.removeAttribute(e), "is" === e && !ge[e])) + if ((t.removeAttribute(e), 'is' === e && !ge[e])) if (ve || xe) try { ut(t); } catch (e) {} else try { - t.setAttribute(e, ""); + t.setAttribute(e, ''); } catch (e) {} }, pt = function (e) { let t, n; - if (Le) e = "" + e; + if (Le) e = '' + e; else { const t = h(e, /^[\r\n\t ]+/); n = t && t[0]; } - "application/xhtml+xml" === Ze && + 'application/xhtml+xml' === Ze && Xe === qe && (e = '' + e + - ""); + ''); const o = J ? J.createHTML(e) : e; if (Xe === qe) try { t = new z().parseFromString(o, Ze); } catch (e) {} if (!t || !t.documentElement) { - t = ee.createDocument(Xe, "template", null); + t = ee.createDocument(Xe, 'template', null); try { t.documentElement.innerHTML = Ke ? Q : o; } catch (e) {} @@ -1098,10 +1098,10 @@ n && r.insertBefore(l.createTextNode(n), r.childNodes[0] || null), Xe === qe - ? oe.call(t, we ? "html" : "body")[0] + ? oe.call(t, we ? 'html' : 'body')[0] : we - ? t.documentElement - : r + ? t.documentElement + : r ); }, dt = function (e) { @@ -1116,24 +1116,24 @@ ht = function (e) { return ( e instanceof H && - ("string" != typeof e.nodeName || - "string" != typeof e.textContent || - "function" != typeof e.removeChild || + ('string' != typeof e.nodeName || + 'string' != typeof e.textContent || + 'function' != typeof e.removeChild || !(e.attributes instanceof F) || - "function" != typeof e.removeAttribute || - "function" != typeof e.setAttribute || - "string" != typeof e.namespaceURI || - "function" != typeof e.insertBefore || - "function" != typeof e.hasChildNodes) + 'function' != typeof e.removeAttribute || + 'function' != typeof e.setAttribute || + 'string' != typeof e.namespaceURI || + 'function' != typeof e.insertBefore || + 'function' != typeof e.hasChildNodes) ); }, gt = function (e) { - return "object" == typeof _ + return 'object' == typeof _ ? e instanceof _ : e && - "object" == typeof e && - "number" == typeof e.nodeType && - "string" == typeof e.nodeName; + 'object' == typeof e && + 'number' == typeof e.nodeType && + 'string' == typeof e.nodeName; }, Tt = function (e, t, n) { ie[e] && @@ -1143,10 +1143,10 @@ }, yt = function (e) { let t; - if ((Tt("beforeSanitizeElements", e, null), ht(e))) return ut(e), !0; + if ((Tt('beforeSanitizeElements', e, null), ht(e))) return ut(e), !0; const n = et(e.nodeName); if ( - (Tt("uponSanitizeElement", e, { tagName: n, allowedTags: de }), + (Tt('uponSanitizeElement', e, { tagName: n, allowedTags: de }), e.hasChildNodes() && !gt(e.firstElementChild) && (!gt(e.content) || !gt(e.content.firstElementChild)) && @@ -1173,23 +1173,23 @@ } return e instanceof b && !mt(e) ? (ut(e), !0) - : ("noscript" !== n && "noembed" !== n) || + : ('noscript' !== n && 'noembed' !== n) || !E(/<\/no(script|embed)/i, e.innerHTML) - ? (Re && + ? (Re && 3 === e.nodeType && ((t = e.textContent), - (t = g(t, ae, " ")), - (t = g(t, le, " ")), - (t = g(t, ce, " ")), + (t = g(t, ae, ' ')), + (t = g(t, le, ' ')), + (t = g(t, ce, ' ')), e.textContent !== t && (f(o.removed, { element: e.cloneNode() }), (e.textContent = t))), - Tt("afterSanitizeElements", e, null), + Tt('afterSanitizeElements', e, null), !1) - : (ut(e), !0); + : (ut(e), !0); }, Et = function (e, t, n) { - if (ke && ("id" === t || "name" === t) && (n in l || n in nt)) + if (ke && ('id' === t || 'name' === t) && (n in l || n in nt)) return !1; if (be && !Ae[t] && E(se, t)); else if (_e && E(me, t)); @@ -1204,7 +1204,7 @@ E(ye.attributeNameCheck, t)) || (ye.attributeNameCheck instanceof Function && ye.attributeNameCheck(t)))) || - ("is" === t && + ('is' === t && ye.allowCustomizedBuiltInElements && ((ye.tagNameCheck instanceof RegExp && E(ye.tagNameCheck, n)) || (ye.tagNameCheck instanceof Function && ye.tagNameCheck(n)))) @@ -1212,29 +1212,29 @@ ) return !1; } else if (We[t]); - else if (E(pe, g(n, fe, ""))); + else if (E(pe, g(n, fe, ''))); else if ( - ("src" !== t && "xlink:href" !== t && "href" !== t) || - "script" === e || - 0 !== T(n, "data:") || + ('src' !== t && 'xlink:href' !== t && 'href' !== t) || + 'script' === e || + 0 !== T(n, 'data:') || !ze[e] ) { - if (Ne && !E(ue, g(n, fe, ""))); + if (Ne && !E(ue, g(n, fe, ''))); else if (n) return !1; } else; return !0; }, At = function (e) { - return e.indexOf("-") > 0; + return e.indexOf('-') > 0; }, _t = function (e) { let t, n, r, i; - Tt("beforeSanitizeAttributes", e, null); + Tt('beforeSanitizeAttributes', e, null); const { attributes: a } = e; if (!a) return; const l = { - attrName: "", - attrValue: "", + attrName: '', + attrValue: '', keepAttr: !0, allowedAttributes: ge, }; @@ -1242,13 +1242,13 @@ t = a[i]; const { name: c, namespaceURI: s } = t; if ( - ((n = "value" === c ? t.value : y(t.value)), + ((n = 'value' === c ? t.value : y(t.value)), (r = et(c)), (l.attrName = r), (l.attrValue = n), (l.keepAttr = !0), (l.forceKeepAttr = void 0), - Tt("uponSanitizeAttribute", e, l), + Tt('uponSanitizeAttribute', e, l), (n = l.attrValue), l.forceKeepAttr) ) @@ -1258,39 +1258,39 @@ ft(c, e); continue; } - Re && ((n = g(n, ae, " ")), (n = g(n, le, " ")), (n = g(n, ce, " "))); + Re && ((n = g(n, ae, ' ')), (n = g(n, le, ' ')), (n = g(n, ce, ' '))); const m = et(e.nodeName); if (Et(m, r, n)) { if ( - (!Oe || ("id" !== r && "name" !== r) || (ft(c, e), (n = Ie + n)), + (!Oe || ('id' !== r && 'name' !== r) || (ft(c, e), (n = Ie + n)), J && - "object" == typeof B && - "function" == typeof B.getAttributeType) + 'object' == typeof B && + 'function' == typeof B.getAttributeType) ) if (s); else switch (B.getAttributeType(m, r)) { - case "TrustedHTML": - n = J.createHTML(n); - break; - case "TrustedScriptURL": - n = J.createScriptURL(n); + case 'TrustedHTML': + n = J.createHTML(n); + break; + case 'TrustedScriptURL': + n = J.createScriptURL(n); } try { s ? e.setAttributeNS(s, c, n) : e.setAttribute(c, n), - u(o.removed); + u(o.removed); } catch (e) {} } } - Tt("afterSanitizeAttributes", e, null); + Tt('afterSanitizeAttributes', e, null); }, bt = function e(t) { let n; const o = dt(t); - for (Tt("beforeSanitizeShadowDOM", t, null); (n = o.nextNode()); ) - Tt("uponSanitizeShadowNode", n, null), - yt(n) || (n.content instanceof c && e(n.content), _t(n)); - Tt("afterSanitizeShadowDOM", t, null); + for (Tt('beforeSanitizeShadowDOM', t, null); (n = o.nextNode()); ) + Tt('uponSanitizeShadowNode', n, null), + yt(n) || (n.content instanceof c && e(n.content), _t(n)); + Tt('afterSanitizeShadowDOM', t, null); }; return ( (o.sanitize = function (e) { @@ -1301,34 +1301,34 @@ l = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {}; if ( - ((Ke = !e), Ke && (e = "\x3c!--\x3e"), "string" != typeof e && !gt(e)) + ((Ke = !e), Ke && (e = '\x3c!--\x3e'), 'string' != typeof e && !gt(e)) ) { - if ("function" != typeof e.toString) - throw A("toString is not a function"); - if ("string" != typeof (e = e.toString())) - throw A("dirty is not a string, aborting"); + if ('function' != typeof e.toString) + throw A('toString is not a function'); + if ('string' != typeof (e = e.toString())) + throw A('dirty is not a string, aborting'); } if (!o.isSupported) return e; if ( - (De || rt(l), (o.removed = []), "string" == typeof e && (Ue = !1), Ue) + (De || rt(l), (o.removed = []), 'string' == typeof e && (Ue = !1), Ue) ) { if (e.nodeName) { const t = et(e.nodeName); if (!de[t] || Ee[t]) throw A( - "root node is forbidden and cannot be sanitized in-place", + 'root node is forbidden and cannot be sanitized in-place', ); } } else if (e instanceof _) - (t = pt("\x3c!----\x3e")), - (n = t.ownerDocument.importNode(e, !0)), - (1 === n.nodeType && "BODY" === n.nodeName) || "HTML" === n.nodeName - ? (t = n) - : t.appendChild(n); + (t = pt('\x3c!----\x3e')), + (n = t.ownerDocument.importNode(e, !0)), + (1 === n.nodeType && 'BODY' === n.nodeName) || 'HTML' === n.nodeName + ? (t = n) + : t.appendChild(n); else { - if (!ve && !Re && !we && -1 === e.indexOf("<")) + if (!ve && !Re && !we && -1 === e.indexOf('<')) return J && Ce ? J.createHTML(e) : e; - if (((t = pt(e)), !t)) return ve ? null : Ce ? Q : ""; + if (((t = pt(e)), !t)) return ve ? null : Ce ? Q : ''; } t && Le && ut(t.firstChild); const s = dt(Ue ? e : t); @@ -1347,13 +1347,13 @@ let m = we ? t.outerHTML : t.innerHTML; return ( we && - de["!doctype"] && + de['!doctype'] && t.ownerDocument && t.ownerDocument.doctype && t.ownerDocument.doctype.name && E(j, t.ownerDocument.doctype.name) && - (m = "\n" + m), - Re && ((m = g(m, ae, " ")), (m = g(m, le, " ")), (m = g(m, ce, " "))), + (m = '\n' + m), + Re && ((m = g(m, ae, ' ')), (m = g(m, le, ' ')), (m = g(m, ce, ' '))), J && Ce ? J.createHTML(m) : m ); }), @@ -1370,7 +1370,7 @@ return Et(o, r, n); }), (o.addHook = function (e, t) { - "function" == typeof t && ((ie[e] = ie[e] || []), f(ie[e], t)); + 'function' == typeof t && ((ie[e] = ie[e] || []), f(ie[e], t)); }), (o.removeHook = function (e) { if (ie[e]) return u(ie[e]); diff --git a/safari/Shared (App)/Resources/Script.js b/safari/Shared (App)/Resources/Script.js index 823a8d34..d0947029 100644 --- a/safari/Shared (App)/Resources/Script.js +++ b/safari/Shared (App)/Resources/Script.js @@ -1,24 +1,24 @@ function show(platform, enabled, useSettingsInsteadOfPreferences) { - document.body.classList.add(`platform-${platform}`); + document.body.classList.add(`platform-${platform}`); - if (useSettingsInsteadOfPreferences) { - document.getElementsByClassName('platform-mac state-on')[0].innerText = "BetterSEQTA+’s extension is currently on. You can turn it off in the Extensions section of Safari Settings."; - document.getElementsByClassName('platform-mac state-off')[0].innerText = "BetterSEQTA+’s extension is currently off. You can turn it on in the Extensions section of Safari Settings."; - document.getElementsByClassName('platform-mac state-unknown')[0].innerText = "You can turn on BetterSEQTA+’s extension in the Extensions section of Safari Settings."; - document.getElementsByClassName('platform-mac open-preferences')[0].innerText = "Quit and Open Safari Settings…"; - } + if (useSettingsInsteadOfPreferences) { + document.getElementsByClassName('platform-mac state-on')[0].innerText = 'BetterSEQTA+’s extension is currently on. You can turn it off in the Extensions section of Safari Settings.'; + document.getElementsByClassName('platform-mac state-off')[0].innerText = 'BetterSEQTA+’s extension is currently off. You can turn it on in the Extensions section of Safari Settings.'; + document.getElementsByClassName('platform-mac state-unknown')[0].innerText = 'You can turn on BetterSEQTA+’s extension in the Extensions section of Safari Settings.'; + document.getElementsByClassName('platform-mac open-preferences')[0].innerText = 'Quit and Open Safari Settings…'; + } - if (typeof enabled === "boolean") { - document.body.classList.toggle(`state-on`, enabled); - document.body.classList.toggle(`state-off`, !enabled); - } else { - document.body.classList.remove(`state-on`); - document.body.classList.remove(`state-off`); - } + if (typeof enabled === 'boolean') { + document.body.classList.toggle('state-on', enabled); + document.body.classList.toggle('state-off', !enabled); + } else { + document.body.classList.remove('state-on'); + document.body.classList.remove('state-off'); + } } function openPreferences() { - webkit.messageHandlers.controller.postMessage("open-preferences"); + webkit.messageHandlers.controller.postMessage('open-preferences'); } -document.querySelector("button.open-preferences").addEventListener("click", openPreferences); +document.querySelector('button.open-preferences').addEventListener('click', openPreferences); diff --git a/src/SEQTA.js b/src/SEQTA.js index c1e23fe0..4a4f8df8 100644 --- a/src/SEQTA.js +++ b/src/SEQTA.js @@ -1,26 +1,26 @@ /*global chrome*/ -import { animate, spring, stagger } from "motion"; -import Color from "color"; +import { animate, spring, stagger } from 'motion'; +import Color from 'color'; -import ShortcutLinks from "./seqta/content/links.json"; -import MenuitemSVGKey from "./seqta/content/MenuItemSVGKey.json"; -import stringToHTML from "./seqta/utils/stringToHTML.js"; -import loading, { AppendLoadingSymbol } from "./seqta/ui/Loading.js"; +import ShortcutLinks from './seqta/content/links.json'; +import MenuitemSVGKey from './seqta/content/MenuItemSVGKey.json'; +import stringToHTML from './seqta/utils/stringToHTML.js'; +import loading, { AppendLoadingSymbol } from './seqta/ui/Loading.js'; // Icons -import assessmentsicon from "./seqta/icons/assessmentsIcon.js"; -import coursesicon from "./seqta/icons/coursesIcon.js"; -import StorageListener from "./seqta/utils/StorageListener.js"; -import { MessageHandler } from "./seqta/utils/MessageListener.js"; -import { updateBgDurations } from "./seqta/ui/Animation.js"; -import { updateAllColors } from "./seqta/ui/colors/Manager.js"; -import { appendBackgroundToUI } from "./seqta/ui/ImageBackgrounds.js"; -import { enableCurrentTheme } from "./seqta/ui/Themes.js"; +import assessmentsicon from './seqta/icons/assessmentsIcon.js'; +import coursesicon from './seqta/icons/coursesIcon.js'; +import StorageListener from './seqta/utils/StorageListener.js'; +import { MessageHandler } from './seqta/utils/MessageListener.js'; +import { updateBgDurations } from './seqta/ui/Animation.js'; +import { updateAllColors } from './seqta/ui/colors/Manager.js'; +import { appendBackgroundToUI } from './seqta/ui/ImageBackgrounds.js'; +import { enableCurrentTheme } from './seqta/ui/Themes.js'; export let isChrome = window.chrome; let SettingsClicked = false; export let MenuOptionsOpen = false; -let UserInitalCode = ""; +let UserInitalCode = ''; let currentSelectedDate = new Date(); let LessonInterval; export let DarkMode; @@ -38,12 +38,12 @@ function animbkEnable(item) { CreateBackground(); } else { RemoveBackground(); - document.getElementById("container").style.background = "var(--background-secondary)"; + document.getElementById('container').style.background = 'var(--background-secondary)'; } } export function ApplyCSSToHiddenMenuItems() { - var stylesheetInnerText = ""; + var stylesheetInnerText = ''; chrome.storage.local.get(null, function (result) { for (let i = 0; i < Object.keys(result.menuitems).length; i++) { if (!Object.values(result.menuitems)[i].toggle) { @@ -55,43 +55,43 @@ export function ApplyCSSToHiddenMenuItems() { ); } } - let MenuItemStyle = document.createElement("style"); + let MenuItemStyle = document.createElement('style'); MenuItemStyle.innerText = stylesheetInnerText; document.head.appendChild(MenuItemStyle); }); } function OpenWhatsNewPopup() { - const background = document.createElement("div"); - background.id = "whatsnewbk"; - background.classList.add("whatsnewBackground"); + const background = document.createElement('div'); + background.id = 'whatsnewbk'; + background.classList.add('whatsnewBackground'); - const container = document.createElement("div"); - container.classList.add("whatsnewContainer"); + const container = document.createElement('div'); + container.classList.add('whatsnewContainer'); var header = stringToHTML(`

What's New

BetterSEQTA+ V${chrome.runtime.getManifest().version}

`).firstChild; - let imagecont = document.createElement("div"); - imagecont.classList.add("whatsnewImgContainer"); - let video = document.createElement("video"); - let source = document.createElement("source"); - source.setAttribute("src", chrome.runtime.getURL("resources/update-video.mp4")); - source.setAttribute("type", "video/mp4"); + let imagecont = document.createElement('div'); + imagecont.classList.add('whatsnewImgContainer'); + let video = document.createElement('video'); + let source = document.createElement('source'); + source.setAttribute('src', chrome.runtime.getURL('resources/update-video.mp4')); + source.setAttribute('type', 'video/mp4'); video.autoplay = true; video.muted = true; video.loop = true; video.appendChild(source); - video.classList.add("whatsnewImg"); + video.classList.add('whatsnewImg'); imagecont.appendChild(video); - let textcontainer = document.createElement("div"); - textcontainer.classList.add("whatsnewTextContainer"); + let textcontainer = document.createElement('div'); + textcontainer.classList.add('whatsnewTextContainer'); let textheader = stringToHTML( - "

DESIGN OVERHAUL

", + '

DESIGN OVERHAUL

', ).firstChild; textcontainer.append(textheader); @@ -180,8 +180,8 @@ function OpenWhatsNewPopup() { `).firstChild; - let exitbutton = document.createElement("div"); - exitbutton.id = "whatsnewclosebutton"; + let exitbutton = document.createElement('div'); + exitbutton.id = 'whatsnewclosebutton'; container.append(header); container.append(imagecont); @@ -192,10 +192,10 @@ function OpenWhatsNewPopup() { background.append(container); - document.getElementById("container").append(background); + document.getElementById('container').append(background); - let bkelement = document.getElementById("whatsnewbk"); - let popup = document.getElementsByClassName("whatsnewContainer")[0]; + let bkelement = document.getElementById('whatsnewbk'); + let popup = document.getElementsByClassName('whatsnewContainer')[0]; animate( [popup, bkelement], @@ -204,7 +204,7 @@ function OpenWhatsNewPopup() { ); animate( - ".whatsnewTextContainer *", + '.whatsnewTextContainer *', { opacity: [0, 1], y: [10, 0] }, { delay: stagger(0.05, { start: 0.1 }), @@ -213,32 +213,32 @@ function OpenWhatsNewPopup() { } ); - chrome.storage.local.remove(["justupdated"]); + chrome.storage.local.remove(['justupdated']); - bkelement.addEventListener("click", function (event) { + bkelement.addEventListener('click', function (event) { // Check if the click event originated from the element itself and not any of its children if (event.target === bkelement) { DeleteWhatsNew(); } }); - var closeelement = document.getElementById("whatsnewclosebutton"); - closeelement.addEventListener("click", function () { + var closeelement = document.getElementById('whatsnewclosebutton'); + closeelement.addEventListener('click', function () { DeleteWhatsNew(); }); } async function finishLoad() { try { - var loadingbk = document.getElementById("loading"); - loadingbk.style.opacity = "0"; + var loadingbk = document.getElementById('loading'); + loadingbk.style.opacity = '0'; await delay(501); loadingbk.remove(); } catch (err) { console.log(err); } - chrome.storage.local.get(["justupdated"], function (result) { + chrome.storage.local.get(['justupdated'], function (result) { if (result.justupdated) { OpenWhatsNewPopup(); } @@ -246,8 +246,8 @@ async function finishLoad() { } async function DeleteWhatsNew() { - const bkelement = document.getElementById("whatsnewbk"); - const popup = document.getElementsByClassName("whatsnewContainer")[0]; + const bkelement = document.getElementById('whatsnewbk'); + const popup = document.getElementsByClassName('whatsnewContainer')[0]; animate( [popup, bkelement], @@ -260,28 +260,28 @@ async function DeleteWhatsNew() { export function CreateBackground() { // Creating and inserting 3 divs containing the background applied to the pages - var bklocation = document.getElementById("container"); - var menu = document.getElementById("menu"); - var bk = document.createElement("div"); - bk.classList.add("bg"); + var bklocation = document.getElementById('container'); + var menu = document.getElementById('menu'); + var bk = document.createElement('div'); + bk.classList.add('bg'); bklocation.insertBefore(bk, menu); - var bk2 = document.createElement("div"); - bk2.classList.add("bg"); - bk2.classList.add("bg2"); + var bk2 = document.createElement('div'); + bk2.classList.add('bg'); + bk2.classList.add('bg2'); bklocation.insertBefore(bk2, menu); - var bk3 = document.createElement("div"); - bk3.classList.add("bg"); - bk3.classList.add("bg3"); + var bk3 = document.createElement('div'); + bk3.classList.add('bg'); + bk3.classList.add('bg3'); bklocation.insertBefore(bk3, menu); } export function RemoveBackground() { - var bk = document.getElementsByClassName("bg"); - var bk2 = document.getElementsByClassName("bg2"); - var bk3 = document.getElementsByClassName("bg3"); + var bk = document.getElementsByClassName('bg'); + var bk2 = document.getElementsByClassName('bg2'); + var bk3 = document.getElementsByClassName('bg3'); if (bk.length == 0 || bk2.length == 0 || bk3.length == 0) return; @@ -312,21 +312,21 @@ export function waitForElm(selector) { async function RunColourCheck(element) { if ( - typeof element.contentDocument.documentElement.childNodes[1] == "undefined" + typeof element.contentDocument.documentElement.childNodes[1] == 'undefined' ) { await delay(1000); RunColourCheck(element); } else { - element.contentDocument.documentElement.childNodes[1].style.color = "white"; + element.contentDocument.documentElement.childNodes[1].style.color = 'white'; } } export function GetiFrameCSSElement() { - var cssFile = chrome.runtime.getURL("inject/iframe.css"); - var fileref = document.createElement("link"); - fileref.setAttribute("rel", "stylesheet"); - fileref.setAttribute("type", "text/css"); - fileref.setAttribute("href", cssFile); + var cssFile = chrome.runtime.getURL('inject/iframe.css'); + var fileref = document.createElement('link'); + fileref.setAttribute('rel', 'stylesheet'); + fileref.setAttribute('type', 'text/css'); + fileref.setAttribute('href', cssFile); return fileref; } @@ -338,38 +338,38 @@ function CheckiFrameItems() { const observer = new MutationObserver(function (mutations_list) { mutations_list.forEach(function (mutation) { mutation.addedNodes.forEach(function (added_node) { - if (added_node.tagName == "IFRAME") { - chrome.storage.local.get(["DarkMode"], function (result) { + if (added_node.tagName == 'IFRAME') { + chrome.storage.local.get(['DarkMode'], function (result) { DarkMode = result.DarkMode; if (DarkMode) { RunColourCheck(added_node); if ( added_node.contentDocument.documentElement.childNodes[1].style - .color != "white" + .color != 'white' ) { added_node.contentDocument.documentElement.childNodes[1].style.color = - "white"; + 'white'; } if ( !added_node.contentDocument.documentElement.firstChild.innerHTML.includes( - "iframe.css", + 'iframe.css', ) ) { added_node.contentDocument.documentElement.firstChild.appendChild( fileref, ); } - added_node.addEventListener("load", function () { + added_node.addEventListener('load', function () { if ( added_node.contentDocument.documentElement.childNodes[1].style - .color != "white" + .color != 'white' ) { added_node.contentDocument.documentElement.childNodes[1].style.color = - "white"; + 'white'; } if ( !added_node.contentDocument.documentElement.firstChild.innerHTML.includes( - "iframe.css", + 'iframe.css', ) ) { added_node.contentDocument.documentElement.firstChild.appendChild( @@ -391,12 +391,12 @@ function CheckiFrameItems() { } function SortMessagePageItems(messagesParentElement) { - let filterbutton = document.createElement("div"); - filterbutton.classList.add("messages-filterbutton"); - filterbutton.innerText = "Filter"; + let filterbutton = document.createElement('div'); + filterbutton.classList.add('messages-filterbutton'); + filterbutton.innerText = 'Filter'; let header = document.getElementsByClassName( - "MessageList__MessageList___3DxoC", + 'MessageList__MessageList___3DxoC', )[0].firstChild; header.append(filterbutton); @@ -418,10 +418,10 @@ function SortMessagePageItems(messagesParentElement) { async function LoadPageElements() { await AddBetterSEQTAElements(true); - var sublink = window.location.href.split("/")[4]; + var sublink = window.location.href.split('/')[4]; switch (sublink) { - case "news": - console.log("[BetterSEQTA+] Started Init"); + case 'news': + console.log('[BetterSEQTA+] Started Init'); chrome.storage.local.get(null, function (result) { if (result.onoff) { SendNewsPage(); @@ -437,7 +437,7 @@ async function LoadPageElements() { }); break; - case "home": + case 'home': window.location.replace(`${location.origin}/#?page=/home`); LoadInit(); break; @@ -460,15 +460,15 @@ async function LoadPageElements() { const observer = new MutationObserver(function (mutations_list) { mutations_list.forEach(function (mutation) { mutation.addedNodes.forEach(function (added_node) { - if (added_node.classList.contains("messages")) { - let element = document.getElementById("title").firstChild; - element.innerText = "Direct Messages"; - document.title = "Direct Messages ― SEQTA Learn"; + if (added_node.classList.contains('messages')) { + let element = document.getElementById('title').firstChild; + element.innerText = 'Direct Messages'; + document.title = 'Direct Messages ― SEQTA Learn'; SortMessagePageItems(added_node); - waitForElm("[data-message]").then(() => { + waitForElm('[data-message]').then(() => { animate( - "[data-message]", + '[data-message]', { opacity: [0, 1], y: [10, 0] }, { delay: stagger(0.05), @@ -477,15 +477,15 @@ async function LoadPageElements() { } ); }); - } else if (added_node.classList.contains("notices")) { + } else if (added_node.classList.contains('notices')) { CheckNoticeTextColour(added_node); - } else if (added_node.classList.contains("dashboard")) { + } else if (added_node.classList.contains('dashboard')) { let ranOnce = false; - waitForElm(".dashlet").then(() => { + waitForElm('.dashlet').then(() => { if (ranOnce) return; ranOnce = true; animate( - ".dashboard *:not(.dashlet-timetable), .dashboard .message *", + '.dashboard *:not(.dashlet-timetable), .dashboard .message *', { opacity: [0, 1], y: [10, 0] }, { delay: stagger(0.01), @@ -494,13 +494,13 @@ async function LoadPageElements() { } ); }); - } else if (added_node.classList.contains("documents")) { + } else if (added_node.classList.contains('documents')) { let ranOnce = false; - waitForElm(".document").then(() => { + waitForElm('.document').then(() => { if (ranOnce) return; ranOnce = true; animate( - ".documents tbody tr.document", + '.documents tbody tr.document', { opacity: [0, 1], y: [10, 0] }, { delay: stagger(0.05), @@ -509,13 +509,13 @@ async function LoadPageElements() { } ); }); - } else if (added_node.classList.contains("reports")) { + } else if (added_node.classList.contains('reports')) { let ranOnce = false; - waitForElm(".report").then(() => { + waitForElm('.report').then(() => { if (ranOnce) return; ranOnce = true; animate( - ".reports .item", + '.reports .item', { opacity: [0, 1], y: [10, 0] }, { delay: stagger(0.05, { start: 0.2 }), @@ -529,7 +529,7 @@ async function LoadPageElements() { }); }); - observer.observe(document.querySelector("#main"), { + observer.observe(document.querySelector('#main'), { subtree: false, childList: true, }); @@ -539,13 +539,13 @@ function CheckNoticeTextColour(notice) { const observer = new MutationObserver(function (mutations_list) { mutations_list.forEach(function (mutation) { mutation.addedNodes.forEach(function (added_node) { - chrome.storage.local.get(["DarkMode"], function (result) { + chrome.storage.local.get(['DarkMode'], function (result) { DarkMode = result.DarkMode; - if (added_node.classList.contains("notice")) { - var hex = added_node.style.cssText.split(" ")[1]; + if (added_node.classList.contains('notice')) { + var hex = added_node.style.cssText.split(' ')[1]; var threshold = GetThresholdOfColor(hex); if (DarkMode && threshold < 100) { - added_node.style.cssText = "--color: undefined;"; + added_node.style.cssText = '--color: undefined;'; } } }); @@ -560,25 +560,25 @@ function CheckNoticeTextColour(notice) { } export function tryLoad() { - waitForElm(".login").then(() => { + waitForElm('.login').then(() => { finishLoad(); }); - waitForElm(".day-container").then(() => { + waitForElm('.day-container').then(() => { finishLoad(); }); - waitForElm("[data-key=welcome]").then((elm) => { - elm.classList.remove("active"); + waitForElm('[data-key=welcome]').then((elm) => { + elm.classList.remove('active'); }); - waitForElm(".code").then((elm) => { - if (!elm.innerText.includes("BetterSEQTA")) LoadPageElements(); + waitForElm('.code').then((elm) => { + if (!elm.innerText.includes('BetterSEQTA')) LoadPageElements(); }); // Waits for page to call on load, run scripts document.addEventListener( - "load", + 'load', function () { CheckiFrameItems(); }, @@ -589,7 +589,7 @@ export function tryLoad() { function ChangeMenuItemPositions(storage) { let menuorder = storage; - var menuList = document.querySelector("#menu").firstChild.childNodes; + var menuList = document.querySelector('#menu').firstChild.childNodes; let listorder = []; for (let i = 0; i < menuList.length; i++) { @@ -604,11 +604,11 @@ function ChangeMenuItemPositions(storage) { newArr[listorder[i]] = menuList[i]; } - let listItemsDOM = document.getElementById("menu").firstChild; + let listItemsDOM = document.getElementById('menu').firstChild; for (let i = 0; i < newArr.length; i++) { const element = newArr[i]; if (element) { - element.setAttribute("data-checked", "true"); + element.setAttribute('data-checked', 'true'); listItemsDOM.appendChild(element); } } @@ -634,7 +634,7 @@ export async function ObserveMenuItemPosition() { }); }); - observer.observe(document.querySelector("#menu").firstChild, { + observer.observe(document.querySelector('#menu').firstChild, { subtree: true, childList: true, }); @@ -645,11 +645,11 @@ export async function ObserveMenuItemPosition() { function main(storedSetting) { DarkMode = storedSetting.DarkMode; // If the option is 'on', open BetterSEQTA - if (typeof storedSetting.onoff == "undefined") { - chrome.runtime.sendMessage({ type: "setDefaultStorage" }); + if (typeof storedSetting.onoff == 'undefined') { + chrome.runtime.sendMessage({ type: 'setDefaultStorage' }); } if (storedSetting.onoff) { - console.log("[BetterSEQTA+] Enabled"); + console.log('[BetterSEQTA+] Enabled'); InjectStyles(); InjectCustomIcons(); updateAllColors(storedSetting); @@ -657,21 +657,21 @@ function main(storedSetting) { loading(); CheckLoadOnPeriods(); - if (!isChrome || isChrome == "undefined") { + if (!isChrome || isChrome == 'undefined') { tryLoad(); } - window.addEventListener("load", function () { + window.addEventListener('load', function () { tryLoad(); }); } else { - if (!isChrome || isChrome == "undefined") { - waitForElm(".code").then(() => { + if (!isChrome || isChrome == 'undefined') { + waitForElm('.code').then(() => { AppendElementsToDisabledPage(); }); } - window.addEventListener("load", function () { - waitForElm(".code").then(() => { + window.addEventListener('load', function () { + waitForElm('.code').then(() => { AppendElementsToDisabledPage(); }); }); @@ -679,20 +679,20 @@ function main(storedSetting) { } function InjectStyles() { - var cssFile = chrome.runtime.getURL("inject/injected.css"); - var fileref = document.createElement("link"); - fileref.setAttribute("rel", "stylesheet"); - fileref.setAttribute("type", "text/css"); - fileref.setAttribute("href", cssFile); + var cssFile = chrome.runtime.getURL('inject/injected.css'); + var fileref = document.createElement('link'); + fileref.setAttribute('rel', 'stylesheet'); + fileref.setAttribute('type', 'text/css'); + fileref.setAttribute('href', cssFile); document.head.appendChild(fileref); - document.getElementsByTagName("html")[0].appendChild(fileref); + document.getElementsByTagName('html')[0].appendChild(fileref); } function InjectCustomIcons() { - const fontURL = chrome.runtime.getURL("fonts/IconFamily.woff"); + const fontURL = chrome.runtime.getURL('fonts/IconFamily.woff'); - const style = document.createElement("style"); - style.setAttribute("type", "text/css"); + const style = document.createElement('style'); + style.setAttribute('type', 'text/css'); style.innerHTML = ` @font-face { font-family: 'IconFamily'; @@ -706,7 +706,7 @@ function InjectCustomIcons() { export function AppendElementsToDisabledPage() { AddBetterSEQTAElements(false); - let settingsStyle = document.createElement("style"); + let settingsStyle = document.createElement('style'); settingsStyle.innerText = ` .addedButton { position: absolute !important; @@ -737,7 +737,7 @@ var PageLoaded = false; async function CheckLoadOnPeriods() { if (!PageLoaded) { await delay(1000); - var code = document.getElementsByClassName("code")[0]; + var code = document.getElementsByClassName('code')[0]; if (code && !UserInitalCode) { LoadPageElements(); finishLoad(); @@ -753,24 +753,24 @@ var MenuItemMutation = false; var NonSEQTAPage = false; var IsSEQTAPage = false; document.addEventListener( - "load", + 'load', function () { CheckForMenuList(); if ( document.childNodes[1].textContent?.includes( - "Copyright (c) SEQTA Software", + 'Copyright (c) SEQTA Software', ) && - document.title.includes("SEQTA Learn") && + document.title.includes('SEQTA Learn') && !IsSEQTAPage ) { IsSEQTAPage = true; - console.log("[BetterSEQTA+] Verified SEQTA Page"); + console.log('[BetterSEQTA+] Verified SEQTA Page'); - var link = document.createElement("link"); - link.href = chrome.runtime.getURL("inject/documentload.css"); - link.type = "text/css"; - link.rel = "stylesheet"; - document.getElementsByTagName("html")[0].appendChild(link); + var link = document.createElement('link'); + link.href = chrome.runtime.getURL('inject/documentload.css'); + link.type = 'text/css'; + link.rel = 'stylesheet'; + document.getElementsByTagName('html')[0].appendChild(link); enableCurrentTheme(); chrome.storage.local.get(null, function (items) { @@ -778,7 +778,7 @@ document.addEventListener( }); } if ( - !document.childNodes[1].textContent?.includes("SEQTA") && + !document.childNodes[1].textContent?.includes('SEQTA') && !NonSEQTAPage ) { NonSEQTAPage = true; @@ -788,18 +788,18 @@ document.addEventListener( ); export function closeSettings() { - var extensionsettings = document.getElementById("ExtensionPopup"); + var extensionsettings = document.getElementById('ExtensionPopup'); - extensionsettings.classList.add("hide"); + extensionsettings.classList.add('hide'); SettingsClicked = false; } function addExtensionSettings() { - let link = document.createElement("link"); - link.href = chrome.runtime.getURL("popup/popup.css"); - link.type = "text/css"; - link.rel = "stylesheet"; - document.getElementsByTagName("html")[0].appendChild(link); + let link = document.createElement('link'); + link.href = chrome.runtime.getURL('popup/popup.css'); + link.type = 'text/css'; + link.rel = 'stylesheet'; + document.getElementsByTagName('html')[0].appendChild(link); let Settings = stringToHTML( @@ -809,26 +809,26 @@ function addExtensionSettings() { `); document.body.append(Settings.firstChild); - let iframe = document.createElement("iframe"); - iframe.src = chrome.runtime.getURL("interface/index.html"); - iframe.id = "ExtensionIframe"; - iframe.allowTransparency = "true"; - iframe.style.width = "384px"; - iframe.style.height = "600px"; - iframe.style.border = "none"; - iframe.setAttribute("excludeDarkCheck", "true"); + let iframe = document.createElement('iframe'); + iframe.src = chrome.runtime.getURL('interface/index.html'); + iframe.id = 'ExtensionIframe'; + iframe.allowTransparency = 'true'; + iframe.style.width = '384px'; + iframe.style.height = '600px'; + iframe.style.border = 'none'; + iframe.setAttribute('excludeDarkCheck', 'true'); - document.getElementById("ExtensionPopup").append(iframe); + document.getElementById('ExtensionPopup').append(iframe); - var container = document.getElementById("container"); - var extensionsettings = document.getElementById("ExtensionPopup"); - var extensionIframe = document.getElementById("ExtensionIframe"); + var container = document.getElementById('container'); + var extensionsettings = document.getElementById('ExtensionPopup'); + var extensionIframe = document.getElementById('ExtensionIframe'); container.onclick = function (event) { - if (event.target.id !== "AddedSettings") { + if (event.target.id !== 'AddedSettings') { if (!SettingsClicked) { - extensionsettings.classList.add("hide"); - extensionIframe.contentWindow.postMessage("popupClosed", "*"); + extensionsettings.classList.add('hide'); + extensionIframe.contentWindow.postMessage('popupClosed', '*'); } SettingsClicked = false; } else { @@ -838,7 +838,7 @@ function addExtensionSettings() { } function ApplyDraggableFunctions() { - var listItens = document.querySelectorAll(".draggable"); + var listItens = document.querySelectorAll('.draggable'); [].forEach.call(listItens, function (item) { addEventsDragAndDrop(item); }); @@ -847,24 +847,24 @@ function ApplyDraggableFunctions() { var dragSrcEl; function dragStart(e) { - this.style.opacity = "0.4"; + this.style.opacity = '0.4'; dragSrcEl = this; - e.dataTransfer.effectAllowed = "move"; - e.dataTransfer.setData("text/html", this.innerHTML); + e.dataTransfer.effectAllowed = 'move'; + e.dataTransfer.setData('text/html', this.innerHTML); } function dragEnter() { - this.classList.add("over"); + this.classList.add('over'); } function dragLeave(e) { e.stopPropagation(); - this.classList.remove("over"); + this.classList.remove('over'); } function dragOver(e) { e.preventDefault(); - e.dataTransfer.dropEffect = "move"; + e.dataTransfer.dropEffect = 'move'; return false; } @@ -894,20 +894,20 @@ function dragDrop() { } function dragEnd() { - var listItens = document.querySelectorAll(".draggable"); + var listItens = document.querySelectorAll('.draggable'); [].forEach.call(listItens, function (item) { - item.classList.remove("over"); + item.classList.remove('over'); }); - this.style.opacity = "1"; + this.style.opacity = '1'; } function addEventsDragAndDrop(el) { - el.addEventListener("dragstart", dragStart, false); - el.addEventListener("dragenter", dragEnter, false); - el.addEventListener("dragover", dragOver, false); - el.addEventListener("dragleave", dragLeave, false); - el.addEventListener("drop", dragDrop, false); - el.addEventListener("dragend", dragEnd, false); + el.addEventListener('dragstart', dragStart, false); + el.addEventListener('dragenter', dragEnter, false); + el.addEventListener('dragover', dragOver, false); + el.addEventListener('dragleave', dragLeave, false); + el.addEventListener('drop', dragDrop, false); + el.addEventListener('dragend', dragEnd, false); } function cloneAttributes(target, source) { @@ -918,10 +918,10 @@ function cloneAttributes(target, source) { export function OpenMenuOptions() { chrome.storage.local.get(null, function (result) { - var container = document.getElementById("container"); - var menu = document.getElementById("menu"); + var container = document.getElementById('container'); + var menu = document.getElementById('menu'); - if (result.defaultmenuorder.length == "0") { + if (result.defaultmenuorder.length == '0') { let childnodes = menu.firstChild.childNodes; let newdefaultmenuorder = []; for (let i = 0; i < childnodes.length; i++) { @@ -944,24 +944,24 @@ export function OpenMenuOptions() { MenuOptionsOpen = true; - let cover = document.createElement("div"); - cover.classList.add("notMenuCover"); - menu.style.zIndex = "20"; - menu.style.setProperty("--menuHidden", "flex"); + let cover = document.createElement('div'); + cover.classList.add('notMenuCover'); + menu.style.zIndex = '20'; + menu.style.setProperty('--menuHidden', 'flex'); container.append(cover); - let menusettings = document.createElement("div"); - menusettings.classList.add("editmenuoption-container"); + let menusettings = document.createElement('div'); + menusettings.classList.add('editmenuoption-container'); - let defaultbutton = document.createElement("div"); - defaultbutton.classList.add("editmenuoption"); - defaultbutton.innerText = "Restore Default"; - defaultbutton.id = "restoredefaultoption"; + let defaultbutton = document.createElement('div'); + defaultbutton.classList.add('editmenuoption'); + defaultbutton.innerText = 'Restore Default'; + defaultbutton.id = 'restoredefaultoption'; - let savebutton = document.createElement("div"); - savebutton.classList.add("editmenuoption"); - savebutton.innerText = "Save"; - savebutton.id = "restoredefaultoption"; + let savebutton = document.createElement('div'); + savebutton.classList.add('editmenuoption'); + savebutton.innerText = 'Save'; + savebutton.id = 'restoredefaultoption'; menusettings.appendChild(defaultbutton); menusettings.appendChild(savebutton); @@ -972,11 +972,11 @@ export function OpenMenuOptions() { for (let i = 0; i < ListItems.length; i++) { const element = ListItems[i]; - element.classList.add("draggable"); - element.setAttribute("draggable", true); - if (element.classList.contains("hasChildren")) { - element.classList.remove("active"); - menu.firstChild.classList.remove("noscroll"); + element.classList.add('draggable'); + element.setAttribute('draggable', true); + if (element.classList.contains('hasChildren')) { + element.classList.remove('active'); + menu.firstChild.classList.remove('noscroll'); } let MenuItemToggle = stringToHTML( @@ -985,7 +985,7 @@ export function OpenMenuOptions() { element.append(MenuItemToggle); if (!element.dataset.betterseqta) { - var a = document.createElement("section"); + var a = document.createElement('section'); a.innerHTML = element.innerHTML; cloneAttributes(a, element); menu.firstChild.insertBefore(a, element); @@ -1005,10 +1005,10 @@ export function OpenMenuOptions() { chrome.storage.local.set({ menuitems: menuItems }); } - var menubuttons = document.getElementsByClassName("menuitem"); - chrome.storage.local.get(["menuitems"], function (result) { + var menubuttons = document.getElementsByClassName('menuitem'); + chrome.storage.local.get(['menuitems'], function (result) { var menuItems = result.menuitems; - let buttons = document.getElementsByClassName("menuitem"); + let buttons = document.getElementsByClassName('menuitem'); for (var i = 0; i < buttons.length; i++) { var id = buttons[i].id; if (menuItems[id]) { @@ -1023,10 +1023,10 @@ export function OpenMenuOptions() { ApplyDraggableFunctions(); function StoreMenuSettings() { - chrome.storage.local.get(["menuitems"], function () { + chrome.storage.local.get(['menuitems'], function () { var menuItems = {}; menubuttons = menu.firstChild.childNodes; - let button = document.getElementsByClassName("menuitem"); + let button = document.getElementsByClassName('menuitem'); for (var i = 0; i < menubuttons.length; i++) { var id = menubuttons[i].dataset.key; const element = {}; @@ -1040,20 +1040,20 @@ export function OpenMenuOptions() { function changeDisplayProperty(element) { if (!element.checked) { - element.parentNode.parentNode.style.display = "var(--menuHidden)"; + element.parentNode.parentNode.style.display = 'var(--menuHidden)'; } if (element.checked) { element.parentNode.parentNode.style.setProperty( - "display", - "flex", - "important", + 'display', + 'flex', + 'important', ); } } for (let i = 0; i < menubuttons.length; i++) { const element = menubuttons[i]; - element.addEventListener("change", () => { + element.addEventListener('change', () => { StoreMenuSettings(); changeDisplayProperty(element); }); @@ -1064,15 +1064,15 @@ export function OpenMenuOptions() { menusettings.remove(); cover.remove(); MenuOptionsOpen = false; - menu.style.setProperty("--menuHidden", "none"); + menu.style.setProperty('--menuHidden', 'none'); for (let i = 0; i < ListItems.length; i++) { const element = ListItems[i]; - element.classList.remove("draggable"); - element.setAttribute("draggable", false); + element.classList.remove('draggable'); + element.setAttribute('draggable', false); if (!element.dataset.betterseqta) { - var a = document.createElement("li"); + var a = document.createElement('li'); a.innerHTML = element.innerHTML; cloneAttributes(a, element); menu.firstChild.insertBefore(a, element); @@ -1080,7 +1080,7 @@ export function OpenMenuOptions() { } } - let switches = menu.querySelectorAll(".onoffswitch"); + let switches = menu.querySelectorAll('.onoffswitch'); for (let i = 0; i < switches.length; i++) { switches[i].remove(); } @@ -1088,10 +1088,10 @@ export function OpenMenuOptions() { StoreMenuSettings(); } - cover.addEventListener("click", closeAll); - savebutton.addEventListener("click", closeAll); + cover.addEventListener('click', closeAll); + savebutton.addEventListener('click', closeAll); - defaultbutton.addEventListener("click", function () { + defaultbutton.addEventListener('click', function () { chrome.storage.local.get(null, function (response) { const options = response.defaultmenuorder; chrome.storage.local.set({ menuorder: options }); @@ -1101,9 +1101,9 @@ export function OpenMenuOptions() { const element = menubuttons[i]; element.checked = true; element.parentNode.parentNode.style.setProperty( - "display", - "flex", - "important", + 'display', + 'flex', + 'important', ); } StoreMenuSettings(); @@ -1116,8 +1116,8 @@ function ReplaceMenuSVG(element, svg) { let item = element.firstChild; item.firstChild.remove(); - if (element.dataset.key == "messages") { - element.firstChild.innerText = "Direct Messages"; + if (element.dataset.key == 'messages') { + element.firstChild.innerText = 'Direct Messages'; } let newsvg = stringToHTML(svg).firstChild; @@ -1125,56 +1125,56 @@ function ReplaceMenuSVG(element, svg) { } async function AddBetterSEQTAElements(toggle) { - var code = document.getElementsByClassName("code")[0]; + var code = document.getElementsByClassName('code')[0]; // Replaces students code with the version of BetterSEQTA if (code != null) { - if (!code.innerHTML.includes("BetterSEQTA")) { + if (!code.innerHTML.includes('BetterSEQTA')) { UserInitalCode = code.innerText; code.innerText = `BetterSEQTA v${chrome.runtime.getManifest().version}`; - code.setAttribute("data-hover", "Click for user code"); - code.addEventListener("click", function () { - var code = document.getElementsByClassName("code")[0]; - if (code.innerText.includes("BetterSEQTA")) { + code.setAttribute('data-hover', 'Click for user code'); + code.addEventListener('click', function () { + var code = document.getElementsByClassName('code')[0]; + if (code.innerText.includes('BetterSEQTA')) { code.innerText = UserInitalCode; - code.setAttribute("data-hover", "Click for BetterSEQTA version"); + code.setAttribute('data-hover', 'Click for BetterSEQTA version'); } else { code.innerText = `BetterSEQTA v${ chrome.runtime.getManifest().version }`; - code.setAttribute("data-hover", "Click for user code"); + code.setAttribute('data-hover', 'Click for user code'); } }); if (toggle) { // Creates Home menu button and appends it as the first child of the list - const result = chrome.storage.local.get(["animatedbk"]); - const sliderVal = chrome.storage.local.get(["bksliderinput"]); + const result = chrome.storage.local.get(['animatedbk']); + const sliderVal = chrome.storage.local.get(['bksliderinput']); result.then(animbkEnable); sliderVal.then(updateBgDurations); // Load darkmode state - chrome.storage.local.get(["DarkMode"], function (result) { + chrome.storage.local.get(['DarkMode'], function (result) { DarkMode = result.DarkMode; }); - var titlebar = document.createElement("div"); - titlebar.classList.add("titlebar"); - let container = document.getElementById("content"); + var titlebar = document.createElement('div'); + titlebar.classList.add('titlebar'); + let container = document.getElementById('content'); container.append(titlebar); - var NewButtonStr = "
  • "; + var NewButtonStr = '
  • '; var NewButton = stringToHTML(NewButtonStr); - var menu = document.getElementById("menu"); + var menu = document.getElementById('menu'); var List = menu.firstChild; List.insertBefore(NewButton.firstChild, List.firstChild); fetch(`${location.origin}/seqta/student/login`, { - method: "POST", + method: 'POST', headers: { - "Content-Type": "application/json; charset=utf-8", + 'Content-Type': 'application/json; charset=utf-8', }, body: JSON.stringify({ - mode: "normal", + mode: 'normal', query: null, redirect_url: location.origin, }), @@ -1183,10 +1183,10 @@ async function AddBetterSEQTAElements(toggle) { .then((response) => { let info = response.payload; - var titlebar = document.getElementsByClassName("titlebar")[0]; + var titlebar = document.getElementsByClassName('titlebar')[0]; titlebar.append( stringToHTML( - "
    ", + '
    ', ).firstChild, ); var userinfostr = `

    ${info.userDesc}

    ${UserInitalCode}

    `; @@ -1194,29 +1194,29 @@ async function AddBetterSEQTAElements(toggle) { titlebar.append(userinfo); - var logoutbutton = document.getElementsByClassName("logout")[0]; - var userInfosvgdiv = document.getElementById("logouttooltip"); + var logoutbutton = document.getElementsByClassName('logout')[0]; + var userInfosvgdiv = document.getElementById('logouttooltip'); userInfosvgdiv.appendChild(logoutbutton); fetch(`${location.origin}/seqta/student/load/message/people`, { - method: "POST", + method: 'POST', headers: { - "Content-Type": "application/json; charset=utf-8", + 'Content-Type': 'application/json; charset=utf-8', }, - body: JSON.stringify({ mode: "student" }), + body: JSON.stringify({ mode: 'student' }), }) .then((result) => result.json()) .then((response) => { let students = response.payload; var index = students.findIndex(function (person) { return ( - person.firstname == info.userDesc.split(" ")[0] && - person.surname == info.userDesc.split(" ")[1] + person.firstname == info.userDesc.split(' ')[0] && + person.surname == info.userDesc.split(' ')[1] ); }); let houseelement = - document.getElementsByClassName("userInfohouse")[0]; + document.getElementsByClassName('userInfohouse')[0]; if (students[index]?.house) { houseelement.style.background = students[index].house_colour; try { @@ -1225,11 +1225,11 @@ async function AddBetterSEQTAElements(toggle) { ); if (colorresult && colorresult > 300) { - houseelement.style.color = "black"; + houseelement.style.color = 'black'; } else if (colorresult < 300) { - houseelement.style.color = "white"; + houseelement.style.color = 'white'; } else { - houseelement.style.color = "black"; + houseelement.style.color = 'black'; } houseelement.innerText = students[index].year + students[index].house; @@ -1242,51 +1242,51 @@ async function AddBetterSEQTAElements(toggle) { }); }); - var NewsButtonStr = "
  • "; + var NewsButtonStr = '
  • '; var NewsButton = stringToHTML(NewsButtonStr); List.appendChild(NewsButton.firstChild); - editmenu = document.createElement("div"); - editmenu.classList.add("editmenu"); + editmenu = document.createElement('div'); + editmenu.classList.add('editmenu'); let svg = stringToHTML( - "", + '', ); editmenu.append(svg.firstChild); menu.appendChild(editmenu); - let a = document.createElement("div"); - a.classList.add("icon-cover"); - a.id = "icon-cover"; + let a = document.createElement('div'); + a.classList.add('icon-cover'); + a.id = 'icon-cover'; menu.appendChild(a); - var editmenu = document.querySelector("#editmenu"); - editmenu.addEventListener("click", function () { + var editmenu = document.querySelector('#editmenu'); + editmenu.addEventListener('click', function () { if (!MenuOptionsOpen) { OpenMenuOptions(); } }); - var menuCover = document.querySelector("#icon-cover"); - menuCover.addEventListener("click", function () { - location.href = "../#?page=/home"; + var menuCover = document.querySelector('#icon-cover'); + menuCover.addEventListener('click', function () { + location.href = '../#?page=/home'; SendHomePage(); document - .getElementById("menu") - .firstChild.classList.remove("noscroll"); + .getElementById('menu') + .firstChild.classList.remove('noscroll'); }); // Creates the home container when the menu button is pressed - var homebutton = document.getElementById("homebutton"); - homebutton.addEventListener("click", function () { + var homebutton = document.getElementById('homebutton'); + homebutton.addEventListener('click', function () { if (!MenuOptionsOpen) { SendHomePage(); } }); // Creates the news container when the menu button is pressed - var newsbutton = document.getElementById("newsbutton"); - newsbutton.addEventListener("click", function () { + var newsbutton = document.getElementById('newsbutton'); + newsbutton.addEventListener('click', function () { if (!MenuOptionsOpen) { SendNewsPage(); } @@ -1300,9 +1300,9 @@ async function AddBetterSEQTAElements(toggle) { if (toggle) { // Creates settings and dashboard buttons next to alerts var SettingsButton = stringToHTML( - "", + '', ); - var ContentDiv = document.getElementById("content"); + var ContentDiv = document.getElementById('content'); ContentDiv.append(SettingsButton.firstChild); const result = await new Promise(resolve => { @@ -1311,8 +1311,8 @@ async function AddBetterSEQTAElements(toggle) { const DarkMode = result.DarkMode; const tooltipString = GetLightDarkModeString(DarkMode); - const svgContent = DarkMode ? "" : - ""; + const svgContent = DarkMode ? '' : + ''; const LightDarkModeButton = stringToHTML(` ", + '', ); - ContentDiv = document.getElementById("content"); + ContentDiv = document.getElementById('content'); ContentDiv.append(SettingsButton.firstChild); } - var AddedSettings = document.getElementById("AddedSettings"); - var extensionsettings = document.getElementById("ExtensionPopup"); + var AddedSettings = document.getElementById('AddedSettings'); + var extensionsettings = document.getElementById('ExtensionPopup'); - AddedSettings.addEventListener("click", function () { - extensionsettings.classList.toggle("hide"); + AddedSettings.addEventListener('click', function () { + extensionsettings.classList.toggle('hide'); SettingsClicked = true; }); } @@ -1373,9 +1373,9 @@ let tooltipstring; function GetLightDarkModeString(darkmodetoggle) { if (darkmodetoggle) { - tooltipstring = "Switch to light theme"; + tooltipstring = 'Switch to light theme'; } else { - tooltipstring = "Switch to dark theme"; + tooltipstring = 'Switch to dark theme'; } return tooltipstring; } @@ -1388,15 +1388,15 @@ function CheckCurrentLesson(lesson, num) { // Takes start time of current lesson and makes it into a Date function for comparison let startDate = new Date(currentDate.getTime()); - startDate.setHours(startTime.split(":")[0]); - startDate.setMinutes(startTime.split(":")[1]); - startDate.setSeconds("00"); + startDate.setHours(startTime.split(':')[0]); + startDate.setMinutes(startTime.split(':')[1]); + startDate.setSeconds('00'); // Takes end time of current lesson and makes it into a Date function for comparison let endDate = new Date(currentDate.getTime()); - endDate.setHours(endTime.split(":")[0]); - endDate.setMinutes(endTime.split(":")[1]); - endDate.setSeconds("00"); + endDate.setHours(endTime.split(':')[0]); + endDate.setMinutes(endTime.split(':')[1]); + endDate.setSeconds('00'); // Gets the difference between the start time and current time var difference = startDate.getTime() - currentDate.getTime(); @@ -1414,16 +1414,16 @@ function CheckCurrentLesson(lesson, num) { clearInterval(LessonInterval); } else { if ( - currentSelectedDate.toLocaleDateString("en-au") == - date.toLocaleDateString("en-au") + currentSelectedDate.toLocaleDateString('en-au') == + date.toLocaleDateString('en-au') ) { if (valid) { // Apply the activelesson class to increase the box-shadow of current lesson - elementA.classList.add("activelesson"); + elementA.classList.add('activelesson'); } else { // Removes the activelesson class to ensure only the active lesson have the class if (elementA != null) { - elementA.classList.remove("activelesson"); + elementA.classList.remove('activelesson'); } } } @@ -1431,40 +1431,40 @@ function CheckCurrentLesson(lesson, num) { // If 5 minutes before the start of another lesson: if (minutes == 5) { - chrome.storage.local.get("lessonalert", function (result) { + chrome.storage.local.get('lessonalert', function (result) { if (result.lessonalert) { // Checks if notifications are supported if (!window.Notification) { - console.log("Browser does not support notifications."); + console.log('Browser does not support notifications.'); } else { // check if permission is already granted - if (Notification.permission === "granted") { - new Notification("Next Lesson in 5 Minutes:", { + if (Notification.permission === 'granted') { + new Notification('Next Lesson in 5 Minutes:', { body: - "Subject: " + + 'Subject: ' + lesson.description + - " \nRoom: " + + ' \nRoom: ' + lesson.room + - " \nTeacher: " + + ' \nTeacher: ' + lesson.staff, }); } else { // request permission from user Notification.requestPermission() .then(function (p) { - if (p === "granted") { + if (p === 'granted') { // show notification here - new Notification("Next Lesson in 5 Minutes:", { + new Notification('Next Lesson in 5 Minutes:', { body: - "Subject: " + + 'Subject: ' + lesson.description + - " \nRoom: " + + ' \nRoom: ' + lesson.room + - " \nTeacher: " + + ' \nTeacher: ' + lesson.staff, }); } else { - console.log("User blocked notifications."); + console.log('User blocked notifications.'); } }) .catch(function (err) { @@ -1482,7 +1482,7 @@ export function GetThresholdOfColor(color) { const rgbaRegex = /rgba?\(([^)]+)\)/gi; // Check if the color string is a gradient (linear or radial) - if (color.includes("gradient")) { + if (color.includes('gradient')) { let gradientThresholds = []; // Find and replace all instances of RGBA in the gradient @@ -1490,7 +1490,7 @@ export function GetThresholdOfColor(color) { while ((match = rgbaRegex.exec(color)) !== null) { // Extract the individual components (r, g, b, a) const rgbaString = match[1]; - const [r, g, b] = rgbaString.split(",").map(str => str.trim()); + const [r, g, b] = rgbaString.split(',').map(str => str.trim()); // Compute the threshold using your existing algorithm const threshold = Math.sqrt(r ** 2 + g ** 2 + b ** 2); @@ -1523,41 +1523,62 @@ function CheckCurrentLessonAll(lessons) { ); } -function MakeLessonDiv(lesson, num) { - let assessmentstring = ""; - var lessonstring = `

    ${lesson?.description ?? "Unknown"}

    ${ - lesson?.staff ?? "Unknown" - }

    ${lesson?.room ?? "Unknown"}

    ${ - lesson?.from ?? "Unknown" - } - ${lesson?.until ?? "Unknown"}

    ${ - lesson?.attendanceTitle ?? "Unknown" - }
    `; +// Helper function to build the assessment URL +function buildAssessmentURL(programmeID, metaID, itemID = '') { + const base = '../#?page=/assessments/'; + return itemID ? `${base}${programmeID}:${metaID}&item=${itemID}` : `${base}${programmeID}:${metaID}`; +} - if (lesson.programmeID != 0) { - lessonstring += `
    ${assessmentsicon}
    ${coursesicon}
    `; +// Function to create a lesson div element from a lesson object +function makeLessonDiv(lesson, num) { + if (!lesson) throw new Error('No lesson provided.'); + + const { code, colour, description, staff, room, from, until, attendanceTitle, programmeID, metaID, assessments } = lesson; + + // Construct the base lesson string with default values using ternary operators + let lessonString = ` +
    +

    ${description || 'Unknown'}

    +

    ${staff || 'Unknown'}

    +

    ${room || 'Unknown'}

    s +

    ${from || 'Unknown'} - ${until || 'Unknown'}

    +
    ${attendanceTitle || 'Unknown'}
    + `; + + // Add buttons for assessments and courses if applicable + if (programmeID !== 0) { + lessonString += ` +
    ${assessmentsicon}
    +
    ${coursesicon}
    + `; } - if (lesson.assessments.length > 0) { - for (let i = 0; i < lesson.assessments.length; i++) { - const element = lesson.assessments[i]; - assessmentstring += `

    ${element.title}

    `; - } - lessonstring += `
    - -
    ${assessmentstring}
    `; + // Add assessments if they exist + if (assessments && assessments.length > 0) { + const assessmentString = assessments.map(element => + `

    ${element.title}

    ` + ).join(''); + + lessonString += ` +
    + + + +
    ${assessmentString}
    +
    + `; } - lessonstring += "
    "; - var lessondiv = stringToHTML(lessonstring); - return lessondiv; + + lessonString += '
    '; + + return stringToHTML(lessonString); } function CheckUnmarkedAttendance(lessonattendance) { if (lessonattendance) { var lesson = lessonattendance.label; } else { - lesson = " "; + lesson = ' '; } return lesson; } @@ -1565,16 +1586,16 @@ function CheckUnmarkedAttendance(lessonattendance) { function callHomeTimetable(date, change) { // Creates a HTTP Post Request to the SEQTA page for the students timetable var xhr = new XMLHttpRequest(); - xhr.open("POST", `${location.origin}/seqta/student/load/timetable?`, true); + xhr.open('POST', `${location.origin}/seqta/student/load/timetable?`, true); // Sets the response type to json - xhr.setRequestHeader("Content-Type", "application/json; charset=utf-8"); + xhr.setRequestHeader('Content-Type', 'application/json; charset=utf-8'); xhr.onreadystatechange = function () { // Once the response is ready if (xhr.readyState === 4) { var serverResponse = JSON.parse(xhr.response); let lessonArray = []; - var DayContainer = document.getElementById("day-container"); + var DayContainer = document.getElementById('day-container'); // If items in response: if (serverResponse.payload.items.length > 0) { if (!DayContainer.innerText || change) { @@ -1595,7 +1616,7 @@ function callHomeTimetable(date, change) { (element) => element.name === subjectname, ); if (!subject) { - lessonArray[i].colour = "--item-colour: #8e8e8e;"; + lessonArray[i].colour = '--item-colour: #8e8e8e;'; } else { lessonArray[i].colour = `--item-colour: ${subject.value};`; let result = GetThresholdOfColor(subject.value); @@ -1614,12 +1635,12 @@ function callHomeTimetable(date, change) { ); } // If on home page, apply each lesson to HTML with information in each div - DayContainer.innerText = ""; + DayContainer.innerText = ''; for (let i = 0; i < lessonArray.length; i++) { - var div = MakeLessonDiv(lessonArray[i], i + 1); + var div = makeLessonDiv(lessonArray[i], i + 1); // Append each of the lessons into the day-container if (lessonArray[i].invert) { - div.firstChild.classList.add("day-inverted"); + div.firstChild.classList.add('day-inverted'); } DayContainer.append(div.firstChild); @@ -1637,13 +1658,13 @@ function callHomeTimetable(date, change) { } } else { if (!DayContainer.innerText || change) { - DayContainer.innerText = ""; - var dummyDay = document.createElement("div"); - dummyDay.classList.add("day-empty"); - let img = document.createElement("img"); - img.src = chrome.runtime.getURL("icons/betterseqta-light-icon.png"); - let text = document.createElement("p"); - text.innerText = "No lessons available."; + DayContainer.innerText = ''; + var dummyDay = document.createElement('div'); + dummyDay.classList.add('day-empty'); + let img = document.createElement('img'); + img.src = chrome.runtime.getURL('icons/betterseqta-light-icon.png'); + let text = document.createElement('p'); + text.innerText = 'No lessons available.'; dummyDay.append(img); dummyDay.append(text); DayContainer.append(dummyDay); @@ -1664,9 +1685,9 @@ function callHomeTimetable(date, change) { function GetUpcomingAssessments() { let func = fetch(`${location.origin}/seqta/student/assessment/list/upcoming?`, { - method: "POST", + method: 'POST', headers: { - "Content-Type": "application/json; charset=utf-8", + 'Content-Type': 'application/json; charset=utf-8', }, body: JSON.stringify({ student: 69 }), }); @@ -1678,9 +1699,9 @@ function GetUpcomingAssessments() { function GetActiveClasses() { let func = fetch(`${location.origin}/seqta/student/load/subjects?`, { - method: "POST", + method: 'POST', headers: { - "Content-Type": "application/json; charset=utf-8", + 'Content-Type': 'application/json; charset=utf-8', }, body: JSON.stringify({}), }); @@ -1721,43 +1742,43 @@ function CreateElement(type, class_, id, innerText, innerHTML, style) { } function createAssessmentDateDiv(date, value, datecase = undefined) { - var options = { weekday: "long", month: "long", day: "numeric" }; + var options = { weekday: 'long', month: 'long', day: 'numeric' }; const FormattedDate = new Date(date); const assessments = value.assessments; const container = value.div; - let DateTitleDiv = document.createElement("div"); - DateTitleDiv.classList.add("upcoming-date-title"); + let DateTitleDiv = document.createElement('div'); + DateTitleDiv.classList.add('upcoming-date-title'); if (datecase) { - let datetitle = document.createElement("h5"); - datetitle.classList.add("upcoming-special-day"); + let datetitle = document.createElement('h5'); + datetitle.classList.add('upcoming-special-day'); datetitle.innerText = datecase; DateTitleDiv.append(datetitle); - container.setAttribute("data-day", datecase); + container.setAttribute('data-day', datecase); } - let DateTitle = document.createElement("h5"); - DateTitle.innerText = FormattedDate.toLocaleDateString("en-AU", options); + let DateTitle = document.createElement('h5'); + DateTitle.innerText = FormattedDate.toLocaleDateString('en-AU', options); DateTitleDiv.append(DateTitle); container.append(DateTitleDiv); - let assessmentContainer = document.createElement("div"); - assessmentContainer.classList.add("upcoming-date-assessments"); + let assessmentContainer = document.createElement('div'); + assessmentContainer.classList.add('upcoming-date-assessments'); for (let i = 0; i < assessments.length; i++) { const element = assessments[i]; - let item = document.createElement("div"); - item.classList.add("upcoming-assessment"); - item.setAttribute("data-subject", element.code); + let item = document.createElement('div'); + item.classList.add('upcoming-assessment'); + item.setAttribute('data-subject', element.code); item.id = `assessment${element.id}`; item.style = element.colour; - let titlediv = document.createElement("div"); - titlediv.classList.add("upcoming-subject-title"); + let titlediv = document.createElement('div'); + titlediv.classList.add('upcoming-subject-title'); let titlesvg = stringToHTML(` @@ -1765,13 +1786,13 @@ function createAssessmentDateDiv(date, value, datecase = undefined) { `).firstChild; titlediv.append(titlesvg); - let detailsdiv = document.createElement("div"); - detailsdiv.classList.add("upcoming-details"); - let detailstitle = document.createElement("h5"); + let detailsdiv = document.createElement('div'); + detailsdiv.classList.add('upcoming-details'); + let detailstitle = document.createElement('h5'); detailstitle.innerText = `${element.subject} assessment`; - let subject = document.createElement("p"); + let subject = document.createElement('p'); subject.innerText = element.title; - subject.classList.add("upcoming-assessment-title"); + subject.classList.add('upcoming-assessment-title'); subject.onclick = function () { location.href = `../#?page=/assessments/${element.programmeID}:${element.metaclassID}&item=${element.id}`; }; @@ -1783,9 +1804,9 @@ function createAssessmentDateDiv(date, value, datecase = undefined) { assessmentContainer.append(item); fetch(`${location.origin}/seqta/student/assessment/submissions/get`, { - method: "POST", + method: 'POST', headers: { - "Content-Type": "application/json; charset=utf-8", + 'Content-Type': 'application/json; charset=utf-8', }, body: JSON.stringify({ assessment: element.id, @@ -1801,9 +1822,9 @@ function createAssessmentDateDiv(date, value, datecase = undefined) { // ticksvg = stringToHTML(``).firstChild // ticksvg.classList.add('upcoming-tick'); // assessment.append(ticksvg); - let submittedtext = document.createElement("div"); - submittedtext.classList.add("upcoming-submittedtext"); - submittedtext.innerText = "Submitted"; + let submittedtext = document.createElement('div'); + submittedtext.classList.add('upcoming-submittedtext'); + submittedtext.innerText = 'Submitted'; assessment.append(submittedtext); } }); @@ -1820,40 +1841,40 @@ function CheckSpecialDay(date1, date2) { date1.getMonth() === date2.getMonth() && date1.getDate() - 1 === date2.getDate() ) { - return "Yesterday"; + return 'Yesterday'; } if ( date1.getFullYear() === date2.getFullYear() && date1.getMonth() === date2.getMonth() && date1.getDate() === date2.getDate() ) { - return "Today"; + return 'Today'; } if ( date1.getFullYear() === date2.getFullYear() && date1.getMonth() === date2.getMonth() && date1.getDate() + 1 === date2.getDate() ) { - return "Tomorrow"; + return 'Tomorrow'; } } function CreateSubjectFilter(subjectcode, itemcolour, checked) { - let label = CreateElement("label", "upcoming-checkbox-container"); + let label = CreateElement('label', 'upcoming-checkbox-container'); label.innerText = subjectcode; - let input = CreateElement("input"); - input.type = "checkbox"; + let input = CreateElement('input'); + input.type = 'checkbox'; input.checked = checked; input.id = `filter-${subjectcode}`; label.style = itemcolour; - let span = CreateElement("span", "upcoming-checkmark"); + let span = CreateElement('span', 'upcoming-checkmark'); label.append(input); label.append(span); - input.addEventListener("change", function (change) { + input.addEventListener('change', function (change) { chrome.storage.local.get(null, function (storage) { let filters = storage.subjectfilters; - let id = change.target.id.split("-")[1]; + let id = change.target.id.split('-')[1]; filters[id] = change.target.checked; chrome.storage.local.set({ subjectfilters: filters }); @@ -1867,7 +1888,7 @@ function CreateFilters(subjects) { chrome.storage.local.get(null, function (result) { let filteroptions = result.subjectfilters; - let filterdiv = document.querySelector("#upcoming-filters"); + let filterdiv = document.querySelector('#upcoming-filters'); for (let i = 0; i < subjects.length; i++) { const element = subjects[i]; // eslint-disable-next-line @@ -1887,7 +1908,7 @@ function CreateFilters(subjects) { } function CreateUpcomingSection(assessments) { - let upcomingitemcontainer = document.querySelector("#upcoming-items"); + let upcomingitemcontainer = document.querySelector('#upcoming-items'); let overdueDates = []; let upcomingDates = {}; @@ -1921,7 +1942,7 @@ function CreateUpcomingSection(assessments) { let subject = subjects.find((element) => element.name === subjectname); if (!subject) { - assessments[i].colour = "--item-colour: #8e8e8e;"; + assessments[i].colour = '--item-colour: #8e8e8e;'; } else { assessments[i].colour = `--item-colour: ${subject.value};`; GetThresholdOfColor(subject.value); // result (originally) result = GetThresholdOfColor @@ -1934,7 +1955,7 @@ function CreateUpcomingSection(assessments) { let subjectname = `timetable.subject.colour.${element.code}`; let colour = colours.find((element) => element.name === subjectname); if (!colour) { - element.colour = "--item-colour: #8e8e8e;"; + element.colour = '--item-colour: #8e8e8e;'; } else { element.colour = `--item-colour: ${colour.value};`; let result = GetThresholdOfColor(colour.value); @@ -1985,7 +2006,7 @@ function CreateUpcomingSection(assessments) { assessmentDate = createAssessmentDateDiv(date, upcomingDates[date]); } - if (specialcase === "Yesterday") { + if (specialcase === 'Yesterday') { upcomingitemcontainer.insertBefore( assessmentDate, upcomingitemcontainer.firstChild, @@ -2002,15 +2023,15 @@ function CreateUpcomingSection(assessments) { } function AddPlaceHolderToParent(parent, numberofassessments) { - let textcontainer = CreateElement("div", "upcoming-blank"); - let textblank = CreateElement("p", "upcoming-hiddenassessment"); - let s = ""; + let textcontainer = CreateElement('div', 'upcoming-blank'); + let textblank = CreateElement('p', 'upcoming-hiddenassessment'); + let s = ''; if (numberofassessments > 1) { - s = "s"; + s = 's'; } textblank.innerText = `${numberofassessments} hidden assessment${s} due`; textcontainer.append(textblank); - textcontainer.setAttribute("data-hidden", true); + textcontainer.setAttribute('data-hidden', true); parent.append(textcontainer); } @@ -2023,37 +2044,37 @@ function FilterUpcomingAssessments(subjectoptions) { const element = subjectdivs[i]; if (!subjectoptions[item]) { - element.classList.add("hidden"); + element.classList.add('hidden'); } if (subjectoptions[item]) { - element.classList.remove("hidden"); + element.classList.remove('hidden'); } - element.parentNode.classList.remove("hidden"); + element.parentNode.classList.remove('hidden'); let children = element.parentNode.parentNode.children; for (let i = 0; i < children.length; i++) { const element = children[i]; - if (element.hasAttribute("data-hidden")) { + if (element.hasAttribute('data-hidden')) { element.remove(); } } if ( element.parentNode.children.length == - element.parentNode.querySelectorAll(".hidden").length + element.parentNode.querySelectorAll('.hidden').length ) { - if (element.parentNode.querySelectorAll(".hidden").length > 0) { - if (!element.parentNode.parentNode.hasAttribute("data-day")) { - element.parentNode.parentNode.classList.add("hidden"); + if (element.parentNode.querySelectorAll('.hidden').length > 0) { + if (!element.parentNode.parentNode.hasAttribute('data-day')) { + element.parentNode.parentNode.classList.add('hidden'); } else { AddPlaceHolderToParent( element.parentNode.parentNode, - element.parentNode.querySelectorAll(".hidden").length, + element.parentNode.querySelectorAll('.hidden').length, ); } } } else { - element.parentNode.parentNode.classList.remove("hidden"); + element.parentNode.parentNode.classList.remove('hidden'); } } } @@ -2067,11 +2088,11 @@ chrome.storage.onChanged.addListener(function (changes) { async function GetLessonColours() { let func = fetch(`${location.origin}/seqta/student/load/prefs?`, { - method: "POST", + method: 'POST', headers: { - "Content-Type": "application/json; charset=utf-8", + 'Content-Type': 'application/json; charset=utf-8', }, - body: JSON.stringify({ request: "userPrefs", asArray: true, user: 69 }), + body: JSON.stringify({ request: 'userPrefs', asArray: true, user: 69 }), }); return func .then((result) => result.json()) @@ -2080,12 +2101,12 @@ async function GetLessonColours() { export function CreateCustomShortcutDiv(element) { // Creates the stucture and element information for each seperate shortcut - var shortcut = document.createElement("a"); - shortcut.setAttribute("href", element.url); - shortcut.setAttribute("target", "_blank"); - var shortcutdiv = document.createElement("div"); - shortcutdiv.classList.add("shortcut"); - shortcutdiv.classList.add("customshortcut"); + var shortcut = document.createElement('a'); + shortcut.setAttribute('href', element.url); + shortcut.setAttribute('target', '_blank'); + var shortcutdiv = document.createElement('div'); + shortcutdiv.classList.add('shortcut'); + shortcutdiv.classList.add('customshortcut'); let image = stringToHTML( ` @@ -2104,29 +2125,29 @@ export function CreateCustomShortcutDiv(element) { `, ).firstChild; - image.classList.add("shortcuticondiv"); - var text = document.createElement("p"); + image.classList.add('shortcuticondiv'); + var text = document.createElement('p'); text.textContent = element.name; shortcutdiv.append(image); shortcutdiv.append(text); shortcut.append(shortcutdiv); - document.getElementById("shortcuts").append(shortcut); + document.getElementById('shortcuts').append(shortcut); } export function RemoveShortcutDiv(elements) { elements.forEach((element) => { - const shortcuts = document.querySelectorAll(".shortcut"); + const shortcuts = document.querySelectorAll('.shortcut'); shortcuts.forEach((shortcut) => { const anchorElement = shortcut.parentElement; // the element is the parent - const textElement = shortcut.querySelector("p"); //

    is a direct child of .shortcut - const title = textElement ? textElement.textContent : ""; + const textElement = shortcut.querySelector('p'); //

    is a direct child of .shortcut + const title = textElement ? textElement.textContent : ''; let shouldRemove = title === element.name; // Check href only if element.url exists if (element.url) { - shouldRemove = shouldRemove && (anchorElement.getAttribute("href") === element.url); + shouldRemove = shouldRemove && (anchorElement.getAttribute('href') === element.url); } if (shouldRemove) { @@ -2137,11 +2158,11 @@ export function RemoveShortcutDiv(elements) { } function AddCustomShortcutsToPage() { - chrome.storage.local.get(["customshortcuts"], function (result) { + chrome.storage.local.get(['customshortcuts'], function (result) { var customshortcuts = Object.values(result)[0]; if (customshortcuts.length > 0) { - document.getElementsByClassName("shortcut-container")[0].style.display = - "block"; + document.getElementsByClassName('shortcut-container')[0].style.display = + 'block'; for (let i = 0; i < customshortcuts.length; i++) { const element = customshortcuts[i]; CreateCustomShortcutDiv(element); @@ -2153,26 +2174,26 @@ function AddCustomShortcutsToPage() { function SendHomePage() { setTimeout(function () { // Sends the html data for the home page - console.log("[BetterSEQTA] Started Loading Home Page"); - document.title = "Home ― SEQTA Learn"; - var element = document.querySelector("[data-key=home]"); + console.log('[BetterSEQTA] Started Loading Home Page'); + document.title = 'Home ― SEQTA Learn'; + var element = document.querySelector('[data-key=home]'); // Apply the active class to indicate clicked on home button - element.classList.add("active"); + element.classList.add('active'); // Remove all current elements in the main div to add new elements - var main = document.getElementById("main"); - main.innerHTML = ""; + var main = document.getElementById('main'); + main.innerHTML = ''; - const titlediv = document.getElementById("title").firstChild; - titlediv.innerText = "Home"; - document.querySelector("link[rel*=\"icon\"]").href = - chrome.runtime.getURL("icons/icon-48.png"); + const titlediv = document.getElementById('title').firstChild; + titlediv.innerText = 'Home'; + document.querySelector('link[rel*="icon"]').href = + chrome.runtime.getURL('icons/icon-48.png'); currentSelectedDate = new Date(); // Creates the root of the home page added to the main div - var html = stringToHTML("

    "); + var html = stringToHTML('
    '); // Appends the html file to main div // Note : firstChild of html is done due to needing to grab the body from the stringToHTML function @@ -2183,30 +2204,30 @@ function SendHomePage() { // Formats the current date used send a request for timetable and notices later var TodayFormatted = - date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate(); + date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate(); // Replaces actual date with a selected date. Used for testing. // TodayFormatted = "2020-08-31"; // Creates the shortcut container into the home container - var ShortcutStr = "
    "; + var ShortcutStr = '
    '; var Shortcut = stringToHTML(ShortcutStr); // Appends the shortcut container into the home container - document.getElementById("home-container").append(Shortcut.firstChild); + document.getElementById('home-container').append(Shortcut.firstChild); // Creates the container div for the timetable portion of the home page - var TimetableStr = "

    Today's Lessons

    "; + var TimetableStr = '

    Today\'s Lessons

    '; var Timetable = stringToHTML(TimetableStr); // Appends the timetable container into the home container - document.getElementById("home-container").append(Timetable.firstChild); + document.getElementById('home-container').append(Timetable.firstChild); - var timetablearrowback = document.getElementById("home-timetable-back"); + var timetablearrowback = document.getElementById('home-timetable-back'); var timetablearrowforward = document.getElementById( - "home-timetable-forward", + 'home-timetable-forward', ); function SetTimetableSubtitle() { - var homelessonsubtitle = document.getElementById("home-lesson-subtitle"); + var homelessonsubtitle = document.getElementById('home-lesson-subtitle'); const date = new Date(); if ( date.getYear() == currentSelectedDate.getYear() && @@ -2214,26 +2235,26 @@ function SendHomePage() { ) { if (date.getDate() == currentSelectedDate.getDate()) { // Change text to Today's Lessons - homelessonsubtitle.innerText = "Today's Lessons"; + homelessonsubtitle.innerText = 'Today\'s Lessons'; } else if (date.getDate() - 1 == currentSelectedDate.getDate()) { // Change text to Yesterday's Lessons - homelessonsubtitle.innerText = "Yesterday's Lessons"; + homelessonsubtitle.innerText = 'Yesterday\'s Lessons'; } else if (date.getDate() + 1 == currentSelectedDate.getDate()) { // Change text to Tomorrow's Lessons - homelessonsubtitle.innerText = "Tomorrow's Lessons"; + homelessonsubtitle.innerText = 'Tomorrow\'s Lessons'; } else { // Change text to date of the day homelessonsubtitle.innerText = `${currentSelectedDate.toLocaleString( - "en-us", - { weekday: "short" }, - )} ${currentSelectedDate.toLocaleDateString("en-au")}`; + 'en-us', + { weekday: 'short' }, + )} ${currentSelectedDate.toLocaleDateString('en-au')}`; } } else { // Change text to date of the day homelessonsubtitle.innerText = `${currentSelectedDate.toLocaleString( - "en-us", - { weekday: "short" }, - )} ${currentSelectedDate.toLocaleDateString("en-au")}`; + 'en-us', + { weekday: 'short' }, + )} ${currentSelectedDate.toLocaleDateString('en-au')}`; } } @@ -2241,63 +2262,63 @@ function SendHomePage() { currentSelectedDate.setDate(currentSelectedDate.getDate() + value); let FormattedDate = currentSelectedDate.getFullYear() + - "-" + + '-' + (currentSelectedDate.getMonth() + 1) + - "-" + + '-' + currentSelectedDate.getDate(); callHomeTimetable(FormattedDate, true); SetTimetableSubtitle(); } - timetablearrowback.addEventListener("click", function () { + timetablearrowback.addEventListener('click', function () { changeTimetable(-1); }); - timetablearrowforward.addEventListener("click", function () { + timetablearrowforward.addEventListener('click', function () { changeTimetable(1); }); // Adds the shortcuts to the shortcut container - chrome.storage.local.get(["shortcuts"], function (result) { + chrome.storage.local.get(['shortcuts'], function (result) { const shortcuts = Object.values(result)[0]; addShortcuts(shortcuts); }); // Creates the upcoming container and appends to the home container - var upcomingcontainer = document.createElement("div"); - upcomingcontainer.classList.add("upcoming-container"); - upcomingcontainer.classList.add("border"); + var upcomingcontainer = document.createElement('div'); + upcomingcontainer.classList.add('upcoming-container'); + upcomingcontainer.classList.add('border'); - let upcomingtitlediv = CreateElement("div", "upcoming-title"); - let upcomingtitle = document.createElement("h2"); - upcomingtitle.classList.add("home-subtitle"); - upcomingtitle.innerText = "Upcoming Assessments"; + let upcomingtitlediv = CreateElement('div', 'upcoming-title'); + let upcomingtitle = document.createElement('h2'); + upcomingtitle.classList.add('home-subtitle'); + upcomingtitle.innerText = 'Upcoming Assessments'; upcomingtitlediv.append(upcomingtitle); let upcomingfilterdiv = CreateElement( - "div", - "upcoming-filters", - "upcoming-filters", + 'div', + 'upcoming-filters', + 'upcoming-filters', ); upcomingtitlediv.append(upcomingfilterdiv); upcomingcontainer.append(upcomingtitlediv); - let upcomingitems = document.createElement("div"); - upcomingitems.id = "upcoming-items"; - upcomingitems.classList.add("upcoming-items"); + let upcomingitems = document.createElement('div'); + upcomingitems.id = 'upcoming-items'; + upcomingitems.classList.add('upcoming-items'); upcomingcontainer.append(upcomingitems); - document.getElementById("home-container").append(upcomingcontainer); + document.getElementById('home-container').append(upcomingcontainer); // Creates the notices container into the home container - var NoticesStr = "

    Notices

    "; + var NoticesStr = '

    Notices

    '; var Notices = stringToHTML(NoticesStr); // Appends the shortcut container into the home container - document.getElementById("home-container").append(Notices.firstChild); + document.getElementById('home-container').append(Notices.firstChild); animate( - ".home-container > div", + '.home-container > div', { opacity: [0, 1], y: [10, 0] }, { delay: stagger(0.2, { start: 0 }), @@ -2310,50 +2331,50 @@ function SendHomePage() { // Sends similar HTTP Post Request for the notices var xhr2 = new XMLHttpRequest(); - xhr2.open("POST", `${location.origin}/seqta/student/load/notices?`, true); - xhr2.setRequestHeader("Content-Type", "application/json; charset=utf-8"); + xhr2.open('POST', `${location.origin}/seqta/student/load/notices?`, true); + xhr2.setRequestHeader('Content-Type', 'application/json; charset=utf-8'); xhr2.onreadystatechange = function () { if (xhr2.readyState === 4) { var NoticesPayload = JSON.parse(xhr2.response); - var NoticeContainer = document.getElementById("notice-container"); + var NoticeContainer = document.getElementById('notice-container'); if (NoticesPayload.payload.length == 0) { if (!NoticeContainer.innerText) { // If no notices: display no notices - var dummyNotice = document.createElement("div"); - dummyNotice.textContent = "No notices for today."; - dummyNotice.classList.add("dummynotice"); + var dummyNotice = document.createElement('div'); + dummyNotice.textContent = 'No notices for today.'; + dummyNotice.classList.add('dummynotice'); NoticeContainer.append(dummyNotice); } } else { if (!NoticeContainer.innerText) { // For each element in the response json: - chrome.storage.local.get(["DarkMode"], function (result) { + chrome.storage.local.get(['DarkMode'], function (result) { DarkMode = result.DarkMode; for (let i = 0; i < NoticesPayload.payload.length; i++) { // Create a div, and place information from json response - var NewNotice = document.createElement("div"); - NewNotice.classList.add("notice"); + var NewNotice = document.createElement('div'); + NewNotice.classList.add('notice'); var title = stringToHTML( - "

    " + + '

    ' + NoticesPayload.payload[i].title + - "

    ", + '', ); NewNotice.append(title.firstChild); if (NoticesPayload.payload[i].label_title != undefined) { var label = stringToHTML( - "
    " + + '
    ' + NoticesPayload.payload[i].label_title + - "
    ", + '', ); NewNotice.append(label.firstChild); } var staff = stringToHTML( - "
    " + + '
    ' + NoticesPayload.payload[i].staff + - "
    ", + '', ); NewNotice.append(staff.firstChild); // Converts the string into HTML @@ -2369,16 +2390,16 @@ function SendHomePage() { // Gets the colour for the top section of each notice var colour = NoticesPayload.payload[i].colour; - if (typeof colour == "string") { + if (typeof colour == 'string') { let rgb = GetThresholdOfColor(colour); if (rgb < 100 && result.DarkMode) { colour = undefined; } } - var colourbar = document.createElement("div"); - colourbar.classList.add("colourbar"); - colourbar.style.background = "var(--colour)"; + var colourbar = document.createElement('div'); + colourbar.classList.add('colourbar'); + colourbar.style.background = 'var(--colour)'; NewNotice.style = `--colour: ${colour}`; // Appends the colour bar to the new notice NewNotice.append(colourbar); @@ -2442,7 +2463,7 @@ export function addShortcuts(shortcuts) { const currentShortcut = shortcuts[i]; if (currentShortcut?.enabled) { - const Itemname = (currentShortcut?.name ?? "").replace(/\s/g, ""); + const Itemname = (currentShortcut?.name ?? '').replace(/\s/g, ''); const linkDetails = ShortcutLinks?.[Itemname]; if (linkDetails) { @@ -2462,19 +2483,19 @@ export function addShortcuts(shortcuts) { export function enableNotificationCollector() { var xhr3 = new XMLHttpRequest(); - xhr3.open("POST", `${location.origin}/seqta/student/heartbeat?`, true); + xhr3.open('POST', `${location.origin}/seqta/student/heartbeat?`, true); xhr3.setRequestHeader( - "Content-Type", - "application/json; charset=utf-8" + 'Content-Type', + 'application/json; charset=utf-8' ); xhr3.onreadystatechange = function () { if (xhr3.readyState === 4) { var Notifications = JSON.parse(xhr3.response); var alertdiv = document.getElementsByClassName( - "notifications__bubble___1EkSQ" + 'notifications__bubble___1EkSQ' )[0]; - if (typeof alertdiv == "undefined") { - console.log("[BetterSEQTA] No notifications currently"); + if (typeof alertdiv == 'undefined') { + console.log('[BetterSEQTA] No notifications currently'); } else { alertdiv.textContent = Notifications.payload.notifications.length; } @@ -2482,102 +2503,102 @@ export function enableNotificationCollector() { }; xhr3.send( JSON.stringify({ - timestamp: "1970-01-01 00:00:00.0", - hash: "#?page=/home", + timestamp: '1970-01-01 00:00:00.0', + hash: '#?page=/home', }) ); } export function disableNotificationCollector() { - var alertdiv = document.getElementsByClassName("notifications__bubble___1EkSQ")[0]; - if (typeof alertdiv != "undefined") { + var alertdiv = document.getElementsByClassName('notifications__bubble___1EkSQ')[0]; + if (typeof alertdiv != 'undefined') { var currentNumber = parseInt(alertdiv.textContent); if (currentNumber < 9) { alertdiv.textContent = currentNumber; } else { - alertdiv.textContent = "9+"; + alertdiv.textContent = '9+'; } } } function createNewShortcut(link, icon, viewBox, title) { // Creates the stucture and element information for each seperate shortcut - let shortcut = document.createElement("a"); - shortcut.setAttribute("href", link); - shortcut.setAttribute("target", "_blank"); - let shortcutdiv = document.createElement("div"); - shortcutdiv.classList.add("shortcut"); + let shortcut = document.createElement('a'); + shortcut.setAttribute('href', link); + shortcut.setAttribute('target', '_blank'); + let shortcutdiv = document.createElement('div'); + shortcutdiv.classList.add('shortcut'); let image = stringToHTML( ``, ).firstChild; - image.classList.add("shortcuticondiv"); - let text = document.createElement("p"); + image.classList.add('shortcuticondiv'); + let text = document.createElement('p'); text.textContent = title; shortcutdiv.append(image); shortcutdiv.append(text); shortcut.append(shortcutdiv); - document.getElementById("shortcuts").appendChild(shortcut); + document.getElementById('shortcuts').appendChild(shortcut); } function SendNewsPage() { setTimeout(function () { // Sends the html data for the home page - console.log("[BetterSEQTA] Started Loading News Page"); - document.title = "News ― SEQTA Learn"; - var element = document.querySelector("[data-key=news]"); + console.log('[BetterSEQTA] Started Loading News Page'); + document.title = 'News ― SEQTA Learn'; + var element = document.querySelector('[data-key=news]'); // Apply the active class to indicate clicked on home button - element.classList.add("active"); + element.classList.add('active'); // Remove all current elements in the main div to add new elements - var main = document.getElementById("main"); - main.innerHTML = ""; + var main = document.getElementById('main'); + main.innerHTML = ''; // Creates the root of the home page added to the main div - var htmlStr = "

    Latest Headlines - ABC News

    "; + var htmlStr = '

    Latest Headlines - ABC News

    '; var html = stringToHTML(htmlStr); // Appends the html file to main div // Note : firstChild of html is done due to needing to grab the body from the stringToHTML function main.append(html.firstChild); - const titlediv = document.getElementById("title").firstChild; - titlediv.innerText = "News"; - AppendLoadingSymbol("newsloading", "#news-container"); + const titlediv = document.getElementById('title').firstChild; + titlediv.innerText = 'News'; + AppendLoadingSymbol('newsloading', '#news-container'); - chrome.runtime.sendMessage({ type: "sendNews" }, function (response) { + chrome.runtime.sendMessage({ type: 'sendNews' }, function (response) { let newsarticles = response.news.articles; - var newscontainer = document.querySelector("#news-container"); - document.getElementById("newsloading").remove(); + var newscontainer = document.querySelector('#news-container'); + document.getElementById('newsloading').remove(); for (let i = 0; i < newsarticles.length; i++) { - let newsarticle = document.createElement("a"); - newsarticle.classList.add("NewsArticle"); + let newsarticle = document.createElement('a'); + newsarticle.classList.add('NewsArticle'); newsarticle.href = newsarticles[i].url; - newsarticle.target = "_blank"; + newsarticle.target = '_blank'; - let articleimage = document.createElement("div"); - articleimage.classList.add("articleimage"); + let articleimage = document.createElement('div'); + articleimage.classList.add('articleimage'); - if (newsarticles[i].urlToImage == "null") { + if (newsarticles[i].urlToImage == 'null') { articleimage.style.backgroundImage = `url(${chrome.runtime.getURL( - "icons/betterseqta-light-outline.png", + 'icons/betterseqta-light-outline.png', )})`; - articleimage.style.width = "20%"; - articleimage.style.margin = "0 7.5%"; + articleimage.style.width = '20%'; + articleimage.style.margin = '0 7.5%'; } else { articleimage.style.backgroundImage = `url(${newsarticles[i].urlToImage})`; } - let articletext = document.createElement("div"); - articletext.classList.add("ArticleText"); - let title = document.createElement("a"); + let articletext = document.createElement('div'); + articletext.classList.add('ArticleText'); + let title = document.createElement('a'); title.innerText = newsarticles[i].title; title.href = newsarticles[i].url; - title.target = "_blank"; + title.target = '_blank'; - let description = document.createElement("p"); + let description = document.createElement('p'); description.innerHTML = newsarticles[i].description; articletext.append(title); @@ -2594,7 +2615,7 @@ function SendNewsPage() { async function CheckForMenuList() { if (!MenuItemMutation) { try { - if (document.getElementById("menu").firstChild) { + if (document.getElementById('menu').firstChild) { ObserveMenuItemPosition(); MenuItemMutation = true; } @@ -2605,7 +2626,7 @@ async function CheckForMenuList() { } function LoadInit() { - console.log("[BetterSEQTA] Started Init"); + console.log('[BetterSEQTA] Started Init'); chrome.storage.local.get(null, function (result) { if (result.onoff) { SendHomePage(); diff --git a/src/background.js b/src/background.js index f9671182..aa18c9be 100644 --- a/src/background.js +++ b/src/background.js @@ -2,11 +2,11 @@ export const openDB = () => { return new Promise((resolve, reject) => { - const request = indexedDB.open("MyDatabase", 1); + const request = indexedDB.open('MyDatabase', 1); request.onupgradeneeded = (event) => { const db = event.target.result; - db.createObjectStore("backgrounds", { keyPath: "id" }); + db.createObjectStore('backgrounds', { keyPath: 'id' }); }; request.onsuccess = () => { @@ -14,7 +14,7 @@ export const openDB = () => { }; request.onerror = (event) => { - reject("Error opening database: " + event.target.errorCode); + reject('Error opening database: ' + event.target.errorCode); }; }); }; @@ -22,9 +22,9 @@ export const openDB = () => { export const writeData = async (type, data) => { const db = await openDB(); - const tx = db.transaction("backgrounds", "readwrite"); - const store = tx.objectStore("backgrounds"); - const request = await store.put({ id: "customBackground", type, data }); + const tx = db.transaction('backgrounds', 'readwrite'); + const store = tx.objectStore('backgrounds'); + const request = await store.put({ id: 'customBackground', type, data }); return request.result; }; @@ -33,11 +33,11 @@ export const readData = () => { return new Promise((resolve, reject) => { openDB() .then(db => { - const tx = db.transaction("backgrounds", "readonly"); - const store = tx.objectStore("backgrounds"); + const tx = db.transaction('backgrounds', 'readonly'); + const store = tx.objectStore('backgrounds'); // Retrieve the custom background - const getRequest = store.get("customBackground"); + const getRequest = store.get('customBackground'); // Attach success and error event handlers getRequest.onsuccess = function(event) { @@ -45,12 +45,12 @@ export const readData = () => { }; getRequest.onerror = function(event) { - console.error("An error occurred:", event); + console.error('An error occurred:', event); reject(event); }; }) .catch(error => { - console.error("An error occurred:", error); + console.error('An error occurred:', error); reject(error); }); }); @@ -59,7 +59,7 @@ export const readData = () => { function ReloadSEQTAPages() { chrome.tabs.query({}, function (tabs) { for (let tab of tabs) { - if (tab.title.includes("SEQTA Learn")) { + if (tab.title.includes('SEQTA Learn')) { chrome.tabs.reload(tab.id); } } @@ -68,12 +68,12 @@ function ReloadSEQTAPages() { // Helper function to handle setting permissions const handleAddPermissions = () => { - if (typeof chrome.declarativeContent !== "undefined") { + if (typeof chrome.declarativeContent !== 'undefined') { chrome.declarativeContent.onPageChanged.removeRules(undefined, () => {}); } chrome.permissions.request( - { permissions: ["declarativeContent"], origins: ["*://*/*"] }, + { permissions: ['declarativeContent'], origins: ['*://*/*'] }, (granted) => { if (granted) { const rules = [ @@ -84,7 +84,7 @@ const handleAddPermissions = () => { chrome.declarativeContent.onPageChanged.addRules([rule]); }); - alert("Permissions granted. Reload SEQTA pages to see changes. If this workaround doesn't work, please contact the developer. It will be an easy fix"); + alert('Permissions granted. Reload SEQTA pages to see changes. If this workaround doesn\'t work, please contact the developer. It will be an easy fix'); } } ); @@ -93,15 +93,15 @@ const handleAddPermissions = () => { // Main message listener chrome.runtime.onMessage.addListener((request, sender, sendResponse) => { switch (request.type) { - case "reloadTabs": + case 'reloadTabs': ReloadSEQTAPages(); break; - case "IndexedDB": + case 'IndexedDB': HandleIntexedDB(request, sendResponse); return true; - case "currentTab": + case 'currentTab': chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) { chrome.tabs.sendMessage(tabs[0].id, request, function (response) { sendResponse(response); @@ -109,36 +109,36 @@ chrome.runtime.onMessage.addListener((request, sender, sendResponse) => { }); return true; - case "githubTab": - chrome.tabs.create({ url: "github.com/SethBurkart123/EvenBetterSEQTA" }); + case 'githubTab': + chrome.tabs.create({ url: 'github.com/SethBurkart123/EvenBetterSEQTA' }); break; - case "setDefaultStorage": + case 'setDefaultStorage': SetStorageValue(DefaultValues); break; - case "addPermissions": + case 'addPermissions': handleAddPermissions(); break; - case "sendNews": + case 'sendNews': GetNews(sendResponse); return true; // eslint-disable-next-line no-unreachable break; default: - console.log("Unknown request type"); + console.log('Unknown request type'); } }); function HandleIntexedDB(request, sendResponse) { switch (request.action) { - case "write": + case 'write': writeData(request.data.type, request.data.data); break; - case "read": + case 'read': readData().then((data) => { sendResponse(data); }); @@ -152,9 +152,9 @@ function GetNews(sendResponse) { const from = date.getFullYear() + - "-" + + '-' + (date.getMonth() + 1) + - "-" + + '-' + (date.getDate() - 1); let url = `https://newsapi.org/v2/everything?domains=abc.net.au&from=${from}&apiKey=17c0da766ba347c89d094449504e3080`; @@ -162,8 +162,8 @@ function GetNews(sendResponse) { fetch(url) .then((result) => result.json()) .then((response) => { - if (response.code == "rateLimited") { - url += "%00"; + if (response.code == 'rateLimited') { + url += '%00'; GetNews(); } else { sendResponse({ news: response }); @@ -181,55 +181,55 @@ const DefaultValues = { menuitems: {}, menuorder: [], subjectfilters: {}, - selectedColor: "linear-gradient(40deg, rgba(201,61,0,1) 0%, RGBA(170, 5, 58, 1) 100%)", + selectedColor: 'linear-gradient(40deg, rgba(201,61,0,1) 0%, RGBA(170, 5, 58, 1) 100%)', DarkMode: true, shortcuts: [ { - name: "YouTube", + name: 'YouTube', enabled: false, }, { - name: "Outlook", + name: 'Outlook', enabled: true, }, { - name: "Office", + name: 'Office', enabled: true, }, { - name: "Spotify", + name: 'Spotify', enabled: false, }, { - name: "Google", + name: 'Google', enabled: true, }, { - name: "DuckDuckGo", + name: 'DuckDuckGo', enabled: false, }, { - name: "Cool Math Games", + name: 'Cool Math Games', enabled: false, }, { - name: "SACE", + name: 'SACE', enabled: false, }, { - name: "Google Scholar", + name: 'Google Scholar', enabled: false, }, { - name: "Gmail", + name: 'Gmail', enabled: false, }, { - name: "Netflix", + name: 'Netflix', enabled: false, }, { - name: "Education Perfect", + name: 'Education Perfect', enabled: false, }, ], @@ -250,8 +250,8 @@ function UpdateCurrentValues() { function CheckInnerElement(element) { for (let i in element) { - if (typeof element[i] === "object") { - if (typeof DefaultValues[i].length == "undefined") { + if (typeof element[i] === 'object') { + if (typeof DefaultValues[i].length == 'undefined') { NewValue[i] = Object.assign({}, DefaultValues[i], CurrentValues[i]); } else { // If the object is an array, turn it back after @@ -268,8 +268,8 @@ function UpdateCurrentValues() { } CheckInnerElement(DefaultValues); - if (items["customshortcuts"]) { - NewValue["customshortcuts"] = items["customshortcuts"]; + if (items['customshortcuts']) { + NewValue['customshortcuts'] = items['customshortcuts']; } SetStorageValue(NewValue); @@ -281,7 +281,7 @@ function migrateOldStorage() { let shouldUpdate = false; // Flag to check if there is anything to update // Check for the old "Name" field and convert it to "name" - if (items.shortcuts && items.shortcuts.length > 0 && "Name" in items.shortcuts[0]) { + if (items.shortcuts && items.shortcuts.length > 0 && 'Name' in items.shortcuts[0]) { shouldUpdate = true; items.shortcuts = items.shortcuts.map((shortcut) => { return { @@ -294,9 +294,9 @@ function migrateOldStorage() { // Check for "educationperfect" and convert it to "Education Perfect" if (items.shortcuts && items.shortcuts.length > 0) { for (let shortcut of items.shortcuts) { - if (shortcut.name === "educationperfect" || shortcut.name === "Education Perfect") { + if (shortcut.name === 'educationperfect' || shortcut.name === 'Education Perfect') { shouldUpdate = true; - shortcut.name = "Education Perfect"; + shortcut.name = 'Education Perfect'; } } } @@ -304,16 +304,16 @@ function migrateOldStorage() { // If there"s something to update, set the new values in storage if (shouldUpdate) { chrome.storage.local.set({ shortcuts: items.shortcuts }, function() { - console.log("Migration completed."); + console.log('Migration completed.'); }); } }); } chrome.runtime.onInstalled.addListener(function (event) { - chrome.storage.local.remove(["justupdated"]); + chrome.storage.local.remove(['justupdated']); UpdateCurrentValues(); - if ( event.reason == "install", event.reason == "update" ) { + if ( event.reason == 'install', event.reason == 'update' ) { chrome.storage.local.set({ justupdated: true }); migrateOldStorage(); } diff --git a/src/inject/documentload.js b/src/inject/documentload.js index b089896e..c5ea1999 100644 --- a/src/inject/documentload.js +++ b/src/inject/documentload.js @@ -1 +1 @@ -import "./documentload.css"; +import './documentload.css'; diff --git a/src/inject/iframe.js b/src/inject/iframe.js index 7e4a3b35..ceb9b40d 100644 --- a/src/inject/iframe.js +++ b/src/inject/iframe.js @@ -1 +1 @@ -import "./iframe.css"; +import './iframe.css'; diff --git a/src/inject/injected.js b/src/inject/injected.js index 3e2e8777..81b6f527 100644 --- a/src/inject/injected.js +++ b/src/inject/injected.js @@ -1 +1 @@ -import "./injected.css"; +import './injected.css'; diff --git a/src/seqta/ui/Animation.js b/src/seqta/ui/Animation.js index 940fa93d..108ea20a 100644 --- a/src/seqta/ui/Animation.js +++ b/src/seqta/ui/Animation.js @@ -6,7 +6,7 @@ */ export function updateBgDurations(speed, minDuration = 0.5, maxDuration = 10) { // Class names to look for - const bgClasses = ["bg", "bg2", "bg3"]; + const bgClasses = ['bg', 'bg2', 'bg3']; let reversedValue; if (speed.bksliderinput === undefined) { diff --git a/src/seqta/ui/ImageBackgrounds.js b/src/seqta/ui/ImageBackgrounds.js index 41b78435..8d07fc8d 100644 --- a/src/seqta/ui/ImageBackgrounds.js +++ b/src/seqta/ui/ImageBackgrounds.js @@ -1,15 +1,15 @@ /* global chrome */ export async function appendBackgroundToUI() { - console.log("Starting appendBackgroundToUI..."); + console.log('Starting appendBackgroundToUI...'); - const parent = document.getElementById("container"); + const parent = document.getElementById('container'); // embed background.html - const background = document.createElement("iframe"); - background.id = "background"; - background.classList.add("imageBackground"); - background.setAttribute("excludeDarkCheck", "true"); - background.src = chrome.runtime.getURL("backgrounds/background.html"); + const background = document.createElement('iframe'); + background.id = 'background'; + background.classList.add('imageBackground'); + background.setAttribute('excludeDarkCheck', 'true'); + background.src = chrome.runtime.getURL('backgrounds/background.html'); parent.appendChild(background); } diff --git a/src/seqta/ui/Loading.js b/src/seqta/ui/Loading.js index 8b54d2a5..07dc28b5 100644 --- a/src/seqta/ui/Loading.js +++ b/src/seqta/ui/Loading.js @@ -1,5 +1,5 @@ /*global chrome*/ -import stringToHTML from "../utils/stringToHTML.js"; +import stringToHTML from '../utils/stringToHTML.js'; const loadingSpinner = ` @@ -77,6 +77,6 @@ export default function loading() { chrome.runtime.getManifest().version }`, ); - var html = document.getElementsByTagName("html")[0]; + var html = document.getElementsByTagName('html')[0]; html.append(loadinghtml.firstChild); } \ No newline at end of file diff --git a/src/seqta/ui/Themes.js b/src/seqta/ui/Themes.js index eb110695..92e4d255 100644 --- a/src/seqta/ui/Themes.js +++ b/src/seqta/ui/Themes.js @@ -1,10 +1,10 @@ -import localforage from "localforage"; +import localforage from 'localforage'; -let currentThemeClass = ""; +let currentThemeClass = ''; // Utility function to fetch and parse JSON const fetchJSON = async (url) => { - const res = await fetch(url, {cache: "no-store"}); + const res = await fetch(url, {cache: 'no-store'}); return await res.json(); }; @@ -48,7 +48,7 @@ const saveToIndexedDB = async (theme, themeName) => { const applyTheme = async (themeName) => { const { css, className, images } = await localforage.getItem(`css_${themeName}`); - const newStyle = document.createElement("style"); + const newStyle = document.createElement('style'); newStyle.innerHTML = css; document.head.appendChild(newStyle); @@ -80,8 +80,8 @@ const applyTheme = async (themeName) => { export const listThemes = async () => { const themes = await localforage.keys(); return { - themes: themes.filter((key) => key.startsWith("css_")).map((key) => key.replace("css_", "")), - selectedTheme: await localforage.getItem("selectedTheme") + themes: themes.filter((key) => key.startsWith('css_')).map((key) => key.replace('css_', '')), + selectedTheme: await localforage.getItem('selectedTheme') }; }; @@ -92,7 +92,7 @@ export const downloadTheme = async (themeName, themeUrl) => { }; export const deleteTheme = async (themeName) => { - const currentTheme = await localforage.getItem("selectedTheme"); + const currentTheme = await localforage.getItem('selectedTheme'); if (currentTheme === themeName) { await disableTheme(); } @@ -107,14 +107,14 @@ export const setTheme = async (themeName, themeUrl) => { await downloadTheme(themeName, themeUrl); } - await localforage.setItem("selectedTheme", themeName); + await localforage.setItem('selectedTheme', themeName); await applyTheme(themeName).catch((error) => { console.error(`Failed to apply theme: ${error}`); }); }; export const enableCurrentTheme = async () => { - const currentTheme = await localforage.getItem("selectedTheme"); + const currentTheme = await localforage.getItem('selectedTheme'); if (currentTheme) { await applyTheme(currentTheme).catch((error) => { @@ -133,11 +133,11 @@ export const disableTheme = async () => { // Remove current theme's class if it exists if (currentThemeClass) { document.body.classList.remove(currentThemeClass); - currentThemeClass = ""; + currentThemeClass = ''; } // Remove any applied image URLs from the root element - const currentTheme = await localforage.getItem("selectedTheme"); + const currentTheme = await localforage.getItem('selectedTheme'); if (currentTheme) { const themeData = await localforage.getItem(`css_${currentTheme}`); if (themeData && themeData.images) { @@ -148,5 +148,5 @@ export const disableTheme = async () => { } // Clear the selected theme from localforage - localforage.removeItem("selectedTheme"); + localforage.removeItem('selectedTheme'); }; \ No newline at end of file diff --git a/src/seqta/ui/colors/ColorLuminance.js b/src/seqta/ui/colors/ColorLuminance.js index bd8e0933..10c92764 100644 --- a/src/seqta/ui/colors/ColorLuminance.js +++ b/src/seqta/ui/colors/ColorLuminance.js @@ -1,4 +1,4 @@ -import Color from "color"; +import Color from 'color'; function adjustLuminance(color, lum) { let adjustedColor = Color(color.toLowerCase()); @@ -17,7 +17,7 @@ function adjustLuminance(color, lum) { export default function ColorLuminance(color, lum = 0) { const colorRegex = /rgba?\(([^)]+)\)/gi; // Case-insensitive match for rgb() or rgba() - if (color.toLowerCase().includes("gradient")) { + if (color.toLowerCase().includes('gradient')) { let gradient = color; let uniqueColorSet = new Set(); @@ -31,7 +31,7 @@ export default function ColorLuminance(color, lum = 0) { // Adjust luminance for each unique color stop for (let colorStop of uniqueColorSet) { const adjustedColor = adjustLuminance(colorStop, lum); - gradient = gradient.replace(new RegExp(colorStop, "gi"), adjustedColor); + gradient = gradient.replace(new RegExp(colorStop, 'gi'), adjustedColor); } return gradient; diff --git a/src/seqta/ui/colors/Manager.js b/src/seqta/ui/colors/Manager.js index 858036c1..5ecf6e7e 100644 --- a/src/seqta/ui/colors/Manager.js +++ b/src/seqta/ui/colors/Manager.js @@ -1,7 +1,7 @@ /* global chrome */ -import { GetThresholdOfColor, GetiFrameCSSElement } from "../../../SEQTA.js"; -import { lightenAndPaleColor } from "./lightenAndPaleColor.js"; -import ColorLuminance from "./ColorLuminance.js"; +import { GetThresholdOfColor, GetiFrameCSSElement } from '../../../SEQTA.js'; +import { lightenAndPaleColor } from './lightenAndPaleColor.js'; +import ColorLuminance from './ColorLuminance.js'; // Helper functions const setCSSVar = (varName, value) => document.documentElement.style.setProperty(varName, value); @@ -14,37 +14,37 @@ export function updateAllColors(storedSetting, newColor = null) { // Determine the color to use const selectedColor = newColor || storedSetting.selectedColor; - DarkMode = (typeof storedSetting?.DarkMode === "boolean") ? storedSetting.DarkMode : DarkMode; + DarkMode = (typeof storedSetting?.DarkMode === 'boolean') ? storedSetting.DarkMode : DarkMode; - if (typeof storedSetting === "boolean") { + if (typeof storedSetting === 'boolean') { DarkMode = storedSetting; } // Common properties, always applied const commonProps = { - "--better-sub": "#161616", - "--better-alert-highlight": "#c61851", - "--better-main": selectedColor + '--better-sub': '#161616', + '--better-alert-highlight': '#c61851', + '--better-main': selectedColor }; // Mode-based properties, applied if storedSetting is provided let modeProps = {}; if (DarkMode !== null) { modeProps = DarkMode ? { - "--background-primary": "#232323", - "--background-secondary": "#1a1a1a", - "--text-primary": "white", - "--betterseqta-logo": `url(${getChromeURL("icons/betterseqta-light-full.png")})` + '--background-primary': '#232323', + '--background-secondary': '#1a1a1a', + '--text-primary': 'white', + '--betterseqta-logo': `url(${getChromeURL('icons/betterseqta-light-full.png')})` } : { - "--background-primary": "#ffffff", - "--background-secondary": "#e5e7eb", - "--text-primary": "black", - "--better-pale": lightenAndPaleColor(selectedColor), - "--betterseqta-logo": `url(${getChromeURL("icons/betterseqta-dark-full.png")})` + '--background-primary': '#ffffff', + '--background-secondary': '#e5e7eb', + '--text-primary': 'black', + '--better-pale': lightenAndPaleColor(selectedColor), + '--betterseqta-logo': `url(${getChromeURL('icons/betterseqta-dark-full.png')})` }; if (DarkMode) { - document.documentElement.style.removeProperty("--better-pale"); + document.documentElement.style.removeProperty('--better-pale'); } } @@ -52,8 +52,8 @@ export function updateAllColors(storedSetting, newColor = null) { const rgbThreshold = GetThresholdOfColor(selectedColor); const isBright = rgbThreshold > 210; const dynamicProps = { - "--text-color": isBright ? "black" : "white", - "--better-light": selectedColor === "#ffffff" ? "#b7b7b7" : ColorLuminance(selectedColor, 0.95) + '--text-color': isBright ? 'black' : 'white', + '--better-light': selectedColor === '#ffffff' ? '#b7b7b7' : ColorLuminance(selectedColor, 0.95) }; // Apply all the properties @@ -61,16 +61,16 @@ export function updateAllColors(storedSetting, newColor = null) { // Set favicon, if storedSetting is provided if (DarkMode !== null) { - document.querySelector("link[rel*='icon']").href = getChromeURL("icons/icon-48.png"); + document.querySelector('link[rel*=\'icon\']').href = getChromeURL('icons/icon-48.png'); } - let alliframes = document.getElementsByTagName("iframe"); + let alliframes = document.getElementsByTagName('iframe'); let fileref = GetiFrameCSSElement(); for (let i = 0; i < alliframes.length; i++) { const element = alliframes[i]; - if (element.getAttribute("excludeDarkCheck") == "true") { + if (element.getAttribute('excludeDarkCheck') == 'true') { continue; } @@ -78,7 +78,7 @@ export function updateAllColors(storedSetting, newColor = null) { console.log(element.contentDocument.documentElement); element.contentDocument.documentElement.childNodes[1].style.color = - DarkMode ? "black" : "white"; + DarkMode ? 'black' : 'white'; element.contentDocument.documentElement.firstChild.appendChild( fileref, ); @@ -87,7 +87,7 @@ export function updateAllColors(storedSetting, newColor = null) { export function getDarkMode() { return new Promise((resolve, reject) => { - chrome.storage.local.get("DarkMode", (result) => { + chrome.storage.local.get('DarkMode', (result) => { if (chrome.runtime.lastError) { return reject(chrome.runtime.lastError); } diff --git a/src/seqta/ui/colors/lightenAndPaleColor.js b/src/seqta/ui/colors/lightenAndPaleColor.js index 52b76a24..2dc28709 100644 --- a/src/seqta/ui/colors/lightenAndPaleColor.js +++ b/src/seqta/ui/colors/lightenAndPaleColor.js @@ -1,8 +1,8 @@ -import Color from "color"; +import Color from 'color'; export function lightenAndPaleColor(inputColor, lightenFactor = 0.75, paleFactor = 0.55) { - if (inputColor.includes("gradient")) { + if (inputColor.includes('gradient')) { const baseColor = findMatchingColor(inputColor); return lightenAndPaleColor(baseColor, lightenFactor, paleFactor); @@ -44,11 +44,11 @@ function findMatchingColor(cssGradient) { const colorStops = cssGradient.match(regex); if (!colorStops) { - throw new Error("No valid color stops found in the provided CSS gradient."); + throw new Error('No valid color stops found in the provided CSS gradient.'); } // Normalize and trim the color stops - const normalizedColorStops = colorStops.map(color => color.toLowerCase().replace(/\s+/g, "")); + const normalizedColorStops = colorStops.map(color => color.toLowerCase().replace(/\s+/g, '')); // Convert the color stops to Color objects const colorObjects = normalizedColorStops.map(color => Color(color)); diff --git a/src/seqta/utils/MessageListener.js b/src/seqta/utils/MessageListener.js index 70e1892c..b7ce2dbe 100644 --- a/src/seqta/utils/MessageListener.js +++ b/src/seqta/utils/MessageListener.js @@ -1,7 +1,7 @@ /* global chrome */ -import { MenuOptionsOpen, OpenMenuOptions, closeSettings } from "../../SEQTA.js"; -import { deleteTheme, disableTheme, downloadTheme, listThemes, setTheme } from "../ui/Themes.js"; +import { MenuOptionsOpen, OpenMenuOptions, closeSettings } from '../../SEQTA.js'; +import { deleteTheme, disableTheme, downloadTheme, listThemes, setTheme } from '../ui/Themes.js'; export class MessageHandler { constructor() { @@ -11,40 +11,40 @@ export class MessageHandler { routeMessage(request, sender, sendResponse) { switch (request.info) { - case "EditSidebar": + case 'EditSidebar': this.editSidebar(); break; /* Theme related */ - case "SetTheme": + case 'SetTheme': console.log(request); setTheme(request.body.themeName, request.body.themeURL).then(() => { - sendResponse({ status: "success" }); + sendResponse({ status: 'success' }); }); return true; - case "DownloadTheme": + case 'DownloadTheme': downloadTheme(request.body.themeName, request.body.themeURL).then(() => { - sendResponse({ status: "success" }); + sendResponse({ status: 'success' }); }); return true; - case "ListThemes": + case 'ListThemes': listThemes().then((response) => { sendResponse(response); }); return true; - case "DisableTheme": + case 'DisableTheme': disableTheme().then(() => { - sendResponse({ status: "success" }); + sendResponse({ status: 'success' }); }); return true; - case "DeleteTheme": + case 'DeleteTheme': deleteTheme(request.body.themeName).then(() => { - sendResponse({ status: "success" }); + sendResponse({ status: 'success' }); }); return true; default: - console.log("Unknown request info:", request.info); + console.log('Unknown request info:', request.info); } } diff --git a/src/seqta/utils/StorageListener.js b/src/seqta/utils/StorageListener.js index bcbe30e8..4adc2b29 100644 --- a/src/seqta/utils/StorageListener.js +++ b/src/seqta/utils/StorageListener.js @@ -8,9 +8,9 @@ import { addShortcuts, disableNotificationCollector, enableNotificationCollector, -} from "../../SEQTA.js"; -import { updateBgDurations } from "../ui/Animation.js"; -import { getDarkMode, updateAllColors } from "../ui/colors/Manager.js"; +} from '../../SEQTA.js'; +import { updateBgDurations } from '../ui/Animation.js'; +import { getDarkMode, updateAllColors } from '../ui/colors/Manager.js'; export default class StorageListener { constructor() { @@ -22,23 +22,23 @@ export default class StorageListener { Object.keys(changes).forEach((changeKey) => { switch (changeKey) { - case "selectedColor": + case 'selectedColor': this.handleSelectedColorChange(changes.selectedColor.newValue); break; - case "shortcuts": + case 'shortcuts': this.handleShortcutsChange( changes.shortcuts.oldValue, changes.shortcuts.newValue ); break; - case "DarkMode": + case 'DarkMode': this.darkMode = changes.DarkMode.newValue; console.log(this.darkMode); break; - case "customshortcuts": + case 'customshortcuts': if (changes.customshortcuts.newValue) { this.handleCustomShortcutsChange( changes.customshortcuts.oldValue, @@ -47,20 +47,20 @@ export default class StorageListener { } break; - case "notificationcollector": + case 'notificationcollector': this.handleNotificationCollectorChange(changes.notificationcollector); break; - case "bksliderinput": + case 'bksliderinput': updateBgDurations(changes.bksliderinput.newValue); break; - case "animatedbk": + case 'animatedbk': if (changes.animatedbk.newValue) { CreateBackground(); } else { RemoveBackground(); - document.getElementById("container").style.background = "var(--background-secondary)"; + document.getElementById('container').style.background = 'var(--background-secondary)'; } break; diff --git a/src/seqta/utils/stringToHTML.js b/src/seqta/utils/stringToHTML.js index 8d06b7aa..4941620b 100644 --- a/src/seqta/utils/stringToHTML.js +++ b/src/seqta/utils/stringToHTML.js @@ -1,12 +1,12 @@ -import DOMPurify from "dompurify"; +import DOMPurify from 'dompurify'; export default function stringToHTML(str, styles = false) { var parser = new DOMParser(); - str = DOMPurify.sanitize(str, { ADD_ATTR: ["onclick"] }); - var doc = parser.parseFromString(str, "text/html"); + str = DOMPurify.sanitize(str, { ADD_ATTR: ['onclick'] }); + var doc = parser.parseFromString(str, 'text/html'); if (styles) { doc.body.style.cssText = - "height: auto; overflow: scroll; margin: 0px; background: var(--background-primary);"; + 'height: auto; overflow: scroll; margin: 0px; background: var(--background-primary);'; } return doc.body; } \ No newline at end of file diff --git a/tailwind.config.js b/tailwind.config.js index 829e4be9..82b6b0df 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -1,20 +1,20 @@ /** @type {import('tailwindcss').Config} */ export default { content: [ - "./index.html", - "./src/**/*.{js,ts,jsx,tsx}", + './index.html', + './src/**/*.{js,ts,jsx,tsx}', ], - darkMode: "class", + darkMode: 'class', theme: { fontSize: { - "xs": ".65rem", - "sm": ".775rem", - "base": "0.65rem", - "md": "0.65rem", - "lg": "1rem", - "xl": "1.25rem", - "2xl": "1.5rem", - "3xl": "1.875rem", + 'xs': '.65rem', + 'sm': '.775rem', + 'base': '0.65rem', + 'md': '0.65rem', + 'lg': '1rem', + 'xl': '1.25rem', + '2xl': '1.5rem', + '3xl': '1.875rem', } }, plugins: [], diff --git a/webpack.config.js b/webpack.config.js index bc197034..efaa2eb9 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,11 +1,11 @@ -import path from "path"; -import MiniCssExtractPlugin from "mini-css-extract-plugin"; -import CopyWebpackPlugin from "copy-webpack-plugin"; -import ESLintPlugin from "eslint-webpack-plugin"; +import path from 'path'; +import MiniCssExtractPlugin from 'mini-css-extract-plugin'; +import CopyWebpackPlugin from 'copy-webpack-plugin'; +import ESLintPlugin from 'eslint-webpack-plugin'; export default { - target: "web", + target: 'web', node: { __dirname: true }, @@ -14,22 +14,22 @@ export default { maxEntrypointSize: 512000, maxAssetSize: 512000, }, - devtool: "cheap-module-source-map", + devtool: 'cheap-module-source-map', entry: { - SEQTA: "./src/SEQTA.js", - background: "./src/background.js", - "inject/documentload": "./src/inject/documentload.css", // Entry for CSS - "inject/iframe": "./src/inject/iframe.css", // Entry for CSS - "inject/injected": "./src/inject/injected.css", // Entry for CSS + SEQTA: './src/SEQTA.js', + background: './src/background.js', + 'inject/documentload': './src/inject/documentload.css', // Entry for CSS + 'inject/iframe': './src/inject/iframe.css', // Entry for CSS + 'inject/injected': './src/inject/injected.css', // Entry for CSS }, output: { filename: (pathData) => { - const name = pathData.chunk.name.replace("inject-", ""); - return name.includes("inject") ? `inject/${name}.js` : `${name}.js`; + const name = pathData.chunk.name.replace('inject-', ''); + return name.includes('inject') ? `inject/${name}.js` : `${name}.js`; }, // eslint-disable-next-line no-undef - path: path.resolve("build"), - publicPath: "", + path: path.resolve('build'), + publicPath: '', }, module: { rules: [ @@ -38,7 +38,7 @@ export default { use: [ MiniCssExtractPlugin.loader, { - loader: "css-loader", + loader: 'css-loader', options: { importLoaders: 1 } @@ -47,9 +47,9 @@ export default { }, { test: /\.(png|svg|jpg|jpeg|gif)$/i, - type: "asset/resource", + type: 'asset/resource', generator: { - filename: "src/[path][name][ext]", + filename: 'src/[path][name][ext]', }, }, ], @@ -57,15 +57,15 @@ export default { plugins: [ new ESLintPlugin(), new MiniCssExtractPlugin({ - filename: "[name].css" + filename: '[name].css' }), new CopyWebpackPlugin({ patterns: [ - { from: "public", to: "." }, - { from: "src/inject/preview", to: "inject/preview" }, - { from: "node_modules/webextension-polyfill/dist/browser-polyfill.js", to: "."}, - { from: "interface/dist/client", to: "client" }, - { from: "interface/dist/index.html", to: "interface/index.html" } + { from: 'public', to: '.' }, + { from: 'src/inject/preview', to: 'inject/preview' }, + { from: 'node_modules/webextension-polyfill/dist/browser-polyfill.js', to: '.'}, + { from: 'interface/dist/client', to: 'client' }, + { from: 'interface/dist/index.html', to: 'interface/index.html' } ], }), ],