GOTOES Fit File Editor - Auto Close Popup

Automatically clicks the close button on popup donation nag

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         GOTOES Fit File Editor - Auto Close Popup
// @namespace    typpi.online
// @version      2024.11.06
// @description  Automatically clicks the close button on popup donation nag
// @author       Nick2bad4u
// @match        https://gotoes.org/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=gotoes.org
// @grant        none
// @homepageURL  https://github.com/Nick2bad4u/UserStyles
// @supportURL   https://github.com/Nick2bad4u/UserStyles/issues
// @license      UnLicense
// ==/UserScript==

(function () {
	'use strict';

	// Function to click the close button
	function closePopup() {
		const popupContent = document.querySelector(
			'a[href="https://gotoes.org/stravatoolsforum/viewtopic.php?f=2&t=115"] h3',
		);
		console.log('closePopup: popupContent', popupContent);
		if (
			popupContent &&
			popupContent.innerHTML.includes('Option 2:<br>Help Others (FREE)')
		) {
			const closeButton = document.getElementById('cboxClose');
			console.log('closePopup: closeButton', closeButton);
			if (closeButton) {
				closeButton.click();
				console.log('closePopup: closeButton clicked');
			}
		}
	}

	// Observe changes in the DOM to detect when the popup appears
	const observer = new MutationObserver(() => {
		const popupContent = document.querySelector(
			'a[href="https://gotoes.org/stravatoolsforum/viewtopic.php?f=2&t=115"] h3',
		);
		console.log('MutationObserver: popupContent', popupContent);
		if (popupContent) {
			closePopup();
		}
	});
	observer.observe(document.body, {
		childList: true,
		subtree: true,
	});

	// Initial check in case the popup is already present
	const popupContent = document.querySelector(
		'a[href="https://gotoes.org/stravatoolsforum/viewtopic.php?f=2&t=115"] h3',
	);
	console.log('Initial check: popupContent', popupContent);
	if (popupContent) {
		closePopup();
	}
})();