TBD Auto Rep & Thanks

Automates adding reputation and thanking uploader on TorrentBD

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name         TBD Auto Rep & Thanks
// @namespace    https://tanmoythebot.github.io/
// @version      1.0
// @description  Automates adding reputation and thanking uploader on TorrentBD
// @match        https://www.torrentbd.com/torrents-details.php?id=*
// @match        https://www.torrentbd.net/torrents-details.php?id=*
// @match        https://www.torrentbd.me/torrents-details.php?id=*
// @match        https://www.torrentbd.org/torrents-details.php?id=*
// @license      MIT
// @icon         https://www.torrentbd.net/themes/material/static/favicon/favicon-32x32.png
// @grant        none
// ==/UserScript==
 
(function() {
    'use strict';
 
    // Configuration options
    var config = {
        waitTimeout: 10000, // Timeout for waiting for elements (in ms)
        clickDelay: 500 // Delay between actions (in ms)
    };
 
    // Function to wait for an element to appear
    function waitForElement(selector, callback) {
        var interval = 100;
        var elapsed = 0;
        var checkInterval = setInterval(function() {
            var element = document.querySelector(selector);
            if (element) {
                clearInterval(checkInterval);
                callback(null, element);
            } else if (elapsed >= config.waitTimeout) {
                clearInterval(checkInterval);
                callback(new Error('Element ' + selector + ' not found within ' + config.waitTimeout + 'ms'));
            }
            elapsed += interval;
        }, interval);
    }
 
    // Function to click an element with delay
    function clickElement(selector, callback) {
        waitForElement(selector, function(err, element) {
            if (err) {
                console.error('Error clicking ' + selector + ':', err);
                return callback(err);
            }
            element.click();
            console.log('Clicked ' + selector);
            setTimeout(function() {
                callback(null);
            }, config.clickDelay);
        });
    }
 
    // Function to perform all actions
    function performActions() {
        clickElement('#add-rep-button', function(err) {
            if (err) return;
            clickElement('#thanks-button', function(err) {
                if (err) return;
                console.log('All actions performed successfully');
            });
        });
    }
 
    // Event listener for page load to start actions
    window.addEventListener('load', performActions);
 
    // Global error handling
    window.addEventListener('error', function(e) {
        console.error('Global error occurred:', e.error);
    });
})();