Archive for the ‘JavaScript’ Category

JQuery Image Zoom Plugin

Sunday, March 7th, 2010

I recently posted the code for my jquery image zoom plugin here.

YouTube & Twitter – Grease Monkey Script

Tuesday, April 7th, 2009

Greasemonkey is a popular Firefox Add-on that allows you to modify any web page after it has been loaded. This script is a mash up of YouTube and Twitter. Browse any page on youtube.com and Twitter results for that video are displayed.

 
// ==UserScript==
// @name           VideoTweet
// @namespace      com.spooner.videoTweet
// @description    Twitter Video Comments
// @include        http://youtube.com/watch?*
// ==/UserScript==
(function()
{      
	function create(htmlStr) {
	    var frag = document.createDocumentFragment();
	    var temp = document.createElement('div');
	    temp.innerHTML = htmlStr;
	    while (temp.firstChild) {
	        frag.appendChild(temp.firstChild);
	    }
	    return frag;
	}
 
    var primaryCollection;
	try {
		  	primaryCollection = document.getElementById("watch-vid-title").childNodes[3].innerHTML;
	} catch(e) {}
 
	if(primaryCollection)
	{
	    var fragment = create('<div id="videoTweet"><iframe src="http://search.twitter.com/search?q=' + escape(primaryCollection) + '" width="100%" height="200" ></iframe></div>')
		document.body.insertBefore(fragment, document.body.childNodes[0]);   		
	}
 
})();