User Blocker - MAL

Block any user on any forum topic with a single click!

目前为 2024-08-13 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name User Blocker - MAL
  3. // @namespace Blocker
  4. // @version 3
  5. // @description Block any user on any forum topic with a single click!
  6. // @author hacker09
  7. // @match https://myanimelist.net/forum/?topicid=*
  8. // @icon https://t3.gstatic.com/faviconV2?client=SOCIAL&type=FAVICON&fallback_opts=TYPE,SIZE,URL&url=http://myanimelist.net&size=64
  9. // @run-at document-end
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. (async function() {
  14. 'use strict';
  15. document.querySelectorAll(".mal-post-toolbar > div").forEach(function(el, i) { //ForEach topic
  16. if (document.querySelectorAll(".username")[i].innerText !== document.querySelector("a.header-profile-link").innerText) { //If it is not the script user topic
  17. el.insertAdjacentHTML('afterbegin', `<button title="Block ${document.querySelectorAll(".username")[i].innerText}" class="mal-btn secondary small outline noborder js-topic-message-report"><i class="fa-solid fa-circle-exclamation fa-fw mr4"></i>Block</button>`); //Add the block button on the page
  18.  
  19. el.querySelector(`button`).onclick = async function(e) //When the block btn is clicked
  20. { //Starts the function
  21. fetch("https://myanimelist.net/forum/settings/ignored_users", { //Fetch
  22. "headers": {
  23. "content-type": "application/x-www-form-urlencoded; charset=UTF-8"
  24. },
  25. "body": `name=${document.querySelectorAll(".username")[i].innerText}&csrf_token=${document.head.querySelector("[name='csrf_token']").content}`,
  26. "method": "POST"
  27. });
  28. location.reload(); //Reloads the page
  29. }; //Finishes the function
  30. } //Finishes the if condition
  31. }); //Finishes the forEach loop
  32. })();