// ==UserScript==
// @name         link-tweaks
// @version      1.0
// @description  Open External Links in New Tab, add rel=noreferrer, remove a.ping
// @namespace    http://kafene.org
// @include      *
// @require      https://code.jquery.com/jquery-2.1.1.min.js
// @require      https://cdn.rawgit.com/brandonaaron/livequery/master/jquery.livequery.min.js
// @run-at       document-start
// @grant        unsafeWindow
// @copyright    Copyright (c) 2014 kafene software <http://kafene.org/>
// @license      MIT <https://raw.githubusercontent.com/kafene/userscripts/mater/LICENSE>
// @downloadURL  https://raw.githubusercontent.com/kafene/userscripts/master/link-tweaks.user.js
// @updateURL    https://raw.githubusercontent.com/kafene/userscripts/master/link-tweaks.user.js
// ==/UserScript==

$(function () {
    $(document).livequery('a[href]', function (a) {
        if (a.ping) {
            a.ping = '';
            a.removeAttribute('ping');
        }

        if (!a.href || 0 !== a.href.indexOf('http') || a.host === window.location.host) {
            return;
        }

        var href = a.href,
            u = encodeURIComponent(a.href),
            rel = a.rel || '';

        a.rel = rel.trim().split(/\s+/).concat('noreferrer').join(' ');
        a.target = '_blank';
    });
});

@@ -202,163 +202,8 @@
   *%0A
-// @require      https://code.jquery.com/jquery-2.1.1.min.js%0A// @require      https://cdn.rawgit.com/brandonaaron/livequery/master/jquery.livequery.min.js%0A
 // @
@@ -251,20 +251,12 @@
     
-unsafeWindow
+none
 %0A// 
@@ -633,60 +633,127 @@
 ==%0A%0A
-$(function () %7B%0A    $(document).livequery('a%5Bhref%5D',
+ document.addEventListener('DOMContentLoaded', function () %7B%0A    var host = window.location.host;%0A%0A    var handleLink =
  fun
@@ -881,100 +881,185 @@
 !a.h
-ref
+ost
  %7C%7C 
-0 !=
+a.host !== host) %7B%0A            var rels 
 = a.
-h
 re
-f.indexOf('http') %7C%7C a.host === window.location.host) %7B%0A            return
+l ? a.rel.trim().split(/%5Cs+/) : %5B%5D;%0A            a.rel = rels.concat('noreferrer').join(' ');%0A            a.target = '_blank'
 ;%0A  
@@ -1070,21 +1070,24 @@
   %7D%0A
-%0A
     
+%7D;%0A%0A
     var 
 href
@@ -1086,107 +1086,342 @@
 var 
-href = a.href,%0A            u = encodeURIComponent(a.href),%0A            rel = a.rel %7C%7C ''
+observer = new MutationObserver(function (mutations, observer) %7B%0A        mutations.forEach(function (mutation) %7B%0A            if (mutation.addedNodes) %7B%0A                %5B%5D.forEach.call(mutation.addedNodes, function (node) %7B%0A                    if (node instanceof HTMLAnchorElement) %7B%0A                        handleLink(node)
 ;%0A
-%0A
         
 a.re
@@ -1420,109 +1420,430 @@
     
-a.rel = rel.trim().split(/%5Cs+/).concat('noreferrer').join(' ');%0A        a.target = '_blank';%0A    %7D
+            %7D else if (node.querySelectorAll) %7B%0A                        %5B%5D.forEach.call(node.querySelectorAll('a'), handleLink);%0A                    %7D%0A                %7D);%0A            %7D%0A        %7D);%0A    %7D);%0A%0A    observer.observe(document, %7B%0A        childList: true,%0A        subtree: true,%0A        attributes: false,%0A        characterData: false%0A    %7D);%0A%0A    %5B%5D.forEach.call(document.getElementsByTagName('a'), handleLink
 );%0A%7D);%0A
+%0A

fix stuff