解锁黑料网

1)去除广告 2)内容页的播放器置顶并播放

You will need to install an extension such as Tampermonkey, Greasemonkey 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 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.

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

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

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         解锁黑料网
// @namespace    Unlock_Heiliao
// @version      1.1
// @description  1)去除广告 2)内容页的播放器置顶并播放
// @author       cocang
// @match        *://18hlw.com/*
// @match        *://zztt15.com/*
// @match        *://*.dbeggt.com/*
// @match        *://*.hewhsu.com/*
// @icon         https://18hlw.com/static/pc/icons/icon_64x64.820c9b.png
// @run-at       document-idle
// @grant        none
// @license      MIT
// ==/UserScript==

(() => {
    'use strict';

    const queryAndRemoveElements = (selectors) => {
        selectors.forEach((selector) => {
            document.querySelectorAll(selector).forEach((element) => element.remove());
        });
    };

    const applyStylesToDPlayer = (dPlayer, styles) => {
        Object.assign(dPlayer.style, styles);
    };

    const playFirstDPlayerVideo = (container) => {
        const firstDPlayer = container.querySelector('.dplayer');
        firstDPlayer?.querySelector('video')?.play();
    };

    const moveDPlayersToTop = (container, dPlayers) => {
        dPlayers.reverse().forEach((dPlayer) => {
            applyStylesToDPlayer(dPlayer, { width: '100%', height: '960px' });
            container.prepend(dPlayer);
        });
    };

    const processDPlayers = () => {
        const contentPlaceholder = document.querySelector('.client-only-placeholder.editormd-preview');
        if (!contentPlaceholder) return;

        const dPlayers = Array.from(contentPlaceholder.querySelectorAll('.dplayer'));
        if (dPlayers.length === 0) return;

        moveDPlayersToTop(contentPlaceholder, dPlayers);
        playFirstDPlayerVideo(contentPlaceholder);
    };

    const filterAndStyleVideoLinks = () => {
        const videoItems = document.querySelectorAll('.video-list .video-item');
        videoItems.forEach((videoItem) => {
            const anchor = videoItem.querySelector('a');
            if (anchor) {
                if (anchor.href.includes('/archives/') && !anchor.href.includes('/archives/25117.html')) {
                    anchor.setAttribute('target', '_blank');
                } else {
                    videoItem.remove();
                }
            }
        });
    };

    const cleanUpPage = () => {
        const elementsToRemove = ['.event-notice', '.infomation', '.list-sec', '.list-sec-top', 'blockquote'];
        queryAndRemoveElements(elementsToRemove);
        filterAndStyleVideoLinks();
        processDPlayers();
    };

    cleanUpPage();
})();