jm-remove-ad

JM漫画去广告

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        jm-remove-ad
// @namespace   Violentmonkey Scripts
// @match       https://18comic.vip/*
// @match       https://18comic.ink/*
// @run-at      document-idle
// @grant       GM_addStyle
// @version     1.0.0
// @author      mesimpler
// @require     https://cdn.jsdelivr.net/npm/@violentmonkey/dom@2
// @license MIT
// @description JM漫画去广告
// ==/UserScript==

// 首页
const urls = ["https://18comic.vip/", "https://18comic.ink/"];
if (urls.includes(window.location.href)) {
  const ads = [
    // 弹窗
    "#guide-modal",
    // 弹窗
    "div[data-group*='sticky']",
    // banner
    ".div-bf-pv",
    // 顶栏
    ".top-nav",
    // 贴片
    "div[data-group*='all_bottom']",
    // 返回顶部
    ".float_right > div:nth-child(1)",
    ".float_right > div:nth-child(2)",
    // 底边栏
    ".ph-bottom.switch-group .ph-active:nth-child(1)",
    ".ph-bottom.switch-group .ph-active:nth-child(3)",
    ".ph-bottom.switch-group .ph-active:nth-child(4)",
  ];

  ads.forEach((selector) => {
    const ad = document.querySelectorAll(selector);
    ad.forEach((el) => el.classList.add("hidden-ad"));
  });

  GM_addStyle(`
    #Comic_Top_Nav {
      top: 0 !important;
    }

    .ph-active {
      flex: 1 !important;
    }

    .float_right {
      top: 80% !important;
    }
  `);
}

// 类别页
if (window.location.href.includes("/theme")) {
  const ads = [
    // 顶栏
    ".top-nav",
    // 弹窗
    "div[data-group*='sticky']",
    // 贴片
    ".row:has(div[data-group*='list'])",
    // 底边栏
    ".ph-bottom.switch-group .ph-active:nth-child(1)",
    ".ph-bottom.switch-group .ph-active:nth-child(3)",
    ".ph-bottom.switch-group .ph-active:nth-child(4)",
  ];

  ads.forEach((selector) => {
    const ad = document.querySelectorAll(selector);
    ad.forEach((el) => el.classList.add("hidden-ad"));
  });

  GM_addStyle(`
    #Comic_Top_Nav {
      top: 0 !important;
    }

    .navbar {
      top: 30px !important;
    }

    .ph-active {
      flex: 1 !important;
    }
  `);
}

// 本子详情页
if (window.location.href.includes("/album/")) {
  const ads = [
    // 顶栏
    ".top-nav",
    // 顶部贴片
    ".row:has(div[data-group*='content_page'])",
    // 中间贴片
    "div[data-group*='album_detail']",
    // 底部贴片
    ".row:has(div[data-group*='album_related'])",
    // 弹窗
    "div[data-group*='sticky']",
    // 贴片
    ".row:has(div[data-group*='list'])",
    // 底边栏
    ".ph-bottom.switch-group .ph-active:nth-child(1)",
    ".ph-bottom.switch-group .ph-active:nth-child(3)",
    ".ph-bottom.switch-group .ph-active:nth-child(4)",
    // 返回顶部
    ".float_right > div:nth-child(1)",
    ".float_right > div:nth-child(2)",
  ];

  ads.forEach((selector) => {
    const ad = document.querySelectorAll(selector);
    ad.forEach((el) => el.classList.add("hidden-ad"));
  });

  GM_addStyle(`
    #Comic_Top_Nav {
      top: 0 !important;
    }

    .navbar {
      top: 30px !important;
    }

    .ph-active {
      flex: 1 !important;
    }

    .float_right {
      top: 80% !important;
    }
  `);
}

// 本子浏览页
if (window.location.href.includes("/photo/")) {
  VM.observe(document.body, () => {
    const ads = [
      // 返回顶部
      ".float_right > div:nth-child(1)",
      ".float_right > div:nth-child(2)",
      // 弹窗
      "div[style*='position: fixed; overflow: hidden; padding: 10px;']",
      "div[style='text-align:center;width: 844px;margin: 0 auto;max-width: 100%;']",
      // 顶部
      ".row:has(div[data-group*='photo_bottom'])",
      // 中间插入
      "div[data-group*='photo_center']",
    ];

    ads.forEach((selector) => {
      const ad = document.querySelectorAll(selector);
      ad.forEach((el) => el.classList.add("hidden-ad"));
    });
  });

  GM_addStyle(`
    .navbar {
      top: 30px !important;
    }

    .float_right {
      top: 80% !important;
    }
  `);
}

// 个人主页
if (window.location.href.includes("/user/")) {
  const ads = [
    // 顶栏
    ".top-nav",
    // 每日任务
    ".user-daily-mission",
    // 菜单块
    ".header-menu-block",
    // 底部贴片
    ".row:has(div[data-group*='album_related'])",
    // 弹窗
    "div[data-group*='sticky']",
    // 底边栏
    ".ph-bottom.switch-group .ph-active:nth-child(1)",
    ".ph-bottom.switch-group .ph-active:nth-child(3)",
    ".ph-bottom.switch-group .ph-active:nth-child(4)",
  ];

  ads.forEach((selector) => {
    const ad = document.querySelectorAll(selector);
    ad.forEach((el) => el.classList.add("hidden-ad"));
  });

  GM_addStyle(`
    #Comic_Top_Nav {
      top: 0 !important;
    }

    .navbar {
      top: 30px !important;
    }

    .ph-active {
      flex: 1 !important;
    }
  `);
}

GM_addStyle(`
  .hidden-ad {
    display: none !important;
  }
`);