YouTube Direct Links

By JoeSimmons Last update Oct 25, 2009 — Installed 1,897 times. Daily Installs: 82, 73, 13, 8, 11, 12, 7, 10, 7, 11, 3, 6, 8, 4, 6, 5, 8, 7, 5, 3, 4, 9, 6, 1, 9, 1, 3, 6, 4, 4, 4, 5

There are 5 previous versions of this script.

// ==UserScript==
// @name           YouTube Direct Links
// @namespace      http://userscripts.org/users/23652
// @description    Changes javascript links into direct links
// @include        http://*.youtube.com/*
// @include        http://youtube.com/*
// @copyright      JoeSimmons
// @version        1.0.3
// @license        Creative Commons Attribution-Noncommercial 3.0 United States License
// ==/UserScript==

// Change video links
var v_links = document.evaluate("//a[contains(@onClick, 'onPlayVideos')]",document,null,6,null), video=/onPlayVideos\(['"]([^'"]+)['"]\)/;
for(var i=0,l; (l=v_links.snapshotItem(i)); i++) {
if(l.href.indexOf("/watch?v=")==-1) l.href=l.getAttribute("onClick").match(video)[1];
l.removeAttribute('onClick');
}

// Change page links
var p_links=document.evaluate("//a[contains(@onClick, 'applyPage(')]",document,null,6,null);
for(var i=0,p; (p=p_links.snapshotItem(i)); i++) {
p.href = 'http://'+document.domain+'/my_videos?pi='+((p.getAttribute("onClick").match(/\d+(?=\)\;)/)||'0')[0])+'&ps=20&sf=added&sa=0&sq=&dm=1';
p.removeAttribute("onClick");
}