-
-
Save reppyricky/6822dff4dcc8554f2b6ecd6c6ff68302 to your computer and use it in GitHub Desktop.
Web novel Downloader
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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(); |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This will help you with getting the headers too
anchor.download = 'allChaptersWithHeaders.txt'; the name can be swapped as needed