forked from PreMiD/Presences
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Kickstarter): add presence (PreMiD#6734)
- Loading branch information
1 parent
29e11a7
commit f5d75d6
Showing
3 changed files
with
118 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,35 @@ | ||
{ | ||
"$schema": "https://schemas.premid.app/metadata/1.7", | ||
"author": { | ||
"name": "RisingSunLight", | ||
"id": "240521747852558347" | ||
}, | ||
"service": "Kickstarter", | ||
"description": { | ||
"en": "Kickstarter exists to help bring creative projects to life. A home for film, music, art, theater, games, comics, design, photography, and more.", | ||
"de": "Kickstarter existiert, um kreativen Projekten zur Verwirklichung zu verhelfen. Hier findest du Filme, Musik, Kunst, Theater, Spiele, Comics, Design, Fotografie und vieles mehr.", | ||
"fr": "Kickstarter existe pour faire vivre les projets créatifs. Un site dédié à la musique, à l'art, au cinéma, au théâtre, à la BD, au design, à la photographie et aux jeux, entre autres.", | ||
"es": "Kickstarter existe para ayudar a hacer realidad proyectos creativos. Un lugar para el cine, la música, el arte, el teatro, los juegos, las historietas, el diseño, la fotografía y más.", | ||
"it": "Kickstarter esiste per aiutare a dare vita ai progetti creativi. Kickstarter accoglie tanti progetti: film, musica, arte, teatro, videogiochi, fumetti, grafica, fotografia e tanto altro.", | ||
"ja_JP": "Kickstarterは、映画、音楽、アート、シアター、ゲーム、コミック、デザイン、写真など、多種多様なクリエイティブプロジェクトを実現させるための場です。" | ||
}, | ||
"url": "www.kickstarter.com", | ||
"version": "1.0.0", | ||
"logo": "https://i.imgur.com/evUBiFh.png", | ||
"thumbnail": "https://i.imgur.com/f2hPZZy.png", | ||
"color": "#05ce78", | ||
"category": "other", | ||
"tags": [ | ||
"kickstarter", | ||
"projects", | ||
"crowdfunding" | ||
], | ||
"settings": [ | ||
{ | ||
"id": "buttons", | ||
"title": "Show Buttons", | ||
"icon": "fas fa-compress-arrows-alt", | ||
"value": true | ||
} | ||
] | ||
} |
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,77 @@ | ||
const presence = new Presence({ clientId: "1014441192106229790" }), | ||
browsingTimestamp = Math.floor(Date.now() / 1000), | ||
slideshow = presence.createSlideshow(), | ||
staticsTabsProject: { [name: string]: string } = { | ||
description: "Reading Project Description", | ||
faqs: "Reading Project FAQ", | ||
posts: "Reading Project News", | ||
comments: "Reading Project Comments", | ||
community: "Viewing Project Contributors", | ||
pledge: "Contributing to the Project", | ||
}, | ||
staticPages: { [name: string]: string } = { | ||
"": "Viewing homepage", | ||
start: "Starting a new project", | ||
arts: "Browsing arts projects", | ||
"comics-illustration": "Browsing comic and illustration projects", | ||
"design-tech": "Browsing design and tech projects", | ||
film: "Browsing film projects", | ||
"food-craft": "Browsing food craft projects", | ||
games: "Browsing game projects", | ||
music: "Browsing music projects", | ||
publishing: "Browsing publishing projects", | ||
blog: "Reading blog posts", | ||
}; | ||
|
||
enum Assets { | ||
Logo = "https://i.imgur.com/evUBiFh.png", | ||
Reading = "https://i.imgur.com/53N4eY6.png", | ||
} | ||
|
||
presence.on("UpdateData", async () => { | ||
const presenceData: PresenceData = { | ||
largeImageKey: Assets.Logo, | ||
startTimestamp: browsingTimestamp, | ||
}, | ||
presenceDataSlide: PresenceData = { | ||
largeImageKey: Assets.Logo, | ||
startTimestamp: browsingTimestamp, | ||
}, | ||
{ href, pathname } = document.location, | ||
pathArr = pathname.split("/"), | ||
showButtons = await presence.getSetting<boolean>("buttons"); | ||
|
||
if (pathArr[1] === "projects") { | ||
presenceData.details = presenceDataSlide.details = | ||
pathArr.length > 4 ? staticsTabsProject[pathArr[4]] : "Viewing a project"; | ||
presenceData.state = | ||
document.querySelector(".project-name")?.textContent ?? | ||
document.querySelector("span > a")?.textContent; | ||
if (!pathname.includes("pledge")) { | ||
presenceDataSlide.state = document.querySelector("a#back-project-button") | ||
? `${document.querySelector(".ksr-green-500").textContent} on ${ | ||
document.querySelector(".money").textContent | ||
}` | ||
: `${document.querySelector(".money").textContent} obtained`; | ||
slideshow.addSlide("moneySlide", presenceDataSlide, 5000); | ||
} | ||
|
||
presenceData.smallImageKey = presenceDataSlide.smallImageKey = | ||
Assets.Reading; | ||
presenceData.buttons = presenceDataSlide.buttons = [ | ||
{ label: "View Project", url: href.split("pledge")[0] }, | ||
]; | ||
|
||
slideshow.addSlide("projectName", presenceData, 5000); | ||
} else if (Object.keys(staticPages).includes(pathArr[1])) | ||
presenceData.details = staticPages[pathArr[1]]; | ||
else presenceData.details = "Browsing"; | ||
|
||
if (!showButtons) { | ||
delete presenceData.buttons; | ||
delete presenceDataSlide.buttons; | ||
} | ||
|
||
if (slideshow.getSlides().length > 1) presence.setActivity(slideshow); | ||
else presence.setActivity(presenceData); | ||
}); |
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,6 @@ | ||
{ | ||
"extends": "../../../tsconfig.json", | ||
"compilerOptions": { | ||
"outDir": "./dist/" | ||
} | ||
} |