// ==UserScript==
// @name          MyHeise
// @namespace     http://tomhost.de/
// @description   script to remove ads from heise.de, feel free to customize
// @include       http://www.heise.de/
// @include       http://heise.de/
// @include       http://www.heise.de/newsticker/*
// @include       http://heise.de/newsticker/*
// ==/UserScript==

// Some const locations
var container = "/html/body/div[@id='container']";
var sidebar = container + "/div[@id='container_content']/div[@id='mitte']/div[@id='mitte_rechts']";
var content = container + "/div[@id='container_content']/div[@id='mitte']/div[@id='mitte_links']";

// FUNCTION: Remove element (XPath)
function removeByXPath(query) 
{
    var snapshots = document.evaluate(query, document, null,
        XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
    for (var i = 0; i!=snapshots.snapshotLength; ++i) 
    {
        var thisElmt = snapshots.snapshotItem(i);
        thisElmt.parentNode.removeChild(thisElmt);
    }
}

// now top ad and sitemap
removeByXPath(container + "/div[@id='bannerzone']")
removeByXPath(container + "/div[@id='sitemap']")
removeByXPath("/html/body/ul[@id='navi_bottom']")

// now remove ads from main-content
removeByXPath(content + "//div[contains(@class,'bcadv')]");
removeByXPath(content + "//div[contains(@class,'dms_ad')]");
removeByXPath(content + "//div[contains(@class,'adbottom')]");

// now remove ads from sidebar
removeByXPath(sidebar + "//div[contains(@class,'bcadv')]");
removeByXPath(sidebar + "//div[contains(@class,'online-markt')]");
removeByXPath(sidebar + "//div[contains(@class,'preisvergleich')]");
removeByXPath(sidebar + "//div[contains(@class,'ebook')]");
removeByXPath(sidebar + "//div[contains(@class,'contentbanner')]");
removeByXPath(sidebar + "//div[contains(@class,'teaser_adlist')]");
removeByXPath(sidebar + "//div[contains(@class,'naviad')]");

// change design
var content_container = document.evaluate(container + "/div[@id='container_content']", document, null,
        XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);;
content_container.snapshotItem(0).style.top = '0px';
