DeepWiki

Adds an inline display of actual effects to acquired effects in potion and item descriptions on KoL wiki pages.

  1. // ==UserScript==
  2. // @name DeepWiki
  3. // @namespace psly4mne.kolwiki
  4. // @description Adds an inline display of actual effects to acquired effects in potion and item descriptions on KoL wiki pages.
  5. // @include http://kol.coldfront.net/thekolwiki*
  6. // @grant GM_log
  7. // @grant GM_xmlhttpRequest
  8. // @version 1.0
  9. // ==/UserScript==
  10.  
  11. // Version 1.0
  12. // - forked from http://userscripts.org/scripts/source/54462.user.js
  13. // - fixed regex, as wiki switched to <span> for effects
  14.  
  15. function findEffect(acq) {
  16. var ps = document.evaluate('//td[text()="You '+acq+' an effect: "]',document,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);
  17. for (var i=ps.snapshotLength-1;i>=0;i--) {
  18. var p = ps.snapshotItem(i);
  19. var pps = document.evaluate('b/a[@title]',p,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);
  20. for (var j=pps.snapshotLength-1;j>=0;j--) {
  21. var pp = pps.snapshotItem(j);
  22. var u = 'http://kol.coldfront.net'+pp.getAttribute('href');
  23. GM_log('found effect: '+(pp.innerHTML));
  24. getUrl(u,p.parentNode);
  25. }
  26. }
  27. }
  28.  
  29. function getUrl(u,p) {
  30. GM_xmlhttpRequest({
  31. method: "GET",
  32. url: u,
  33. headers: {
  34. "User-Agent": "Mozilla/5.0",
  35. "Accept": "text/xml"
  36. },
  37. onload: function(response) {
  38. var m = response.responseText.replace(/\n/g,' ').match(/<span[\s]*style=\"[^\"\>]*color:blue;[\s]*font-weight:bold;\"\>.*/);
  39. if (m) {
  40. var eff1 = m[0];
  41. if (eff1) {
  42. //GM_log('Effect1 is '+eff1);
  43. var eff2 = eff1.match(/<\/span>.*/)[0];
  44. if (eff2) {
  45. eff1 = eff1.substr(0,eff1.length-eff2.length);
  46. eff1 = eff1.match(/>.*/)[0].substr(1);
  47. //GM_log("Effect is "+eff1);
  48.  
  49. var f = document.createElement('font');
  50. f.setAttribute('size','1');
  51. f.innerHTML='<p style="text-align:center;color:blue;font-weight:bold;line-height:12px;">'+eff1+'</p>';
  52. //GM_log('creating font with innerHTML: '+f.innerHTML);
  53. var tr = document.createElement('tr');
  54. //var tr = tb.insertRow(-1);
  55. var td = tr.insertCell(-1);
  56. td.setAttribute('colspan','2');
  57. td.appendChild(f);
  58. if (p.nextSibling)
  59. p.parentNode.insertBefore(tr,p.nextSibling);
  60. else
  61. p.parentNode.appendChild(tr);
  62. return eff1;
  63. }
  64. }
  65. }
  66. }
  67. });
  68. }
  69.  
  70. findEffect('acquire');
  71. findEffect('lose');