Skip to content

Instantly share code, notes, and snippets.

@CTimmerman
Last active June 8, 2023 21:32
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CTimmerman/cb304d55e436dab093aad882e10d4494 to your computer and use it in GitHub Desktop.
Save CTimmerman/cb304d55e436dab093aad882e10d4494 to your computer and use it in GitHub Desktop.
Bookmarklets / Favelets - Drag to bookmarks bar and rename, then click on page to affect.
// Speed up / slow down HTML5 videos! Just set as URLs of bookmark bar items:
javascript:(function(){v = []; for(x of document.querySelectorAll("audio, video")) v.push(x); try{v.push(window.frames[0].document.querySelector("audio, video"))}catch(ex){}; for(i of v) i.playbackRate += .4}())
javascript:(function(){v = []; for(x of document.querySelectorAll("audio, video")) v.push(x); try{v.push(window.frames[0].document.querySelector("audio, video"))}catch(ex){}; for(i of v) i.playbackRate -= .4}())
// Highlight new Facebook notifications.
javascript:(function(){var s = document.createElement('style'); s.appendChild(document.createTextNode(".jewelItemNew ._33e{background-color:lightgreen!important;}")); document.head.appendChild(s)}())
// Show videos from messy framework HTML, can't show toolbar in popup due to Chrome bug 82522.
javascript:(function(){var w=window.open();var d=w.document;d.title='Videos';d.body.style.backgroundColor='0';for(var v of document.getElementsByTagName('video')){v.style='';v.controls=1;v.loop=1;d.body.innerHTML+='<div>'+v.outerHTML+'</div>'}})()
// List images.
javascript:(function(){for(img of document.getElementsByTagName('img')) console.log(img.width, img.height, img.src)})()
// Talk.
javascript:(function(){s=window.speechSynthesis;u=new SpeechSynthesisUtterance("Hi, I'm free!");u.voice=s.getVoices()[2];u.pitch=1.0;u.rate=1.0;s.speak(u)})()
// Talk foreign without checking each voice, possibly with phrases from Google Translate which i don't think works without internet access.
javascript:(function(){s=window.speechSynthesis;u=new SpeechSynthesisUtterance("Hi, I'm free!");u.lang="en-US";u.pitch=1.0;u.rate=1.0;s.speak(u)})()
// Sort YouTube playlists
javascript:(()=>{let a=document.querySelector('#playlists');[...a.children].sort((a,b)=>a.innerText>b.innerText?1:-1).forEach(node=>a.appendChild(node))})()
// Open open YouTube transcript in a popup window to simply read/search/save it.
javascript:(()=>{var transcript = [...document.querySelectorAll('div.ytd-transcript-segment-renderer')].map(e=>e.innerText).join("\n"); var popup = window.open('', 'yt-transcript', `scrollbars=yes,resizable=yes,status=yes,location=no,toolbar=no,menubar=no,width=0,height=0,left=-1000,top=-1000`); popup.focus(); popup.document.body.style.color='white'; popup.document.body.style.backgroundColor='black'; popup.document.body.innerHTML="<h3><a href='"+document.location+"'>"+document.title+"</a></h3><a download='"+document.title+" transcript.html' onclick='this.href=\"data:text/plain;charset=utf-8,\"+encodeURIComponent(document.documentElement.outerHTML)'>Download transcript</a><br><br>"+transcript.replaceAll(/ u[hm]\b/g, ' ').replaceAll(/\n[ :0-9]+\n/g, '\n').replaceAll(/\n([ :0-9]+)\n/g, '<br>$1 ')})()
// Dark mode
javascript:(()=>{document.body.style.backgroundColor = 'black'; document.body.style.color = 'white'})()
@CTimmerman
Copy link
Author

@CTimmerman
Copy link
Author

Firefox (57.0.2) needed the self-invocation wrappers.

@CTimmerman
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment