Melvor Completion Log Helper

The completion logs now show images of undiscovered items/monsters/pets, including those entities that do not count towards completion.

  1. // ==UserScript==
  2. // @name Melvor Completion Log Helper
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.7.1
  5. // @description The completion logs now show images of undiscovered items/monsters/pets, including those entities that do not count towards completion.
  6. // @author GMiclotte
  7. // @include https://melvoridle.com/*
  8. // @include https://*.melvoridle.com/*
  9. // @exclude https://melvoridle.com/index.php
  10. // @exclude https://*.melvoridle.com/index.php
  11. // @exclude https://wiki.melvoridle.com/*
  12. // @exclude https://*.wiki.melvoridle.com/*
  13. // @inject-into page
  14. // @noframes
  15. // @grant none
  16. // ==/UserScript==
  17. /* jshint esversion: 6 */
  18.  
  19. // Thanks to Breindahl#2660 for the original implementation
  20. // Big thanks to Visua#9999 for helping with parts of the code and troubleshooting
  21.  
  22. ((main) => {
  23. const script = document.createElement('script');
  24. script.textContent = `try { (${main})(); } catch (e) { console.log(e); }`;
  25. document.body.appendChild(script).parentNode.removeChild(script);
  26. })(() => {
  27.  
  28. function patchCode(code, additionalPatch) {
  29. code = code.toString();
  30. code = code.replace(/!items\[[a-zA-Z]*\].ignoreCompletion/g, 'true');
  31. code = code.replace(/!MONSTERS\[[a-zA-Z]*\].ignoreCompletion/g, 'true');
  32. code = code.replace(/!PETS\[[a-zA-Z]*\].ignoreCompletion/g, 'true');
  33. if (additionalPatch !== undefined) {
  34. code = additionalPatch(code);
  35. }
  36. return code.replace(/^function (\w+)/, 'window.$1 = function');
  37. }
  38.  
  39. const toPatch = [
  40. filterItemLog,
  41. createItemLogTooltip,
  42. createMonsterLogTooltip,
  43. createPetLogTooltip,
  44. ];
  45.  
  46. function additionalPatchApplyCompletionLogEntryElement(code) {
  47. code = code.split(/Element\(-8,/);
  48. for (let i = 1; i < code.length; i++) {
  49. code[i] = code[i].replace(';', `; const htmlIdx = html.lastIndexOf('<img ') + 5; html = html.substring(0, htmlIdx) + 'style="opacity: 25%"' + html.substring(htmlIdx); `);
  50. }
  51. return code.join('Element(id,');
  52. }
  53.  
  54. function startCompletionLogHelper() {
  55. // patch functions
  56. toPatch.forEach(x => eval(patchCode(x)));
  57. eval(patchCode(applyCompletionLogEntryElement, additionalPatchApplyCompletionLogEntryElement));
  58.  
  59. // reset loaded variables
  60. itemLogLoaded = false;
  61. monsterLogLoaded = false;
  62. petLogLoaded = false;
  63.  
  64. // build Monster and pet logs
  65. buildMonsterLog();
  66. buildPetLog();
  67.  
  68. // logging
  69. console.log('Melvor Completion Log Helper Loaded');
  70. }
  71.  
  72. function loadScript() {
  73. if (typeof confirmedLoaded !== typeof undefined && confirmedLoaded) {
  74. clearInterval(scriptLoader);
  75. startCompletionLogHelper();
  76. }
  77. }
  78.  
  79. const scriptLoader = setInterval(loadScript, 200);
  80. });