Makima 发表于 2025-8-19 19:29:26

GM简化1.3

增加了对公告的自动关闭能不能加入“已读”功能哇{:4_89:}
发现主页和搜索页面和公告还不是一个东西https://img.gamemale.com/forum/202412/24/170302ig4zy4ew94cll4we.jpg

@Name @Match
// ==UserScript==
// @name            GM简化
// @version         1.3
// @authoe            MKM
// @match             https://www.gamemale.com/*
// @grant             GM_addStyle
// ==/UserScript==
(function() {
    'use strict';

    GM_addStyle(`
      #hd .wp .comiis_nav,
      .md_ctrl,
      p.xg1,
      nav.toc,
      .scbar_hot_td,
      .pls .avatar_p .vm,
      fieldset,
      .hm-t-container,
      .hm-t-main,
      .hm-t-body,
      .dnch_eo_f,
      .sign,
      .signature,
      .bui .m img,
      div,
      li.pm2,
      li.pm2 a.xi2,
      ul,
      div.focus#sitefocus,
      div.focus#focus,
      div.bm.h.cl,
      div.bm.h.cl,
      div#focus_con {
            display: none !important;
            visibility: hidden !important;
            height: 0 !important;
            width: 0 !important;
            margin: 0 !important;
            padding: 0 !important;
            border: 0 !important;
            position: absolute !important;
            clip: rect(0,0,0,0) !important;
      }

      #postlist .plhin {
            background: none !important;
      }

      .pls .avatar img,
      #fastpostform .pls .avatar img,
      .personinformaion .person-imgs img,
      #main .t.t2 table .tr1 table .tac img,
      #um .avt img,
      #tath img,
      .rate table img,
      .rate dd li img,
      .cm .vm img,
      .card_mn .avt img {
            border-radius: 50% !important;
            background-size: cover !important;
            background-position: center !important;
            background-repeat: no-repeat !important;
      }

      .pls .avatar img {
            width: 80px !important;
            height: 80px !important;
            border: none !important;
            padding: 0 !important;
            margin: 0 !important;
      }

      .pls .avatar {
            margin: 10px auto !important;
            width: 80px !important;
            height: 80px !important;
            border-radius: 50% !important;
            border: 2px solid white !important;
            overflow: hidden !important;
            position: relative !important;
      }

      .pls .avatar:before {
            content: "" !important;
            display: block !important;
            padding-top: 100% !important;
      }

      .pls .avatar img {
            position: absolute !important;
            top: 0 !important;
            left: 0 !important;
            right: 0 !important;
            bottom: 0 !important;
      }

      body {
            background: none !important;
      }
    `);

    const blockedUrls = [
      'unwanted-ad.js',
      'banner.jpg',
      'tracking.gif'
    ];

    const handleNode = (node) => {
      if (node.tagName === 'IMG' || node.tagName === 'SCRIPT') {
            blockedUrls.forEach(url => {
                if (node.src.includes(url)) {
                  if (node.tagName === 'IMG') node.src = '';
                  node.remove();
                }
            });
      }
      autoCloseAnnouncement(node);
    };

    const autoCloseAnnouncement = (node) => {
      const focusSelectors = [
            'div.focus#sitefocus',
            'div.focus#focus'
      ];

      let focusElement = null;

      focusSelectors.forEach(selector => {
            if (!focusElement && node.querySelector) {
                focusElement = node.querySelector(selector);
            }
      });

      if (!focusElement && node.nodeType === 1 && node.classList.contains('focus') &&
            (node.id === 'sitefocus' || node.id === 'focus')) {
            focusElement = node;
      }

      if (focusElement) {
            const closeButton = focusElement.querySelector('a');
            if (closeButton) {
                setTimeout(() => {
                  closeButton.click();
                }, 100);
            } else {
                focusElement.style.display = 'none';
            }
      }
    };

    const observer = new MutationObserver(mutations => {
      mutations.forEach(mutation => {
            mutation.addedNodes.forEach(node => {
                if (node.nodeType === 1) handleNode(node);
            });
      });
    });

    observer.observe(document, {
      childList: true,
      subtree: true
    });

    const processExistingContent = () => {
      blockedUrls.forEach(url => {
            document.querySelectorAll(`img, script`).forEach(el => el.remove());
      });

      autoCloseAnnouncement(document);
    };

    if (document.readyState === 'loading') {
      document.addEventListener('DOMContentLoaded', processExistingContent);
    } else {
      processExistingContent();
    }
})();

紫-漾 发表于 2025-8-19 19:36:05

脚本调整后面看着清爽不少,这个公告也是每次登录都要点一次,之前还以为是一次性提醒的{:6_175:}

凯诺斯 发表于 2025-8-19 19:45:49

不用手动去关闭公告了感觉还素很方便的惹:$

396149358 发表于 2025-8-19 19:49:19

终于不用手动点公告惹,虽然大多数都是直接让公告放在那里()

尘盏供月 发表于 2025-8-19 19:50:57

感谢楼主,强迫症每次都要点一下,更加方便在泥潭瑟瑟了。
追随用完了,明天点,白字为证。

远方传来风笛 发表于 2025-8-19 19:56:12

非常方便了 之前一直挡住挺难受的

枫叶UC 发表于 2025-8-19 19:59:23

要是能顺便把IP的安全提醒也一起关掉就更好了

Styphon 发表于 2025-8-19 20:05:16

终于不用点这个提醒了,强迫症福音

crabee 发表于 2025-8-19 20:11:35

很实用了,电脑上还好说,平板上这个小公告还是有点不方便的,当然公告已经熟读过了:loveliness:

娱乐法师火布偶 发表于 2025-8-19 20:12:47

这个公告确实一直都有,不过已经习惯了,懒得点掉

Lihajte 发表于 2025-8-19 20:16:29

好功能,确实如果可以已读不显示的话就更好了,每次都从下面弹出来老烦了

万俟 发表于 2025-8-19 20:25:14

强烈同意加入已读功能,右下角的弹框真的很烦

Yeries 发表于 2025-8-19 20:31:43

强迫症福音,每次上线都有这个弹窗确实挺烦的

Satopika 发表于 2025-8-19 20:37:15

还好吧,可能我用的是电脑,本人也没有强迫症,不过有这个脚本看着清爽了不少

Burry 发表于 2025-8-19 20:39:06

能把公告关闭这个功能挺好的,每次进网站都要弹出来挺麻烦的。

PKfire 发表于 2025-8-19 20:42:03

对于IP飞来飞去的人来说这小东西简直是究极折磨,所以我要把你简化出去了桀桀桀

月读命 发表于 2025-8-19 20:45:54

其实已经差不多习惯了,感觉关不关都没什么区别了。

lonong 发表于 2025-8-19 20:47:11

不需要手动关闭也是非常方便了{:6_197:}

小晨风 发表于 2025-8-19 20:54:47

看起来确实蛮有用的,虽然平时也不会去刻意关掉啦

拒绝敷敷99次 发表于 2025-8-19 20:59:32

比较好的一个优化呢,这样不会每次上线弹窗了:loveliness:
页: [1] 2 3 4
查看完整版本: GM简化1.3