// ==UserScript==
// @include www.heise.de/newsticker/
// @name Show Updates
// @author Torsten Keil
// @namespace http://www.torsten-keil.net/ 
// @version 1.0.0
// @description Show Updated Messages in extra div-layer
// ==/UserScript==
document.addEventListener(
    'load',
    function (e) {
// Search all Updated Site-Links
      var elements;
      var newElements = new Array();
      elements = document.getElementsByTagName("a");
      for (i = 0; i < elements.length; i++) {
        element = elements[i];
        if (element.firstChild != null && element.firstChild.nodeValue != null && element.firstChild.nodeValue.indexOf("Update]") != -1) {
          newElements.push(element.cloneNode(true));
        }
      }
      if (newElements.length == 0) {
        return;
      }
// Create DIV for the Link-Box
      bodyElements = document.getElementsByTagName("body");
      bodyElem = bodyElements[0];
      newDiv = document.createElement("div");
      newDiv.style.position = "fixed";
      newDiv.style.zIndex = "999";
      newDiv.style.top = "10px";
      newDiv.style.right = "10px";
      newDiv.style.padding = "3px";
      newDiv.style.border = "1px solid black";
      newDiv.style.background = "#DDDDDD";
      newDiv.style.textAlign = "right";
      newDiv.id = 'Updates';
      newA = document.createElement("a");
      newA.href = "";
      newA.onclick = 'javascript:hideUpdates(this);return false;';
      newA.id = "LinkUpdates";
      var newText = document.createTextNode("[-]");
      newA.appendChild(newText);
      newDiv.appendChild(newA);
      newDiv.appendChild(document.createElement("br"));
      for (n = 0; n < Math.min(4, newElements.length); n++) {
        newElements[n].style.fontSize = "smaller";
        newDiv.appendChild(newElements[n]);
        newDiv.appendChild(document.createElement("br"));
      }
      bodyElem.appendChild(newDiv);
// Create DIV for the maximize-Box
      newDiv2 = document.createElement("div");
      newDiv2.style.position = "fixed";
      newDiv2.style.zIndex = "999";
      newDiv2.style.top = "10px";
      newDiv2.style.right = "10px";
      newDiv2.style.padding = "3px";
      newDiv2.style.border = "1px solid black";
      newDiv2.style.background = "#DDDDDD";
      newDiv2.id = 'Button';
      newDiv2.style.display = "none";
      newA2 = document.createElement("a");
      newA2.href = "";
      newA2.onclick = 'javascript:hideUpdates(this);return false;';
      newA2.id = "LinkButton";
      newA2.style.fontSize = "smaller";
      var newText2 = document.createTextNode("[+]");
      newA2.appendChild(newText2);
      newDiv2.appendChild(newA2);
      newDiv2.appendChild(document.createElement("br"));
      bodyElem.appendChild(newDiv2);
    },
    false
);

// function that hides/shows the Link-Box
function hideUpdates(obj) {
  if (obj.id == "LinkUpdates") {
    document.getElementById("Updates").style.display = "none";
    document.getElementById("Button").style.display = "";
  }
  if (obj.id == "LinkButton") {
    document.getElementById("Updates").style.display = "";
    document.getElementById("Button").style.display = "none";
  }
}

