Echo Bazaar - Display Storylet Prerequisites

For Fallen London (previously Echo Bazaar) - Displays storylet prerequisites in plain text so that you can see the information at a glance without having to mouse over multiple icons to uncover it bit by bit.

当前为 2016-12-01 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Echo Bazaar - Display Storylet Prerequisites
  3. // @namespace http://arundor/echo.bazaar.disply.storylet.prerequisites
  4. // @description For Fallen London (previously Echo Bazaar) - Displays storylet prerequisites in plain text so that you can see the information at a glance without having to mouse over multiple icons to uncover it bit by bit.
  5. // @version 1.8
  6. // @include http://echobazaar.failbettergames.com/Gap/Load*
  7. // @include http://*fallenlondon.com/Gap/Load*
  8. // @include http://*fallenlondon.storynexus.com/Gap/Load*
  9. // ==/UserScript==
  10.  
  11. /*
  12. I am an amateur script writer. What you see here is not necessarily the best way to achieve what has been done.
  13.  
  14. Changelog:
  15.  
  16. v1.8
  17. December 1, 2016
  18. - updated to work without www subdomain.
  19.  
  20. v.1.7
  21. July 29, 2015
  22. - updated to work after layout changes in the game
  23.  
  24. v1.6
  25. January 6, 2014
  26. - updated to work after layout changes in the game
  27.  
  28. v1.5
  29. August 24, 2012
  30. - updated for the new fallenlondon.storynexus.com domain.
  31.  
  32. v1.4:
  33. May 27, 2012
  34. - requirements you have not met are now displayed in grey
  35. - updated script @description to reflect the game's new name (@name cannot be updated in the same way, as doing so would break the update process for users of the old version)
  36. - the @version meta data tag is now used
  37.  
  38. v1.3:
  39. March 26, 2012
  40. - now works on the new fallenlondon.com domain
  41.  
  42. v1.2:
  43. Jan 26, 2012
  44. - support for Google Chrome
  45. - removes item acquisition tips from the list of prerequisites
  46. - better method of preventing the script from running before Ajax has fully loaded the main content
  47. - better method of constructing the the new div that holds the plain text prereqs, this method prevents unnecessary nested divs.
  48. - prereq text now prints inside the storylet_rhs block to prevent clipping issues with the prereq icons
  49.  
  50. v1.1:
  51. Jan 24, 2012
  52. -initial release
  53. */
  54.  
  55.  
  56. //The main content of the page is loaded by Ajax so an action listener is used to detect it when it is inserted.
  57. document.addEventListener('DOMNodeInserted', showPrereqs, false);
  58.  
  59. //Due to the way the action listener is set up, this function may fire multiple times per storylet.
  60. //I know of no better way to handle this, but since it fires multiple times each iteration will need to check if a previous iteration has already done of the work of adding the plain text requirements list.
  61. function showPrereqs() {
  62. var qreqs = document.getElementsByClassName('qreqs');
  63. if (qreqs) {
  64. for (var a=0; a<qreqs.length; a++) {
  65. var parent = qreqs[a].parentNode.parentNode.getElementsByClassName('storylet_rhs')[0];
  66. if (parent) {
  67. //Each iteration of the script checks for the 'plain_text_reqs' class to determine if a previous iteration of the function has already done the work.
  68. if (parent.getElementsByClassName('plain_text_reqs').length == 0) {
  69. var tooltips = qreqs[a].getElementsByTagName('a');
  70.  
  71. //Constructing a new div element to hold the list of plain text requirements.
  72. //The class is set to 'plain_text_reqs' as a marker that future iterations of the function can look for to determine if the work is already done.
  73. var div = document.createElement('div');
  74. div.setAttribute('class', 'plain_text_reqs');
  75. div.style.fontSize = '65%';
  76. div.style.width = '100%';
  77. div.style.clear = 'both';
  78. div.style.paddingBottom = '10px';
  79. if (tooltips) {
  80. for (var b=0; b<tooltips.length; b++) {
  81. var text;
  82. if (tooltips[b].getElementsByClassName('tt')[0].getElementsByTagName('p')[0]) {
  83. text = tooltips[b].getElementsByClassName('tt')[0].getElementsByTagName('p')[0].innerHTML;
  84. }
  85. var wordy_list;
  86. var addon_text = '';
  87. if (tooltips[b].getElementsByClassName('wordy-list')[0]) {
  88. wordy_list = tooltips[b].getElementsByClassName('wordy-list')[0].getElementsByTagName('li');
  89. for (var c=0; c<wordy_list.length; c++) {
  90. if (wordy_list[c].innerHTML.substring(0,2) == '- ') {
  91. addon_text += '<br> &nbsp; &nbsp; &nbsp; &nbsp; -' + wordy_list[c].innerHTML.substring(2, wordy_list[c].innerHTML.length);
  92. }
  93. else {
  94. addon_text += '<br> &nbsp; &nbsp; &nbsp; &nbsp; -' + wordy_list[c].innerHTML;
  95. }
  96. if (wordy_list[c].getAttribute('class') != 'current') {
  97. addon_text = '<span style="color: grey">' + addon_text + '</span>';
  98. }
  99. }
  100. }
  101. if (addon_text.length > 0) {
  102. text += addon_text;
  103. }
  104. //If the requirement has not yet been met, display the text in grey.
  105. if (tooltips[b].getAttribute('class') == 'tooltip qreq unlock') {
  106. text = '<span style="color: grey">' + text + '</span>';
  107. }
  108. div.innerHTML += '<br>- ' + text;
  109. }
  110. }
  111. //Even if the new div is empty it is added to the page anyway.
  112. //This is done so that future iterations of the function can find it and know that the work is already done.
  113. parent.appendChild(div);
  114. }
  115. }
  116. }
  117. }
  118. }