|
|
使用了一下发现从其他网页跳转会首页会失效 紧急修复了一下 应该会好不少
刚刚下载了的可以试试这个新版
效果be like: 防止被命大的镇楼图喜出柜
@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[href*="space&do=album"]',
- 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);
- })();
复制代码
|
评分
-
| 参与人数 4 | 血液 +14 |
追随 +2 |
堕落 +4 |
收起
理由
|
书の妖怪
| + 3 |
|
+ 1 |
喜翻儿 |
提尔特
| + 1 |
|
+ 1 |
喜翻儿 |
相见忧
| + 5 |
+ 1 |
+ 1 |
三连献上 |
前方无怪
| + 5 |
+ 1 |
+ 1 |
NICEEEEEE! |
查看全部评分
|