Title: [JavaScript] gpu.user.js Author: someone_ Pastebin link: http://pastebin.com/sNQLQBhA First Edit: Monday 3rd of December 2012 04:59:26 PM CDT Last Edit: Monday 3rd of December 2012 04:59:26 PM CDT // ==UserScript== // @name           4chan Linkify // @namespace      csimi // @author         csimi // @description    Linkification of text links. // @homepage       http://userscripts.org/users/156405/scripts // @version        1.4.6 // @updateURL      http://userscripts.org/scripts/source/87750.meta.js // @icon           http://i.imgur.com/JHVzK.png // @include        http://boards.4chan.org/* // @include        https://boards.4chan.org/* // ==/UserScript==   (function () {   ///////////////////////////////////   var config = {         'multiLineLinks': true,         'targetBlank': false }   ///////////////////////////////////   function $ (a, b) { if (a && document.querySelector) return (b || document).querySelector(a); } function $$ (a, b) { if (a && document.querySelectorAll) return (b || document).querySelectorAll(a); } function foreach (a, f) { if (typeof(a) == 'object' && a.length && typeof(f) == 'function') { for (var i = 0; i < a.length; i++) { a[i] = f(a[i], i) || a[i]; } } } function ce (a, b) { if (typeof(a) != 'string') return; var c = document.createElement(a); foreach(b, function (d) { if (d.nodeType == 1) { c.appendChild(d); } else if (typeof(d) == 'object' && !d.length) { for (var k in d) { c.setAttribute(k, d[k]); } } else if (typeof(d) == 'string') { c.appendChild(document.createTextNode(d)); } }); return c; }   function checkLinks (a) {         if (!a) return;         if (a.nodeType == 3) {                 var b = a.nodeValue.match(/[a-zA-Z][a-zA-Z0-9+-.]+:\/\/[^\s]+/);                 if (!b) b = a.nodeValue.match(/mailto:[^\s]+/);                 if (!b) b = a.nodeValue.match(/magnet:[^\s]+/);                 if (!b) b = a.nodeValue.match(/news:[^\s]+/);                 if (b && (a.parentNode.nodeName.toLowerCase() != 'a')) {                         var m = b[0];                         if (a.nodeValue.length == m.length) {                                 var el = ce('a', [                                         {'href': a.nodeValue,                                         'class': 'chanlinkify'},                                         a.nodeValue                                 ]);                                 if (a.nextSibling && (((a.nextSibling.className && a.nextSibling.className === 'spoiler') || a.nextSibling.tagName && (a.nextSibling.tagName.toLowerCase() === "s" || a.nextSibling.tagName.toLowerCase() === "wbr") ) || a.nextSibling.nodeType === 3)) {                                         a.nodeValue = a.nodeValue+((a.nextSibling.nodeType === 3)? a.nextSibling.nodeValue : ((a.nextSibling.childNodes.length)? a.nextSibling.childNodes[0].nodeValue : ''));                                         a.parentNode.removeChild(a.nextSibling);                                         return checkLinks(a);                                 }                                 if (config.targetBlank) el.setAttribute('target', 'blank');                                 a.parentNode.replaceChild(el, a);                         }                         else {                                 var c = a.nodeValue.indexOf(m);                                 if (a.nodeValue.substring(c-1, c) == '(') {                                         if (/(.*)\x29$/.test(m)) {                                                 m = m.match(/(.*)\x29$/)[1];                                                 c = a.nodeValue.indexOf(m);                                         }                                 }                                 if (a.nodeValue.substring(c-2, c) == '("') {                                         if (/(.*)\x22\x29$/.test(m)) {                                                 m = m.match(/(.*)\x22\x29$/)[1];                                                 c = a.nodeValue.indexOf(m);                                         }                                 }                                 if (a.nodeValue.substring(c-2, c) == '(\'') {                                         if (/(.*)\x27\x29$/.test(m)) {                                                 m = m.match(/(.*)\x27\x29$/)[1];                                                 c = a.nodeValue.indexOf(m);                                         }                                 }                                 var d = c+m.length;                                 if (c != 0) a.parentNode.insertBefore(document.createTextNode(a.nodeValue.substring(0, c)), a);                                 var el = ce('a', [                                         {'href': m,                                         'class': 'chanlinkify'},                                         m                                 ]);                                 if (config.targetBlank) el.setAttribute('target', 'blank');                                 a.parentNode.insertBefore(el, a);                                 if (d == a.nodeValue.length) a.parentNode.removeChild(a);                                 else {                                         a.nodeValue = a.nodeValue.substring(d);                                         checkLinks(a);                                 }                         }                 }         }         else if (a.className == 'quote' || 'spoiler') checkLinks(a.childNodes[0]); }   foreach($$('blockquote'), function (a) {         foreach(a.childNodes, function (b) {                 checkLinks(b);         }); });   foreach($$('span.subject'), function (b) {         checkLinks(b.childNodes[0]); });   function handler(e) {         var t = e && e.target || e;         if (t.nodeType === 1 && t.nodeName.toLowerCase() === 'div') {                 if (t.className.split(' ').filter(function (cls) { return cls === 'postContainer'; }).length) {                         foreach($('blockquote', t).childNodes, function (a) {                                 checkLinks(a);                         });                 }         }         if (t.nodeType === 3 && t.parentNode.nodeName.toLowerCase() === 'blockquote') {                 checkLinks(t);         }         if (t.nodeName.toLowerCase() == 'blockquote') {                 foreach(t.childNodes, function (a) {                         checkLinks(a);                 });         } }   if (MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.OMutationObserver) {         observer = new MutationObserver(function(a) {                 for (var i = 0; a[i]; i++) {                         foreach(a[i].addedNodes, handler);                 }         });         observer.observe($('.board'), {                 childList: true,                 subtree: true         }) } else {         document.addEventListener('DOMNodeInserted', handler, false); }   function appendNextTextNode (a, b) {         var r = (a.parentNode.className == 'quote') ? a.parentNode : a;         if (r.nextSibling && (r.nextSibling.nodeName.toLowerCase() == 'br')) {                 if (r.nextSibling.nextSibling && (r.nextSibling.nextSibling.nodeType == 3)) {                         var b = r.nextSibling.nextSibling;                         var c = b.nodeValue.match(/^[^\s]+/);                         if (!c) return;                         a.href += c[0];                         a.childNodes[0].nodeValue += c[0];                         if (b.nodeValue.length == c[0].length) {                                 r.parentNode.removeChild(r.nextSibling);                                 r.parentNode.removeChild(b);                         }                         else {                                 r.parentNode.removeChild(r.nextSibling);                                 b.nodeValue = b.nodeValue.substring(c[0].length);                         }                 }         }         else if (b === true && r.nextSibling && (r.nextSibling.nodeType == 3)) {                 var b = r.nextSibling;                 var c = b.nodeValue.match(/^[^\s]+/);                 if (!c) return;                 a.href += c[0];                 a.childNodes[0].nodeValue += c[0];                 if (b.nodeValue.length == c[0].length) {                         r.parentNode.removeChild(b);                 }                 else {                         b.nodeValue = b.nodeValue.substring(c[0].length);                 }         } }   if (config.multiLineLinks) document.addEventListener('click', function (e) {         var t = e.target;         if ((t.className == 'chanlinkify') && e.shiftKey && e.ctrlKey) {                 e.preventDefault();                 e.stopPropagation();                 appendNextTextNode(t);         } }, false);   })();   // ==UserScript== // @id             GPU embeds // @name           gpu // @version        1.0 // @namespace       // @author         // @description     // @include        http* // @run-at         document-start // ==/UserScript==   var d = document, s = function(a,b,c) { a.setAttribute(b,c); }, rm = function(a){ a.parentNode.removeChild(a); }, event = function(e) {  if (e.animationName == 'nodeInserted') {   if (e.target.tagName.match(/embed|object/i)) {   try {    var a1, a2, a3;    for (var i=0,x=e.target.getElementsByTagName('param');i