Greasy Fork

Greasy Fork is available in English.

纯净版boylove.cc

2024/3/2 11:15:27

当前为 2024-03-02 提交的版本,查看 最新版本

// ==UserScript==
// @name        纯净版boylove.cc
// @namespace   Violentmonkey Scripts
// @match       https://boylove.cc/*
// @grant       none
// @version     1.1
// @author      happyday001
// @license     MIT
// @description 2024/3/2 11:15:27
// ==/UserScript==

(function() {
    'use strict';

    /** 通用页面 **/
    /** 去除右下角广告 **/
    const rightBottomAds = document.querySelectorAll('.div_sticky2');
    /** 去除阅读也底部广告 **/
    const bottomAds = document.querySelectorAll('.pop_words');
    /** 阅读页广告 **/
    const centerAds = [];
    const tabTitle = document.querySelector('.row.mo-tab_title');
    if(tabTitle) {
      let temp = tabTitle.previousElementSibling;
      while(temp) {
        centerAds.push(temp);
        temp = temp.previousElementSibling;
      }
    }
    /** 头部广告 **/
    const topAds = [document.querySelector('.row.stui-pannel')]; // 第一个
    [...rightBottomAds,...bottomAds, ...centerAds, ...topAds].forEach((item)=>{
      item && item.remove();
    })

    /** 首页 **/
    if(location.pathname === '/') {
      /** 首页中部广告 **/
      const homeCenterAds = [];
      const mainContentWrap = document.querySelector('.row > .stui-pannel > .stui-pannel__bd');
      if(mainContentWrap && mainContentWrap.children) {
        [...mainContentWrap.children].forEach((item)=>{
          const id = item.getAttribute('id');
          const domClass = item.getAttribute('class');
          if((!id || !id.startsWith('temp_block')) && domClass!=='cm_block index_bottom') {
            homeCenterAds.push(item);
          }
        });
      }
      /** 首页公告 **/
      const homeNotice = document.querySelectorAll('#temp_block_03');
      [...homeCenterAds, ...homeNotice].forEach((item)=>{
        item && item.remove();
      })
    }

    /** 去除头部的小商店、影片、游戏 **/
    const header = document.querySelector('.stui-header__menu');
    const shop = header.children[3];
    const movie = header.children[4];
    const game = header.children[5];
    header.removeChild(shop);
    header.removeChild(movie);
    header.removeChild(game);

    /** 小说页 **/
    if(location.pathname.includes('novel')) {
      window.onload = () => {
        /** 广告 **/
        const ads = [];
        const listHead = document.querySelectorAll('.stui-vodlist__head');
        if(listHead) {
          listHead.forEach((head) => {
            const prev = head.previousElementSibling;
            if(prev) {
              const domClass = prev.getAttribute('class');
              if(domClass!=='stui-vodlist clearfix') {
                ads.push(prev);
              }
            }
          })
        }
        ads.forEach((item)=>{
          item && item.remove();
        })

        /** 公告 **/
        const notice = [];
        if(listHead) {
          listHead.forEach((head)=>{
            if(head.innerText.includes('香香公告')) {
              notice.push(head);
              notice.push(head.nextElementSibling);
            }
          })
        }
        notice.forEach((item)=>{
          item && item.remove();
        })
      }
    }
})();