Quotes - MAL

Brings back the original MAL quotes button! Now you can copy in a single click original BBCodes and image URLs!

安装此脚本?
作者推荐脚本

您可能也喜欢User Blocker - MAL

安装此脚本
  1. // ==UserScript==
  2. // @name Quotes - MAL
  3. // @namespace Quote
  4. // @version 4
  5. // @description Brings back the original MAL quotes button! Now you can copy in a single click original BBCodes and image URLs!
  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. (function() {
  14. 'use strict';
  15.  
  16. function Function() { //Starts the Function
  17. setTimeout(() => { //Starts the setTimeout function
  18. document.querySelectorAll(".mal-post-toolbar > div, .toolbar.left").forEach(function(el, i) { //ForEach topic
  19. var counter = i; //Create a new variable
  20. document.querySelector(".mal-post-toolbar > div") === null ? counter = i + 1 : counter = i; //If the page is on the conversation view
  21. if ((document.querySelectorAll(".username, .item.name")[counter].innerText !== window.dataLayer[0].user_name) && document.querySelectorAll(".mal-post-toolbar > div, .toolbar.left")[i].innerHTML.match("Quote") === null) { //If it is not the script user message and the current message does not have the quote button
  22. el.insertAdjacentHTML('afterbegin', `<button title="Quote ${document.querySelectorAll(".username, .item.name")[counter].innerText}" class="mal-btn secondary small outline noborder js-topic-message-report"><i class="fa-solid fa-reply fa-fw mr4"></i>Quote</button>`); //Add the quote button on the page
  23.  
  24. el.querySelector(`button`).onclick = async function() //When the quote btn is clicked
  25. { //Starts the onclick function
  26. document.querySelector(".topic-reply-container.hide") !== null ? document.querySelector(".topic-reply-container.hide").remove() : ''; //Remove needless hidden new reply btn
  27. document.querySelectorAll(".js-reply-start:not(.pressed)").forEach(el => el.click());; //If the reply btn closed, open it
  28. document.querySelectorAll(".postnum > a, .item.name")[document.querySelectorAll(".postnum > a, .item.name").length - 1].scrollIntoView(); //Scroll the page to the bottom
  29.  
  30. const response = await (await fetch('https://myanimelist.net/includes/quotetext.php', {
  31. "headers": {
  32. "content-type": "application/x-www-form-urlencoded"
  33. },
  34. "body": `msgid=${document.querySelector(".postnum") !== null ? document.querySelectorAll(".postnum > a")[i].href.match(/\d+/g)[1] : document.querySelectorAll("[class='message']")[i].dataset.id}&csrf token=${document.head.querySelector("[name='csrf_token']").content}`,
  35. "method": "POST"
  36. })).text(); //Finishes the fetch
  37.  
  38. setTimeout(() => { //Paste the quoted content on the bottom new reply btn
  39. document.querySelectorAll(".sourceMode > textarea, .forum-post-reply-comment, .bbcode-message-editor").forEach(el => el.value += `[quote=${document.querySelectorAll(".username, .item.name")[counter].innerText} message=${document.querySelector(".postnum") !== null ? document.querySelectorAll(".postnum > a")[i].href.match(/\d+/g)[1] : document.querySelectorAll("[class='message']")[i].dataset.id}]` + new DOMParser().parseFromString(response, "text/html").documentElement.textContent + '[/quote]'); //Paste the text and BBCode content from the topic reply the user wants to quote
  40. }, 500); //Finishes the click event listener and setTimeout function
  41. }; //Finishes the onclick function
  42. } //Finishes the if condition
  43. }) //Finishes the forEach loop
  44. }, 500); //Finishes the setTimeout function
  45. } //FInishes the Function
  46.  
  47. Function(); //Run the script when the page is loaded
  48.  
  49. document.querySelectorAll(".js-thread-childs").forEach(function(el) { //ForEach reply child
  50. el.onclick = function() { //When the reply child btn is clicked
  51. Function(); //Run the script again
  52. }; //Finishes the onclick function
  53. }) //Finishes the forEach loop
  54. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址