Skip to content

Commit

Permalink
fix(Invidious): add privacy mode (#8323)
Browse files Browse the repository at this point in the history
  • Loading branch information
ION606 authored Apr 29, 2024
1 parent fa68fac commit 2918144
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 16 deletions.
10 changes: 9 additions & 1 deletion websites/I/Invidious/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,21 @@
"vid.mint.lgbt",
"yewtu.be"
],
"version": "1.0.23",
"version": "1.0.24",
"logo": "https://cdn.rcd.gg/PreMiD/websites/I/Invidious/assets/logo.png",
"thumbnail": "https://cdn.rcd.gg/PreMiD/websites/I/Invidious/assets/thumbnail.jpg",
"color": "#00B6F0",
"category": "videos",
"tags": [
"video",
"media"
],
"settings": [
{
"id": "privacy",
"title": "Privacy Mode",
"icon": "fad fa-user-secret",
"value": false
}
]
}
37 changes: 22 additions & 15 deletions websites/I/Invidious/presence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const presence = new Presence({

function getTime() {
const time = document
.querySelectorAll(".vjs-current-time-display")[0]
.querySelector(".vjs-current-time-display")
.textContent.split(":")
.map(n => Number(n));
if (time.length === 3)
Expand All @@ -21,6 +21,8 @@ presence.on("UpdateData", async () => {
};
let clear = false;

const privacy = await presence.getSetting<boolean>("privacy");

switch (document.location.pathname.replace("/feed", "").split("/")[1]) {
case "":
case "popular":
Expand Down Expand Up @@ -56,28 +58,33 @@ presence.on("UpdateData", async () => {
break;

case "watch":
presenceData.smallImageKey = document.querySelectorAll(".vjs-playing")[0]
? Assets.Play
: Assets.Pause;
presenceData.details = document
.querySelectorAll("h1")[0]
.textContent.trim();
presenceData.state = document.querySelector("#channel-name").textContent;
if (document.querySelectorAll(".vjs-playing")[0])
presenceData.startTimestamp = getTime();

if (!privacy) {
presenceData.smallImageKey = document.querySelector(".vjs-playing")
? Assets.Play
: Assets.Pause;
presenceData.details = document.querySelector("h1").textContent.trim();
presenceData.state =
document.querySelector("#channel-name").textContent;
if (document.querySelector(".vjs-playing"))
presenceData.startTimestamp = getTime();
}
break;

case "playlist":
presenceData.details = "Viewing playlist";
presenceData.state = document.querySelectorAll("h3")[0].textContent;
if (!privacy)
presenceData.state = document.querySelector("h3").textContent;
break;

case "channel":
presenceData.details = "Viewing channel";
presenceData.state = document
.querySelectorAll(".channel-profile")[0]
.textContent.trim();

if (!privacy) {
presenceData.state = document
.querySelector(".channel-profile")
.textContent.trim();
}

break;

default:
Expand Down

0 comments on commit 2918144

Please sign in to comment.