WK_of_Angmar

Reddit - WowDB to Wowhead

Sep 8th, 2013
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var paths = document.location.pathname.split("/");
  2.  
  3. var number = parseInt(paths[2]);
  4.  
  5. var directory = paths[1];
  6. var validDirectories = {
  7.     "achievements": "achievement",
  8.     "currencies": "currency",
  9.     "factions": "faction",
  10.     "items": "item",
  11.     "item-sets": "itemset",
  12.     "npcs": "npc",
  13.     "objects": "object",
  14.     "pet-abilities": "petability",
  15.     "quests": "quest",
  16.     "spells": "spell",
  17.     "titles": "title",
  18.     "world-events": "event",
  19.     "zones": "zone"
  20. }
  21. var directoryLookup = validDirectories[directory];
  22.  
  23. if (number && directoryLookup) {
  24.     document.location = "http://www.wowhead.com/" + directoryLookup + "=" + number;
  25. } else {
  26.     window.addEventListener("DOMContentLoaded", function() {
  27.         var wowheadLink = document.querySelector("[data-tracking=wowhead-link]");
  28.         if (wowheadLink) {
  29.             window.location = wowheadLink.getAttribute("href");
  30.         }
  31.     }, false);
  32. }
Add Comment
Please, Sign In to add comment