SteamDB Auto Activate

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

当前为 2023-06-21 提交的版本,查看 最新版本

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