]> git.r.bdr.sh - rbdr/junction/blob - safari/Junction/Resources/Script.js
Add safari code
[rbdr/junction] / safari / Junction / Resources / Script.js
1 function show(enabled, useSettingsInsteadOfPreferences) {
2 if (useSettingsInsteadOfPreferences) {
3 document.getElementsByClassName('state-on')[0].innerText = "Junction’s extension is currently on. You can turn it off in the Extensions section of Safari Settings.";
4 document.getElementsByClassName('state-off')[0].innerText = "Junction’s extension is currently off. You can turn it on in the Extensions section of Safari Settings.";
5 document.getElementsByClassName('state-unknown')[0].innerText = "You can turn on Junction’s extension in the Extensions section of Safari Settings.";
6 document.getElementsByClassName('open-preferences')[0].innerText = "Quit and Open Safari Settings…";
7 }
8
9 if (typeof enabled === "boolean") {
10 document.body.classList.toggle(`state-on`, enabled);
11 document.body.classList.toggle(`state-off`, !enabled);
12 } else {
13 document.body.classList.remove(`state-on`);
14 document.body.classList.remove(`state-off`);
15 }
16 }
17
18 function openPreferences() {
19 webkit.messageHandlers.controller.postMessage("open-preferences");
20 }
21
22 document.querySelector("button.open-preferences").addEventListener("click", openPreferences);