Erome Like Visible On Albums

Show album like count from any page with albums

As of 2022-11-23. See the latest version.

  1. // ==UserScript==
  2. // @name Erome Like Visible On Albums
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.2.9
  5. // @description Show album like count from any page with albums
  6. // @author throwinglove23
  7. // @license MIT
  8. // @match https://www.erome.com/*
  9. // @match http://www.erome.com/*
  10. // @exclude http://www.erome.com/a/*/
  11. // @exclude https://www.erome.com/a/*/
  12. // @exclude https://www.erome.com/a/*/edit
  13. // @exclude http://www.erome.com/a/*/edit
  14. // @icon https://www.erome.com/favicon-32x32.png
  15. // @grant none
  16. // ==/UserScript==
  17. /* jshint esversion: 8 */
  18.  
  19. function likeShowable()
  20. {
  21. const albums = Array.from(document.getElementsByClassName('album-link'));
  22. albums.forEach(async function(album)
  23. {
  24. const hr = album.href;
  25. const hdr = await fetch(hr);
  26. const data = await hdr.text();
  27. var parser = new DOMParser();
  28. var doc = parser.parseFromString(data, 'text/html');
  29. let count = doc.querySelector('#like_count').textContent;
  30. if (+count < 1)
  31. {
  32. return;
  33. }
  34. if (album.parentElement.querySelector('.album-bottom-right').children.length > 1)
  35. {
  36. const viewSec = album.parentElement.querySelector('.album-bottom-right').lastElementChild.insertAdjacentHTML("afterbegin", `<span style="
  37. position: absolute;
  38. bottom: 26px;
  39. right: -0.1px;
  40. ">${count}</span><i class="ml-5 mr-5 fas pink fa-heart fa-lg" aria-hidden="true" style="bottom: 30px;position: absolute;left: 10px;"></i>`);
  41. }
  42. else
  43. {
  44. const viewSec = album.parentElement.querySelector('.album-bottom-right').lastElementChild.insertAdjacentHTML("afterbegin", `<span style="
  45. position: absolute;
  46. bottom: 26px;
  47. left: 10px;
  48. ">${count}</span><i class="ml-5 mr-5 fas pink fa-heart fa-lg" aria-hidden="true" style="bottom: 30px;position: absolute;left: -12px;"></i>`);
  49. }
  50. });
  51. }
  52.  
  53. window.addEventListener('load', likeShowable);