Created
November 17, 2022 14:42
-
-
Save victor141516/fc7091b3850fa0f4336182fc3621c58f to your computer and use it in GitHub Desktop.
Copy text from Google Play Books
This file contains 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
// Select the proper frame in devtools and run this script | |
const nextPageButton = Array.from(document.querySelectorAll('mat-icon')).find((e) => e.innerHTML === 'chevron_right'); | |
const getCurrentPageText = () => Array.from(document.querySelectorAll('reader-page')) | |
.filter(e => e.checkVisibility()) | |
.map((e) => e.textContent) | |
.join(''); | |
const isLastPage = () => nextPageButton.classList.contains('mat-button-disabled'); | |
const sleep = async () => new Promise(res => setTimeout(res, 5)); | |
let allText = ''; | |
;(async () => { | |
while (!isLastPage()) { | |
const currentPageText = getCurrentPageText() | |
allText += currentPageText | |
console.log(allText) | |
nextPageButton.click() | |
while (currentPageText !== '' && currentPageText === getCurrentPageText()) { | |
await sleep() | |
} | |
} | |
})() | |
console.log(allText) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment