SteamDB Auto Activate

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

目前为 2023-04-25 提交的版本。查看 最新版本

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