YouTube Long URL's

By JoeSimmons Last update Mar 7, 2011 — Installed 626 times.

There are 5 previous versions of this script.

// ==UserScript==
// @name           YouTube Long URL's
// @namespace      http://userscripts.org/users/23652
// @description    Makes links show the full name of the video in the text
// @include        http://*.youtube.com/*
// @include        http://youtube.com/*
// @copyright      JoeSimmons
// @version        1.0.31
// @license        Creative Commons Attribution-Noncommercial 3.0 United States License
// ==/UserScript==

// Define GM_addStyle if it's not Firefox
if(typeof GM_addStyle==='undefined') 
    GM_addStyle = function(css) {
        var head = document.getElementsByTagName('head')[0], style = document.createElement('style');
        if (!head) {return}
        style.type = 'text/css';
        try {style.innerHTML = css} catch(x) {style.innerText = css}
        head.appendChild(style);
    }

var array = document.evaluate("//a[contains(@href, 'watch?')]//span[@class='title'] | //div[@class='vtitle']",document,null,6,null);
for(var i=0,item; (item=array.snapshotItem(i)); i++) {
	if(item.title.length>0 && item.title.indexOf(item.textContent.trim().substring(0,(item.textContent.length/2)))!=-1 && item.textContent!=item.title) item.textContent = item.title;
	if(item.tagName.toLowerCase()=="div") {
		item.parentNode.style.display = "block";
		item.parentNode.parentNode.parentNode.style.paddingTop = "4px";
		item.style.height = "auto";
	}
}

GM_addStyle(<><![CDATA[
	.video-short-title {
		display: none !important;
	}

	.video-long-title {
		display: inline !important;
		font-size: .9em !important;
	}
]]></>.toString());