SteamDB Auto Activate

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

目前為 2023-06-21 提交的版本,檢視 最新版本

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