Created
February 2, 2023 18:55
-
-
Save iamsilk/be7b0c1116201d7390095f3b0eb5b3b9 to your computer and use it in GitHub Desktop.
For use in Firefox's PDF viewer. Dumps subsection titles and page numbers for a given PDF section. Used simply in the browser console.
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
| chapter = document.getElementById("heretakeme"); // choose element somehow | |
| chapterText = chapter.querySelector('a').innerText; | |
| chapterLink = chapter.querySelector('a').href; | |
| chapterPage = parseInt(decodeURI(chapterLink).split("#[")[1]) + 1; | |
| chapterDump = ""; | |
| chapterDump += "Introduction" + "\t" + chapterPage + "\n"; | |
| sections = chapter.children[2].children; | |
| for (var i = 0; i < sections.length; i++) { | |
| let section = sections[i]; | |
| let sectionText = section.querySelector('a').innerText; | |
| let sectionLink = section.querySelector('a').href; | |
| let sectionPage = parseInt(decodeURI(sectionLink).split("#[")[1]) + 1; | |
| chapterDump += sectionText + "\t" + sectionPage + "\n"; | |
| } | |
| console.log(chapterDump); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment