diff options
| author | Ruben Beltran del Rio <ruben@unlimited.pizza> | 2023-09-13 18:39:01 +0200 |
|---|---|---|
| committer | Ruben Beltran del Rio <ruben@unlimited.pizza> | 2023-09-13 18:39:01 +0200 |
| commit | 4a191e8036581893bf5f4cfb284770d1bfe9a807 (patch) | |
| tree | abbf7be12b65b56c9b6a11861fd96ad406ad4590 /safari/Junction/Resources/Script.js | |
| parent | 06b7617a863d00dbcc91d1e46f09942c6aad366e (diff) | |
Add safari code
Diffstat (limited to 'safari/Junction/Resources/Script.js')
| -rw-r--r-- | safari/Junction/Resources/Script.js | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/safari/Junction/Resources/Script.js b/safari/Junction/Resources/Script.js new file mode 100644 index 0000000..f551e6b --- /dev/null +++ b/safari/Junction/Resources/Script.js @@ -0,0 +1,22 @@ +function show(enabled, useSettingsInsteadOfPreferences) { + if (useSettingsInsteadOfPreferences) { + document.getElementsByClassName('state-on')[0].innerText = "Junction’s extension is currently on. You can turn it off in the Extensions section of Safari Settings."; + document.getElementsByClassName('state-off')[0].innerText = "Junction’s extension is currently off. You can turn it on in the Extensions section of Safari Settings."; + document.getElementsByClassName('state-unknown')[0].innerText = "You can turn on Junction’s extension in the Extensions section of Safari Settings."; + document.getElementsByClassName('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`); + } +} + +function openPreferences() { + webkit.messageHandlers.controller.postMessage("open-preferences"); +} + +document.querySelector("button.open-preferences").addEventListener("click", openPreferences); |