-
-
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.
* kqm * edit logo Signed-off-by: selvuen <[email protected]> * oops Signed-off-by: selvuen <[email protected]> * add new field * Update websites/K/KQM/presence.ts Co-authored-by: Daniel Lau <[email protected]> Signed-off-by: selvuen <[email protected]> * remove iframematches Signed-off-by: selvuen <[email protected]> * largeimagekey Signed-off-by: selvuen <[email protected]> * m Signed-off-by: selvuen <[email protected]> * Update presence.ts Signed-off-by: selvuen <[email protected]> * me when the Signed-off-by: selvuen <[email protected]> --------- Signed-off-by: selvuen <[email protected]> Co-authored-by: Daniel Lau <[email protected]>
- Loading branch information
Showing
2 changed files
with
156 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,22 @@ | ||
{ | ||
"$schema": "https://schemas.premid.app/metadata/1.10", | ||
"author": { | ||
"id": "290820916051705868", | ||
"name": "clevernt" | ||
}, | ||
"service": "KQM", | ||
"description": { | ||
"en": "KQM is home to the best Genshin Impact guides and the most reputable theorycrafting community. Learn about your favorite Genshin Impact characters’ builds, artifacts, weapons, teams, and more!" | ||
}, | ||
"url": "keqingmains.com", | ||
"matches": ["*://*.keqingmains.com/*"], | ||
"version": "1.0.0", | ||
"logo": "https://i.imgur.com/zPaoj5v.png", | ||
"thumbnail": "https://keqingmains.com/wp-content/uploads/2023/12/KQM_Banner-1536x254.webp", | ||
"color": "#dab2f9", | ||
"category": "games", | ||
"tags": [ | ||
"genshin-impact", | ||
"game" | ||
] | ||
} |
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,134 @@ | ||
const presence = new Presence({ | ||
clientId: "1215004822676312174", | ||
}); | ||
|
||
function cleanAndCapitalize(string: string): string { | ||
return string | ||
.replace(/[_-]/g, " ") | ||
.split(" ") | ||
.map(word => word.charAt(0).toUpperCase() + word.substring(1)) | ||
.join(" "); | ||
} | ||
|
||
const browsingTimestamp = Math.floor(Date.now() / 1000), | ||
characterList = [ | ||
"amber", | ||
"barbara", | ||
"beidou", | ||
"bennett", | ||
"chongyun", | ||
"diluc", | ||
"diona", | ||
"eula", | ||
"fischl", | ||
"ganyu", | ||
"hu_tao", | ||
"jean", | ||
"kaeya", | ||
"kaedehara_kazuha", | ||
"keqing", | ||
"klee", | ||
"lisa", | ||
"mona", | ||
"ningguang", | ||
"noelle", | ||
"qiqi", | ||
"razor", | ||
"rosaria", | ||
"sucrose", | ||
"tartaglia", | ||
"anemo-traveler", | ||
"geo-traveler", | ||
"venti", | ||
"xiangling", | ||
"xiao", | ||
"xingqiu", | ||
"xinyan", | ||
"yanfei", | ||
"zhongli", | ||
"albedo", | ||
"kujou_sara", | ||
"raiden_shogun", | ||
"kamisato_ayaka", | ||
"yoimiya", | ||
"electro-traveler", | ||
"sangonomiya_kokomi", | ||
"sayu", | ||
"aloy", | ||
"thoma", | ||
"itto", | ||
"gorou", | ||
"yunjin", | ||
"shenhe", | ||
"yae", | ||
"ayato", | ||
"shinobu", | ||
"dendro-traveler", | ||
"heizou", | ||
"tighnari", | ||
"collei", | ||
"dori", | ||
"candace", | ||
"cyno", | ||
"nilou", | ||
"nahida", | ||
"layla", | ||
"faruzan", | ||
"wanderer", | ||
"alhaitham", | ||
"yaoyao", | ||
"dehya", | ||
"mika", | ||
"baizhu", | ||
"kaveh", | ||
"kirara", | ||
"hydro-traveler", | ||
"lyney", | ||
"lynette", | ||
"freminet", | ||
"neuvillette", | ||
"wriothesley", | ||
"furina", | ||
"charlotte", | ||
"navia", | ||
"chevreuse", | ||
"xianyun", | ||
"gaming", | ||
]; | ||
|
||
presence.on("UpdateData", async () => { | ||
const presenceData: PresenceData = { | ||
largeImageKey: "https://i.nuuls.com/Z1rY4.png", | ||
startTimestamp: browsingTimestamp, | ||
}, | ||
{ pathname, host } = document.location; | ||
|
||
if (pathname === "/") presenceData.details = "Browsing KQM"; | ||
|
||
const matchedCharacter = characterList.find(character => { | ||
return new RegExp( | ||
`^/(${character}|q/${character.toLowerCase()}[^/]*-quickguide)/$` | ||
).test(pathname); | ||
}); | ||
|
||
if (matchedCharacter) { | ||
presenceData.details = `Reading a ${ | ||
pathname.includes("-quickguide") ? "Quick Guide" : "Guide" | ||
}`; | ||
presenceData.state = document.title | ||
.replace(" - KQM", "") | ||
.replace(" Quick Guide", ""); | ||
} else if (pathname.includes("/misc")) { | ||
presenceData.details = "Reading a Miscellaneous Guide"; | ||
presenceData.state = document.title.replace(" - KQM", ""); | ||
} else if (host === "library.keqingmains.com") { | ||
presenceData.details = "Browsing TCL"; | ||
presenceData.state = | ||
cleanAndCapitalize(document.title.replace(" | KQM TCL", "")) || null; | ||
} else if (host === "compendium.keqingmains.com") { | ||
presenceData.details = "Browsing The Compendium"; | ||
presenceData.state = cleanAndCapitalize(pathname.substring(1)) || null; | ||
} | ||
|
||
presence.setActivity(presenceData); | ||
}); |