// ==UserScript== // @name 我的世界去除跳转网易提示 // @namespace https://github.com/marioplus/minecraft-net-easy-tips-remover // @version 1.0.2 // @author marioplus // @license GPL-3.0 // @icon https://www.google.com/s2/favicons?sz=64&domain=minecraft.net // @match https://www.minecraft.net/* // @run-at document-start // @description 去掉网易跳转提示提示 // @downloadURL none // ==/UserScript== (function () { 'use strict'; var __defProp = Object.defineProperty; var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; var __publicField = (obj, key, value) => { __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); return value; }; class ElementCreateListener { constructor(mode = "auto") { __publicField(this, "_observer"); __publicField(this, "_mHandlers", /* @__PURE__ */ new Map()); __publicField(this, "status", "stop"); __publicField(this, "mode"); this.mode = mode; this._observer = new MutationObserver((mutations) => mutations.forEach((mutation) => { if (mutation.type !== "childList") { return; } if (mutation.target.nodeType !== Node.ELEMENT_NODE) { return; } if (mutation.addedNodes.length === 0) { return; } Object.values(mutation.addedNodes).filter((node) => node.nodeType === Node.ELEMENT_NODE && node instanceof HTMLElement).forEach((node) => { const addElement = node; this._mHandlers.forEach((handler, selector) => { var _a; if (addElement.matches(selector)) { this.safeCallHandler(handler, addElement, selector); } else { (_a = addElement.querySelectorAll(selector)) == null ? void 0 : _a.forEach((subElement) => { this.safeCallHandler(handler, subElement, selector); }); } }); }); })); } safeCallHandler(handler, element, selector) { if (!(element instanceof HTMLElement)) { return; } try { handler(element, selector); } catch (error) { console.error(`Error executing handler for selector ${selector}:`, error); } } register(selector, callback) { this._mHandlers.set(selector, callback); if (this.mode === "auto") { this.start(); } return this; } unregister(...selectors) { selectors.forEach((selector) => this._mHandlers.delete(selector)); if (this._mHandlers.size === 0) { this.stop(); } return this; } clear() { this._mHandlers.clear(); this.stop(); return this; } start() { if (this.status === "stop") { this.status = "start"; this._observer.observe(document.documentElement, { childList: true, subtree: true }); } return this; } stop() { this.status = "stop"; this._observer.disconnect(); return this; } stopTimeout(timeout) { setTimeout(() => this.stop(), timeout); return this; } } function skip(el) { setTimeout(() => el == null ? void 0 : el.click(), 100); } const listener = new ElementCreateListener("auto").stopTimeout(1e3 * 5); [ "#netease-promotion-modal button#popup-btn.btn.btn-link", 'button[aria-label="继续浏览该网站"]' ].forEach((selector) => { document.querySelectorAll(selector).forEach((el) => skip(el)); listener.register(selector, (el) => skip(el)); }); })();