locked
Kill CSS Popups! RRS feed

  • General discussion

  • Ever since MS released a popup blocker for IE, webmasters have been switching to css popups and modal popups. You can't surf the net for a minute without bumping into one. Enough is enough! It's not just ads, it's also those weird css menues you see everywhere. If you scroll down the page, they follow you! I am getting paranoid here!

    I've written an jscript that will move the css popups out of the way or make them invisible. I inject it into pages using a web filtering proxy called Proxomitron. The script goes like this:

    -----------
    oDIV=document.getElementsByTagName('DIV')

    if (document.compatMode != "BackCompat")
    IHateDocType = document.documentElement
    else if (document.body)
    IHateDocType = document.body

    for (var oDIVCount = 0; oDIVCount < oDIV.length; oDIVCount++)
    {
    if ( (oDIV[oDIVCount].parentElement.tagName=="BODY" || oDIV[oDIVCount].parentElement.tagName=="DIV") && ( (oDIV[oDIVCount].currentStyle.position =="absolute" && oDIV[oDIVCount].currentStyle.top=="auto") || oDIV[oDIVCount].currentStyle.position =="fixed") )
    {
    //alert("compat mode: " + document.compatMode + " id: " + oDIV[oDIVCount].id + " top: " + oDIV[oDIVCount].currentStyle.top + " position: " + oDIV[oDIVCount].currentStyle.position  + " parentElement: " + oDIV[oDIVCount].parentElement.tagName + " offsetTop:" + oDIV[oDIVCount].offsetTop + " offsetLeft: " +  oDIV[oDIVCount].offsetLeft + " Z-Index: " + oDIV[oDIVCount].style.zIndex)

    oDIV[oDIVCount].style.setAttribute("top",oDIV[oDIVCount].offsetTop)
    oDIV[oDIVCount].style.setAttribute("position","absolute")
    oDIV[oDIVCount].style.setAttribute("left",IHateDocType.clientLeft-oDIV[oDIVCount].clientWidth+5)

    oDIV[oDIVCount].onmouseover=new Function ("this.style.setAttribute('left',this.offsetLeft-5+this.clientWidth);document.recalc()")
    oDIV[oDIVCount].onmouseout=new Function ("this.style.setAttribute('left',IHateDocType.clientLeft-this.clientWidth+5);document.recalc()")
    //oDIV[oDIVCount].style.setAttribute("display","none")
    //oDIV[oDIVCount].style.setAttribute("visibility","hidden")
    //oDIV[oDIVCount].removeNode(true)

    document.recalc()
    }
    }
    ---------------

    Needs some further testing, but seems to be working so far. Begone, popups!

    Saturday, January 16, 2010 6:08 PM