Saturday, January 22, 2011

Removed most of the fluff from the new youtube homepage


// ==UserScript==
// @name           YouTube
// @namespace      http://youtube.com
// @include        http://www.youtube.com/
// ==/UserScript==


// Add jQuery & thickbox to the header
var GM_JQ = document.createElement('script');
GM_JQ.src = 'https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js';
GM_JQ.type = 'text/javascript';
 
document.getElementsByTagName('head')[0].appendChild(GM_JQ);
 
// Check if jQuery's loaded
function GM_wait()
{
 if(typeof unsafeWindow.jQuery == 'undefined') { window.setTimeout(GM_wait,100); }
 else
 {
  $ = unsafeWindow.jQuery;
  letsJQuery();
 }
}
 
GM_wait();
 

// All your GM code must be inside this function
function letsJQuery()
{
 // new eliminateParent function

 // example: $(div#id0).eliminateParent('class') will hide the div#id0's 1st parent that has the class that was passed in.

 (function ($) {
  $.fn.eliminateParent = function (objclass) {
   return this.each(function () {
    var $this = $(this);
    //$this.parents(objclass).css('border', 'solid 1px lime');
    $this.parents(objclass).hide().addClass("eliminated-by-electric-sheep");
   });
  };

 })(unsafeWindow.jQuery);


 $('a[href*="/trends"]').eliminateParent('.homepage-side-block');
 $(':contains("Featured Videos")').eliminateParent('.homepage-side-block');
 $(':contains("Recommended Videos")').eliminateParent('.feedmodule-data');
 $('#personalized_sub_recs').eliminateParent('.yt-rounded');
 $(':contains("What\'s New")').eliminateParent('.homepage-side-block');

 // add show link
 $('div:contains("Welcome to the new YouTube homepage.")').eq(0).append("<div class='show-electric-sheep'><a href='#'>[+] show hidden content</a></div>");
 $('div.show-electric-sheep').click(function () {
  $('div.eliminated-by-electric-sheep').show();
  $(this).hide();
 });

}

0 comments:

Post a Comment