From 2acbcca30c551284a14b825afe8d67f7fff1e4e0 Mon Sep 17 00:00:00 2001 From: ManeraKai Date: Wed, 23 Feb 2022 07:19:56 +0300 Subject: Added medium tor support #32 --- src/pages/options/medium/medium.html | 285 +++++++++++++++++++---------------- src/pages/options/medium/medium.js | 38 +++++ 2 files changed, 197 insertions(+), 126 deletions(-) (limited to 'src/pages/options/medium') diff --git a/src/pages/options/medium/medium.html b/src/pages/options/medium/medium.html index 9efd21cc..f19f8d49 100644 --- a/src/pages/options/medium/medium.html +++ b/src/pages/options/medium/medium.html @@ -2,146 +2,179 @@ - - - - - - LibRedirect Options: Medium + + + + + + LibRedirect Options: Medium - + + + + Wikipedia + +
+ + + + + + + + + + Medium +
+ -
-
-

Enable

- -
+
+
+

Enable

+ +
-
+
+

Protocol

+ +
+ +
+ +
+
+

Default Instances

+
+
+
+
+

Custom Instances

+
+
-

Default Instances

+ +
-
-
+
+
+
+ +
+
+

Default Instances

+
+
+
+
+

Custom Instances

+
+
-

Custom Instances

+ +
- -
- - -
-
-
-
+ +
+ +
- - - + + + - + \ No newline at end of file diff --git a/src/pages/options/medium/medium.js b/src/pages/options/medium/medium.js index 8c302fc2..dcc4b4a4 100644 --- a/src/pages/options/medium/medium.js +++ b/src/pages/options/medium/medium.js @@ -6,9 +6,36 @@ disableMediumElement.addEventListener("change", (event) => mediumHelper.setDisable(!event.target.checked) ); +let protocolElement = document.getElementById("protocol") +protocolElement.addEventListener("change", + (event) => { + let protocol = event.target.options[protocolElement.selectedIndex].value + mediumHelper.setProtocol(protocol); + changeProtocolSettings(protocol); + } +); + +function changeProtocolSettings(protocol) { + let normalDiv = document.getElementById("normal"); + let torDiv = document.getElementById("tor"); + if (protocol == 'normal') { + normalDiv.style.display = 'block'; + torDiv.style.display = 'none'; + } + else if (protocol == 'tor') { + normalDiv.style.display = 'none'; + torDiv.style.display = 'block'; + } +} + + mediumHelper.init().then(() => { disableMediumElement.checked = !mediumHelper.getDisable(); + let protocol = mediumHelper.getProtocol(); + protocolElement.value = protocol; + changeProtocolSettings(protocol); + commonHelper.processDefaultCustomInstances( 'scribe', 'normal', @@ -19,4 +46,15 @@ mediumHelper.init().then(() => { mediumHelper.getScribeNormalCustomRedirects, mediumHelper.setScribeNormalCustomRedirects ) + + commonHelper.processDefaultCustomInstances( + 'scribe', + 'tor', + mediumHelper, + document, + mediumHelper.getScribeTorRedirectsChecks, + mediumHelper.setScribeTorRedirectsChecks, + mediumHelper.getScribeTorCustomRedirects, + mediumHelper.setScribeTorCustomRedirects + ) }) \ No newline at end of file -- cgit 1.4.1