Twitter Interests: Uncheck All

Unchecks all Interests on the Twitter/X Interests page

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

You will need to install an extension such as Tampermonkey to install this script.

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Twitter Interests: Uncheck All
// @license MIT
// @namespace    http://tampermonkey.net/
// @version      2024-05-25
// @description  Unchecks all Interests on the Twitter/X Interests page
// @author       You
// @match        https://twitter.com/settings/your_twitter_data/twitter_interests
// @match        https://x.com/settings/your_twitter_data/twitter_interests
// @icon         https://www.google.com/s2/favicons?sz=64&domain=x.com
// @grant        none
// ==/UserScript==

(function() {
        setTimeout(() => {
            var checkboxes = [];
            // we only really want to find those that are checked/ticked
            // so instead of looping over all of them (with an interval)
            // only loop over the checked ones, and put them into
            // the checkboxes array
            document.querySelectorAll('input[type="checkbox"]').forEach((c) => {
                if (c.checked) {
                    checkboxes[checkboxes.length] = c;
                }
            });
            var i = 0;

            var loopId = setInterval(() => {
                var e = checkboxes[i++];
                if (i % 10 == 0) { console.log("Running... (" + i + ")") } // added in to make it give some idea that it's working...
                if (e !== undefined) {
                    if (e.checked) {
                        console.log(e);
                        e.parentElement.click();
                    }
                } else {
                    clearInterval(loopId);
                }
            }, 650); // seems to be a good interval to not overload the API
        }, 4000);
})();