Skip to content

Commit

Permalink
feat(Writers Duet): add presence (#8322)
Browse files Browse the repository at this point in the history
  • Loading branch information
ION606 authored Apr 29, 2024
1 parent 6da804f commit fa68fac
Show file tree
Hide file tree
Showing 2 changed files with 102 additions and 0 deletions.
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);
});

0 comments on commit fa68fac

Please sign in to comment.