RealDebrid Time Conversion

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

  1. // ==UserScript==
  2. // @name RealDebrid Time Conversion
  3. // @description Converts the server's generated time to the browser or system internet time on Real-Debrid downloads page
  4. // @icon none
  5. // @version 0.1
  6. // @author Overshields (https://www.reddit.com/user/Overshields)
  7. // @license MIT
  8. // @match https://real-debrid.com/downloads
  9. // @grant none
  10. // @namespace https://greasyfork.org/users/1142602
  11. // ==/UserScript==
  12.  
  13.  
  14. (function() {
  15. 'use strict';
  16.  
  17. // Function to convert displayed time to local time
  18. function convertTime() {
  19. const tdElements = document.querySelectorAll('td'); // Get all td elements on the page
  20.  
  21. // Loop through each td element
  22. for (const td of tdElements) {
  23. const dateStr = td.textContent.trim();
  24. const dateRegex = /\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/;
  25.  
  26. if (dateRegex.test(dateStr)) {
  27. const utcDate = new Date(dateStr + ' UTC'); // Convert the date string to a UTC date object
  28. const localDate = new Date(utcDate.getTime() + (new Date().getTimezoneOffset() * 60000)); // Convert to local time
  29.  
  30. // Format the local date as 'YYYY-MM-DD HH:mm:ss'
  31. const formattedDate = localDate.toISOString().slice(0, 19).replace('T', ' ');
  32.  
  33. // Replace the content of the td element with the formatted local date
  34. td.textContent = formattedDate;
  35. }
  36. }
  37. }
  38.  
  39. // Call the function to convert the time once the page is fully loaded
  40. window.addEventListener('load', convertTime);
  41. })();