Jump to content

User:CALR/dpl.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by CALR (talk | contribs) at 04:54, 27 August 2006. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
addOnloadHook(addCountLinks);

function hidePagesOutsideArticleNamespace(){
  var body = document.getElementById('bodyContent');
  if( !body ){ return; }

  var links = body.getElementsByTagName( "li" );

  for( var i in links ){
    var link = links[i];
    var isFirst = true;

    if( link.innerHTML && (
          link.innerHTML.match( '<a href="\/wiki\/Talk:' ) || 
          link.innerHTML.match( '<a href="\/wiki\/Wikipedia:' ) ||
          link.innerHTML.match( '<a href="\/wiki\/Wikipedia_talk:' ) ||
          link.innerHTML.match( '<a href="\/wiki\/User:' ) ||
          link.innerHTML.match( '<a href="\/wiki\/User_talk:' ) ) ){
      link.style.display = 'none';
      if( isFirst ){
         isFirst = false;
         link.parentNode.style.dog = 'cat';
         link.parentNode.style.listStyleType = 'decimal';
      }
    }
  }
}

function addCountLinks(){
  var target = document.getElementById('p-tb').getElementsByTagName( "ul" );
  if( target.length === 0 ){ return; } //no toolbox to hook into
  target = target[0];

  var newTool = document.createElement("li");
  target.appendChild( newTool );
  newTool.innerHTML = '<a href="" onclick="hidePagesOutsideArticleNamespace(); return false;">DPL mode</a>';  
}