Auto-Sort RuneLite.net Plugin Hub

Automatically selects "Sort by time added" on RuneLite plugin hub

  1. // ==UserScript==
  2. // @name Auto-Sort RuneLite.net Plugin Hub
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.1
  5. // @description Automatically selects "Sort by time added" on RuneLite plugin hub
  6. // @author Vexy
  7. // @match https://runelite.net/plugin-hub/*
  8. // @grant none
  9. // @license GNU GPLv3
  10. // ==/UserScript==
  11.  
  12. (function () {
  13. 'use strict';
  14.  
  15. // Function to sort by "time added"
  16. function sortByTimeAdded() {
  17. // Make a list of dropdown options
  18. const buttons = document.querySelectorAll('.dropdown-menu .dropdown-item');
  19. for (const button of buttons) {
  20. // If button text is "Sort by time added", click it
  21. if (button.textContent.trim() === 'Sort by time added') {
  22. // Simulate a click on the button
  23. button.click();
  24. console.log('Sorted by time added');
  25. break;
  26. }
  27. }
  28. }
  29.  
  30. // Wait for the dropdown menu to be present
  31. const observer = new MutationObserver(() => {
  32. if (document.querySelector('.dropdown-menu')) {
  33. observer.disconnect(); // Stop observing once found
  34. sortByTimeAdded(); // Trigger the sorting
  35. }
  36. });
  37.  
  38. // Start observing the document for changes
  39. observer.observe(document.body, { childList: true, subtree: true });
  40. })();