Nexus Clash: Lore Counter

Adds total Lore collected so far to the Lore button in the sidebar when Lore is selected.

当前为 2014-08-13 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Nexus Clash: Lore Counter
  3. // @namespace http://nexusclash.com/wiki/index.php/user:xensyria
  4. // @version 1.1
  5. // @description Adds total Lore collected so far to the Lore button in the sidebar when Lore is selected.
  6. // @match http://nexusclash.com/modules.php?name=Game*
  7. // @match http://www.nexusclash.com/modules.php?name=Game*
  8. // @exclude http://nexusclash.com/modules.php?name=Game&op=disconnect
  9. // @exclude http://www.nexusclash.com/modules.php?name=Game&op=disconnect
  10. // @copyright PD
  11. // ==/UserScript==
  12.  
  13. var sideBars = document.getElementsByName('sidebar'); // Find the sidebar
  14.  
  15. for (var i = 0; i < sideBars.length; i++){ // Cycle through the buttons
  16.  
  17. if (sideBars[i].value == 'Lore'){ // Find the Lore button if it's there
  18.  
  19. var possibleLore = sideBars[i].parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.nextSibling.firstChild.textContent // Select the sidebar pane from the Lore button
  20.  
  21. if (possibleLore.match(/^(\n\s+\d{1,2}\.\s+[a-z ,\?\-:\.\;]+)+\s*$/i)){ // Check if the pane contents match Lore formatting (e.g. 1. blah / 20. blah / etc.)
  22.  
  23. sideBars[i].nextSibling.value = 'Lore (' + possibleLore.match(/\n\s+\d{1,2}\.\s+[a-z ,\?\-:\.\;]+/gi).length + '/50)'; // If so, change Lore button to include Lore count
  24.  
  25. }
  26.  
  27. }
  28.  
  29. }