/* This is a bookmarklet. Copy it to a bookmark in your web browser and add javascript: in front of it. */ var watch = function () { if (window.watchclicked == undefined) window.watchclicked = 0; if (window.watchlasttime == undefined) window.watchlasttime = 0; var vid = function (href) { return 'watch:' + href.replace(/(https?:\/?\/?www\.youtube\.com\/watch.*)&list=.*$/,'$1'); }; var reset = function () { window.watchclicked = 0; Array.from(document.getElementsByTagName('a')).forEach(function (el) { el.onclick = undefined; el.style.cursor = el.getAttribute('data-watch-cursor-orig'); }); }; var open = function (ev) { reset(); location.href = vid(ev.target.href); ev.preventDefault(); }; var d = new Date(); if (d.getTime() - window.watchlasttime <= 500) { /* double click */ location.href = vid(location.href); window.watchlasttime = d.getTime(); return; } window.watchlasttime = d.getTime(); if (window.watchclicked == 0) { window.watchclicked = 1; Array.from(document.getElementsByTagName('a')).forEach(function (el) { el.onclick = open; el.setAttribute('data-watch-cursor-orig', el.style.cursor); el.style.setProperty('cursor', 'alias', 'important'); }); } else { reset(); } }; watch();