您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Adds a conformation box before tweeting with media lacking alt text
- // ==UserScript==
- // @name Don't tweet without alt text
- // @description Adds a conformation box before tweeting with media lacking alt text
- // @author stick
- // @version 1
- // @homepageURL https://github.com/sticks-stuff/Dont-tweet-without-alt-text
- // @include https://twitter.*/*
- // @grant none
- // @require https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js
- // @require https://gf.qytechs.cn/scripts/31940-waitforkeyelements/code/waitForKeyElements.js
- // @namespace https://gf.qytechs.cn/users/710818
- // ==/UserScript==
- console.log("Don't tweet without alt text loaded!");
- waitForKeyElements ('[data-testid="tweetButton"][data-focusable="true"]', tweetButtonLoaded);
- waitForKeyElements ('[aria-label="Media"][role="group"]', imagesAdded);
- function tweetButtonLoaded (tweetButton)
- {
- console.log("hijacked tweet button");
- var tweetButtonReal = tweetButton[0];
- tweetButtonReal.dataset.testid = "hijacked";
- var clonedButton = $(tweetButtonReal).clone(true);
- var parentOfButton = $(tweetButtonReal).parent();
- console.log($(tweetButtonReal).data('events'));
- $(tweetButtonReal).hide();
- $(clonedButton).appendTo($(parentOfButton));
- $(clonedButton).click(function () {
- var attachmentsWithoutAlt = document.querySelectorAll('[aria-label="Media"][role="group"]').length;
- if(attachmentsWithoutAlt > 0) {
- var answer = window.confirm("You have " + attachmentsWithoutAlt + " attachments without alt text in this tweet. Are you sure you want to send?");
- if (answer) {
- $(clonedButton).remove();
- $(tweetButtonReal).click();
- $(tweetButtonReal).show();
- }
- else {
- console.log("cancelled");
- }
- } else {
- $(clonedButton).remove();
- $(tweetButtonReal).click();
- $(tweetButtonReal).show();
- }
- });
- }
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址