JavDB Toolbox

JavDB 工具箱:1. 添加搜索在线观看资源按钮 2. 添加到 JavLibrary 等站点跳转按钮

Versione datata 04/01/2022. Vedi la nuova versione l'ultima versione.

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

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

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==UserScript==
// @name         JavDB Toolbox
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  JavDB 工具箱:1. 添加搜索在线观看资源按钮 2. 添加到 JavLibrary 等站点跳转按钮
// @author       naughtyEvenstar
// @include      /^https:\/\/javdb[0-9]*.com\/v\/*/
// @icon         https://javdb.com/favicon-32x32.png
// @grant        none
// @license      MIT
// ==/UserScript==

(function () {
  "use strict";

  const openWindowWithPost = (url, data) => {
    var form = document.createElement("form");
    form.target = "_blank";
    form.method = "POST";
    form.action = url;
    form.style.display = "none";

    for (var key in data) {
      var input = document.createElement("input");
      input.type = "hidden";
      input.name = key;
      input.value = data[key];
      form.appendChild(input);
    }

    document.body.appendChild(form);
    form.submit();
    document.body.removeChild(form);
  };

  const tmpl = `
          <div class="panel-block generated">
              <div class="columns">
              <div class="column">
                  <div class="buttons are-small review-buttons" />
              </div>
              </div>
          </div>`;

  [...document.querySelectorAll(".movie-panel-info div.panel-block")]
    .pop()
    .insertAdjacentHTML("afterend", tmpl);

  const buttonRowEle = document.querySelector(".generated .review-buttons");

  const registerButton = (text, onClick, hint) => {
    const btnEle = document.createElement("a");
    btnEle.className = "button is-info is-outlined";
    btnEle.addEventListener("click", onClick);
    btnEle.textContent = text;
    buttonRowEle.appendChild(btnEle);
    if (hint) btnEle.title = hint;
    return btnEle;
  };

  const movieCode = document.querySelector(
    ".panel-block.first-block > span"
  ).textContent;
  const movieTitle = document.querySelector(".title.is-4 > strong").textContent;
  const isFC2 = movieCode.startsWith("FC2");
  const isUncensored = isFC2 || movieTitle.includes("無碼");
  const searchType = isUncensored ? "uncensored" : "censored";
  const searchKeyword = isFC2 ? movieCode.slice(4) : movieCode;

  const btn7mmtv = registerButton(
    "🔎 7MMTV",
    () => {
      openWindowWithPost(
        "https://7mmtv.tv/zh/searchform_search/all/index.html",
        {
          search_keyword: searchKeyword,
          search_type: searchType,
          op: "search",
        }
      );
    },
    "适合搜索骑兵和fc2"
  );
  const btnAvgle = registerButton("🔎 Avgle", () =>
    window.open(
      `https://avgle.com/search/videos?search_query=${searchKeyword}&search_type=videos`
    )
  );
  const btnJavBigo = registerButton("🔎 JavBigo", () =>
    window.open(`https://javbigo.com/?s=${searchKeyword}`)
  );
  const btnJavLib = registerButton("🔎 JavLibrary", () =>
    window.open(
      `https://www.javlibrary.com/cn/vl_searchbyid.php?keyword=${searchKeyword}`
    )
  );
})();