Last active
August 29, 2015 14:10
-
-
Save IrealiTY/61bdcfc0fc2006352a1f to your computer and use it in GitHub Desktop.
URL converter
This file contains hidden or 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
javascript:(function(){var videoEmbed = {invoke: function(){$('body').html(function(i, html) {return videoEmbed.convertMedia(html);});},convertMedia: function(html){var pattern1 = /(?:http?s?:\/\/)?(?:www\.)?(?:vimeo\.com)\/?(.+)/g;var pattern2 = /(?:http?s?:\/\/)?(?:www\.)?(?:youtube\.com|youtu\.be)\/(?:watch\?v=)?(.+)/g;var pattern3 = /([-a-zA-Z0-9@:%_\+.~#?&//=]{2,256}\.[a-z]{2,4}\b(\/[-a-zA-Z0-9@:%_\+.~#?&//=]*)?(?:jpg|jpeg|gif|png))/gi;if(pattern1.test(html)){ var replacement = '<iframe width="420" height="345" src="//player.vimeo.com/video/$1" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>'; var html = html.replace(pattern1, replacement);if(pattern2.test(html)){var replacement = '<iframe width="420" height="345" src="http://www.youtube.com/embed/$1" frameborder="0" allowfullscreen></iframe>';var html = html.replace(pattern2, replacement);}if(pattern3.test(html)){var replacement = '<a href="$1" target="_blank"><img class="sml" src="$1" /></a><br />';var html = html.replace(pattern3, replacement);}return html; }}})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment