Created
July 14, 2022 05:33
-
-
Save LenAnderson/247d034272e730dded345103d10ce749 to your computer and use it in GitHub Desktop.
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
// ==UserScript== | |
// @name YouTube - Download Your Thumbnails | |
// @namespace https://github.com/LenAnderson/ | |
// @version 1.0 | |
// @author LenAnderson | |
// @match https://studio.youtube.com/channel/*/videos/upload?* | |
// @icon https://www.google.com/s2/favicons?sz=64&domain=youtube.com | |
// @grant GM_download | |
// @connect img.youtube.com | |
// @run-at context-menu | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
const $ = (root,query)=>(query?root:document).querySelector(query?query:root); | |
const $$ = (root,query)=>Array.from((query?root:document).querySelectorAll(query?query:root)); | |
const download = async(details)=>{ | |
details.name = details.name.replace(/\?.*$/, ''); | |
return new Promise((resolve,reject)=>{ | |
details.onload = resolve; | |
details.onerror = reject; | |
GM_download(details); | |
}); | |
}; | |
const run = async()=>{ | |
await Promise.all($$('ytcp-video-section-content ytcp-video-row a#video-title').map(it=>{ | |
const id = it.href.replace(/^.+\/video\/([^\/]+)\/edit.*$/, '$1'); | |
const title = it.textContent.trim().replace(/[^a-z0-9 \-\(\)]+/ig, '_'); | |
return download({ | |
url:`https://img.youtube.com/vi/${id}/maxresdefault.jpg`, | |
name:`YouTube Thumbnails/${title} [${id}].jpg` | |
}); | |
})); | |
alert('all thumbnails downloaded'); | |
}; | |
run(); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment