diff --git a/_locales/en/messages.json b/_locales/en/messages.json index e7f641aa..9fdfcbf1 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -335,5 +335,11 @@ }, "createdBy": { "message": "Created By" + }, + "autoSkip": { + "message": "Auto Skip" + }, + "showSkipNotice": { + "message": "Show Notice After A Sponsor Is Skipped" } } diff --git a/options/options.css b/options/options.css index c92114c5..4c73e7a1 100644 --- a/options/options.css +++ b/options/options.css @@ -3,6 +3,11 @@ body { font-family: Sans-Serif; } +.smallDescription { + color: white; + font-size: 13; +} + #options { max-width: 60%; text-align: left; @@ -39,6 +44,9 @@ body { right: 0; bottom: 0; background-color: #707070; +} + +.animated * { -webkit-transition: .4s; transition: .4s; } @@ -51,6 +59,9 @@ body { left: 4px; bottom: 4px; background-color: white; +} + +.animated .slider:before { -webkit-transition: .4s; transition: .4s; } diff --git a/options/options.html b/options/options.html index e0f3b7d8..130a7a3f 100644 --- a/options/options.html +++ b/options/options.html @@ -10,7 +10,7 @@
- + SponsorBlock
@@ -20,13 +20,102 @@

__MSG_Options__

-
- + diff --git a/options/options.js b/options/options.js index 9e398588..9c625c13 100644 --- a/options/options.js +++ b/options/options.js @@ -1,5 +1,38 @@ window.addEventListener('DOMContentLoaded', init); -function init() { +async function init() { localizeHtmlPage(); + + // Set all of the toggle options to the correct option + let optionsContainer = document.getElementById("options"); + let optionsElements = optionsContainer.children; + + // How many checks are left to be done + let checksLeft = 0; + + for (let i = 0; i < optionsElements.length; i++) { + switch (optionsElements[i].getAttribute("option-type")) { + case "toggle": + chrome.storage.sync.get([optionsElements[i].getAttribute("toggle-sync-option")], function(result) { + let optionResult = result[optionsElements[i].getAttribute("toggle-sync-option")]; + if (optionResult != undefined) { + optionsElements[i].querySelector("input").checked = optionResult; + + if (optionsElements[i].getAttribute("toggle-type") == "reverse") { + optionsElements[i].querySelector("input").checked = !optionResult; + } + } + + checksLeft--; + }); + + checksLeft++; + break; + } + } + + await wait(() => checksLeft == 0, 1000, 50); + + optionsContainer.style.display = "inherit"; + optionsContainer.classList.add("animated"); } \ No newline at end of file