Erome Like Visible On Albums

Show album like count from any page with albums

  1. // ==UserScript==
  2. // @name Erome Like Visible On Albums
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.3.3
  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: 11 */
  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. // nullish coalescing es11
  30. let countArea = doc.querySelector('#like_count');
  31. let count = 0;
  32. if (countArea == null)
  33. {
  34. countArea = doc.querySelector('.far.fa-heart.fa-lg');
  35. count = countArea.nextElementSibling.firstChild.textContent.trim();
  36. }
  37. else
  38. {
  39. count = countArea.textContent.trim();
  40. }
  41. if (+count < 1)
  42. {
  43. return;
  44. }
  45. if (album.parentElement.querySelector('.album-bottom-right').children.length > 1)
  46. {
  47. const viewSec = album.parentElement.querySelector('.album-bottom-right').lastElementChild.insertAdjacentHTML("afterbegin", `<span style="
  48. position: absolute;
  49. bottom: 26px;
  50. right: -0.1px;
  51. ">${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>`);
  52. }
  53. else
  54. {
  55. const viewSec = album.parentElement.querySelector('.album-bottom-right').lastElementChild.insertAdjacentHTML("afterbegin", `<span style="
  56. position: absolute;
  57. bottom: 26px;
  58. left: 10px;
  59. ">${count}</span><i class="ml-5 mr-5 fas pink fa-heart fa-lg" aria-hidden="true" class="ml-5 mr-5"style="bottom: 30px;position: absolute;left: -15px;"></i>`);
  60. }
  61. });
  62. }
  63.  
  64. window.addEventListener('load', likeShowable);