Gendou.com - Sub-Forums Menu

Add new menu for easy navigating between sub-forums

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name           Gendou.com - Sub-Forums Menu
// @namespace      http://loucypher.wordpress.com/
// @include        http://gendou.com/*
// @include        http://animesheep.com/*
// @description    Add new menu for easy navigating between sub-forums
// @version 0.0.1.20140630034959
// ==/UserScript==

(function() { 
  var ID = [8, 1, 11, 4, 10, 5, 7, 12, 15, 13, 2, 3, 14, 6];
  var topics = ["Help", "Anime", "Game", "Music", "Report Problems",
    "\u65e5\u672c\u8a9e", "Japan", "Introduce Yourself", "Philosophy",
    "Gendou City", "Physics", "Programming", "Waste of Time", "Other"]

  var XPath = "//div[@id='navPanel']/ul[@class='navHorizontal']" + 
              "/li/a[contains(@href, '/forum/search.php')]/parent::li";
  var forumMenu = document.evaluate(XPath, document, null, 9, null)
                          .singleNodeValue;
  if (!forumMenu) return;

  var forumLink = addLink("http://gendou.com/forum/", "Sub-Forums");
  var newMenu = insertMenu(forumMenu.nextSibling, forumLink);
  var newSubMenu = addSubMenu(newMenu);

  var link, menu;
  for (var i in ID) {
    link = addLink("http://gendou.com/forum/topic.php?top=" + ID[i], topics[i]);
    link.style.display = "block";
    if (location == link.href) {
      link.style.fontWeight = "bold";
      link.style.color = "white";
      link.title = "You are here!";
    }
    menu = addMenu(newSubMenu, link);
  }

  function insertMenu(aNode, aChild) {
    var mi = aNode.parentNode.insertBefore(document.createElement("li"),
                                           aNode);
    mi.appendChild(aChild);
    return mi;
  }

  function addSubMenu(aNode) {
    var mp = aNode.appendChild(document.createElement("ul"));
    mp.className = "navVertical";
    return mp;
  }

  function addMenu(aNode, aChild) {
    var mi = aNode.appendChild(document.createElement("li"));
    mi.appendChild(aChild);
    return mi;
  }

  function addLink(aURL, aText) {
    var lnk = document.createElement("a");
    lnk.href = aURL;
    lnk.textContent = aText;
    return lnk;
  }
})();