mirror of
https://codeberg.org/Nero/InviTube.git
synced 2024-11-21 23:33:39 +00:00
^Adjust to Invidious
This commit is contained in:
parent
312a0664f1
commit
5ea86baf06
3 changed files with 8 additions and 25 deletions
|
@ -1,12 +1,8 @@
|
|||
let ausnahme = false;
|
||||
let w2gRegex = /w2g\.tv/;
|
||||
|
||||
|
||||
// Einstellungen ziehen, ContentScript registrieren
|
||||
browser.storage.local.get(
|
||||
{
|
||||
activated: true,
|
||||
instance: "redirect.invidio.us",
|
||||
instance: "yewtu.be",
|
||||
}
|
||||
).then((storage) => {
|
||||
if (storage.activated) {
|
||||
|
@ -71,25 +67,22 @@ browser.webRequest.onBeforeRequest.addListener(async (details) => {
|
|||
|
||||
let activated;
|
||||
let instance;
|
||||
let proxy;
|
||||
let imageRedirect;
|
||||
|
||||
await browser.storage.local.get({
|
||||
activated: true,
|
||||
instance: "redirect.invidio.us",
|
||||
imageRedirect: true
|
||||
instance: "yewtu.be",
|
||||
}).then((item) => {
|
||||
activated = item.activated;
|
||||
instance = item.instance;
|
||||
imageRedirect = item.imageRedirect;
|
||||
});
|
||||
|
||||
if (activated) {
|
||||
const youtubeRegex = /youtube.com(\/?.*)/;
|
||||
const youtubeShortRegex = /youtu.be\/.+/;
|
||||
|
||||
if (imageRedirect && details.url.startsWith("https://img.youtube.com/vi")) {
|
||||
return { redirectUrl: 'https://' + proxy + '/vi/' + details.url.split("/vi/")[1].split("/")[0] + "/hqdefault.jpg?host=i.ytimg.com" }
|
||||
if (details.url.startsWith("https://img.youtube.com/vi")) {
|
||||
console.log("JOOOOO");
|
||||
return { redirectUrl: 'https://' + instance + '/vi/' + details.url.split("/vi/")[1].split("/")[0] + "/mqdefault.jpg" }
|
||||
}
|
||||
else if (youtubeRegex.test(details.url)) {
|
||||
return { redirectUrl: 'https://' + instance + youtubeRegex.exec(details.url)[1] };
|
||||
|
|
|
@ -81,18 +81,12 @@
|
|||
</style>
|
||||
<meta charset="utf-8">
|
||||
</head>
|
||||
<body bgcolor="202023">
|
||||
<body bgcolor="202023" style="padding: 2em">
|
||||
<form>
|
||||
<p>
|
||||
Instance URL:
|
||||
<input id="instance" class="textfield" placeholder="piped.kavin.rocks"/>
|
||||
<br>
|
||||
<label class="switch">
|
||||
<input type="checkbox" id="imageRedirect">
|
||||
<span class="slider" />
|
||||
</label> Redirect images
|
||||
<span title="Might cause not every image to be loaded">❓</span>
|
||||
<br>
|
||||
<button id="saveBtn" type="submit">Save</button>
|
||||
</p>
|
||||
</form>
|
||||
|
|
|
@ -3,14 +3,12 @@ document.querySelector("form").addEventListener("submit", (e) => {
|
|||
e.preventDefault();
|
||||
let instance = document.querySelector("#instance").value.trim();
|
||||
instance = instance.replace(/^https?:?\/?\/?/, '').replace('\/$');
|
||||
proxy = proxy.replace(/^https?:?\/?\/?/, '').replace('\/$');
|
||||
if (!instance || !proxy) {
|
||||
if (!instance) {
|
||||
return alert("Please fill out the fields!");
|
||||
}
|
||||
|
||||
browser.storage.local.set({
|
||||
instance: instance,
|
||||
imageRedirect: document.querySelector("#imageRedirect").checked
|
||||
}).then(() => alert("Saved!"));
|
||||
});
|
||||
|
||||
|
@ -18,10 +16,8 @@ document.querySelector("form").addEventListener("submit", (e) => {
|
|||
// Restore options
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
browser.storage.local.get({
|
||||
imageRedirect: true,
|
||||
instance: "redirect.invidio.us",
|
||||
instance: "yewtu.be",
|
||||
}).then((item) => {
|
||||
document.querySelector("#instance").value = item.instance;
|
||||
document.querySelector("#imageRedirect").checked = item.imageRedirect;
|
||||
});
|
||||
});
|
Loading…
Reference in a new issue