-
-
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: add and initialize Memrise presence * feat: add dashboard and course * fix: selector fix * feat: add settings and format * feat: lots of things * refactor: lint * feat: nl translation * feat: add about, team, jobs and blog * feat: add philosophy, contact, terms, privacy and cookies * feat: add dictionary * feat: add community domain * fix: lock files * fix: lock files * Revert "fix: lock files" This reverts commit f96f511. * refactor: better sentence * fix: selector and new standardized assets * fix: schema version * feat: add new presence * fix: update schema version * feat: live and offline streamer * feat: revamp and add help section * feat: add buttons to streamer and privacy settings * chore: linting * refactor: readable url * fix: remove trailing non-breaking space character from url path * chore: remove unnecessary parentheses and add show logo only option * feat: add personal account data * chore: add smallImage key * refactor: better alternative for directing * Update websites/K/Kick/presence.ts Co-authored-by: Dark_Ville <[email protected]> Signed-off-by: Giang <[email protected]> * Update websites/K/Kick/presence.ts Co-authored-by: Dark_Ville <[email protected]> Signed-off-by: Giang <[email protected]> * Update websites/K/Kick/presence.ts Co-authored-by: Dark_Ville <[email protected]> Signed-off-by: Giang <[email protected]> * refactor: href location * refactor: delete instead of null and use url for shorthand * refactor: remove unnecessary parentheses * refactor: revert the previous commit to adhere lint --------- Signed-off-by: Giang <[email protected]> Co-authored-by: Bas950 <[email protected]> Co-authored-by: Dark_Ville <[email protected]>
- Loading branch information
1 parent
a50e178
commit c0b888a
Showing
2 changed files
with
246 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,40 @@ | ||
{ | ||
"$schema": "https://schemas.premid.app/metadata/1.9", | ||
"author": { | ||
"id": "135058085386387457", | ||
"name": "giang." | ||
}, | ||
"service": "Kick", | ||
"description": { | ||
"en": "Kick is the most rewarding gaming and livestreaming platform." | ||
}, | ||
"url": [ | ||
"kick.com", | ||
"help.kick.com" | ||
], | ||
"version": "1.0.0", | ||
"logo": "https://i.imgur.com/7pAQJgm.png", | ||
"thumbnail": "https://i.imgur.com/DrveDUP.png", | ||
"color": "#53fc18", | ||
"category": "videos", | ||
"tags": [ | ||
"videos", | ||
"streaming", | ||
"entertainment", | ||
"livestreaming" | ||
], | ||
"settings": [ | ||
{ | ||
"id": "details", | ||
"title": "Show details", | ||
"icon": "fas fa-eye-slash", | ||
"value": true | ||
}, | ||
{ | ||
"id": "logo", | ||
"title": "Show only logo", | ||
"icon": "fas fa-image", | ||
"value": false | ||
} | ||
] | ||
} |
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,206 @@ | ||
const presence = new Presence({ clientId: "1125405319594512404" }), | ||
browsingTimestamp = Math.floor(Date.now() / 1000); | ||
|
||
const enum Assets { | ||
Logo = "https://i.imgur.com/7pAQJgm.png", | ||
} | ||
|
||
presence.on("UpdateData", async () => { | ||
const { pathname, hostname, href } = document.location, | ||
pathArr = pathname.split("/"), | ||
{ details, smallImageKey, largeImageKey, state, buttons } = getPageData( | ||
pathArr[1], | ||
pathArr[2], | ||
pathArr[3], | ||
hostname, | ||
href | ||
), | ||
presenceData: PresenceData = { | ||
largeImageKey: largeImageKey || Assets.Logo, | ||
startTimestamp: browsingTimestamp, | ||
details, | ||
}; | ||
if (buttons) presenceData.buttons = buttons; | ||
if (smallImageKey) presenceData.smallImageKey = smallImageKey; | ||
if (state) presenceData.state = state; | ||
|
||
if (!(await presence.getSetting<boolean>("details"))) { | ||
presenceData.details = "Browsing Kick..."; | ||
delete presenceData.state; | ||
presenceData.largeImageKey = Assets.Logo; | ||
delete presenceData.smallImageKey; | ||
delete presenceData.buttons; | ||
} | ||
|
||
if (await presence.getSetting<boolean>("logo")) | ||
presenceData.largeImageKey = Assets.Logo; | ||
|
||
if (details) presence.setActivity(presenceData); | ||
}); | ||
|
||
function getPageData( | ||
page: string, | ||
pageDetail: string, | ||
title: string, | ||
hostname: string, | ||
url: string | ||
): { | ||
details?: string; | ||
smallImageKey?: string; | ||
largeImageKey?: string; | ||
state?: string; | ||
buttons?: [ButtonData, ButtonData?]; | ||
} { | ||
switch (hostname) { | ||
case "kick.com": { | ||
switch (page) { | ||
case "": | ||
return { details: "Viewing home...", smallImageKey: Assets.Search }; | ||
case "categories": { | ||
const activeMainCategory = document.querySelector( | ||
"a.category-tile-active" | ||
)?.textContent; | ||
let state = "", | ||
largeImageKey = ""; | ||
|
||
if (activeMainCategory) { | ||
state = activeMainCategory; | ||
// Replace .gif with .png on main category image | ||
const imageElement = document.querySelector( | ||
'a.category-tile-active [src$=".gif"]' | ||
), | ||
newSrc = imageElement.getAttribute("src").replace(".gif", ".png"); | ||
imageElement.setAttribute("src", newSrc); | ||
largeImageKey = newSrc; | ||
} | ||
// If there is a subcategory | ||
if (pageDetail && title) { | ||
state += ` > ${formatText(pageDetail)} > ${formatText(title)}`; | ||
largeImageKey = | ||
document.querySelector<HTMLImageElement>("div.h-full > img")?.src; | ||
} | ||
return { | ||
details: "Viewing categories...", | ||
state, | ||
largeImageKey, | ||
smallImageKey: Assets.Search, | ||
}; | ||
} | ||
case "following": { | ||
return { | ||
details: "Viewing following...", | ||
state: `${ | ||
document.querySelector(".\\!border-primary\\/100").textContent | ||
} section`, | ||
smallImageKey: Assets.Search, | ||
}; | ||
} | ||
case "dashboard": { | ||
let state = document.querySelector( | ||
".router-link-active .item-title" | ||
).textContent; | ||
const isContentExpanded = document.querySelector( | ||
".content-expanded .item-title" | ||
); | ||
|
||
if (isContentExpanded) { | ||
state = `${isContentExpanded.textContent} > | ||
${ | ||
document.querySelector( | ||
".content-expanded .router-link-active .item-title" | ||
).textContent | ||
}`; | ||
} | ||
return { | ||
details: `Viewing ${formatText(page)}...`, | ||
state, | ||
smallImageKey: Assets.Viewing, | ||
}; | ||
} | ||
case "transactions": { | ||
return { | ||
details: `Viewing ${formatText(page)}...`, | ||
state: formatText(pageDetail), | ||
}; | ||
} | ||
case "community-guidelines": | ||
case "dmca-policy": | ||
case "privacy-policy": | ||
case "terms-of-service": | ||
return { | ||
details: `Reading ${formatText(page)}...`, | ||
smallImageKey: Assets.Reading, | ||
}; | ||
default: | ||
// watching/viewing a stream | ||
if (document.querySelector(".stream-username")) { | ||
let smallImageKey = "", | ||
state = "", | ||
buttons: [ButtonData, ButtonData?]; | ||
const streamer = | ||
document.querySelector(".stream-username").textContent; | ||
if (document.querySelector(".odometer-value")) { | ||
state = `Watching: ${streamer}`; | ||
smallImageKey = Assets.Live; | ||
buttons = [ | ||
{ | ||
label: "Watch Stream", | ||
url, | ||
}, | ||
]; | ||
} else { | ||
state = `Viewing: ${streamer}`; | ||
smallImageKey = Assets.Viewing; | ||
buttons = [ | ||
{ | ||
label: "View Streamer", | ||
url, | ||
}, | ||
]; | ||
} | ||
return { | ||
details: document.querySelector(".stream-title").textContent, | ||
state, | ||
largeImageKey: | ||
document.querySelector<HTMLImageElement>(".owner-avatar img") | ||
?.src, | ||
smallImageKey, | ||
buttons, | ||
}; | ||
} else { | ||
return { | ||
details: "Browsing Kick...", | ||
}; | ||
} | ||
} | ||
} | ||
case "help.kick.com": { | ||
switch (pageDetail) { | ||
case "collections": { | ||
return { | ||
details: document.querySelector("header.text-2xl").textContent, | ||
state: "Searching resource category...", | ||
smallImageKey: Assets.Search, | ||
}; | ||
} | ||
case "articles": { | ||
return { | ||
details: document.querySelector("header.text-2xl").textContent, | ||
state: "Reading article...", | ||
smallImageKey: Assets.Reading, | ||
}; | ||
} | ||
default: { | ||
return { details: "Browsing Kick Help..." }; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
function formatText(text: string) { | ||
return text | ||
.replace(/-/g, " ") | ||
.replace(/\b\w/g, (match: string) => match.toUpperCase()) | ||
.replace(/%C2%A0$/, ""); | ||
} |