Twitter Interests: Uncheck All

Unchecks all Interests on the Twitter/X Interests page

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 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);
})();