Closes #113 - Added support for FreeTube

This commit is contained in:
SimonBrazell 2020-11-04 21:55:42 +11:00
parent 5f42431bd8
commit 748f3d0f3a
5 changed files with 53 additions and 3 deletions

View File

@ -106,5 +106,9 @@
"version": {
"message": "Version",
"description": "Version"
},
"useFreeTube": {
"message": "Use FreeTube over Invidious when possible",
"description": "Label for 'Use FreeTube over Invidious when possible' option (options)."
}
}

View File

@ -1,10 +1,13 @@
# Extension Store (AMO & Chrome Web Store) Listing
## Summary:
```
A simple web extension that redirects Twitter, YouTube, Instagram & Google Maps requests to privacy friendly alternatives.
```
## Description:
```
Redirects Twitter, YouTube, Instagram, & Google Maps requests to privacy friendly alternatives - <a href='https://nitter.net/'>Nitter</a>, <a href='https://invidio.us/'>Invidious</a>, <a href='https://bibliogram.art/'>Bibliogram</a>, & <a href='https://www.openstreetmap.org'>OpenStreetMap</a>.
@ -23,10 +26,12 @@ The code for this web extension is available on <a href='https://github.com/Simo
<b>★ Donate: 👨🏻‍💻</b>
If you like this extension and are financially able please consider <a href='https://www.buymeacoffee.com/SimonBrazell'>buying me a coffee</a> ☕️ to show your appreciation and support the continuation of the project.
<b>★ What's New in This Version (v1.1.36) 🆕</b>
<b>★ What's New in This Version (v1.1.42) 🆕</b>
<ul>
<li>Added Russian language translation.</li>
<li>Fix Invidious autoplay parameter.</li>
<li>Added Polish language translation.</li>
<li>Added Chinese language translation.</li>
<li>Pruned the Invidious random instances list.</li>
<li>Added support for FreeTube redirects (where possible).</li>
</ul>
<b>★ Permissions: </b>

View File

@ -119,6 +119,7 @@ let invidiousVolume;
let invidiousPlayerStyle;
let invidiousSubtitles;
let invidiousAutoplay;
let useFreeTube;
let exceptions;
window.browser = window.browser || window.chrome;
@ -141,6 +142,7 @@ browser.storage.sync.get(
"invidiousPlayerStyle",
"invidiousSubtitles",
"invidiousAutoplay",
"useFreeTube",
"exceptions",
],
(result) => {
@ -165,6 +167,7 @@ browser.storage.sync.get(
invidiousPlayerStyle = result.invidiousPlayerStyle;
invidiousSubtitles = result.invidiousSubtitles || "";
invidiousAutoplay = result.invidiousAutoplay;
useFreeTube = result.useFreeTube;
}
);
@ -217,6 +220,9 @@ browser.storage.onChanged.addListener((changes) => {
if ("invidiousAutoplay" in changes) {
invidiousAutoplay = changes.invidiousAutoplay.newValue;
}
if ("useFreeTube" in changes) {
useFreeTube = changes.useFreeTube.newValue;
}
if ("exceptions" in changes) {
exceptions = changes.exceptions.newValue.map((e) => {
return new RegExp(e);
@ -287,6 +293,9 @@ function redirectYouTube(url, initiator, type) {
if (onlyEmbeddedVideo && type !== "sub_frame") {
return null;
}
if (useFreeTube) {
return `freetube://${url}`;
}
// Apply settings
if (alwaysProxy) {
url.searchParams.append("local", true);

View File

@ -172,6 +172,31 @@
</div>
<div id="advanced" class="tabcontent">
<section class="settings-block">
<table
class="option"
aria-label="Redirect YouTube to FreeTube where possible"
>
<tbody>
<tr>
<td>
<h1 data-localise="__MSG_useFreeTube__">
Use FreeTube over Invidious when possible
</h1>
</td>
<td>
<input
aria-hidden="true"
id="useFreeTube"
type="checkbox"
checked
/>&nbsp;
<label for="useFreeTube" class="checkbox-label"> </label>
</td>
</tr>
</tbody>
</table>
</section>
<section class="settings-block">
<table
class="option"

View File

@ -71,6 +71,7 @@ let invidiousPlayerStyle = document.getElementById("invidious-player-style");
let invidiousSubtitles = document.getElementById("invidious-subtitles");
let invidiousAutoplay = document.getElementById("invidious-autoplay");
let theme = document.getElementById("theme");
let useFreeTube = document.getElementById("useFreeTube");
let exceptions;
window.browser = window.browser || window.chrome;
@ -119,6 +120,7 @@ browser.storage.sync.get(
"invidiousAutoplay",
"exceptions",
"theme",
"useFreeTube",
],
(result) => {
theme.value = result.theme || "";
@ -146,6 +148,7 @@ browser.storage.sync.get(
invidiousPlayerStyle.value = result.invidiousPlayerStyle || "";
invidiousSubtitles.value = result.invidiousSubtitles || "";
invidiousAutoplay.checked = result.invidiousAutoplay;
useFreeTube.checked = result.useFreeTube;
}
);
@ -315,6 +318,10 @@ persistInvidiousPrefs.addEventListener("change", (event) => {
browser.storage.sync.set({ persistInvidiousPrefs: event.target.checked });
});
useFreeTube.addEventListener("change", (event) => {
browser.storage.sync.set({ useFreeTube: event.target.checked });
});
let invidiousVolumeChange = debounce(() => {
document.querySelector(
"#volume-value"