From 16f80568670501f44330ea63f01dd7692ffb71eb Mon Sep 17 00:00:00 2001 From: Ching L Date: Mon, 3 Nov 2025 11:01:48 +0800 Subject: [PATCH] feat: add mastodon alt text modal auto-skip script MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Created new Tampermonkey script to automatically skip Alt text confirmation modal on Mastodon - Auto-detects and clicks "就这样发布" button when posting images without alt text - Uses MutationObserver for efficient DOM monitoring - Updated README with script documentation and usage instructions --- README.md | 36 ++++++++++++++++-- mastodon-skip-alt-modal.user.js | 66 +++++++++++++++++++++++++++++++++ 2 files changed, 98 insertions(+), 4 deletions(-) create mode 100644 mastodon-skip-alt-modal.user.js diff --git a/README.md b/README.md index 95fe800..578e6e8 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,34 @@ --- -### 2. Sort Jable Videos by Like Count (`sortbylikecount.js`) +### 2. Mastodon 自动跳过图片 Alt 提示 (`mastodon-skip-alt-modal.user.js`) + +在 Mastodon 发送带图片的消息时自动跳过 Alt 文本提示弹窗的脚本。 + +#### 功能特性 + +- 自动检测 Alt 文本提示弹窗 +- 自动点击"就这样发布"按钮 +- 无需手动确认,提升发布效率 +- 使用 MutationObserver 监听 DOM 变化,确保及时响应 +- 控制台日志输出,方便调试 + +#### 适用网站 + +- https://nofan.xyz +- 其他 Mastodon 实例(可能需要调整 @match 规则) + +#### 安装使用 + +1. 安装 Tampermonkey 扩展 +2. 打开脚本文件 `mastodon-skip-alt-modal.user.js` +3. 复制内容到 Tampermonkey 新建脚本 +4. 保存并启用脚本 +5. 访问 Mastodon 网站,上传图片并点击发布,脚本会自动跳过 Alt 提示 + +--- + +### 3. Sort Jable Videos by Like Count (`sortbylikecount.js`) 按点赞数排序 Jable 视频的脚本。 @@ -66,7 +93,8 @@ ``` tampermonkey-script/ -├── README.md # 本文档 -├── 51cg-helper.user.js # 51吃瓜网助手脚本 -└── sortbylikecount.js # Jable 排序脚本 +├── README.md # 本文档 +├── 51cg-helper.user.js # 51吃瓜网助手脚本 +├── mastodon-skip-alt-modal.user.js # Mastodon 自动跳过 Alt 提示脚本 +└── sortbylikecount.js # Jable 排序脚本 ``` diff --git a/mastodon-skip-alt-modal.user.js b/mastodon-skip-alt-modal.user.js new file mode 100644 index 0000000..5434d40 --- /dev/null +++ b/mastodon-skip-alt-modal.user.js @@ -0,0 +1,66 @@ +// ==UserScript== +// @name Mastodon 自动跳过图片 Alt 提示 +// @namespace http://tampermonkey.net/ +// @version 1.0.0 +// @description 在 Mastodon 发送带图片的消息时自动跳过 Alt 文本提示弹窗 +// @author Your Name +// @match https://nofan.xyz/* +// @grant none +// @run-at document-end +// ==/UserScript== + +(function() { + 'use strict'; + + console.log('Mastodon Alt Modal Skipper 已加载'); + + // 自动点击"就这样发布"按钮 + function autoClickConfirm() { + // 查找所有按钮 + const buttons = document.querySelectorAll('button'); + + for (const button of buttons) { + const buttonText = button.textContent.trim(); + + // 精确匹配"就这样发布"按钮 + if (buttonText === '就这样发布') { + console.log('找到"就这样发布"按钮,自动点击'); + button.click(); + return true; + } + } + + return false; + } + + // 监听 DOM 变化,检测模态框出现 + const observer = new MutationObserver(function(mutations) { + for (const mutation of mutations) { + if (mutation.addedNodes.length) { + // 检查是否有新增的按钮包含"就这样发布"文字 + const buttons = document.querySelectorAll('button'); + + for (const button of buttons) { + if (button.textContent.trim() === '就这样发布') { + console.log('检测到 Alt 文本提示模态框'); + + // 稍微延迟以确保按钮完全可点击 + setTimeout(() => { + autoClickConfirm(); + }, 100); + + return; + } + } + } + } + }); + + // 开始观察整个 body + observer.observe(document.body, { + childList: true, + subtree: true + }); + + console.log('Mastodon Alt Modal Skipper 初始化完成,等待"就这样发布"按钮出现'); +})();