RealDebrid Time Conversion

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

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 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);
})();