Skip to content

Instantly share code, notes, and snippets.

@beetcb
Last active November 8, 2021 09:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save beetcb/75b511714cec347b9362639e6ff3f923 to your computer and use it in GitHub Desktop.
Save beetcb/75b511714cec347b9362639e6ff3f923 to your computer and use it in GitHub Desktop.
Thumbnail download script for a certain platform
/**
* Thumbnail download script for a certain platform
* @github https://gist.github.com/beetcb/75b511714cec347b9362639e6ff3f923
*/
;(async () => {
// Prerequisite
const rightToggle = document.querySelector('.right-panel-toggle')
if (rightToggle.classList.contains('active')) {
rightToggle.click()
await new Promise(res=>setTimeout(2000, res))
}
// Pics ready
const thumbnailURL = document
.querySelector('#right-panel>div>div>div')
?.getAttribute('style')
?.match(/url\("(.+)"\)/)?.[1]
if (thumbnailURL) {
const response = await fetch(thumbnailURL)
const blob = await response.blob()
const u = URL.createObjectURL(blob)
const a = document.createElement('a')
a.href = u
a.download = 'banner.png'
document.body.appendChild(a)
a.click()
URL.revokeObjectURL(u)
}
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment