curseforge show all file versions

show all the versions listed for a file, rather than hiding them behind a +2 thing you need to hover over

当前为 2022-08-10 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name curseforge show all file versions
  3. // @namespace https://github.com/adrianmgg
  4. // @version 1.0.0
  5. // @description show all the versions listed for a file, rather than hiding them behind a +2 thing you need to hover over
  6. // @author amgg
  7. // @match https://www.curseforge.com/minecraft/mc-mods/*/files
  8. // @match https://www.curseforge.com/minecraft/mc-mods/*/files/*
  9. // @icon https://www.google.com/s2/favicons?sz=64&domain=curseforge.com
  10. // @grant unsafeWindow
  11. // @run-at document-start
  12. // @license MIT
  13. // @compatible chrome
  14. // @compatible firefox
  15. // ==/UserScript==
  16.  
  17.  
  18. // the list of other versions is present in the initial html (in the title of an
  19. // element), but they remove that after they set up the +2 hover thing, so if we
  20. // want to get that info we need to get to those elements right away before they
  21. // have a chance to modify it.
  22.  
  23.  
  24. // replaces the .extra-versions placeholder with a list versions, changes styles
  25. // to make it display nicely
  26. function modifyExtraVersionsElem(elem) {
  27. // in case we happen to get the same one multiple times
  28. if(elem.parentElement === null) return;
  29. for(const version of elem.title.split('<br />')) {
  30. const div = document.createElement('div');
  31. div.classList.add('mr-2');
  32. div.textContent = version;
  33. elem.parentElement.appendChild(div);
  34. }
  35. elem.parentElement.classList.add('flex-col');
  36. elem.parentElement.parentElement.style.paddingTop = '2.5px';
  37. elem.parentElement.parentElement.style.paddingBottom = '2.5px';
  38. elem.parentElement.parentElement.style.verticalAlign = 'bottom';
  39. elem.parentElement.removeChild(elem);
  40. }
  41.  
  42. const observer = new MutationObserver((mutations, observer) => {
  43. for(const mutation of mutations) {
  44. if(mutation.type === 'childList') {
  45. for(const node of mutation.addedNodes) {
  46. if(node.nodeType === Node.ELEMENT_NODE) {
  47. if(node.classList.contains('extra-versions')) {
  48. modifyExtraVersionsElem(node);
  49. }
  50. node.querySelectorAll('.extra-versions').forEach(modifyExtraVersionsElem);
  51. }
  52. }
  53. }
  54. }
  55. });
  56.  
  57. observer.observe(document, { childList: true, subtree: true });
  58.  
  59. // once the page is finished loading we don't need to be watching for new nodes,
  60. // so we disconnect the observer
  61. window.addEventListener('DOMContentLoaded', (e) => {
  62. observer.disconnect();
  63. });

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址