Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(kisskh): add activity #9183

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions websites/K/kisskh/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"$schema": "https://schemas.premid.app/metadata/1.12",
"apiVersion": 1,
"author": {
"id": "374905512661221377",
"name": "slowlife."
},
"service": "kisskh",
"description": {
"en": "Watch drama online in high quality. Free download high quality drama. Various formats from 240p to 720p HD (or even 1080p). Feel Free To Watch!"
},
"url": "kisskh.co",
"regExp": "kisskh[.][a-z]+",
"version": "1.0.0",
"logo": "https://i.imgur.com/zu43jYo.png",
"thumbnail": "https://i.imgur.com/XqWGCZz.png",
"color": "#f77e0b",
"category": "videos",
"tags": [
"series",
"movies",
"anime"
],
"settings": [
{
"id": "showBrowsing",
"title": "Show Browsing",
"icon": "fad fa-search",
"value": false
},
{
"id": "useActivityName",
"title": "Show Title as Activity",
"icon": "fad fa-user-edit",
"value": true
},
{
"id": "showCover",
"title": "Show Cover",
"icon": "fas fa-images",
"value": true
}
]
}
61 changes: 61 additions & 0 deletions websites/K/kisskh/presence.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
const presence = new Presence({
clientId: "1330091956101189632",
}),
startTimestamp = Math.floor(Date.now() / 1000);

presence.on("UpdateData", async () => {
const presenceData: PresenceData = {
largeImageKey: "https://i.imgur.com/zu43jYo.png",
details: "Browsing",
type: ActivityType.Watching,
startTimestamp,
},
{ pathname } = document.location,
[showBrowsing, useActivityName, showCover] = await Promise.all([
presence.getSetting<boolean>("showBrowsing"),
presence.getSetting<boolean>("useActivityName"),
presence.getSetting<boolean>("showCover"),
]);

switch (pathname.split("/")[1]) {
case "Drama": {
const title = document.querySelector("mat-card-title").textContent,
episodeNumber = document
.querySelector("button.mat-accent span")
?.firstChild.textContent.trim(),
category = document.querySelector(
"mat-card-subtitle mat-list-item:nth-child(5)"
).textContent;

if (episodeNumber) {
const video = document.querySelector("video");

if (showCover) presenceData.largeImageKey = video.poster;
if (useActivityName) {
presenceData.name = title;
presenceData.details =
category !== "Movie" ? `Episode ${episodeNumber}` : category;
presenceData.state = `${document
.querySelector("mat-card-subtitle")
.textContent.split(", ")
.pop()}${category !== "Movie" ? ` • ${category}` : ""}`;
} else {
presenceData.details = title;
presenceData.state =
category !== "Movie" ? `Episode ${episodeNumber}` : category;
}

if (!video.paused) {
[presenceData.startTimestamp, presenceData.endTimestamp] =
presence.getTimestampsfromMedia(video);
} else presenceData.smallImageKey = Assets.Pause;
}
break;
}
}

if (!showBrowsing && presenceData.details === "Browsing")
return presence.clearActivity();

presence.setActivity(presenceData);
});
Loading