Makima 发表于 2025-6-10 12:44:53

【脚本】GM小电视(屏蔽小电视图片

使用了一下发现从其他网页跳转会首页会失效紧急修复了一下应该会好不少
刚刚下载了的可以试试这个新版
效果be like:防止被命大的镇楼图喜出柜https://img.gamemale.com/forum/202506/10/102311hiki4nh71v7vdgzi.jpg
@Name@Match
// ==UserScript==
// @name         GM小电视
// @namespace    2568
// @version      0.2
// @description首页小电视显示or不显示
// @author       MKM
// @match      https://www.gamemale.com/*
// @grant      GM_setValue
// @grant      GM_getValue
// @run-at       document-start
// ==/UserScript==


(function() {
    'use strict';

    const config = {
      titleSelector: '.titletext a',
      contentSelector: '.slidebox',
      btnClass: 'gm-toggle-btn-ultimate',
      storageKey: 'gm_slidebox_state_v3'
    };

    let currentState = GM_getValue(config.storageKey, false);
    let buttonCreated = false;

    function applyInitialState() {
      const existingStyle = document.getElementById('gm-slidebox-initial-style');
      if (!existingStyle) {
            const style = document.createElement('style');
            style.id = 'gm-slidebox-initial-style';
            style.textContent = `${config.contentSelector} { display: ${currentState ? 'block' : 'none'} !important; }`;
            document.head.appendChild(style);
      }
    }

    function createButton() {
      if (buttonCreated) return;

      const title = document.querySelector(config.titleSelector);
      if (!title) {
            setTimeout(createButton, 200);
            return;
      }

      if (title.parentNode.querySelector('.' + config.btnClass)) {
            buttonCreated = true;
            return;
      }

      const btn = document.createElement('a');
      btn.className = config.btnClass;
      btn.style.cssText = 'cursor:pointer;margin-left:10px;color:#efe8e4!important;font-size:12px;text-decoration:none;';
      btn.textContent = currentState ? '[隐藏]' : '[显示]';
      title.parentNode.insertAdjacentElement('afterend', btn);
      buttonCreated = true;

      btn.addEventListener('click', function() {
            currentState = !currentState;
            GM_setValue(config.storageKey, currentState);
            updateContentVisibility();
            btn.textContent = currentState ? '[隐藏]' : '[显示]';
      });
    }

    function updateContentVisibility() {
      const style = document.getElementById('gm-slidebox-initial-style') || document.createElement('style');
      style.id = 'gm-slidebox-initial-style';
      style.textContent = `${config.contentSelector} { display: ${currentState ? 'block' : 'none'} !important; }`;
      if (!style.parentNode) {
            document.head.appendChild(style);
      }
    }

    applyInitialState();

    const observer = new MutationObserver(function(mutations) {
      if (!buttonCreated) {
            createButton();
      }
    });

    if (document.readyState === 'complete') {
      createButton();
    } else {
      document.addEventListener('DOMContentLoaded', createButton);
    }

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

    setInterval(function() {
      if (!buttonCreated) {
            createButton();
      }
    }, 1000);
})();

诺鸦cc 发表于 2025-6-10 12:52:42

感谢楼主制作这个jio本,有的时候首页电视图片真的)很劲爆)

娱乐法师火布偶 发表于 2025-6-10 12:52:51

修复了bug应该会更方便使用了

凯诺斯 发表于 2025-6-10 13:07:41

能够不显示图片还是很棒的惹,我个人不太敢用办公电脑看你坛:$

找乐子企鹅仔 发表于 2025-6-10 13:08:41

这个可太有用了(つд⊂),在首页看到文学区命大图真的会鼠掉

前方无怪 发表于 2025-6-10 13:17:34

ww现在可以光明正大的在课堂上打开论坛首页了(以前不太敢就是因为首页图片太爆裂了哈哈哈)

YangGuangSN 发表于 2025-6-10 13:24:05

好强大佬,虽然我用不到,但是必须给技术大佬一个点赞。关注了!

辰翊 发表于 2025-6-10 13:24:14

应该对有些坛友很有用呢{:6_169:}我应该只会在私密的场景下逛泥潭吧

柿请夏 发表于 2025-6-10 13:55:44

好牛的技术大佬,感谢分享,以后我就是命大的继女惹

【周年限定】森 发表于 2025-6-10 13:56:06

感谢大佬,很不错的脚本捏~再也不怕别人看见小电视里的瑟瑟了

未闻青葵 发表于 2025-6-10 13:58:31

你坛是这样的,有时候真的会被命大镇楼图吓鼠,有了这个就能更好地掩饰了,有时候在外面也会忍不住打开的

SweetUncle 发表于 2025-6-10 14:33:03

我一般用手机看耶~不太能被发现小电视的瑟瑟,不过技术力拉满了~很感谢大佬的JB

rayyyyy 发表于 2025-6-10 14:48:15

这下可以不用担心别人走过来一眼看到什么劲爆内容了

Blanco 发表于 2025-6-10 16:12:47

好美,谁懂打开泥潭看到打如码的大吉吉男人的救赎感

PURO_ 发表于 2025-6-10 17:15:30

对于身边经常有人的友友来说非常有用,这下可以稍微放心地点开泥潭了;P

mintea 发表于 2025-6-10 21:18:14

感谢分享,很适合多人家庭,避免突然有人闯入房间看到不该看的东西:$

相见忧 发表于 2025-6-10 22:29:55

在外面打开泥潭的第一件事,窗口缩小化。现在有这个脚本就可以无忧无虑打开论坛了

you9632587 发表于 2025-6-11 07:09:16

屏蔽小电视真的很重要,时不时就有一些很命大的图片出现

parting 发表于 2025-6-11 08:11:03

再也不用担心被迫出柜靴靴;P
有好几次看到那个镇楼图都被吓鼠惹

柏芸 发表于 2025-6-11 14:52:21

太需要这个脚本了真的,前面还在文学区看到很命大的配图;P
页: [1] 2
查看完整版本: 【脚本】GM小电视(屏蔽小电视图片