MediaWiki:Common.js/Removevandal

/*

MediaWiki:Common.js/Removevandal
*/ /* * Antivandal element remover * JSharp (http://www.wikia.com/wiki/User:JSharp) * */

function notifyOnVandalElementFind{ /*No notification set*/ };

function addMatcherToElement(element){ element.matches = function(condition){ switch(condition){ case 'hasStyle': if(element.style){return true}; break; case 'hasOpacitySet': if(element.style.join('').indexOf('opacity') != -1){return true}; break; }; };  return element; };

function isVandalElement(element){ if (element.matches('hasStyle') && element.matches('hasOpacitySet')){ return true; } else /* Not a Vandal Element */ {  return false; }; };

function removeVandalElement(element){ if(element.parentNode) { /* if the node exists in the DOM tree */ element.parentNode.removeChild(element); /* remove the node from the tree */ }; };

function evaluateContentElementsForVandalism{ var contentContainer = document.getElementById('bodyContent'); var elementsToSearch = contentContainer.getElementsByTagName('a'); for(var i=0;i<elementsToSearch.length;i++){ // search all elements inside anchor tags with class external var element = elementsToSearch[i]; if (element.className == 'external text' && element.hasChildNodes){ for(var j=0; j<element.childNodes.length; j++){ var subElement = element.childNodes[j]; recursiveScanForVandalism(subElement, element); };   };  }; };

function recursiveScanForVandalism(element, root){ try{ if (element.hasAttributes ){ removeVandalElement(root); return; }; if (element.hasChildNodes){ for(var j=0; j<element.childNodes.length; j++){ var subElement = element.childNodes[j]; recursiveScanForVandalism(subElement, root); }; }; } catch (e1) { return; }; };

addOnloadHook(evaluateContentElementsForVandalism);

/* */