maloomf9 / Picarto Link De-Nanny (You are leaving Picarto Warning Remover)

// ==UserScript==
// @name        Picarto Link De-Nanny (You are leaving Picarto Warning Remover)
// @namespace   http://www.furaffinity.net/user/Maloo
// @description You know what's annoying? Getting warned that, when I click a link, I'm no longer on picarto! Buzz off. <3
// @license MIT
// @include     https://picarto.tv/*
// @version     3.2
// @grant       none
// @run-at		document-end
// ==/UserScript==


var NannytarEl = document;



var nannynator = function(mutations){
var y;
for (y = 0; y < mutations.length; y++)
{
//var links = document.querySelector('.frame').getElementsByTagName('a');
var links;
if (mutations[y].type == "attributes") {
    if (mutations[y].target.hasAttribute("href")) {
        links = mutations[y].target;
        deNanny(links);
    }
}
else {
    links = mutations[y].target.getElementsByTagName('a');
    if (links.length != 0) deNanny(links);
}

    //console.log("Nannypage TERMINATED");




}
    
    /*mutObserver.disconnect();
    setTimeout(function() {console.log("Nannynator is back online"); mutObserver.observe(NannytarEl, {attributes: true, subtree: true});}, 1000);*/
};

function deNanny(links) {
    var x;
    var count = 0;
    for (x = 0; x < links.length; x++)
{
    var hdata;
    hdata = links[x].getAttribute("href");
    if (hdata === null) continue;
	//else console.log(hdata);
	if (hdata.search("/site/referrer") != -1) // /site/referrer?go=http%3A%2F%2Fwww.furaffinity.net%2Fuser%2Fslowfag&ref=https://picarto.tv/Seff
	{

		//hdata = hdata.substr(14); //Trim off /site/referrer
		hdata = hdata.substr(hdata.search("go=") + 3); //Trim off everything before link.

		if (hdata.search("&") != -1) //If the go parameter isn't last,
			hdata = hdata.substr(0, hdata.search("&")); //Remove everything after it.
		//hdata = hdata.substr(18, hdata.search("&ref=https://picarto.tv") - 18); //17 until "&ref=https://picarto.tv"
        //console.log(unescape(hdata));
		links[x].setAttribute("href", unescape(hdata));
		links[x].removeAttribute("onclick");
        count++;
	}
    }
    //console.log("Terminated " + count + " links.");
    //console.log(links);
}

var mutObserver1 = new MutationObserver(nannynator);
var mutObserver2 = new MutationObserver(nannynator);

//console.log("I lived! Links Found: " + links.length);
//console.log(typeof hdata);
var waitForStrip = setInterval(function() {
   if (document.querySelector('.social-container'))
     {

         deNanny(document.querySelector('.frame').getElementsByTagName('a'));
         //setInterval(nannynator(), 60000);
         NannytarEl = document.querySelector('.social-container');

         mutObserver1.observe(NannytarEl, {attributes: true, childList: true, subtree: true});
         NannytarEl = document.querySelector('.scrollwrapperchat');

         mutObserver1.observe(NannytarEl, {childList: true, subtree: true});
         clearInterval(waitForStrip);

     }
},3000);


//console.log("I lived!");