wnacg-helper

A manga helper for wnacg.com

Version vom 25.07.2024. Aktuellste Version

Du musst eine Erweiterung wie Tampermonkey, Greasemonkey oder Violentmonkey installieren, um dieses Skript zu installieren.

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

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

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

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

Sie müssten eine Skript Manager Erweiterung installieren damit sie dieses Skript installieren können

(Ich habe schon ein Skript Manager, Lass mich es installieren!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         wnacg-helper
// @namespace    https://www.wnacg.com/
// @version      0.0.2
// @author       dzh
// @description  A manga helper for wnacg.com
// @license      MIT
// @icon         https://www.wnacg.com/favicon.ico
// @match        https://www.wnacg.com/*
// @grant        GM_addStyle
// ==/UserScript==

(o=>{if(typeof GM_addStyle=="function"){GM_addStyle(o);return}const t=document.createElement("style");t.textContent=o,document.head.append(t)})(" .shortcut{display:none;position:absolute;bottom:5px;right:25px;border:none;padding:6px 10px;font-size:14px;color:#f0f8ff;background-color:#000;border-radius:25px}.shortcut:hover{background-color:#000c;cursor:pointer}.pic_box:hover .shortcut{display:block} ");

(function () {
  'use strict';

  $(document).ready(() => {
    observerImgList();
  });
  $(window).on("load", () => {
    $(document).keydown(handleKeydownEvent);
  });
  function observerImgList() {
    const targetNode = document.getElementById("img_list");
    if (!targetNode) return;
    const observer = new MutationObserver(handleMutationCallback);
    observer.observe(targetNode, {
      childList: true,
      subtree: true
    });
  }
  function handleMutationCallback(mutationList, observer) {
    mutationList.forEach((mutation) => {
      if (mutation.type === "childList") {
        autoChangeWidth();
      }
    });
  }
  function autoChangeWidth() {
    const imgList = document.querySelectorAll("#img_list img");
    imgList.forEach((img) => {
      img.style.width = "60%";
    });
  }
  function handleKeydownEvent(e) {
    switch (e.key) {
      case "=":
        plusWidth();
        break;
      case "-":
        minusWidth();
        break;
      case "r":
        autoChangeWidth();
        break;
    }
  }
  function plusWidth() {
    const imgList = document.querySelectorAll("#img_list img");
    const plusStep = 2;
    imgList.forEach((img) => {
      const width = parseInt(img.style.width);
      img.style.width = `${width + plusStep}%`;
    });
  }
  function minusWidth() {
    const imgList = document.querySelectorAll("#img_list img");
    const minusStep = 2;
    imgList.forEach((img) => {
      const width = parseInt(img.style.width);
      if (width <= 10) return;
      img.style.width = `${width - minusStep}%`;
    });
  }
  new URL(location.href).pathname;
  const slideViewUrl = (pid) => `https://www.wnacg.com/photos-slide-aid-${pid}.html`;
  $(document).ready(addSlideViewShortcut);
  function addSlideViewShortcut() {
    const mangaBox = $(".gallary_wrap .gallary_item");
    $(mangaBox).each(addShortcutEle);
  }
  function addShortcutEle() {
    const container = $(this).find(".pic_box");
    const ele = $(document.createElement("button"));
    ele.text("Slide View");
    ele.addClass("shortcut");
    ele.on("click", goToSlideView);
    container.append(ele);
  }
  function goToSlideView() {
    const link = $(this).parent().find("a").attr("href");
    const pid = link.match(/\d+/)[0];
    window.open(slideViewUrl(pid), "_blank");
  }

})();