Fix Countdown Timer for PD3 Mask Mania Event

Fix the countdown timer to use Europe/Stockholm timeonze on paydaythegame.com

  1. // ==UserScript==
  2. // @name Fix Countdown Timer for PD3 Mask Mania Event
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.0
  5. // @description Fix the countdown timer to use Europe/Stockholm timeonze on paydaythegame.com
  6. // @author Hoppy
  7. // @match https://www.paydaythegame.com/payday3/updates/maskmania/*
  8. // @grant none
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. // Waiting for the page to load completely
  16. window.addEventListener('load', function() {
  17. // Adding a small delay to ensure all elements are fully loaded
  18. setTimeout(function() {
  19. // Waiting for luxon library to load
  20. function waitForLuxon(callback) {
  21. if (typeof luxon !== 'undefined') {
  22. callback();
  23. } else {
  24. setTimeout(function() {
  25. waitForLuxon(callback);
  26. }, 100);
  27. }
  28. }
  29.  
  30. waitForLuxon(function() {
  31. var DateTimeLastMask = luxon.DateTime;
  32.  
  33. const lastMaskStartDate = DateTimeLastMask.fromISO("2024-07-16T18:00:00", { zone: 'Europe/Stockholm' });
  34. const lastMaskEndDate = DateTimeLastMask.fromISO("2024-07-21T23:59:00", { zone: 'Europe/Stockholm' });
  35.  
  36. var lastMaskCountdown;
  37. var lastMaskProgressCountdown;
  38.  
  39. jQuery(document).ready(function() {
  40. jQuery(".lastmaskgreenscreen").removeClass("hide");
  41.  
  42. jQuery(".lastmaskinfopopup, .lastmaskgreenscreen").hide();
  43.  
  44. jQuery(".lastmaskinfopopup i.fa-xmark").click(function(){
  45. hideLastMaskInfoPopUp();
  46. });
  47.  
  48. jQuery(".lastmaskgreenscreen i.fa-xmark").click(function(){
  49. hideGreenScreen();
  50. });
  51.  
  52. jQuery(".lastmaskgreenscreentoggle").click(function(){
  53. showGreenScreen();
  54. });
  55.  
  56. lastMaskCountdown = setInterval(function(){
  57. doMaskTimers();
  58. }, 30000);
  59.  
  60. doMaskTimers();
  61.  
  62. lastMaskProgressCountdown = setInterval(function(){
  63. doMaskProgressBars();
  64. }, 600000);
  65.  
  66. doMaskProgressBars();
  67. });
  68.  
  69. function doMaskTimers(){
  70. const now = DateTimeLastMask.now().setZone('Europe/Stockholm');
  71. const remaining = lastMaskEndDate.diff(now);
  72.  
  73. var thisTimeLeft = remaining.shiftTo('days', 'hours', 'minutes').toObject();
  74.  
  75. if (thisTimeLeft.days >= 0) {
  76. jQuery(".lastmaskeventstatusinnerdaycount").text(thisTimeLeft.days);
  77. } else {
  78. jQuery(".lastmaskeventstatusinnerday").remove();
  79. }
  80.  
  81. if (thisTimeLeft.hours >= 0) {
  82. jQuery(".lastmaskeventstatusinnerhourcount").text(thisTimeLeft.hours);
  83. } else {
  84. if (thisTimeLeft.days == 0){
  85. jQuery(".lastmaskeventstatusinnerhour").remove();
  86. }
  87. }
  88.  
  89. if (thisTimeLeft.minutes >= 0) {
  90. jQuery(".lastmaskeventstatusinnermincount").text(parseInt(thisTimeLeft.minutes));
  91. } else {
  92. if (thisTimeLeft.hours == 0){
  93. jQuery(".lastmaskeventstatusinnermin").remove();
  94. }
  95. }
  96.  
  97. if (remaining.values.milliseconds < 0) {
  98. clearInterval(lastMaskCountdown);
  99.  
  100. jQuery(".lastmaskeventstatusinnertitle").html("<p><strong>This Event has now concluded</strong></p>");
  101. }
  102. }
  103. });
  104. }, 1000); // Adjust this delay as needed
  105. });
  106.  
  107. })();