Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Physics Wallah): Website updated #8900

Merged
merged 12 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion websites/P/Physics Wallah/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"en": "Physics Wallah is India's top online ed-tech platform that provides affordable and comprehensive learning experience to students of classes 6 to 12 and those preparing for JEE and NEET exams."
},
"url": "www.pw.live",
"version": "1.0.5",
"version": "1.1.0",
"logo": "https://cdn.rcd.gg/PreMiD/websites/P/Physics%20Wallah/assets/logo.png",
"thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/Physics%20Wallah/assets/thumbnail.png",
"color": "#2596be",
Expand Down
99 changes: 42 additions & 57 deletions websites/P/Physics Wallah/presence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ presence.on("UpdateData", async () => {
startTimestamp: browsingTimestamp,
type: ActivityType.Watching,
},
{ pathname, href, search } = document.location,
privacyMode = await presence.getSetting<boolean>("privacy");
{ pathname, href } = document.location,
privacyMode = await presence.getSetting<boolean>("privacy"),
jsonobj = JSON.parse(sessionStorage.getItem("batches_urls"));

if (pathname === "/") {
presenceData.details = "Home";
Expand All @@ -34,85 +35,58 @@ presence.on("UpdateData", async () => {
presenceData.state = "My Batches";
presenceData.smallImageKey = Assets.Reading;
presenceData.smallImageText = "Studying";
} else if (pathname.includes("batch-overview")) {
}
if (href.includes("batch-overview")) {
presenceData.details = "Studying...";
presenceData.state = `Viewing ${
document.querySelector(".bold.text-white").textContent
JSON.parse(localStorage.getItem("BATCH_DETAILS")).name
}`;
presenceData.smallImageKey = Assets.Reading;
presenceData.smallImageText = "Studying";
presenceData.buttons = [{ label: "View Batch", url: href }];
} else if (pathname.includes("batch-video-player")) {
const deta = localStorage.getItem("dpp_subject");
let detal = ` | ${deta}`;
if (deta === null) detal = "";
if (!privacyMode) {
presenceData.details = `Watching Lecture${detal}`;

presenceData.state = `${
JSON.parse(localStorage.getItem("VIDEO_DETAILS")).topic
}`;
presenceData.buttons = [{ label: "Watch Lecture", url: href }];
} else presenceData.details = `Watching a lecture${detal}`;

if (document.querySelectorAll(".vjs-paused").length < 1) {
presenceData.smallImageKey = Assets.Play;
presenceData.smallImageText = "Watching a lecture";
[presenceData.startTimestamp, presenceData.endTimestamp] =
updateVideoTimestamps();
} else {
presenceData.smallImageKey = Assets.Pause;
presenceData.smallImageText = "Paused";
}
} else if (pathname.includes("subject-topics")) {
const urlParams = new URLSearchParams(search);

if (urlParams.has("chapterId")) {
presenceData.details = urlParams.get("subject");
presenceData.state = urlParams.get("topic");
} else if (href.includes("subject-topics")) {
if (href.includes("chapterId")) {
const urlsobj = new URL(jsonobj[3].value, "https://www.pw.live");
presenceData.details = urlsobj.searchParams.get("subject");
presenceData.state = urlsobj.searchParams.get("topic");
presenceData.smallImageKey = Assets.Reading;
presenceData.smallImageText = "Browsing Resources";
} else if (!urlParams.has("chapterId")) {
presenceData.details = urlParams.get("subject");
} else if (!href.includes("chapterId")) {
presenceData.details = new URL(
jsonobj[2].value,
"https://www.pw.live"
).searchParams.get("subject");
presenceData.state = "Browsing Resources...";
presenceData.smallImageKey = Assets.Reading;
presenceData.smallImageText = "Browsing Resources";
}
} else if (pathname.includes("open-pdf")) {
if (localStorage.getItem("dpp_subject")) {
presenceData.details = "Solving DPP (PDF)";
if (!privacyMode)
presenceData.state = localStorage.getItem("dpp_subject");
else presenceData.state = "Improving skills";

presenceData.startTimestamp = browsingTimestamp;
presenceData.smallImageKey = Assets.Viewing;
presenceData.smallImageText = "Viewing DPP";
}
} else if (pathname.includes("q-bank-exercise")) {
presenceData.details = "Solving DPP (MCQ)";
if (!privacyMode)
presenceData.state = localStorage.getItem("dpp_subject");
} else if (href.includes("open-pdf")) {
const urlsobj = new URL(jsonobj[3].value, "https://www.pw.live");
presenceData.details = `Solving DPP (PDF) | ${urlsobj.searchParams.get(
"subject"
)}`;
if (!privacyMode) presenceData.state = urlsobj.searchParams.get("topic");
else presenceData.state = "Improving skills";

presenceData.startTimestamp = browsingTimestamp;
presenceData.smallImageKey = Assets.Viewing;
presenceData.smallImageText = "Viewing DPP";
}
} else if (pathname.startsWith("/watch")) {
const deta = localStorage.getItem("dpp_subject");
let detal = ` | ${deta}`;
if (deta === null) detal = "";
const deta = JSON.parse(localStorage.getItem("SCHEDULE_DETAILS"));
let detal = "";
if (deta.subject === null) detal = "";
else detal = ` | ${deta.subject.name}`;
if (!privacyMode) {
presenceData.details = `Watching Lecture${detal}`;

presenceData.state = `${
JSON.parse(localStorage.getItem("VIDEO_DETAILS")).topic
}`;
presenceData.state = `${deta.topic}`;

presenceData.buttons = [{ label: "Watch Lecture", url: href }];
} else presenceData.details = `Watching a lecture${detal}`;

} else {
presenceData.details = "Watching a lecture";
presenceData.state = `Subject: ${deta.subject.name}`;
}
if (document.querySelectorAll(".vjs-paused").length < 1) {
presenceData.smallImageKey = Assets.Play;
presenceData.smallImageText = "Watching a lecture";
Expand All @@ -122,6 +96,17 @@ presence.on("UpdateData", async () => {
presenceData.smallImageKey = Assets.Pause;
presenceData.smallImageText = "Paused";
}
} else if (pathname.startsWith("/practice")) {
const urlsobj = new URL(jsonobj[3].value, "https://www.pw.live");
presenceData.details = `Solving DPP (MCQ) | ${urlsobj.searchParams.get(
"subject"
)}`;
if (!privacyMode) presenceData.state = urlsobj.searchParams.get("topic");
else presenceData.state = "Improving skills";

presenceData.startTimestamp = browsingTimestamp;
presenceData.smallImageKey = Assets.Viewing;
presenceData.smallImageText = "Viewing DPP";
}
presence.setActivity(presenceData);
});
Expand Down