From b657b1ae2ba818432fa001b07ed40e04348bb011 Mon Sep 17 00:00:00 2001 From: ManeraKai Date: Mon, 18 Apr 2022 10:25:50 +0300 Subject: Adding Raw Link Copy feature #165 --- src/pages/options/imgur/imgur.html | 27 ++++---- src/pages/options/instagram/instagram.html | 18 +++--- src/pages/options/lbry/lbry.html | 18 +++--- src/pages/options/maps/maps.html | 9 +-- src/pages/options/medium/medium.html | 18 +++--- src/pages/options/peertube/peertube.html | 18 +++--- src/pages/options/pixiv/pixiv.html | 18 +++--- src/pages/options/reddit/reddit.html | 36 ++++++----- src/pages/options/search/search.html | 81 +++++++++++++----------- src/pages/options/sendTargets/sendTargets.html | 18 +++--- src/pages/options/speedtest/speedtest.html | 18 +++--- src/pages/options/spotify/spotify.html | 18 +++--- src/pages/options/tiktok/tiktok.html | 18 +++--- src/pages/options/translate/translate.html | 36 ++++++----- src/pages/options/twitter/twitter.html | 27 ++++---- src/pages/options/wikipedia/wikipedia.html | 27 ++++---- src/pages/options/youtube/youtube.html | 54 +++++++++------- src/pages/options/youtubeMusic/youtubeMusic.html | 9 +-- src/pages/popup/popup.html | 16 +++-- src/pages/popup/popup.js | 31 ++++++++- src/pages/popup/style.css | 4 ++ src/pages/stylesheets/styles.css | 19 +++--- 22 files changed, 315 insertions(+), 223 deletions(-) (limited to 'src/pages') diff --git a/src/pages/options/imgur/imgur.html b/src/pages/options/imgur/imgur.html index c9d48622..a97c1c28 100644 --- a/src/pages/options/imgur/imgur.html +++ b/src/pages/options/imgur/imgur.html @@ -84,10 +84,11 @@
- - - - +
@@ -111,10 +112,11 @@
- - - - +
@@ -131,10 +133,11 @@
- - - - +
diff --git a/src/pages/options/instagram/instagram.html b/src/pages/options/instagram/instagram.html index 01556fd8..bc52cd3b 100644 --- a/src/pages/options/instagram/instagram.html +++ b/src/pages/options/instagram/instagram.html @@ -83,10 +83,11 @@
- - - - +
@@ -110,10 +111,11 @@
- - - - +
diff --git a/src/pages/options/lbry/lbry.html b/src/pages/options/lbry/lbry.html index 074ae4b3..d5d459f7 100644 --- a/src/pages/options/lbry/lbry.html +++ b/src/pages/options/lbry/lbry.html @@ -83,10 +83,11 @@
- - - - +
@@ -110,10 +111,11 @@
- - - - +
diff --git a/src/pages/options/maps/maps.html b/src/pages/options/maps/maps.html index d7c551b6..d4288761 100644 --- a/src/pages/options/maps/maps.html +++ b/src/pages/options/maps/maps.html @@ -83,10 +83,11 @@
- - - - +
diff --git a/src/pages/options/medium/medium.html b/src/pages/options/medium/medium.html index 193dbbb8..303524f7 100644 --- a/src/pages/options/medium/medium.html +++ b/src/pages/options/medium/medium.html @@ -83,10 +83,11 @@
- - - - +
@@ -110,10 +111,11 @@
- - - - +
diff --git a/src/pages/options/peertube/peertube.html b/src/pages/options/peertube/peertube.html index 5ebff097..dd034bed 100644 --- a/src/pages/options/peertube/peertube.html +++ b/src/pages/options/peertube/peertube.html @@ -83,10 +83,11 @@
- - - - +
@@ -110,10 +111,11 @@
- - - - +
diff --git a/src/pages/options/pixiv/pixiv.html b/src/pages/options/pixiv/pixiv.html index 36825094..7adbcf2c 100644 --- a/src/pages/options/pixiv/pixiv.html +++ b/src/pages/options/pixiv/pixiv.html @@ -91,10 +91,11 @@
- - - - +
@@ -118,10 +119,11 @@
- - - - +
diff --git a/src/pages/options/reddit/reddit.html b/src/pages/options/reddit/reddit.html index 2ded8094..80aa77c5 100644 --- a/src/pages/options/reddit/reddit.html +++ b/src/pages/options/reddit/reddit.html @@ -96,10 +96,11 @@
- - - - +
@@ -123,10 +124,11 @@
- - - - +
@@ -146,10 +148,11 @@
- - - - +
@@ -173,10 +176,11 @@
- - - - +
diff --git a/src/pages/options/search/search.html b/src/pages/options/search/search.html index 622c0799..01e8511e 100644 --- a/src/pages/options/search/search.html +++ b/src/pages/options/search/search.html @@ -98,10 +98,11 @@
- - - - +
@@ -125,10 +126,11 @@
- - - - +
@@ -145,10 +147,11 @@
- - - - +
@@ -168,10 +171,11 @@
- - - - +
@@ -195,10 +199,11 @@
- - - - +
@@ -215,10 +220,11 @@
- - - - +
@@ -238,10 +244,11 @@
- - - - +
@@ -265,10 +272,11 @@
- - - - +
@@ -285,10 +293,11 @@
- - - - +
diff --git a/src/pages/options/sendTargets/sendTargets.html b/src/pages/options/sendTargets/sendTargets.html index d514b8f0..c54c1582 100644 --- a/src/pages/options/sendTargets/sendTargets.html +++ b/src/pages/options/sendTargets/sendTargets.html @@ -83,10 +83,11 @@
- - - - +
@@ -110,10 +111,11 @@
- - - - +
diff --git a/src/pages/options/speedtest/speedtest.html b/src/pages/options/speedtest/speedtest.html index 50a195e2..5ac5cdaa 100644 --- a/src/pages/options/speedtest/speedtest.html +++ b/src/pages/options/speedtest/speedtest.html @@ -83,10 +83,11 @@
- - - - +
@@ -110,10 +111,11 @@
- - - - +
diff --git a/src/pages/options/spotify/spotify.html b/src/pages/options/spotify/spotify.html index cfcf34b3..0496875a 100644 --- a/src/pages/options/spotify/spotify.html +++ b/src/pages/options/spotify/spotify.html @@ -83,10 +83,11 @@
- - - - +
@@ -110,10 +111,11 @@
- - - - +
diff --git a/src/pages/options/tiktok/tiktok.html b/src/pages/options/tiktok/tiktok.html index 52b09bbb..67fc2488 100644 --- a/src/pages/options/tiktok/tiktok.html +++ b/src/pages/options/tiktok/tiktok.html @@ -83,10 +83,11 @@
- - - - +
@@ -110,10 +111,11 @@
- - - - +
diff --git a/src/pages/options/translate/translate.html b/src/pages/options/translate/translate.html index 53436c91..8f63ace9 100644 --- a/src/pages/options/translate/translate.html +++ b/src/pages/options/translate/translate.html @@ -327,10 +327,11 @@
- - - - +
@@ -354,10 +355,11 @@
- - - - +
@@ -376,10 +378,11 @@
- - - - +
@@ -403,10 +406,11 @@
- - - - +
diff --git a/src/pages/options/twitter/twitter.html b/src/pages/options/twitter/twitter.html index 6d8e0e6f..d7b14abf 100644 --- a/src/pages/options/twitter/twitter.html +++ b/src/pages/options/twitter/twitter.html @@ -165,10 +165,11 @@
- - - - +
@@ -192,10 +193,11 @@
- - - - +
@@ -212,10 +214,11 @@
- - - - +
diff --git a/src/pages/options/wikipedia/wikipedia.html b/src/pages/options/wikipedia/wikipedia.html index b7fcc40a..246c269b 100644 --- a/src/pages/options/wikipedia/wikipedia.html +++ b/src/pages/options/wikipedia/wikipedia.html @@ -84,10 +84,11 @@
- - - - +
@@ -111,10 +112,11 @@
- - - - +
@@ -131,10 +133,11 @@
- - - - +
diff --git a/src/pages/options/youtube/youtube.html b/src/pages/options/youtube/youtube.html index 67c86786..569e7f12 100644 --- a/src/pages/options/youtube/youtube.html +++ b/src/pages/options/youtube/youtube.html @@ -779,10 +779,11 @@
- - - - +
@@ -806,10 +807,11 @@
- - - - +
@@ -1146,10 +1148,11 @@
- - - - +
@@ -1173,10 +1176,11 @@
- - - - +
@@ -1257,10 +1261,11 @@
- - - - +
@@ -1284,10 +1289,11 @@
- - - - +
diff --git a/src/pages/options/youtubeMusic/youtubeMusic.html b/src/pages/options/youtubeMusic/youtubeMusic.html index eae611d6..9286ed64 100644 --- a/src/pages/options/youtubeMusic/youtubeMusic.html +++ b/src/pages/options/youtubeMusic/youtubeMusic.html @@ -76,10 +76,11 @@
- - - - +
diff --git a/src/pages/popup/popup.html b/src/pages/popup/popup.html index 2f83116c..2c4f76d5 100644 --- a/src/pages/popup/popup.html +++ b/src/pages/popup/popup.html @@ -169,26 +169,32 @@
- + Instance - + Settings + + + + + Copy Raw +
- - + \ No newline at end of file diff --git a/src/pages/popup/popup.js b/src/pages/popup/popup.js index 14f59dfc..53e8c103 100644 --- a/src/pages/popup/popup.js +++ b/src/pages/popup/popup.js @@ -59,6 +59,7 @@ async function wholeInit() { await mediumHelper.init(); }; +let copyRawElement = document.getElementById('copy_raw'); wholeInit().then(() => { disableTwitterElement.checked = !twitterHelper.getDisable(); disableYoutubeElement.checked = !youtubeHelper.getDisable(); @@ -79,6 +80,7 @@ wholeInit().then(() => { let changeInstanceElement = document.getElementById("change-instance") changeInstanceElement.addEventListener("click", switchInstance); + copyRawElement.addEventListener("click", copyRaw); }) disableTwitterElement.addEventListener("change", @@ -153,7 +155,6 @@ document.getElementById("more-options").addEventListener("click", () => browser.runtime.openOptionsPage() ); - function switchInstance() { browser.tabs.query({ active: true, currentWindow: true }, function (tabs) { let currTab = tabs[0]; @@ -197,6 +198,34 @@ function switchInstance() { return false; } +function copyRaw() { + browser.tabs.query({ active: true, currentWindow: true }, function (tabs) { + let currTab = tabs[0]; + if (currTab) { + let url = currTab.url; + let tabUrl + try { tabUrl = new URL(url); } + catch (_) { return false; } + let newUrl; + newUrl = youtubeHelper.reverse(tabUrl); + if (!newUrl) newUrl = twitterHelper.reverse(tabUrl); + if (!newUrl) newUrl = instagramHelper.reverse(tabUrl); + if (!newUrl) newUrl = tiktokHelper.reverse(tabUrl); + if (!newUrl) newUrl = imgurHelper.reverse(tabUrl); + if (newUrl) { + navigator.clipboard.writeText(newUrl); + const oldHtml = copyRawElement.innerHTML; + copyRawElement.innerHTML = ` + + + + Copied`; + setTimeout(() => copyRawElement.innerHTML = oldHtml, 1000); + } + } + }) +} + let popupFrontends; generalHelper.init().then(() => { popupFrontends = generalHelper.getPopupFrontends(); diff --git a/src/pages/popup/style.css b/src/pages/popup/style.css index a2fc1256..4cc56145 100644 --- a/src/pages/popup/style.css +++ b/src/pages/popup/style.css @@ -3,6 +3,10 @@ body { min-height: auto; } +html, body { + margin: 0; +} + .hide { display: none !important; } \ No newline at end of file diff --git a/src/pages/stylesheets/styles.css b/src/pages/stylesheets/styles.css index 01a3d89d..5377edf3 100644 --- a/src/pages/stylesheets/styles.css +++ b/src/pages/stylesheets/styles.css @@ -193,7 +193,6 @@ hr { border: none; } - div.some-block { padding: 0 15px; justify-content: space-between; @@ -280,14 +279,11 @@ div.buttons { } div.buttons-popup { - border: 2px solid var(--bg-secondary); border-radius: 5px; display: flex; - margin: 0 15px; - margin-bottom: 15px; - margin-top: 5px; flex-wrap: wrap; - justify-content: center; + margin: 0 10px 7px 10px; + justify-content: start; align-items: center; } @@ -299,7 +295,7 @@ div.buttons-popup { color: var(--text); font-size: 16px; font-weight: bold; - margin: 5px 0px; + margin: 0; padding: 5px 5px; text-decoration: none; cursor: pointer; @@ -311,10 +307,15 @@ div.buttons-popup { } .button svg { - width: 26px; - height: 26px; + width: auto; + height: auto; padding: 0; + margin-right: 5px; +} + +body.rtl { margin-right: 0; + margin-left: 5px; } .button:hover svg { -- cgit 1.4.1