您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Automatically close the current inventory tab based on user-defined timer or when the inventory page expired
// ==UserScript== // @name Auto Close Inventory Tab // @namespace http://tampermonkey.net/ // @version 1.2 // @description Automatically close the current inventory tab based on user-defined timer or when the inventory page expired // @author Lucky11 // @match https://fairview.deadfrontier.com/onlinezombiemmo/DF3D/DF3D_InventoryPage.php?page=31* // @grant none // @license MIT // ==/UserScript== (function() { 'use strict'; // User-defined option to close even if not expired (true or false) const closeEvenIfNotExpired = false; // User-defined timer in seconds (set to 60 seconds by default) even if not expired const closeAfterSeconds = 60; // Function to check for the expired message function checkForExpiredMessage() { if (document.body.innerText.includes("This inventory page has expired.")) { window.close(); // Close the window if the message is found } } // Create a MutationObserver to watch for changes in the DOM const observer = new MutationObserver((mutations) => { mutations.forEach(() => { checkForExpiredMessage(); // Check for the expired message on each DOM update }); }); // Start observing the body for changes observer.observe(document.body, { childList: true, subtree: true }); checkForExpiredMessage(); // If closeEvenIfNotExpired is true, set a timeout to close the tab after the user-defined time if (closeEvenIfNotExpired) { setTimeout(() => { window.close(); // Close the window after the specified time }, closeAfterSeconds * 1000); // Convert seconds to milliseconds } })();