Last active
November 8, 2021 09:22
-
-
Save beetcb/75b511714cec347b9362639e6ff3f923 to your computer and use it in GitHub Desktop.
Thumbnail download script for a certain platform
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
/** | |
* 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