Greasy Fork

Greasy Fork is available in English.

Better Buttons To Edit Anime/Manga Information

The script removes the actual "Edit Anime/Manga Information" drop down menu, and replaces that with Better Buttons To edit the Anime/Manga information.

当前为 2021-11-20 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Better Buttons To Edit Anime/Manga Information
// @namespace    Better Buttons To Edit Anime Information
// @version      1.8
// @description  The script removes the actual "Edit Anime/Manga Information" drop down menu, and replaces that with Better Buttons To edit the Anime/Manga information.
// @author       hacker09
// @include      /^https:\/\/myanimelist\.net\/((anime|manga)(id=)?(\.php\?id=)?)(\/)?([\d]+)?/
// @icon         https://www.google.com/s2/favicons?domain=myanimelist.net
// @run-at       document-end
// @grant        none
// ==/UserScript==

(async function() {
  var MarginLeft = -7; //Creates a new variable
  const id = location.pathname.match(/\d+/)[0]; //Get the entry id
  var type, remove, sourceortype, airingdatesorpubdates, ratingorchapvol; //Create new variables
  const CSSPart = 'height: 10px; width: 10px; background-size: cover; display: inline-block; transform: scale(1.8); vertical-align: top;'; //Stpre part of the CSS codes

  location.pathname.split('/')[1] === 'anime' ? (type = 'aid', remove = 'anime', sourceortype = 'source', airingdatesorpubdates = 'airingdates', ratingorchapvol = 'rating') : (type = 'mid', remove = 'manga', sourceortype = 'type', airingdatesorpubdates = 'pubdates', ratingorchapvol = 'chapvol'); //Set up the constiables

  document.getElementsByClassName('js-' + remove + '-edit-info-button')[0].remove(); //Remove the default Edit Anime/Manga Information Button

  const BroadCastButton = '<a href="https://myanimelist.net/dbchanges.php?aid=' + id + '&t=broadcast" target="_self" title="Edit Anime BroadCast" class="BetterBTN" id="BroadCastButton" style="margin-left: 420px; ' + CSSPart + ' margin-top: -10px; background-image: url(https://i.imgur.com/1TA8f0M.png);"></a>'; //Create a BTN const
  const ProducersButton = '<a href="https://myanimelist.net/dbchanges.php?aid=' + id + '&t=producers" target="_self" title="Edit Anime Producers" class="BetterBTN" id="ProducersButton" style="margin-left: 400px; ' + CSSPart + ' margin-top: -10px; background-image: url(https://i.imgur.com/X8b0lhp.png);"></a>'; //Create a BTN const
  const RatingButton = '<a href="https://myanimelist.net/dbchanges.php?' + type + "=" + id + "&t=" + ratingorchapvol + '" target="_self" title="Edit Anime Rating" class="BetterBTN" id="RatingButton" style="margin-left: 380px; ' + CSSPart + ' margin-top: -10px; background-image: url(https://i.imgur.com/ouIcJ0L.png);"></a>'; //Create a BTN const
  const RelationsButton = '<a href="https://myanimelist.net/dbchanges.php?' + type + "=" + id + '&t=relations" target="_self" title="Edit Anime Relations" class="BetterBTN" id="RelationsButton" style="margin-left: 357px; ' + CSSPart + ' margin-top: -10px; background-image: url(https://i.imgur.com/7tWTGSx.png);"></a>'; //Create a BTN const
  const SourceButton = '<a href="https://myanimelist.net/dbchanges.php?' + type + "=" + id + "&t=" + sourceortype + '" target="_self" title="Edit Anime Source" class="BetterBTN" id="SourceButton" style="margin-left: 335px; ' + CSSPart + ' margin-top: -10px; background-image: url(https://i.imgur.com/wv414uC.png);"></a>'; //Create a BTN const
  const AiringDatesButton = '<a href="https://myanimelist.net/dbchanges.php?' + type + "=" + id + "&t=" + airingdatesorpubdates + '" target="_self" title="Edit Anime Airing Dates" class="BetterBTN" id="AiringDatesButton" style="margin-left: 313px; ' + CSSPart + ' margin-top: -10px; background-image: url(https://i.imgur.com/9j8Jkyc.png);"></a>'; //Create a BTN const
  const BackgroundButton = '<a href= "https://myanimelist.net/dbchanges.php?' + type + "=" + id + '&t=background" target="_self" title="Edit Anime Background" class="BetterBTN" id="BackgroundButton" style="margin-left: 290px; ' + CSSPart + ' margin-top: -10px; background-image: url(https://i.imgur.com/nglIeUs.png);"></a>'; //Create a BTN const
  const AlternativeTitlesButton = '<a href="https://myanimelist.net/dbchanges.php?' + type + "=" + id + '&t=alternative_titles" target="_self" title="Edit Anime Alternative Titles" class="BetterBTN" id="AlternativeTitlesButton" style="margin-left: 270px; ' + CSSPart + ' margin-top: -10px; background-image: url(https://i.imgur.com/YDcRsLh.png);"></a>'; //Create a BTN const
  const SynopsisButton = '<a href="https://myanimelist.net/dbchanges.php?' + type + "=" + id + '&t=synopsis" target="_self" title="Edit Anime Synopsis" class="BetterBTN" id="SynopsisButton" style="margin-left: 250px; ' + CSSPart + ' margin-top: -10px; background-image: url(https://i.imgur.com/G41CHJZ.png);"></a>'; //Create a BTN const
  const PictureButton = '<a href="https://myanimelist.net/dbchanges.php?' + type + "=" + id + '&t=pic" target="_self" title="Edit Anime Picture" class="BetterBTN" id="PictureButton" style="margin-left: 228px; ' + CSSPart + ' margin-top: -10px; background-image: url(https://i.imgur.com/fzxCO0C.png);"></a>'; //Create a BTN const
  var DurationButton = '<a href="https://myanimelist.net/dbchanges.php?aid=' + id + '&t=duration" target="_self" title="Edit Anime Duration" class="BetterBTN" id="DurationButton" style="margin-left: 205px; ' + CSSPart + ' margin-top: -9px; background-image: url(https://i.imgur.com/U9qigWi.png);"></a>'; //Create a BTN const

  //Math.sign(document.querySelector('.header-right').getBoundingClientRect().top) === -1
  [...[...document.querySelectorAll("h2")].find(h2 => h2.textContent === "Information").parentNode.querySelectorAll("h2")].find(info => info.outerHTML.includes("Information")).outerHTML = '<br><div id="InformationDIV"><br><h2>Information</h2></div>'; //Add the Information h2 header inside a div
  const Infoh2Elem = document.querySelector("#InformationDIV"); //Save the information div element

  const BTNsArray = [BroadCastButton, ProducersButton, RatingButton, RelationsButton, SourceButton, AiringDatesButton, BackgroundButton, AlternativeTitlesButton, SynopsisButton, PictureButton, DurationButton]; //Creates an array of BTNs
  BTNsArray.forEach(function(BTNs) { //ForEach button in the array
    document.querySelector('.header-right').parentElement.insertAdjacentHTML("beforeend", BTNs); //Add the BTN on the page
    Infoh2Elem.insertAdjacentHTML("afterbegin", BTNs); //Add the BTN on the page
  }); //Finishes the ForEach function

  if (type === 'mid') //If the user is on a manga entry
  { //Starts the if condition
    MarginLeft = 5; //Centralize the icons
    document.querySelectorAll("#SourceButton").forEach(BTN => BTN.setAttribute("title", "Edit Manga Type")); //Change txt on mouse hover
    document.querySelectorAll("#PictureButton").forEach(BTN => BTN.setAttribute("title", "Edit Manga Picture")); //Change txt on mouse hover
    document.querySelectorAll("#SynopsisButton").forEach(BTN => BTN.setAttribute("title", "Edit Manga Synopsis")); //Change txt on mouse hover
    document.querySelectorAll("#RelationsButton").forEach(BTN => BTN.setAttribute("title", "Edit Manga Relations")); //Change txt on mouse hover
    document.querySelectorAll("#BackgroundButton").forEach(BTN => BTN.setAttribute("title", "Edit Manga Background")); //Change txt on mouse hover
    document.querySelectorAll("#AiringDatesButton").forEach(BTN => BTN.setAttribute("title", "Edit Manga Publishing Dates")); //Change txt on mouse hover
    document.querySelectorAll("#RatingButton").forEach(BTN => BTN.setAttribute("title", "Edit Manga Chapters/Volumes")); //Change txt on mouse hover
    document.querySelectorAll("#RatingButton").forEach(BTN => BTN.style.backgroundImage = "url(https://i.imgur.com/py5QNtd.png)"); //Change rating BTN IMG
    document.querySelectorAll("#AlternativeTitlesButton").forEach(BTN => BTN.setAttribute("title", "Edit Manga Alternative Titles")); //Change txt on mouse hover
    document.querySelectorAll("#BroadCastButton,#ProducersButton,#DurationButton").forEach(BTN => BTN.setAttribute("style", "display: none !important;")); //Hide BTNs
  } //Finishes the if condition

  document.querySelectorAll(".BetterBTN").forEach(function(BTNs, i) { //ForEach Information BTNs
    if (i > 10) { //Only for the Information BTNs
      BTNs.style.marginLeft = MarginLeft + 'px'; //Gradualy increase the left margin
      BTNs.style.display = 'block'; //Change the display mode
      MarginLeft += 22; //Increase the left margin
    } //Finishes the if condition
  }); //Finishes the ForEach loop

  document.querySelectorAll("#PictureButton,#DurationButton").forEach(function(BTN) { //ForEach picture and duration BTNs
    BTN.addEventListener('contextmenu', function() { //When the picture icon is right clicked
      window.open(this.href); //Open the picture edit link on a new tab
    }, false); //Finishes the contextmenu event listener
  }); //Finishes the ForEach loop
})();