biggest-apples

displays a window with links to most thanked items

  1. // ==UserScript==
  2. // @name biggest-apples
  3. // @namespace http://modsgarden.cc/
  4. // @version 0.1.0
  5. // @description displays a window with links to most thanked items
  6. // @author me
  7. // @match http://modsgarden.cc/*
  8. // @grant none
  9. // ==/UserScript==
  10. /* jshint esversion: 6 */
  11. (function() {
  12. 'use strict';
  13. const best = Array.from(
  14. document.querySelectorAll('#thank_you_list_link a'),
  15. el => ({
  16. link: document.location.origin + document.location.pathname + '#msg' + el.getAttribute('href').split('msg=')[1],
  17. count: parseInt(el.querySelector('strong').innerText, 10)
  18. })
  19. )
  20. .sort((a, b) => b.count - a.count);
  21.  
  22. if (best.length) {
  23. const box = document.createElement('div');
  24. box.setAttribute('style', 'position: fixed; top: 10px; right: 10px; width: 100px; height: 300px; background: white; opacity: 0.7; border: 1px solid #ccc; box-shadow: 3px 3px 25px 0px rgba(135,135,135,1); overflow: auto; padding: 5px;');
  25.  
  26. best.forEach((el, idx) => {
  27. const link = document.createElement('a');
  28. link.setAttribute('href', el.link);
  29. link.setAttribute('style', 'display: block; margin-bottom: 5px');
  30. link.innerHTML = `<b>${idx + 1}.</b> ${el.count}`;
  31. box.appendChild(link);
  32. });
  33. document.body.appendChild(box);
  34. }
  35. })();