Quick drop titles

Adds a dropped button to the quick tab for anilist

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name        Quick drop titles
// @namespace   Anilist.co Scripts
// @match       https://anilist.co/search/anime
// @grant       none
// @version     1.0
// @author      KiD Fearless
// @license MIT
// @description Adds a dropped button to the quick tab for anilist
// ==/UserScript==


document.onreadystatechange = () =>
{
  document.onreadystatechange = null;
  
  setInterval(() => 
  {
    let cards = document.querySelectorAll(".media-card");
    for(let card of cards)
    {
      let actions = card.querySelector(".quick-actions");

      // cheap check if we've already ran
      if(actions.lastElementChild.onclick)
      {
        continue;    
      }

      let vue = card.__vue__;

      // don't know if this changes between updates. Just grab it dynamically
      let data = `data-v-${Object.keys(actions.dataset)[0].substring(1).toLowerCase()}`;

      actions.innerHTML += 
        `<div ${data}="" label="Add to Dropped" class="btn">
            <svg ${data}="" aria-hidden="true" focusable="false" data-prefix="fas" class="icon svg-inline--fa fa-w-14" data-icon="calendar" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><path ${data}=""  fill="currentColor"d="M135.2 17.69C140.6 6.848 151.7 0 163.8 0H284.2C296.3 0 307.4 6.848 312.8 17.69L320 32H416C433.7 32 448 46.33 448 64C448 81.67 433.7 96 416 96H32C14.33 96 0 81.67 0 64C0 46.33 14.33 32 32 32H128L135.2 17.69zM394.8 466.1C393.2 492.3 372.3 512 346.9 512H101.1C75.75 512 54.77 492.3 53.19 466.1L31.1 128H416L394.8 466.1z"/></svg>
         </div>`;

      actions.lastElementChild.onclick = (event) =>
      {
        event.preventDefault();
        vue.$store.dispatch("medialistEditor/save", {status: "DROPPED", mediaId: vue.media.id});
      };
    }
  }, 300);
};