added rpc

This commit is contained in:
2025-12-04 03:13:13 +01:00
parent 6973f1485d
commit d0cc461c1c
16 changed files with 268 additions and 8 deletions

View File

@@ -10,8 +10,6 @@ const nextBtn = document.getElementById('next-chapter');
const lnSettings = document.getElementById('ln-settings');
const mangaSettings = document.getElementById('manga-settings');
const hasQuery = window.location.search.length > 0;
const config = {
ln: {
fontSize: 18,
@@ -145,6 +143,18 @@ async function loadChapter() {
document.title = `Chapter ${chapter}`;
}
const res2 = await fetch(`/api/book/${bookId}?source=${source}`);
const data2 = await res2.json();
fetch("/api/rpc", {
method: "POST",
headers: {"Content-Type": "application/json"},
body: JSON.stringify({
details: data2.title.romaji ?? data2.title,
state: `Chapter ${data.title}`,
mode: "reading"
})
});
if (data.error) {
reader.innerHTML = `
<div class="loading-container">
@@ -476,7 +486,16 @@ nextBtn.addEventListener('click', () => {
function updateURL(newChapter) {
chapter = newChapter;
const newUrl = `/read/${provider}/${chapter}/${bookId}`;
const urlParams = new URLSearchParams(window.location.search);
let source = urlParams.get('source');
let src;
if (source === 'anilist') {
src= "?source=anilist"
} else {
src= `?source=${source}`
}
const newUrl = `/read/${provider}/${chapter}/${bookId}${src}`;
window.history.pushState({}, '', newUrl);
}