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

feat(The Odin Project): add presence #6710

Merged
merged 14 commits into from
Aug 31, 2022
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
24 changes: 24 additions & 0 deletions websites/T/The Odin Project/dist/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"$schema": "https://schemas.premid.app/metadata/1.7",
"author": {
"name": "dogukan",
"id": "0420"
},
"service": "The Odin Project",
"description": {
"en": "The Odin Project is one of those \"What I wish I had when I was learning\" resources. Not everyone has access to a computer science education or the funds to attend an intensive coding school and neither of those is right for everyone anyway. This project is designed to fill in the gap for people who are trying to hack it on their own but still want a high quality education."
},
"url": "www.theodinproject.com",
"version": "1.0.0",
"logo": "https://i.imgur.com/gtBvHQH.png",
"thumbnail": "https://i.imgur.com/5rm6BZ6.png",
"color": "#e3b261",
"category": "other",
"tags": [
"top",
"odin",
"project",
"odin-project",
"the-odin-project"
]
}
58 changes: 58 additions & 0 deletions websites/T/The Odin Project/presence.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
const presence = new Presence({
clientId: "1013489969379152022",
}),
browsingTimestamp = Math.floor(Date.now() / 1000);
presence.on("UpdateData", async () => {
const presenceData: PresenceData = {
largeImageKey: "https://i.imgur.com/gtBvHQH.png",
startTimestamp: browsingTimestamp,
},
lesson = document.querySelector<HTMLHeadingElement>(
"body > div.page-container.lesson > header > div > div > h1"
),
course = document.querySelector<HTMLHeadingElement>(
"body > div.gradient.odin-dark-bg > div > div:nth-child(1) > a > h1"
),
courseTitle = document.querySelector<HTMLHeadElement>(
"body > div.page-container.lesson > header > div > div > a > h2"
),
path = document.location.pathname;
switch (path) {
case "/paths": {
presenceData.state = "Viewing all Paths";
break;
}
case "/paths/full-stack-javascript": {
presenceData.state = "Viewing the Full Stack Javascript Path";
break;
}
case "/paths/full-stack-ruby-on-rails": {
presenceData.state = "Viewing the Full Stack Ruby Path";
break;
}
case "/paths/foundations/courses/foundations": {
presenceData.state = "Viewing the Foundations Path";
break;
}
default:
presenceData.state = "Viewing Dashboard";
}

if (path.includes("/paths/full-stack-javascript/courses/")) {
presenceData.details = "Full Stack Javascript - Courses";
presenceData.state = `${course.textContent}`;
} else if (path.includes("/paths/full-stack-ruby-on-rails/courses/")) {
presenceData.details = "Full Stack Ruby - Courses";
presenceData.state = `${course.textContent}`;
} else if (path.includes("/foundations-")) {
presenceData.state = `${lesson.textContent}`;
presenceData.details = "𝙁𝙤𝙪𝙣𝙙𝙖𝙩𝙞𝙤𝙣𝙨 - 𝙇𝙚𝙨𝙨𝙤𝙣";
} else if (path.includes("/lessons/node-")) {
presenceData.details = courseTitle.textContent;
presenceData.state = lesson.textContent;
} else if (path.includes("/lessons/ruby-")) {
presenceData.details = courseTitle.textContent;
presenceData.state = lesson.textContent;
}
presence.setActivity(presenceData);
});
6 changes: 6 additions & 0 deletions websites/T/The Odin Project/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "../../../tsconfig.json",
"compilerOptions": {
"outDir": "./dist/"
}
}