Improve Emp Mouseovers

Preload images and expand tooltip mouseover area

  1. // ==UserScript==
  2. // @name Improve Emp Mouseovers
  3. // @namespace https://greasyfork.org/users/241444
  4. // @version 1.0.0
  5. // @description Preload images and expand tooltip mouseover area
  6. // @author salad: https://greasyfork.org/en/users/241444-salad
  7. // @include https://www.empornium.me/torrents.php*
  8. // @grant none
  9. // @run-at document-idle
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. const links = document.querySelectorAll('a[onmouseover][onmouseout]');
  14. links.forEach(e => {
  15. // fire mouseovers to trigger loading the thumbnail
  16. e.onmouseover();
  17. // grab the thumbnail sand create an img tag with it
  18. const thumbnail = document.querySelector('#overDiv img');
  19. if(thumbnail && thumbnail.src) {
  20. const imgEl = new Image();
  21. imgEl.src = thumbnail.src
  22. }
  23. e.onmouseout();
  24. // bind mouseover events to the parent row instead of just the link
  25. const parentRow = e.closest('tr.torrent');
  26. parentRow.onmouseover = e.onmouseover;
  27. parentRow.onmouseout = e.onmouseout;
  28. });
  29.  
  30. })();