jm-remove-ad

JM漫画去广告

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==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;
  }
`);