Greasy Fork

Greasy Fork is available in English.

AniList - Search Title on AnimeBytes

adds a button on AniList anime pages to search AnimeBytes for the title

当前为 2021-01-16 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name        AniList - Search Title on AnimeBytes
// @namespace   http://greasyfork.icu/en/users/96096-purplepinapples
// @match       https://anilist.co/*
// @grant       none
// @run-at      document-end
// @version     1.2
// @author      purplepinapples
// @description adds a button on AniList anime pages to search AnimeBytes for the title
// ==/UserScript==

(function () {

  function createSearchButton() {
    const navEl = document.querySelector(".content div.nav");
    if (navEl) {
      const lastChild = navEl.children[navEl.children.length - 1];
      const cloned = lastChild.cloneNode(true);
      cloned.innerText = "Search on AB";
      cloned.href = "#";
      cloned.addEventListener("click", function (e) {
        const seriesName = document.querySelector("h1").innerText;
        const targetUrl =
          "https://animebytes.tv/torrents.php?searchstr=" +
          encodeURIComponent(seriesName);
        e.preventDefault();
        window.open(targetUrl, "_blank"); // new tab
      });
      cloned.href = navEl.appendChild(cloned);
    } else {
      // check every 500ms if the page has loaded, so we can add the button
      setTimeout(() => createSearchButton(), 500);
    }
  }

  createSearchButton();
})();