Sleazy Fork is available in English.

tianteng

1. 绅士漫画下拉浏览页面,由原先的一列模式改为两列模式 2. javbus, 添加 "粘贴并搜索" 按钮; 添加 "打开srbt" 链接; 详情页面添加复制车牌号按钮.

Ekde 2024/06/26. Vidu La ĝisdata versio.

// ==UserScript==
// @name         tianteng
// @namespace    https://greasyfork.org/xmlspy
// @version      0.2.1
// @description  1. 绅士漫画下拉浏览页面,由原先的一列模式改为两列模式 2. javbus, 添加 "粘贴并搜索" 按钮; 添加 "打开srbt" 链接; 详情页面添加复制车牌号按钮.
            
// @author       xmlspy
// @license      MIT

// @require      https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.min.js

// @include      *
// @connect      *

// @run-at       document-end

// @grant        GM_xmlhttpRequest
// @grant        GM.setClipboard
// @grant        GM.xmlhttpRequest


// ==/UserScript==

(function () {
  "use strict";

  const skrbtDomain = "skrbtqx";
  const skrbtHost = skrbtDomain + ".top";
  const skrbtUrl = "https://" + skrbtHost;

  // execute(()=>{},()=>{});

  //////////////////////////////////////////////////////////////////////////////////////////////
  /////////////////// 紳士漫畫永久域名: wnacg.com紳士漫畫永久地址發佈頁: wnacg.date
  /////////////////////////////////////////////////////////////////////////////////////////////
  execute(
    () => {
      if ($('head>title:contains("紳士漫畫")').length > 0) {
        return true;
      }
    },
    () => {
      if (location.href.includes("photos-slide-aid")) {
        const nodeToObserve = document.querySelector("#img_list");
        $(nodeToObserve).css({
          width: "100%",
          display: "flex",
          "flex-wrap": "wrap",
          "justify-content": "flex-start",
          "overflow-x": "hidden",
        });
        const imgWidth = document.documentElement.clientWidth / 2 - 10;
        const imgHeight = document.documentElement.clientHeight - 50;
        const observer = new MutationObserver((mutations, observer) => {
          $("#img_list>div").css({
            flex: "1",
            "background-color": "#cacaca",
            margin: "0 5px 5px 0",
            width: "calc((100% - 10px) / 2)",
            "min-width": "calc((100% - 10px) / 2)",
            "max-width": "calc((100% - 10px) / 2)",
          });
          $("#img_list>div>img").on("load", (e) => {
            drawImage(e.target, imgWidth, imgHeight);
          });
        });
        observer.observe(nodeToObserve, { childList: true });
      }
    }
  );

  //////////////////////////////////////////////////////////////////////////////////////////////
  /////////////////// javbus
  /////////////////////////////////////////////////////////////////////////////////////////////
  execute(
    () => {
      if ($('head>title:contains("JavBus")').length > 0) {
        return true;
      }
      // /genre/hd , /genre/sub
      if (
        $("body > nav > div > div.navbar-header.mh50 > a > img[alt='JavBus']")
          .length > 0
      ) {
        return true;
      }
      // 论坛
      if (document.querySelector("#toptb.jav-nav") != null) {
        return true;
      }
    },
    () => {
      const searchButton = $(
        "button[onclick=\"searchs('search-input')\"]:first"
      );
      const searchInput = $("#search-input:first");
      addPasteAndSearchButton(searchButton, searchInput);

      // 调整样式
      $(".nav>li>a").attr("style", "padding-left:8px;padding-right:8px;");

      //添加skrbt链接
      $(".nav-title.nav-inactive:last,ul.nav.navbar-nav:first").append(`
                      <li class="hidden-md hidden-sm">
                          <a href="${skrbtUrl}" target="_blank">打开skrbt</a>
                      </li>
                  `);
      let chePaiNode = document.querySelector(
        "body > div.container > div.row.movie > div.col-md-3.info > p:nth-child(1) > span:nth-child(2)"
      );
      // 明细页面
      if (chePaiNode) {
        const chePai = chePaiNode.innerText.trim();
        const toAppendElement = document.querySelector(
          "body > div.container > div.row.movie > div.col-md-3.info > p:nth-child(1)"
        );

        appendCopyButton(chePai, toAppendElement);

        setInterval(() => $("#magnet-table td").removeAttr("onclick"), 1000);
      }
    }
  );
  //////////////////////////////////////////////////////////////////////////////////////////////
  /////////////////// 公共方法
  /////////////////////////////////////////////////////////////////////////////////////////////
  function execute(condition, callback) {
    let href = window.location.href;
    if (condition instanceof RegExp) {
      if (condition.test(href)) {
        callback();
      }
    }
    if (condition instanceof Function) {
      if (condition() === true) {
        callback();
      }
    }
  }

  function addPasteAndSearchButton($searchButton, $searchInput) {
    const styleMap = {};
    $searchButton[0].computedStyleMap().forEach((value, key) => {
      styleMap[key] = value;
    });
    const $pasteAndSearchButton = $(
      `<input type="button" value="粘贴并搜索" id="pasteAndSearch"></input>`
    );
    $pasteAndSearchButton.css(styleMap);
    $searchButton.after($pasteAndSearchButton);
    $pasteAndSearchButton.click(() => {
      navigator.clipboard.readText().then((clipText) => {
        if (clipText != null && $.trim(clipText) != "") {
          $searchInput.val($.trim(clipText));
          $searchButton.click();
        }
      });
    });
  }

  function appendCopyButton(chePai, toAppendElement) {
    var copyButton = document.createElement("button");
    copyButton.innerHTML = "复 制";
    copyButton.setAttribute("id", "copyButton");
    toAppendElement.appendChild(copyButton);
    document.addEventListener("click", (e) => {
      if (e.srcElement.getAttribute("id") === "copyButton") {
        GM.setClipboard(chePai, "text");
      }
    });
  }

  /**
   * 图片按宽高比例进行自动缩放
   * @param ImgObj
   *     缩放图片源对象
   * @param maxWidth
   *     允许缩放的最大宽度
   * @param maxHeight
   *     允许缩放的最大高度
   * @usage
   *     调用:<img src="图片" onload="javascript:drawImage(this,300,200)">
   */
  function drawImage(ImgObj, maxWidth, maxHeight) {
    var image = new Image();
    //原图片原始地址(用于获取原图片的真实宽高,当<img>标签指定了宽、高时不受影响)
    image.src = ImgObj.src;
    // 用于设定图片的宽度和高度
    var tempWidth;
    var tempHeight;

    if (image.width > 0 && image.height > 0) {
      //原图片宽高比例 大于 指定的宽高比例,这就说明了原图片的宽度必然 > 高度
      if (image.width / image.height >= maxWidth / maxHeight) {
        if (image.width > maxWidth) {
          tempWidth = maxWidth;
          // 按原图片的比例进行缩放
          tempHeight = (image.height * maxWidth) / image.width;
        } else {
          // 按原图片的大小进行缩放
          tempWidth = image.width;
          tempHeight = image.height;
        }
      } else {
        // 原图片的高度必然 > 宽度
        if (image.height > maxHeight) {
          tempHeight = maxHeight;
          // 按原图片的比例进行缩放
          tempWidth = (image.width * maxHeight) / image.height;
        } else {
          // 按原图片的大小进行缩放
          tempWidth = image.width;
          tempHeight = image.height;
        }
      }
      // 设置页面图片的宽和高
      ImgObj.height = tempHeight;
      ImgObj.width = tempWidth;
      // 提示图片的原来大小
      ImgObj.alt = image.width + "×" + image.height;
    }
  }
})();