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(4chan): add presence (PreMiD#7935)
* feat(4chan): add presence * feat(4chan): edit logo and thumbnail to comply with guidelines * feat(4chan): add nsfw tag * feat(4chan): format code * fix(4chan): fix logo link Co-authored-by: Dark_Ville <[email protected]> Signed-off-by: beardotpy <[email protected]> * fix(4chan): fix logo link Co-authored-by: Dark_Ville <[email protected]> Signed-off-by: beardotpy <[email protected]> * refactor(4chan): shorten variable name Co-authored-by: Dark_Ville <[email protected]> Signed-off-by: beardotpy <[email protected]> * refactor(4chan): shorten variable name Co-authored-by: Dark_Ville <[email protected]> Signed-off-by: beardotpy <[email protected]> * fix(4chan): add support for www domain Co-authored-by: Daniel Lau <[email protected]> Signed-off-by: beardotpy <[email protected]> * refactor(4chan): run linter --------- Signed-off-by: beardotpy <[email protected]> Co-authored-by: Dark_Ville <[email protected]> Co-authored-by: Daniel Lau <[email protected]>
- Loading branch information
1 parent
dfaecdc
commit 836b29f
Showing
2 changed files
with
148 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,25 @@ | ||
{ | ||
"$schema": "https://schemas.premid.app/metadata/1.9", | ||
"author": { | ||
"id": "623396579960946690", | ||
"name": "bear_" | ||
}, | ||
"service": "4chan", | ||
"description": { | ||
"en": "4chan is an anonymous English-language imageboard website. Launched by Christopher \\\"moot\\\" Poole in October 2003, the site hosts boards dedicated to a wide variety of topics, from video games and television to literature, cooking, weapons, music, history, anime, fitness, politics, and sports, among others." | ||
}, | ||
"url": [ | ||
"www.4chan.org", | ||
"4chan.org" | ||
], | ||
"version": "1.0.0", | ||
"logo": "https://i.imgur.com/7pI9X5M.png", | ||
"thumbnail": "https://i.imgur.com/lcl0PuO.png", | ||
"color": "#789922", | ||
"category": "socials", | ||
"tags": [ | ||
"4chan", | ||
"imageboard", | ||
"nsfw" | ||
] | ||
} |
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,123 @@ | ||
const presence = new Presence({ | ||
clientId: "1195051461822914640", | ||
}); | ||
|
||
const enum Assets { | ||
Logo = "https://i.imgur.com/7pI9X5M.png", | ||
} | ||
|
||
const boards: { [board: string]: string } = { | ||
"/3/": "3DCG", | ||
"/a/": "Anime & Manga", | ||
"/aco/": "Adult Cartoons", | ||
"/adv/": "Advice", | ||
"/an/": "Animals & Nature", | ||
"/asp/": "Alternative Sports", | ||
"/b/": "Random", | ||
"/bant/": "International/Random", | ||
"/biz/": "Business & Finance", | ||
"/c/": "Anime/Cute", | ||
"/cgl/": "Cosplay & EGL", | ||
"/ck/": "Food & Cooking", | ||
"/cm/": "Cute/Male", | ||
"/co/": "Comics & Cartoons", | ||
"/d/": "Hentai/Alternative", | ||
"/diy/": "Do*It*Yourself", | ||
"/e/": "Ecchi", | ||
"/f/": "Flash", | ||
"/fa/": "Fashion", | ||
"/fit/": "Fitness", | ||
"/g/": "Technology", | ||
"/gd/": "Graphic Design", | ||
"/gif/": "Adult GIF", | ||
"/h/": "Hentai", | ||
"/hc/": "Hardcore", | ||
"/hm/": "Handsome Men", | ||
"/hr/": "High Resolution", | ||
"/i/": "Oekaki", | ||
"/ic/": "Artwork/Critique", | ||
"/his/": "History & Humanities", | ||
"/int/": "International", | ||
"/jp/": "Otaku Culture", | ||
"/k/": "Weapons", | ||
"/lit/": "Literature", | ||
"/lgbt/": "LGBT", | ||
"/m/": "Mecha", | ||
"/mlp/": "Pony", | ||
"/mu/": "Music", | ||
"/news/": "Current News", | ||
"/n/": "Transportation", | ||
"/o/": "Auto", | ||
"/out/": "Outdoors", | ||
"/p/": "Photography", | ||
"/po/": "Papercraft & Origami", | ||
"/pol/": "Politically Incorrect", | ||
"/pw/": "Professional Wrestling", | ||
"/qst/": "Quests", | ||
"/r/": "Adult Requests", | ||
"/r9k/": "ROBOT9001", | ||
"/s4s/": "Shit 4chan Says", | ||
"/s/": "Sexy Beautiful Women", | ||
"/sci/": "Science & Math", | ||
"/soc/": "Cams & Meetups", | ||
"/sp/": "Sports", | ||
"/t/": "Torrents", | ||
"/tg/": "Traditional Games", | ||
"/toy/": "Toys", | ||
"/trash/": "Off*topic", | ||
"/trv/": "Travel", | ||
"/tv/": "Television & Film", | ||
"/u/": "Yuri", | ||
"/v/": "Video Games", | ||
"/vg/": "Video Game Generals", | ||
"/vm/": "Video Games/Multiplayer", | ||
"/vmg/": "Video Games/Mobile", | ||
"/vip/": "Very Important Posts", | ||
"/vp/": "Pokémon", | ||
"/vr/": "Retro Games", | ||
"/vrpg/": "Video Games/RPG", | ||
"/vst/": "Video Games/Strategy", | ||
"/vt/": "Virtual YouTubers", | ||
"/w/": "Anime/Wallpapers", | ||
"/wg/": "Wallpapers/General", | ||
"/wsg/": "Worksafe GIF", | ||
"/wsr/": "Worksafe Requests", | ||
"/x/": "Paranormal", | ||
"/xs/": "Extreme Sports", | ||
"/y/": "Yaoi", | ||
}, | ||
browsingTimestamp = Math.floor(Date.now() / 1000); | ||
|
||
presence.on("UpdateData", async () => { | ||
const presenceData: PresenceData = { | ||
largeImageKey: Assets.Logo, | ||
startTimestamp: browsingTimestamp, | ||
}, | ||
{ pathname } = document.location; | ||
|
||
if (pathname === "/") presenceData.details = "Viewing the front page"; | ||
else if (pathname.startsWith("/faq")) | ||
presenceData.details = "Reading the FAQ"; | ||
else if (pathname.startsWith("/rules")) | ||
presenceData.details = "Reading the rules"; | ||
else if (pathname.startsWith("/4channews")) | ||
presenceData.details = "Viewing news posts"; | ||
else { | ||
for (const board in boards) { | ||
if (pathname.includes(board)) | ||
presenceData.details = `Browsing ${board} - ${boards[board]}`; | ||
} | ||
|
||
if (pathname.includes("/thread/")) { | ||
const threadNum = pathname.split("/").at(-1), | ||
threadSubject = document.querySelector(".subject").textContent; | ||
|
||
if (threadSubject) | ||
presenceData.state = `>>${threadNum} - "${threadSubject}"`; | ||
else presenceData.state = `>>${threadNum}`; | ||
} else if (pathname.includes("/archive")) | ||
presenceData.state = "Checking the archive"; | ||
} | ||
|
||
presence.setActivity(presenceData); | ||
}); |