added rpc
This commit is contained in:
@@ -66,6 +66,16 @@ async function loadMetadata() {
|
||||
document.getElementById('anime-title-details2').innerText = title;
|
||||
document.title = `Watching ${title} - Ep ${currentEpisode}`;
|
||||
|
||||
fetch("/api/rpc", {
|
||||
method: "POST",
|
||||
headers: {"Content-Type": "application/json"},
|
||||
body: JSON.stringify({
|
||||
details: title,
|
||||
state: `Episode ${currentEpisode}`,
|
||||
mode: "watching"
|
||||
})
|
||||
});
|
||||
|
||||
const tempDiv = document.createElement('div');
|
||||
tempDiv.innerHTML = description;
|
||||
document.getElementById('detail-description').innerText = tempDiv.textContent || tempDiv.innerText || 'No description available.';
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
9
src/scripts/rpc-inapp.js
Normal file
9
src/scripts/rpc-inapp.js
Normal file
@@ -0,0 +1,9 @@
|
||||
fetch("/api/rpc", {
|
||||
method: "POST",
|
||||
headers: {"Content-Type": "application/json"},
|
||||
body: JSON.stringify({
|
||||
details: "Browsing",
|
||||
state: `In App`,
|
||||
mode: "idle"
|
||||
})
|
||||
});
|
||||
Reference in New Issue
Block a user