StumbleUpon Video

Subscribe to StumbleUpon Video 3 posts, 2 voices

 
ICDeadPpl User

I'd like to have a way to get the "Embed" HTML code from Youtube when I'm watching videos on http://video.stumbleupon.com/.
This way I don't have to go to www.youtube.com and get the code from there.

 
1212jtraceur Scriptwright

This should work as a base for those with more skill to build upon:


/*
==UserScript==
@name StumbleVideo HTML Displayer
@include http://video.stumbleupon.com/*
@description Displays the "Embed" HTML code when watching videos on http://video.stumbleupon.com/.
==/UserScript==
*/

(function(){
function $(id){ return document.getElementById(id); }

function getCode()
{
var video = $('mymovie');
if (!video){ return ''; }
var src = video.getAttribute('src');

var html = '<embed>';

return html;
}

var codeHolder = document.createElement('textarea');
codeHolder.style.width = '100%'; // Narrow textareas aren't very useful for this purpose.
codeHolder.setAttribute('rows', '3'); // Make it tall enough to display full codes without having to scroll.

$('brdM').appendChild(codeHolder); // Put the code holder below everything in the video area.

showCode(); // Go ahead and show the code of the currently playing video.

function showCode(){ codeHolder.value = getCode(); }

document.addEventListener(
'click',
function()
{
setTimeout(showCode, 1000); // Give a little time for the video to change. If site takes longer, script doesn't switch code.
},
false
);
})();

It won't work if the site takes longer than 1 second to switch videos. Can be somewhat fixed by increased the timeout length.

 
1212jtraceur Scriptwright

Sorry about that last post's script's incompleteness. I'm new here, and just figured out how to upload a script. Try this one: http://userscripts.org/scripts/show/9635