Last active
August 7, 2020 08:13
-
-
Save piousdeer/383788a9075fa1ef3524705201d76f6c to your computer and use it in GitHub Desktop.
A script/bookmarklet to show a little "maxres" link next to every thumbnail on YouTube (obsolete)
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
document.querySelectorAll('#thumbnail').forEach(tn => { | |
if (tn.querySelector('.max-res-link')) { | |
return | |
} | |
const link = document.createElement('a') | |
try { | |
const maxResURL = tn.querySelector('img').src.replace(/\/[a-z]*default.jpg.*/, '/maxresdefault.jpg') | |
link.href = maxResURL | |
} catch (err) { | |
console.error('max-res-thumbnails error:', err) | |
} | |
link.classList.add('max-res-link') | |
link.innerText = 'maxres' | |
link.style.textDecoration = 'none' | |
link.style.color = '#fff' | |
const container = document.createElement('ytd-thumbnail-overlay-time-status-renderer') | |
container.style.left = '0' | |
container.style.right = 'auto' | |
container.style.zIndex = '1' | |
container.append(link) | |
tn.append(container) | |
}) |
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
document.querySelectorAll("#thumbnail").forEach(e=>{if(e.querySelector(".max-res-link"))return;const t=document.createElement("a");try{const r=e.querySelector("img").src.replace(/\/[a-z]*default.jpg.*/,"/maxresdefault.jpg");t.href=r}catch(e){console.error("max-res-thumbnails error:",e)}t.classList.add("max-res-link"),t.innerText="maxres",t.style.textDecoration="none",t.style.color="#fff";const r=document.createElement("ytd-thumbnail-overlay-time-status-renderer");r.style.left="0",r.style.right="auto",r.style.zIndex="1",r.append(t),e.append(r)}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment