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(Writers Duet): add presence #8322

Merged
merged 9 commits into from
Apr 29, 2024
Merged
29 changes: 29 additions & 0 deletions websites/W/WriterDuet/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"$schema": "https://schemas.premid.app/metadata/1.10",
"author": {
"id": "358402930191106049",
"name": "ion606"
},
"service": "WriterDuet",
"description": {
"en": "Plan, write, and share with the industry-standard software used by over 1 million screenwriters, TV shows, and blockbusters"
},
"url": [
"www.writerduet.com",
"writerduet.helpscoutdocs.com"
],
"matches": [
"https://*.writerduet.com/*",
"https://*writerduet.helpscoutdocs.com/*"
],
"version": "1.0.0",
"logo": "https://www.writerduet.com/script/wd-logo-square.png",
"thumbnail": "https://www.writerduet.com/static/media/logo.3fd682b7.png",
"color": "#4598d4",
"category": "other",
"tags": [
"writer",
"writerduet",
"writerduet"
]
}
73 changes: 73 additions & 0 deletions websites/W/WriterDuet/presence.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
const presence = new Presence({
clientId: "1234183805380857907",
}),
browsingTimestamp = Math.floor(Date.now() / 1000);

const enum Assets {
Logo = "https://www.writerduet.com/script/wd-logo-square.png",
}

const enum Pages {
home = "",
script = "script",
blog = "blog",
help = "category",
pricing = "pricing",
article = "article",
}

presence.on("UpdateData", async () => {
const presenceData: PresenceData = {
largeImageKey: Assets.Logo,
startTimestamp: browsingTimestamp,
},
[, page, subpage] = document.location.pathname.split("/");

switch (page.split("#")[0]) {
case Pages.script:
{
presenceData.details = document.title;
presenceData.state = document
.querySelector(".Mui-selected")
.querySelector("[data-tip]").textContent;
presence.setActivity(presenceData);
}
break;

case Pages.home:
{
presenceData.details = "Browsing Home";
}
break;

case Pages.help:
case Pages.article:
{
(presenceData.details = "Browsing Help"),
(presenceData.state =
document.querySelector("#categoryHead > h1")?.textContent ||
document.querySelector(".title").textContent);
}
break;

case Pages.pricing:
presenceData.details = "Reviewing Payement Plans";
break;

case Pages.blog:
{
if (subpage) {
presenceData.details = "Reading Blog Article";
presenceData.state = document.querySelector(
".jupiterx-post-title"
).textContent;
} else presenceData.details = "Reading the Blog";
}
break;

default:
presenceData.details = "Browsing the Site";
}

presence.setActivity(presenceData);
});
Loading