Skip to content
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
25 changes: 25 additions & 0 deletions websites/K/Kakuyomu/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"$schema": "https://schemas.premid.app/metadata/1.17",
"apiVersion": 1,
"author": {
"id": "644840234671931392",
"name": "Phumipat-2005"
},
"service": "Kakuyomu",
"description": {
"en": "Rich Presence for Kakuyomu web novel reader."

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use official description from the service

},
"url": "kakuyomu.jp",
"regExp": "^https?[:][/][/]([a-z0-9-]+[.])?kakuyomu[.]jp[/]",
"version": "1.0.0",
"logo": "https://i.postimg.cc/HnHybSWR/kakuyomu.png",
"thumbnail": "https://i.postimg.cc/HnHybSWR/kakuyomu.png",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thumbnail should be a landscape promotional image or screenshot—not the logo

"color": "#1782c5",
"category": "other",
"tags": [
"novel",
"webnovel",
"reading",
"japanese"
]
}
56 changes: 56 additions & 0 deletions websites/K/Kakuyomu/presence.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { ActivityType, Assets } from 'premid'

const presence = new Presence({
clientId: '1539531465811828777',
})

const browsingTimestamp = Math.floor(Date.now() / 1000)

enum ActivityAssets {
Logo = 'https://i.postimg.cc/HnHybSWR/kakuyomu.png',
}

presence.on('UpdateData', async () => {
const { pathname } = document.location

const presenceData: PresenceData = {
type: ActivityType.Watching,
largeImageKey: ActivityAssets.Logo,
largeImageText: 'Kakuyomu (カクヨム)',
startTimestamp: browsingTimestamp,
}

if (pathname.includes('/episodes/')) {
const workTitle
= document.querySelector('#contentMain header h1 a, #workTitle a, .widget-toc-work-title a')?.textContent?.trim()
|| document.title.split(' - ')[1]
|| 'Web Novel'

const episodeTitle
= document.querySelector('.widget-episode-title, h1.widget-episodeTitle')?.textContent?.trim()
|| document.title.split(' - ')[0]
|| 'Reading Episode'

presenceData.details = `Reading: ${workTitle}`
presenceData.state = episodeTitle
presenceData.smallImageKey = Assets.Reading
presenceData.smallImageText = 'Reading'
}
else if (pathname.includes('/works/')) {
const workTitle
= document.querySelector('#workTitle, h1#work-title')?.textContent?.trim()
|| document.title.split(' - ')[0]
|| 'Novel Overview'

presenceData.details = 'Browsing Novel'
presenceData.state = workTitle
presenceData.smallImageKey = Assets.Reading
presenceData.smallImageText = 'Viewing'
}
else {
presenceData.details = 'Browsing Kakuyomu'
presenceData.state = 'Finding stories...'
}

presence.setActivity(presenceData)
})
Loading