User:Saintrain/J/deSpamWiki.js

Today, User:Saintrain/J/deSpamWiki.js is a topic that has captured the attention of people of all ages and from different parts of the world. The importance of User:Saintrain/J/deSpamWiki.js in today's society has generated extensive debate and led to increased interest in understanding its implications in our daily lives. From its origins to its impact on the present, User:Saintrain/J/deSpamWiki.js has been the subject of numerous investigations, discussions and analyzes that seek to shed light on its multiple dimensions. In this article, we will explore in depth the different aspects of User:Saintrain/J/deSpamWiki.js and its influence on our environment, with the aim of providing a comprehensive and updated vision of this very relevant topic.
//<pre>
//================  deSpamWiki  ============================================================
function deSpamWiki()
{
var GBUG = false;
var  BUG = GBUG;

var SpamObj = { id:"", class:"", clsNdx:0,   act:"" };

var spamList = new Array();

var sndx  = 0;
///-m- spamList = SpamObj = { id : "newarticletext",         act : "delete node" };  sndx++;
///-m- spamList = SpamObj = { id : "userinvalidcssjstitle",  act : "delete node" };  sndx++;
///-m- spamList = SpamObj = { id : "editpage-copywarn",      act : "delete node" };  sndx++;
///-m- spamList = SpamObj = { id : "editpage-copywarn2",     act : "delete node" };  sndx++;
///-m- spamList = SpamObj = { id : "editpage-copywarn3",     act : "delete node" };  sndx++;
spamList = SpamObj = { id : "editpage-specialchars",  act : "hide node" };    sndx++;
///-m- spamList = SpamObj = { id : "talkpagetext",           act : "delete node" };  sndx++;

for(var s=0; s<spamList.length; s++) {
  if(BUG)console.log('dSW: spamList.id={',spamList.id,'}  .class={',spamList.class,'}  .act={',spamList.act,'} ');
  var spamStr;
  with( spamList ) {
    if( "" != id ) {
      spamStr = id;
      var spam = document.getElementById( id );
      }
     else if( "" != class ) {
      spamStr = class;
      var hits = document.getElementsByClass( class, null, null );
      if( hits )
        var spam = hits;  // this is silly!  just use 1st.
      }
     else { if(BUG)console.log('dSW: spamList.id == .class == "" '); continue; }

    if ( !spam ) { if(BUG)console.log('dSW: NO FIND spam={',spamStr,'}' ); continue; }

    switch( act ) {
      case "delete node":  //==========  "delete node"  =======================================
        if( !GBUG ) BUG = false;
        var spamMom = spam.parentNode;
        if ( !spamMom ) { if(BUG)console.log('dSW: NO FIND spam={',spamStr,'}.parentNode' ); continue; }
        spamMom.removeChild( spam );
        spam = null;
        break;

      case "hide node":  //==========  "hide node"  =======================================
        if( !GBUG ) BUG = false;
        var spamMom = spam.parentNode;
        if ( !spamMom ) { if(BUG)console.log('dSW: NO FIND spam={',spamStr,'}.parentNode' ); continue; }
  
        var hndx = 666 + s;  // bump index so as not to interfere with "legit" navframe stuff
  
        var NavFrame = document.createElement("div");
        NavFrame.setAttribute('id', 'NavFrame' + hndx );
        NavFrame.className = 'NavFrame';
        spamMom.insertBefore( NavFrame, spam );
  
        var NavHead = document.createElement( "div" );
        NavHead.textContent = spamStr;
        NavHead.className = 'NavHead';
        NavFrame.appendChild( NavHead );
  
        var NavToggle = document.createElement("a");
        NavHead.appendChild( NavToggle );
        NavToggle.className = 'NavToggle';
        NavToggle.setAttribute('id', 'NavToggle' + hndx );
        NavToggle.setAttribute('href', 'javascript:toggleNavigationBar(' + hndx + ');');
        NavToggle.textContent = "";
  
        spam.id = "NavFrame" + hndx;
        spam.className += " NavContent";
        NavFrame.appendChild( spam );  // re-parents "spam"
  
        toggleNavigationBar( hndx );
        break;
  

      case "delete last kids":  //==========  "delete last kids"  =======================================
        if( !GBUG ) BUG = false;
        if( ! spam.hasChildNodes()) { if(BUG)console.log('dSW: NO FIND spam={',spamStr,'}.hasChildNodes()' ); continue; }
        var c0 = spam.firstChild;
          if(BUG)console.log('dSW: LEAVING: tagName={',c0.tagName,'}, name={',c0.name,'}, kid=',c0 );
          if(BUG)console.log('  innerHTML={',c0.innerHTML,'}' );
        while( 1 < spam.childNodes.length ) {
        var lc = spam.lastChild;
          if(BUG)console.log('dSW: removing: tagName={',lc.tagName,'}, name={',lc.name,'}, kid=',lc );
          if(BUG)console.log('  innerHTML={',lc.innerHTML,'}' );
          spam.removeChild( spam.lastChild ); 
          if(BUG)console.log(' ');
          }
        break;
  
      case "delete last tags":  //==========  "delete last tags"  =======================================
        if( !GBUG ) BUG = false;      
        if( ! spam.hasChildNodes()) { if(BUG)console.log('dSW: NO FIND spam={',spamStr,'}.hasChildNodes()' ); continue; }
        var it0 = -1;
        for(k=0; k<spam.childNodes.length; k++) {
          if( spam.childNodes.tagName ) {  // 1st tag
            it0 = k + 1; 
            break;
            }
          }
        if( it0 < 0 )  // no tags
          break;
        var tag0 = spam.childNodes;
          if(BUG)console.log('dSW: LEAVING: tagName={',tag0.tagName,'}, name={',tag0.name,'}, kid=',tag0 );
          if(BUG)console.log('  innerHTML={',tag0.innerHTML,'}' );
        while( it0 < spam.childNodes.length ) {
          var lc = spam.lastChild;
            if(BUG)console.log('dSW: removing: tagName={',lc.tagName,'}, name={',lc.name,'}, kid=',lc );
            if(BUG)console.log('  innerHTML={',lc.innerHTML,'}' );
          spam.removeChild( spam.lastChild ); 
            if(BUG)console.log(' ');
          }
        break;
  
      default:
        if(BUG)console.log('dSW: UNKNOWN act = {',act,'}.' ); 
        continue; 
      }  // switch
    }  // with( spam )
  BUG = GBUG;
  }  // for(s)
}
//============================================================================
addOnloadHook( deSpamWiki);



//</pre>