RealDebrid Time Conversion

Converts the server's generated time to the browser or system internet time on Real-Debrid downloads page

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         RealDebrid Time Conversion
// @description  Converts the server's generated time to the browser or system internet time on Real-Debrid downloads page
// @icon         none
// @version      0.1
// @author       Overshields (https://www.reddit.com/user/Overshields)
// @license      MIT
// @match        https://real-debrid.com/downloads
// @grant        none
// @namespace https://greasyfork.org/users/1142602
// ==/UserScript==


(function() {
    'use strict';

    // Function to convert displayed time to local time
    function convertTime() {
        const tdElements = document.querySelectorAll('td'); // Get all td elements on the page

        // Loop through each td element
        for (const td of tdElements) {
            const dateStr = td.textContent.trim();
            const dateRegex = /\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/;

            if (dateRegex.test(dateStr)) {
                const utcDate = new Date(dateStr + ' UTC'); // Convert the date string to a UTC date object
                const localDate = new Date(utcDate.getTime() + (new Date().getTimezoneOffset() * 60000)); // Convert to local time

                // Format the local date as 'YYYY-MM-DD HH:mm:ss'
                const formattedDate = localDate.toISOString().slice(0, 19).replace('T', ' ');

                // Replace the content of the td element with the formatted local date
                td.textContent = formattedDate;
            }
        }
    }

    // Call the function to convert the time once the page is fully loaded
    window.addEventListener('load', convertTime);
})();