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": { "version": {
"message": "Version", "message": "Version",
"description": "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 # Extension Store (AMO & Chrome Web Store) Listing
## Summary: ## Summary:
``` ```
A simple web extension that redirects Twitter, YouTube, Instagram & Google Maps requests to privacy friendly alternatives. A simple web extension that redirects Twitter, YouTube, Instagram & Google Maps requests to privacy friendly alternatives.
``` ```
## Description: ## 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>. 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> <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. 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> <ul>
<li>Added Russian language translation.</li> <li>Added Polish language translation.</li>
<li>Fix Invidious autoplay parameter.</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> </ul>
<b>★ Permissions: </b> <b>★ Permissions: </b>

View File

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

View File

@ -172,6 +172,31 @@
</div> </div>
<div id="advanced" class="tabcontent"> <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"> <section class="settings-block">
<table <table
class="option" class="option"

View File

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