Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name YT Embed
- // @version 0.21
- // @description Automatic Youtube video embedding for the blockland forums.
- // @include http://forum.blockland.us/index.php?topic=*
- // @copyright 2012+, Kingdaro
- // ==/UserScript==
- var links = document.getElementsByTagName('a');
- var i;
- for (i in links){
- var link = links[i];
- var code = '';
- if (link.href.search('youtube.com')>-1){
- var from = link.href.search('v=')+2;
- var to = from+11;
- code = link.href.substring(from,to);
- }else if (link.href.search('youtu.be')>-1){
- var from = link.href.lastIndexOf('/')+1;
- var to = from+11; //no need for anything too complicated for youtu.be links.
- code = link.href.substring(from,to);
- }
- if (code!=''){
- link.href = null
- link.innerHTML = '<iframe src="http://www.youtube.com/embed/'+code+'" width="640" height="390" allowfullscreen></iframe>'
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement