Skip to content

Instantly share code, notes, and snippets.

@edo9k
Created February 17, 2017 18:10
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 edo9k/24b593ccf326ececfbecef9785ad33f2 to your computer and use it in GitHub Desktop.
Save edo9k/24b593ccf326ececfbecef9785ad33f2 to your computer and use it in GitHub Desktop.
Javascript (Bookmarklet) to add a play button to each of the pronunciation files in Omniglots "Useful Phrases" pages. (test it there: http://www.omniglot.com/language/phrases/index.htm)
links = document.getElementsByTagName('a');
for (var i=0; i<links.length; i++){
if (links[i].href.endsWith('.mp3')){
console.log(links[i].href);
var sound = document.createElement('audio');
sound.controls = 'controls';
sound.src = links[i].href;
sound.type = 'audio/mpeg';
sound.style.width = '70px';
sound.style.margin = '50px';
links[i].parentNode.appendChild(sound);
}
}
//compressed&encoded
javascript:(function(){links%3Ddocument.getElementsByTagName%28"a"%29%3Bfor%28var i%3D0%3Bi<links.length%3Bi++%29if%28links%5Bi%5D.href.endsWith%28".mp3"%29%29%7Bconsole.log%28links%5Bi%5D.href%29%3Bvar sound%3Ddocument.createElement%28"audio"%29%3Bsound.controls%3D"controls"%3Bsound.src%3Dlinks%5Bi%5D.href%3Bsound.type%3D"audio/mpeg"%3Bsound.style.width%3D"70px"%3Bsound.style.margin%3D"10px"%3Blinks%5Bi%5D.parentNode.appendChild%28sound%29%7D%3B}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment