解锁黑料网

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

  1. // ==UserScript==
  2. // @name 解锁黑料网
  3. // @namespace Unlock_Heiliao
  4. // @version 1.1
  5. // @description 1)去除广告 2)内容页的播放器置顶并播放
  6. // @author cocang
  7. // @match *://18hlw.com/*
  8. // @match *://zztt15.com/*
  9. // @match *://*.dbeggt.com/*
  10. // @match *://*.hewhsu.com/*
  11. // @icon https://18hlw.com/static/pc/icons/icon_64x64.820c9b.png
  12. // @run-at document-idle
  13. // @grant none
  14. // @license MIT
  15. // ==/UserScript==
  16.  
  17. (() => {
  18. 'use strict';
  19.  
  20. const queryAndRemoveElements = (selectors) => {
  21. selectors.forEach((selector) => {
  22. document.querySelectorAll(selector).forEach((element) => element.remove());
  23. });
  24. };
  25.  
  26. const applyStylesToDPlayer = (dPlayer, styles) => {
  27. Object.assign(dPlayer.style, styles);
  28. };
  29.  
  30. const playFirstDPlayerVideo = (container) => {
  31. const firstDPlayer = container.querySelector('.dplayer');
  32. firstDPlayer?.querySelector('video')?.play();
  33. };
  34.  
  35. const moveDPlayersToTop = (container, dPlayers) => {
  36. dPlayers.reverse().forEach((dPlayer) => {
  37. applyStylesToDPlayer(dPlayer, { width: '100%', height: '960px' });
  38. container.prepend(dPlayer);
  39. });
  40. };
  41.  
  42. const processDPlayers = () => {
  43. const contentPlaceholder = document.querySelector('.client-only-placeholder.editormd-preview');
  44. if (!contentPlaceholder) return;
  45.  
  46. const dPlayers = Array.from(contentPlaceholder.querySelectorAll('.dplayer'));
  47. if (dPlayers.length === 0) return;
  48.  
  49. moveDPlayersToTop(contentPlaceholder, dPlayers);
  50. playFirstDPlayerVideo(contentPlaceholder);
  51. };
  52.  
  53. const filterAndStyleVideoLinks = () => {
  54. const videoItems = document.querySelectorAll('.video-list .video-item');
  55. videoItems.forEach((videoItem) => {
  56. const anchor = videoItem.querySelector('a');
  57. if (anchor) {
  58. if (anchor.href.includes('/archives/') && !anchor.href.includes('/archives/25117.html')) {
  59. anchor.setAttribute('target', '_blank');
  60. } else {
  61. videoItem.remove();
  62. }
  63. }
  64. });
  65. };
  66.  
  67. const cleanUpPage = () => {
  68. const elementsToRemove = ['.event-notice', '.infomation', '.list-sec', '.list-sec-top', 'blockquote'];
  69. queryAndRemoveElements(elementsToRemove);
  70. filterAndStyleVideoLinks();
  71. processDPlayers();
  72. };
  73.  
  74. cleanUpPage();
  75. })();