Skip to content

Instantly share code, notes, and snippets.

@marcusmoore
Created December 1, 2015 19:16
Show Gist options
  • Select an option

  • Save marcusmoore/b1376c25644b18869001 to your computer and use it in GitHub Desktop.

Select an option

Save marcusmoore/b1376c25644b18869001 to your computer and use it in GitHub Desktop.
Bookmarklet: Grab mp4 from a webpage
/* Very specific to my use case */
/* ORIGINAL CODE */
// Regex pattern
var re = /src="(.*?)"\s{1,}type="video\/mp4"/;
// Scan DOM for a match
var array = re.exec(document.body.innerHTML);
// Redirect to the video
window.location = array[1].replace(/amp;/g, '');
/* CONVERTED CODE
Converted using:
http://mrcoles.com/bookmarklet
Create bookmark and paste this into the URL field.
*/
javascript:(function()%7Bvar%20re%20%3D%20%2Fsrc%3D%22(.*%3F)%22%5Cs%7B1%2C%7Dtype%3D%22video%5C%2Fmp4%22%2F%3Bvar%20array%20%3D%20re.exec(document.body.innerHTML)%3B%20window.location%20%3D%20array%5B1%5D.replace(%2Famp%3B%2Fg%2C%20'')%7D)()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment