-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Writers Duet): add presence (#8322)
- Loading branch information
Showing
2 changed files
with
102 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); |