SteamDB Auto Activate

Автоматически активировать пакеты на сайте https://steamdb.info/freepackages/ и выводить отчет времени в консоли браузера.

  1. // ==UserScript==
  2. // @name SteamDB Auto Activate
  3. // @version 2.5
  4. // @description Автоматически активировать пакеты на сайте https://steamdb.info/freepackages/ и выводить отчет времени в консоли браузера.
  5. // @match https://steamdb.info/freepackages/*
  6. // @namespace Role_Play
  7. // @grant none
  8. // @license MIT
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. var countdownInterval;
  15.  
  16. function activatePackages() {
  17. clearInterval(countdownInterval);
  18. var activateButton = document.getElementById('js-activate-now');
  19. if (activateButton && activateButton.offsetParent !== null && !activateButton.classList.contains('btn-progress')) {
  20. activateButton.click();
  21. }
  22. }
  23.  
  24. function hideDemosAndLegacyMedia() {
  25. var hideButton = document.getElementById('js-hide-demos');
  26. if (hideButton && hideButton.offsetParent !== null && !hideButton.classList.contains('btn-progress')) {
  27. hideButton.click();
  28. setTimeout(hideDemosAndLegacyMedia, 1000);
  29. }
  30. }
  31.  
  32. function displayTimeReport() {
  33. var countdown = 30;
  34. var stopButton = document.createElement('button');
  35. stopButton.textContent = 'Stop';
  36. stopButton.style.position = 'fixed';
  37. stopButton.style.bottom = '10px';
  38. stopButton.style.right = '10px';
  39. stopButton.style.zIndex = '9999';
  40. stopButton.style.padding = '10px';
  41. stopButton.style.backgroundColor = '#3498db';
  42. stopButton.style.color = '#fff';
  43. stopButton.style.border = 'none';
  44. stopButton.style.cursor = 'pointer';
  45. document.body.appendChild(stopButton);
  46.  
  47. function updateReport() {
  48. console.log('%c Активация продуктов через: ' + countdown + ' сек.', 'color: #c0392b; font-size: 18px; font-weight: bold;');
  49. }
  50.  
  51. countdownInterval = setInterval(function() {
  52. countdown--;
  53. updateReport();
  54.  
  55. if (countdown <= 0) {
  56. clearInterval(countdownInterval);
  57. updateReport();
  58. activatePackages();
  59. stopButton.style.display = 'none';
  60. }
  61. }, 1000);
  62.  
  63. stopButton.addEventListener('click', function() {
  64. clearInterval(countdownInterval);
  65. console.log('%c Отчет времени остановлен.', 'color: #c0392b; font-size: 18px; font-weight: bold;');
  66. stopButton.style.display = 'none';
  67. });
  68.  
  69. window.addEventListener('keydown', function(event) {
  70. if (event.key.toLowerCase() === 's' && event.ctrlKey && !event.altKey && !event.shiftKey) {
  71. clearInterval(countdownInterval);
  72. stopButton.style.display = 'none';
  73. }
  74. });
  75. }
  76.  
  77. function delay(ms) {
  78. return new Promise(resolve => setTimeout(resolve, ms));
  79. }
  80.  
  81. delay(2000).then(() => {
  82. hideDemosAndLegacyMedia();
  83. });
  84.  
  85. displayTimeReport();
  86. })();