Oryx lists expand/collapse buttons

Add collapse/expand buttons to lists of vehicles

  1. // ==UserScript==
  2. // @name Oryx lists expand/collapse buttons
  3. // @namespace https://oryxspioenkop.com/
  4. // @version 0.1
  5. // @description Add collapse/expand buttons to lists of vehicles
  6. // @author lifeAnime / Yhria
  7. // @match https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-equipment.html
  8. // @match https://www.oryxspioenkop.com/2022/02/attack-on-europe-documenting-ukrainian.html
  9. // @icon https://www.google.com/s2/favicons?sz=64&domain=oryxspioenkop.com
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16. var styles =
  17. /* Style the button that is used to open and close the collapsible content */
  18. `
  19. .collapsible {
  20. background-color: #eee;
  21. color: #444;
  22. cursor: pointer;
  23. padding: 18px;
  24. width: 100%;
  25. border: none;
  26. text-align: left;
  27. outline: none;
  28. font-size: 15px;
  29. } `
  30. +
  31. /* Add a background color to the button if it is clicked on (add the .active class with JS), and when you move the mouse over it (hover) */
  32. `
  33. .active, .collapsible:hover {
  34. background-color: #ccc;
  35. } `
  36. +
  37. /* Style the collapsible content. Note: hidden by default */
  38. `
  39. .ccontent {
  40. padding: 0 18px;
  41. display: none;
  42. overflow: hidden;
  43. background-color: #f1f1f1;
  44. }
  45. `
  46. let button = `<button type="button" class="collapsible">Click here to expand list</button>`
  47. let list = document.getElementsByTagName("article")[0].getElementsByTagName("ul")
  48. let coll, i;
  49. var styleSheet = document.createElement("style")
  50.  
  51. styleSheet.innerText = styles
  52. document.head.appendChild(styleSheet)
  53. for (let element in list){
  54. if (Number.isInteger(parseInt(element))){
  55. list[element].className = "ccontent"
  56. list[element].outerHTML = button + list[element].outerHTML
  57. }
  58. }
  59. coll = document.getElementsByClassName("collapsible");
  60. for (i = 0; i < coll.length; i++) {
  61. coll[i].addEventListener("click", function() {
  62. console.log(this)
  63. this.classList.toggle("active");
  64. var content = this.nextElementSibling;
  65. if (content.style.display === "block") {
  66. content.style.display = "none";
  67. } else {
  68. content.style.display = "block";
  69. }
  70. });
  71. }
  72. })();

QingJ © 2025

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