Skip to content

Instantly share code, notes, and snippets.

@reppyricky
Forked from yukiarimo/webnovel-downloader.js
Last active December 6, 2025 14:37
Show Gist options
  • Select an option

  • Save reppyricky/6822dff4dcc8554f2b6ecd6c6ff68302 to your computer and use it in GitHub Desktop.

Select an option

Save reppyricky/6822dff4dcc8554f2b6ecd6c6ff68302 to your computer and use it in GitHub Desktop.
Web novel Downloader
function extractAndDownloadAllChapters() {
// Find all chapter sections that contain both title and content
const chapters = document.querySelectorAll('.chapter_content');
let allChaptersText = [];
chapters.forEach(chapter => {
// Get the header text
const headerElement = chapter.querySelector('.cha-tit.skiptranslate');
const headerText = headerElement ? headerElement.textContent.trim() : 'Untitled Chapter';
// Get the content paragraphs
const contentElement = chapter.querySelector('.cha-words');
let chapterText = '';
if (contentElement) {
const paragraphs = contentElement.querySelectorAll('p');
chapterText = Array.from(paragraphs)
.map(p => p.textContent.trim())
.join('\n');
}
// Combine header + body
const fullChapter = `${headerText}\n\n${chapterText}`;
allChaptersText.push(fullChapter);
});
// Join all chapters with clear separators
const allText = allChaptersText.join('\n\n-----------------------------------\n\n');
// Create a downloadable text file
const blob = new Blob([allText], { type: 'text/plain' });
const anchor = document.createElement('a');
anchor.href = URL.createObjectURL(blob);
anchor.download = 'allChaptersWithHeaders.txt';
document.body.appendChild(anchor);
anchor.click();
document.body.removeChild(anchor);
}
extractAndDownloadAllChapters();
@reppyricky
Copy link
Author

This will help you with getting the headers too

anchor.download = 'allChaptersWithHeaders.txt'; the name can be swapped as needed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment