Thingiverse allow adding things to multiple collections

Enables the Collected button to be pressed to add an item to another collection - this additionally fixes the issue that the server does not update immediately once a thing has been removed from a collection, allowing you to immediately add to another one.

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

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

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

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

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

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

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Thingiverse allow adding things to multiple collections
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  Enables the Collected button to be pressed to add an item to another collection - this additionally fixes the issue that the server does not update immediately once a thing has been removed from a collection, allowing you to immediately add to another one.
// @author       H. J. Norden
// @match        https://www.thingiverse.com/thing:*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    let DONE = false;

    function get_collected_btn() {
        if (DONE) return;
        for (let el of document.getElementsByTagName("a")) {
            if (el.innerHTML === "Collected") {
                return el.parentNode;
            }
        }
    }

    function show_collection_window() {
        let el = document.getElementsByClassName("SidebarMenu__collectWindowWrapper--2dRST")[0];
        el.classList.remove("CollectThingWindow__hidden--OSA7G");
    }

    function hide_collection_window() {
        let el = document.getElementsByClassName("SidebarMenu__collectWindowWrapper--2dRST")[0];
        el.classList.add("CollectThingWindow__hidden--OSA7G");
    }

    function fix_collection_window_closing() {
        let close_btn = document.getElementsByClassName("CollectThingWindow__closeImageWraper--2oYuJ")[0];
        let save_btn = document.getElementsByClassName("CollectThingWindow__buttonWrapper--1rp4p")[0];
        close_btn.addEventListener("click", hide_collection_window);
        save_btn.addEventListener("click", hide_collection_window);
    }

    function enable_collection(from_button) {
        if (DONE) return;
        if (from_button === undefined) {
            console.log("Couldn't find 'Collected' button!");
            return;
        }

        fix_collection_window_closing();

        from_button.classList.remove("SideMenuItem__itemDisabled--pGJ7S");
        from_button.addEventListener("click", show_collection_window);

        DONE = true;
    }


    // Try multiple timeouts for different network conditions...
    setTimeout(function(){enable_collection(get_collected_btn());}, 100);
    setTimeout(function(){enable_collection(get_collected_btn());}, 500);
    setTimeout(function(){enable_collection(get_collected_btn());}, 2000);
    setTimeout(function(){enable_collection(get_collected_btn());}, 5000);

})();