Redbubble Auto Fav Free

The Redbubble Auto Fav automates favoriting on Redbubble

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Redbubble Auto Fav Free
// @namespace    https://greasyfork.org
// @version      1.0
// @description  The Redbubble Auto Fav automates favoriting on Redbubble
// @author       YAD
// @match        https://www.redbubble.com/shop/*
// @license      NO-REDISTRIBUTION
// @grant        none
// @icon         https://www.redbubble.com/boom/public/favicons/favicon.ico
// ==/UserScript==

(function() {
    'use strict';

    let isRunning = false;
    let likeQueue = [];
    let currentLikeIndex = 0;
    let delayBetweenClicks = 2000;
    let maxLikes = 250;
    let likesCount = 0;
    let lastLikeTime = 0;

    const buttonContainer = document.createElement('div');
    buttonContainer.style.position = 'fixed';
    buttonContainer.style.bottom = '20px';
    buttonContainer.style.right = '20px';
    buttonContainer.style.zIndex = '999999';
    document.body.appendChild(buttonContainer);

    const button = document.createElement('button');
    button.innerText = 'Start';
    button.style.width = '50px';
    button.style.height = '50px';
    button.style.borderRadius = '50%';
    button.style.backgroundColor = '#ff596f';
    button.style.color = '#fff';
    button.style.border = 'none';
    button.style.cursor = 'pointer';
    button.style.fontSize = '14px';
    button.style.textAlign = 'center';
    button.style.lineHeight = '50px';
    buttonContainer.appendChild(button);

    function startLiking() {
        const likeButtons = document.querySelectorAll('button[data-testid="add-to-list-button"], button[data-testid="favorite-button"]');
        likeQueue = Array.from(likeButtons).filter(button => !button.querySelector('img[data-testid="favourite-icon-remove"]'));

        if (likeQueue.length > 0) {
            currentLikeIndex = 0;
            processNextLike();
        } else {
            isRunning = false;
            button.innerText = 'Start';
        }
    }

    function processNextLike() {
        if (!isRunning || likesCount >= maxLikes) {
            isRunning = false;
            button.innerText = 'Start';
            return;
        }

        const now = Date.now();

        if (now - lastLikeTime >= delayBetweenClicks) {
            if (currentLikeIndex < likeQueue.length) {
                try {
                    const likeButton = likeQueue[currentLikeIndex];
                    likeButton.click();
                    lastLikeTime = now;
                    currentLikeIndex++;
                    likesCount++;
                    button.innerText = likesCount;
                    requestAnimationFrame(() => setTimeout(processNextLike, delayBetweenClicks));
                } catch (error) {
                    console.error("Error clicking like button", error);
                }
            } else {
                isRunning = false;
                button.innerText = 'Start';
            }
        } else {
            requestAnimationFrame(() => setTimeout(processNextLike, 50));
        }
    }

    button.addEventListener('click', function() {
        if (isRunning) {
            isRunning = false;
            button.innerText = 'Start';
        } else {
            isRunning = true;
            lastLikeTime = Date.now();
            button.innerText = likesCount;
            startLiking();
        }
    });

    document.addEventListener('DOMContentLoaded', function() {
        console.log('Page loaded and script initialized');
    });
})();