User Blocker - MAL

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

You will need to install an extension such as Tampermonkey to install this script.

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name         User Blocker - MAL
// @namespace    Blocker
// @version      3
// @description  Block any user on any forum topic with a single click!
// @author       hacker09
// @match        https://myanimelist.net/forum/?topicid=*
// @icon         https://t3.gstatic.com/faviconV2?client=SOCIAL&type=FAVICON&fallback_opts=TYPE,SIZE,URL&url=http://myanimelist.net&size=64
// @run-at       document-end
// @grant        none
// ==/UserScript==

(async function() {
  'use strict';
  document.querySelectorAll(".mal-post-toolbar > div").forEach(function(el, i) { //ForEach topic
    if (document.querySelectorAll(".username")[i].innerText !== document.querySelector("a.header-profile-link").innerText) { //If it is not the script user topic
      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

      el.querySelector(`button`).onclick = async function(e) //When the block btn is clicked
      { //Starts the function
        fetch("https://myanimelist.net/forum/settings/ignored_users", { //Fetch
          "headers": {
            "content-type": "application/x-www-form-urlencoded; charset=UTF-8"
          },
          "body": `name=${document.querySelectorAll(".username")[i].innerText}&csrf_token=${document.head.querySelector("[name='csrf_token']").content}`,
          "method": "POST"
        });
        location.reload(); //Reloads the page
      }; //Finishes the function
    } //Finishes the if condition
  }); //Finishes the forEach loop
})();