By Xtina
Has 11 other scripts.
// ==UserScript==
// @name LJ YouTube Linker
// @namespace http://twilite.org/~xtina/scripts/
// @description Replaces YouTube embedded videos from LJ when placeholders have been enabled.
// @include http://*.livejournal.com/friends/*
// ==/UserScript==
var allTubes = document.evaluate(
"//div[@class='LJ_Placeholder_Container']",
document,
null,
XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
null);
for (var i = 0; i < allTubes.snapshotLength; i++) {
var thisTube = allTubes.snapshotItem(i);
// Remove the styles and images.
thisTube.removeAttribute("style");
thisTube.removeChild(thisTube.getElementsByTagName('a')[0]);
// Get the hex stuff and pluck out the href part.
var hexText = thisTube.getElementsByTagName('div')[0].firstChild.nodeValue;
var afts = new RegExp("^%3C%69%66%72%61%6D%65%20%73%72%63%3D%22(.*)%22%20%77.*%3E$", "gi");
var news = hexText.replace(afts, "$1");
news = unescape(hexText.replace(afts, "$1"));
// Create the new link.
var newTube = document.createElement('a');
newTube.setAttribute('href', news);
newTube.setAttribute('target', '_blank');
newTube.appendChild(document.createTextNode('[YouTube Link]'));
thisTube.parentNode.insertBefore(newTube, thisTube.nextSibling);
thisTube.parentNode.removeChild(thisTube);
}