From f17463a9ea15a479376597f94f5d920bb8f4cc79 Mon Sep 17 00:00:00 2001 From: ManeraKai Date: Sun, 17 Apr 2022 15:27:21 +0300 Subject: Added latency test #134 --- src/pages/options/lbry/lbry.html | 125 +++++++++++++++++++++++++++++++++++++++ src/pages/options/lbry/lbry.js | 55 +++++++++++++---- 2 files changed, 169 insertions(+), 11 deletions(-) create mode 100644 src/pages/options/lbry/lbry.html (limited to 'src/pages/options/lbry') diff --git a/src/pages/options/lbry/lbry.html b/src/pages/options/lbry/lbry.html new file mode 100644 index 00000000..074ae4b3 --- /dev/null +++ b/src/pages/options/lbry/lbry.html @@ -0,0 +1,125 @@ + + + + + + + + General + + + + + +
+
+

Enable

+ +
+
+

Protocol

+ +
+
+
+
+
+

Default Instances

+
+
+
+
+

Custom Instances

+
+
+
+ + + + + +
+
+
+ + +
+
+
+

Default Instances

+
+
+
+
+

Custom Instances

+
+
+
+ + + + + +
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/src/pages/options/lbry/lbry.js b/src/pages/options/lbry/lbry.js index 75995213..4511373c 100644 --- a/src/pages/options/lbry/lbry.js +++ b/src/pages/options/lbry/lbry.js @@ -35,16 +35,19 @@ lbryHelper.init().then(() => { protocolElement.value = protocol; changeProtocolSettings(protocol); - commonHelper.processDefaultCustomInstances( - 'librarian', - 'normal', - lbryHelper, - document, - lbryHelper.getLibrarianNormalRedirectsChecks, - lbryHelper.setLibrarianNormalRedirectsChecks, - lbryHelper.getLibrarianNormalCustomRedirects, - lbryHelper.setLibrarianNormalCustomRedirects - ); + browser.storage.local.get("librarianLatency").then(r => { + commonHelper.processDefaultCustomInstances( + 'librarian', + 'normal', + lbryHelper, + document, + lbryHelper.getLibrarianNormalRedirectsChecks, + lbryHelper.setLibrarianNormalRedirectsChecks, + lbryHelper.getLibrarianNormalCustomRedirects, + lbryHelper.setLibrarianNormalCustomRedirects, + r.librarianLatency, + ); + }) commonHelper.processDefaultCustomInstances( 'librarian', @@ -56,4 +59,34 @@ lbryHelper.init().then(() => { lbryHelper.getLibrarianTorCustomRedirects, lbryHelper.setLibrarianTorCustomRedirects ) -}) \ No newline at end of file +}) + + +let latencyElement = document.getElementById("latency"); +let latencyLabel = document.getElementById("latency-label"); +latencyElement.addEventListener("click", + async () => { + let reloadWindow = () => location.reload(); + latencyElement.addEventListener("click", reloadWindow); + await lbryHelper.init(); + let redirects = lbryHelper.getRedirects(); + const oldHtml = latencyLabel.innerHTML; + latencyLabel.innerHTML = '...'; + commonHelper.testLatency(latencyLabel, redirects.librarian.normal).then(r => { + browser.storage.local.set({ librarianLatency: r }); + latencyLabel.innerHTML = oldHtml; + commonHelper.processDefaultCustomInstances( + 'librarian', + 'normal', + lbryHelper, + document, + lbryHelper.getLibrarianNormalRedirectsChecks, + lbryHelper.setLibrarianNormalRedirectsChecks, + lbryHelper.getLibrarianNormalCustomRedirects, + lbryHelper.setLibrarianNormalCustomRedirects, + r, + ); + latencyElement.removeEventListener("click", reloadWindow); + }); + } +); \ No newline at end of file -- cgit 1.4.1