|
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.
|