Mentioner - MAL

Adds a button to mention the @user name on all users who have commented on any topics on MAL. The script also adds a search user name box near the box were the reply is written, so that you can search for any user that commented on that topic and click on the @UserName to auto paste it into the reply box.

スクリプトをインストール?
作者が勧める他のスクリプト

Series Highlighter - MALも気に入るかもしれません。

スクリプトをインストール
このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください。
  1. // ==UserScript==
  2. // @name Mentioner - MAL
  3. // @namespace MALMentioner
  4. // @version 17
  5. // @description Adds a button to mention the @user name on all users who have commented on any topics on MAL. The script also adds a search user name box near the box were the reply is written, so that you can search for any user that commented on that topic and click on the @UserName to auto paste it into the reply box.
  6. // @author hacker09
  7. // @match https://myanimelist.net/forum/?topicid=*
  8. // @match https://myanimelist.net/clubs.php?cid=*
  9. // @icon https://t3.gstatic.com/faviconV2?client=SOCIAL&type=FAVICON&fallback_opts=TYPE,SIZE,URL&url=http://myanimelist.net&size=64
  10. // @run-at document-end
  11. // @grant none
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. 'use strict';
  16. var Executed = 0; //Create a new variable with the value 0
  17. const div = document.createElement('div'); //Create a new div element
  18. const textarea = document.createElement('textarea'); //Create a new textarea element
  19. var MALUserParsedList = []; //Creates an array to add all non-dup mal usernames on the page
  20.  
  21. document.querySelectorAll('.username > a, div[style*="margin-bottom: 6px;"] > a, .item.name > a').forEach(function(UserName) { //For each username on the topic/club page
  22. if (!MALUserParsedList.includes(UserName.innerText) && UserName.innerText !== document.querySelector("a.header-profile-link").innerText && UserName.innerText !== 'removed-user') { //If the username isn't already on the array and if isn't the Script Username or a removed-user
  23. MALUserParsedList.push(UserName.innerText); //Add the username to the array
  24.  
  25. window.jQuery('.username > a:contains("' + UserName.innerText + '"), .item.name a:contains("' + UserName.innerText + '")').parent().append(`<a title="Mention @${UserName.innerText}" onclick="document.querySelectorAll('.sourceMode > textarea').forEach(el => el.value += document.querySelector('.sourceMode > textarea').value === '' ? '@${UserName.innerText}\\n\\n' : '@${UserName.innerText}')" style="cursor: pointer; margin-left: 9px; height: 10px; width: 10px; background-size: cover; display: inline-block; transform: scale(1.5); vertical-align: top; margin-top: 2px; background-image: url(${document.querySelector(".dark-mode") !== null ? 'https://i.imgur.com/hIfOM22.png' : 'https://i.imgur.com/vU0m0ye.png'});"></a>`);
  26. window.jQuery('div[style*="margin-bottom: 6px;"] > a:contains("' + UserName.innerText + '")').after(`<a title="Mention @${UserName.innerText}" onclick="document.querySelector('textarea').value += '@${UserName.innerText}'" style="cursor: pointer; margin-left: 9px; height: 10px; width: 10px; background-size: cover; display: inline-block; transform: scale(1.5); vertical-align: top; margin-top: 2px; background-image: url(${document.querySelector(".dark-mode") !== null ? 'https://i.imgur.com/hIfOM22.png' : 'https://i.imgur.com/vU0m0ye.png'});"></a>`); //Add the copy @UserName button to every username that replied on the comments
  27. } //Finishes the if condition
  28. MALUserParsedList = MALUserParsedList.filter(v => v !== document.querySelector("a.header-profile-link").innerText); //Remove the script user username of the array if the script user commented on the topic
  29. MALUserParsedList = MALUserParsedList.filter(v => v !== 'removed-user'); //Remove the 'removed-user' username of the array (if existent on the topic page)
  30. }); //Finishes the forEach loop
  31.  
  32. textarea.setAttribute("id", "autocomplete-input"); //Adds an ID to the button
  33. textarea.setAttribute("placeholder", "Find User"); //Detects a mouse hover on the button and shows an explanation text
  34. textarea.setAttribute("style", "resize: none; margin-left: 360px; margin-bottom: 27px; margin-top: -26px;"); //The CSS for the "button"
  35. textarea.setAttribute("cols", "10"); //Adds a limit of cols to the button
  36. textarea.setAttribute("rows", "1"); //Adds a limit of rows to the button
  37. div.innerHTML = `<div id="autocomplete-list" style="margin-left: 358px; margin-top: -23px; cursor: pointer; width: 140px; height: 130px; overflow-y: scroll; display: none;"></div>`; //Adds the whole content for the div HTML
  38.  
  39. textarea.addEventListener('click', (function() { //When the script text box is clicked
  40. Executed += 1; //Sum the total amount of times that the script text box was clicked
  41. if (Executed === 1) //If it's the first time that the script text box is clicked
  42. { //Starts the if condition
  43. document.querySelector("#autocomplete-list").style.display = ''; //Display the list containing the User Names
  44. MALUserParsedList.forEach(UserName => document.querySelector("#autocomplete-list").innerHTML += `<div title="Mention @${UserName}" onmouseout='this.style.color = ${document.querySelector(".dark-mode") !== null ? "\"white\"" : "\"black\""}' onmouseover='this.style.color = "#6386d5"' onclick='document.querySelectorAll(".sourceMode > textarea").forEach(el => el.value += document.querySelector(".sourceMode > textarea").value === "" ? "@${UserName}\\n\\n" : "@${UserName} ")'>\n@${UserName}</div>
  45. `); //Add the @UserNames to the script div
  46. } //Finishes the if condition
  47. })); //Finishes the onclick event listener
  48.  
  49. textarea.addEventListener('input', (function() { //When any letter is written on the script text box
  50. const matches = MALUserParsedList.filter(MALUserParsedList => MALUserParsedList.match(new RegExp(`^${this.value}`, 'gi'))); //Find the user input in the arrays
  51. document.querySelector("#autocomplete-list").innerHTML = ''; //Remove the previously displayed UserNames
  52. matches.forEach(UserName => document.querySelector("#autocomplete-list").innerHTML += `<div title="Mention @${UserName}" onmouseout='this.style.color = ${document.querySelector(".dark-mode") !== null ? "\"white\"" : "\"black\""}' onmouseover='this.style.color = "#6386d5"' onclick='document.querySelectorAll(".sourceMode > textarea").forEach(el => el.value += document.querySelector(".sourceMode > textarea").value === "" ? "@${UserName}\\n\\n" : "@${UserName} ")'>\n@${UserName}</div>
  53. `); //Display the users found
  54. })); //Finishes the input event listener
  55.  
  56. document.querySelectorAll(".topic-reply-box").forEach((el) => { //ForEach reply box
  57. el.onmouseenter = (e) => { //Add an onmouseenter event listener
  58. el.append(textarea, div); //Append the textarea and the div elements
  59. }; //Finishes the onmouseenter event listener
  60. }); //Finishes the forEach loop
  61. })();