Add "MxJ" option to dropdown menu - MAL

Adds "MxJ" option to MAL's dropdown menu. (for mobile and desktop)

  1. // ==UserScript==
  2. // @name Add "MxJ" option to dropdown menu - MAL
  3. // @namespace https://myanimelist.net/profile/kyoyatempest
  4. // @version 1.3
  5. // @description Adds "MxJ" option to MAL's dropdown menu. (for mobile and desktop)
  6. // @author kyoyacchi
  7. // @match https://myanimelist.net/*
  8. // @grant none
  9. // @run-at document-end
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16. const optionLink = document.createElement('a');
  17. optionLink.href = 'https://mxj.myanimelist.net/about-me/';
  18.  
  19.  
  20.  
  21. const optionIcon = document.createElement('i');
  22. optionIcon.classList.add('fas', 'fa-table-list');
  23. optionIcon.setAttribute('aria-hidden', 'true');
  24.  
  25. optionLink.appendChild(optionIcon);
  26. optionLink.innerHTML += ' MxJ Settings';
  27.  
  28. const option = document.createElement('li');
  29. option.appendChild(optionLink);
  30.  
  31. const mdropdown = document.querySelector('.menu-list');
  32. const ddropdown = document.querySelector('.arrow_box.header-profile-dropdown.header-menu-dropdown > ul');
  33.  
  34. if (mdropdown) {
  35. option.classList.add("link");
  36. mdropdown.appendChild(option);
  37. } else if (ddropdown) {
  38. const bookshelf = Array.from(ddropdown.children).find((child) => child.textContent.trim() === 'Bookshelf');
  39.  
  40. if (bookshelf) {
  41. ddropdown.insertBefore(option, bookshelf.nextSibling);
  42. }
  43. }
  44. })();