|
增加了对公告的自动关闭 能不能加入“已读”功能哇 
发现主页和搜索页面和公告还不是一个东西

- // ==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[style*="width:90%; margin:0 auto;"],
- li.pm2,
- li.pm2 a.xi2[onclick*="showWindow('sendpm', this.href);"],
- ul[id^="nimba_sidebottom_"],
- div.focus#sitefocus,
- div.focus#focus,
- div.bm.h.cl[onclick*="setcookie('nofocus_forum'"],
- div.bm.h.cl[onclick*="setcookie('nofocus_6'"],
- 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[onclick*="setcookie"][onclick*="nofocus"]');
- 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[src*="${url}"], script[src*="${url}"]`).forEach(el => el.remove());
- });
- autoCloseAnnouncement(document);
- };
- if (document.readyState === 'loading') {
- document.addEventListener('DOMContentLoaded', processExistingContent);
- } else {
- processExistingContent();
- }
- })();
复制代码 |