Repository: PotcFdk/SteamDiscoveryQueueAutoSkipper Branch: master Commit: 2763bebcb700 Files: 7 Total size: 30.8 KB Directory structure: gitextract_vave2sv5/ ├── .gitignore ├── LICENSE ├── README.md ├── SteamDiscoveryQueueAutoSkipper.meta.js ├── SteamDiscoveryQueueAutoSkipper.user.js ├── eslint.config.js └── package.json ================================================ FILE CONTENTS ================================================ ================================================ FILE: .gitignore ================================================ /node_modules ================================================ FILE: LICENSE ================================================ Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "{}" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright {yyyy} {name of copyright owner} Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ================================================ FILE: README.md ================================================ # Steam Discovery Queue Auto-Skipper ## Supported Events / Features Currently confirmed working: - Steam Winter Sale 2023 (December 21 - January 04): auto-skipping discovery queue for a free trading card + auto-claiming free daily stickers ✅ ## Description This userscript automates several Steam event-related things. Primarily (and hence, the name) it auto-advances when it detects that you are viewing a Steam Discovery Queue item. During the **Steam Winter Sale 2023** you get one trading card for going through your queue once a day. This script makes it easier to stay lazy. If your browser/setup supports it, it does this is a speedy way. Multiple discovery queues are processed to get the maximum number of cards per day, if supported. ![Screenshot of the "Next in Queue" button](https://i.imgur.com/NuCCY8D.png) If something goes wrong, it auto-retries and/or tries simulating a normal press on the "Next in Queue"-button. This should make sure that minor issues are automatically resolved before the script can be manually fixed/adjusted for new events or site updates. ## Additional Functionality - Age-restricted apps are automatically unlocked (i.e. this script supports automating 18+ confirmations). This feature works outside of the discovery queues, too! - Finally, free daily stickers are also auto-claimed when they are detected. ## Sale The script is optimized for the Steam Winter Sale 2023. Support for some of the functionality, including automation of multiple queues (only one this year), along with other features, might not work with future sales. The script will be updated in such a case. ## Installation 1. Install [Violentmonkey](https://violentmonkey.github.io/get-it/) or another userscript addon such as Tampermonkey for your browser. 2. Open `https://github.com/PotcFdk/SteamDiscoveryQueueAutoSkipper/raw/master/SteamDiscoveryQueueAutoSkipper.user.js` or click [here](https://github.com/PotcFdk/SteamDiscoveryQueueAutoSkipper/raw/master/SteamDiscoveryQueueAutoSkipper.user.js). 3. Click `Install`. ## Issues? Feel free to [open an issue](https://github.com/PotcFdk/SteamDiscoveryQueueAutoSkipper/issues) in case you feel that something is not the way it should be. ## Credits Logo kindly provided by krys (krys#4143). ## Release Notes ### 1.0.0 (released 2024-11-08) - REFACTOR: Big code rearrangement - META: Add `@homepageURL` and `@supportURL` metadata fields to JS files - ORG: Start using git-flow with a (master/develop) branch layout - ORG: Add ESLint config - FIX: Two instances of `return` being used outside of a function (this should make the script a bit more compatible) ### 0.13.0 (released 2023-12-24) - NEW: Add a progress bar to the discovery queue handler. ### 0.12.0 (released 2022-12-22) - FIX: ItemRewards handling is now working again with this year's pages - FIX: possible login state detection issue, the new method should be a bit more reliable for now ### 0.11.1 (released 2021-12-25) - NEW: remove all "last checked" timestamps when not logged in - FIX: don't run and don't set the "last checked" timestamps for most features that require you to be logged in when not logged in ### 0.11 (released 2021-12-23) - NEW: winter sale 2021: Re-add ItemReward handler, and maybe this time we'll keep it in the script for future use! ### 0.10 (released 2021-01-13) - REMOVE: ItemReward handler (page/data is gone from the Steam pages) ### 0.9 (released 2020-12-29) - NEW: winter sale 2020: support for auto-claiming stickers (ItemReward) ### 0.8 (released 2020-12-25) - NEW: the script now notifies you when you can get cards by browsing the discovery queue ================================================ FILE: SteamDiscoveryQueueAutoSkipper.meta.js ================================================ // ==UserScript== // @author PotcFdk // @name Steam Discovery Queue Auto-Skipper // @namespace https://github.com/PotcFdk/SteamDiscoveryQueueAutoSkipper // @description Auto-clicks the "Next in Queue" button in Steam Discovery Queues. // @include http://store.steampowered.com/app/* // @include https://store.steampowered.com/app/* // @include http://store.steampowered.com/agecheck/app/* // @include https://store.steampowered.com/agecheck/app/* // @include http://store.steampowered.com/explore* // @include https://store.steampowered.com/explore* // @version 1.0.0 // @grant none // @icon https://raw.githubusercontent.com/PotcFdk/SteamDiscoveryQueueAutoSkipper/master/logo.png // @downloadURL https://raw.githubusercontent.com/PotcFdk/SteamDiscoveryQueueAutoSkipper/master/SteamDiscoveryQueueAutoSkipper.user.js // @updateURL https://raw.githubusercontent.com/PotcFdk/SteamDiscoveryQueueAutoSkipper/master/SteamDiscoveryQueueAutoSkipper.meta.js // @homepageURL https://github.com/PotcFdk/SteamDiscoveryQueueAutoSkipper // @supportURL https://github.com/PotcFdk/SteamDiscoveryQueueAutoSkipper/issues // ==/UserScript== ================================================ FILE: SteamDiscoveryQueueAutoSkipper.user.js ================================================ // ==UserScript== // @author PotcFdk // @name Steam Discovery Queue Auto-Skipper // @namespace https://github.com/PotcFdk/SteamDiscoveryQueueAutoSkipper // @description Auto-clicks the "Next in Queue" button in Steam Discovery Queues. // @match *://store.steampowered.com/* // @match *://store.steampowered.com/app/* // @match *://store.steampowered.com/agecheck/app/* // @match *://store.steampowered.com/explore* // @match *://store.steampowered.com/points* // @version 1.0.0 // @grant none // @icon https://raw.githubusercontent.com/PotcFdk/SteamDiscoveryQueueAutoSkipper/master/logo.png // @downloadURL https://raw.githubusercontent.com/PotcFdk/SteamDiscoveryQueueAutoSkipper/master/SteamDiscoveryQueueAutoSkipper.user.js // @updateURL https://raw.githubusercontent.com/PotcFdk/SteamDiscoveryQueueAutoSkipper/master/SteamDiscoveryQueueAutoSkipper.meta.js // @require https://cdn.jsdelivr.net/npm/protobufjs@7.1.2/dist/protobuf.js#sha256-6ae1445115d49dac60b8a69e37bd3a2eb6e42120d75f22879a9286b7061608ec // @homepageURL https://github.com/PotcFdk/SteamDiscoveryQueueAutoSkipper // @supportURL https://github.com/PotcFdk/SteamDiscoveryQueueAutoSkipper/issues // ==/UserScript== /* Steam Discovery Queue Auto-Skipper - Copyright (c) PotcFdk, 2015 - 2023 Project logo donated to the project by krys (krys#4143), 2020 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ const CONSTANTS = { HOUR: 60*60*1000 }; const STATE = {}; const SETUP = [ function () { let styleBg = '', styleAppendix = ''; switch ((new Date()).getMonth()) { case 11: styleBg = `background-size: 424px; background-image: repeating-linear-gradient(45deg, #ff0000, #af0000 13px, #1d6a00 6px, #1d4a00 30px); animation: moveGradient 5s linear infinite;`; styleAppendix = `@keyframes moveGradient { 0% { background-position: 0 0; /* Start position */ } 100% { background-position: -424px 0; /* End position */ } }`; break; default: styleBg = 'background-color: #ffcc6a;'; } const style = document.createElement('style'); style.innerHTML = `#queueActionsCtn::after { content: ''; position: absolute; top: 0; left: 0; width: 0px; transition: width 1s ease 0s; height: 100%; ${styleBg} } ${styleAppendix}`; document.getElementsByTagName('head')[0].appendChild(style); STATE.loadingBarAfterStyle = Array.from(style.sheet.cssRules).filter(rule => rule.selectorText === '#queueActionsCtn::after').map(rule => rule.style)[0]; }, function () { STATE.queueCountTotal = Number(document.getElementsByClassName('queue_sub_text')[0]?.textContent.match(/\d+/)[0] || 0); } ]; const HELPERS = { click: (obj) => { var evObj = new MouseEvent('click'); obj.dispatchEvent(evObj); window.addEventListener('load', function () { HELPERS.click(obj); }); }, hasLoginLink: () => Array.from(document.getElementsByClassName('global_action_link')) .filter(a => a.href) .filter(a => a.href .includes('login')).length > 0, hasAvatarClassElements: () => document.getElementsByClassName('playerAvatar').length > 0, isLoggedIn: () => !HELPERS.hasLoginLink() && HELPERS.hasAvatarClassElements(), isLoggedOut: () => HELPERS.hasLoginLink() && !HELPERS.hasAvatarClassElements(), getQueueCount: (doc) => { const _subtext = doc.getElementsByClassName('subtext')[0]; if (_subtext) { const queue_count_subtext = _subtext.innerHTML; let queue_count = parseInt(queue_count_subtext.replace(/[^0-9.]/g, ''), 10); if (isNaN(queue_count)) { const language = doc.documentElement.getAttribute('lang'); switch(language) { case 'de': queue_count = queue_count_subtext.includes(' eine ') ? 1 : 0; break; case 'fr': queue_count = queue_count_subtext.includes(' une ') ? 1 : 0; break; case 'it': queue_count = queue_count_subtext.includes(" un'altra ") ? 1 : 0; break; case 'pl': queue_count = queue_count_subtext.includes(' jedną ') ? 1 : 0; break; case 'ru': case 'uk': queue_count = queue_count_subtext.includes(' одну ') ? 1 : 0; break; default: queue_count = 0; } } return queue_count; } }, claim_sale_reward: (webapi_token) => { return fetch('https://api.steampowered.com/ISaleItemRewardsService/ClaimItem/v1?access_token=' + webapi_token, { 'credentials': 'omit', 'headers': { 'Content-Type': 'multipart/form-data; boundary=---------------------------90594386426341336747734585788' }, 'referrer': 'https://store.steampowered.com/points/shop', 'body': '-----------------------------90594386426341336747734585788\r\nContent-Disposition: form-data; name="input_protobuf_encoded"\r\n\r\n\r\n-----------------------------90594386426341336747734585788--\r\n', 'method': 'POST', 'mode': 'cors' }); }, setLoadingBarProgress: (percent) => { if (STATE.loadingBarAfterStyle && isFinite(percent)) STATE.loadingBarAfterStyle.width = Math.floor(Math.max(0, Math.min(100, percent))) + '%'; }, handleQueuePage: () => { const queueCountRemaining = Number(document.getElementsByClassName('queue_sub_text')[0]?.textContent.match(/\d+/)[0] || 0); const progress = 100 * (STATE.queueCountTotal - queueCountRemaining) / STATE.queueCountTotal; HELPERS.setLoadingBarProgress(progress); var btn = document.getElementsByClassName('btn_next_in_queue')[0]; if (btn) { var btn_text = btn.getElementsByTagName('span')[0]; var btn_subtext = document.getElementsByClassName('queue_sub_text')[0]; if (btn_text) { if (btn_subtext) { btn_text.textContent = 'Loading next item...'; btn_text.appendChild(document.createElement('br')); btn_text.appendChild(btn_subtext); } else { btn_text.textContent = 'Finishing Queue...'; } } } var ajax_failures = 0; function ajax () { var next_in_queue_form = document.getElementById('next_in_queue_form'); var xhr = new XMLHttpRequest(); xhr.responseType = 'document'; xhr.onreadystatechange = function () { if (xhr.readyState === 4 && xhr.status === 200) { var _2_next_in_queue_form = xhr.response.getElementById('next_in_queue_form'); if (_2_next_in_queue_form && _2_next_in_queue_form.length) { next_in_queue_form.parentNode.innerHTML = _2_next_in_queue_form.parentNode.innerHTML; HELPERS.handleQueuePage(); } else { location.href = next_in_queue_form.getAttribute('action'); } } else if (xhr.readyState === 4) { if (ajax_failures++ < 3) { console.log('Failed AJAX (HTTP status ' + xhr.status + '). Retrying (' + ajax_failures + '/3)...'); ajax(); } else { console.log('Failed AJAX (HTTP status ' + xhr.status + '). Retrying using the classic button click method...'); if (btn) HELPERS.click(btn); } } }; xhr.open('POST', next_in_queue_form.getAttribute('action'), true); var form = new FormData(); form.append('sessionid', next_in_queue_form.sessionid.value); form.append('appid_to_clear_from_queue', next_in_queue_form.appid_to_clear_from_queue.value); form.append('snr', next_in_queue_form.snr.value); xhr.send(form); } ajax(); } }; const HandlerResult = Object.freeze({ next: Symbol('next'), abort: Symbol('abort') }); const HANDLERS = [ ['errorPage', () => { const page = document.getElementsByTagName('BODY')[0].innerHTML; if (page.length < 100 || page.includes('An error occurred while processing your request') || page.includes('The Steam Store is experiencing some heavy load right now')) { location.reload(); return HandlerResult.abort; } }], ['ageGate1', () => { const app_agegate = document.getElementById('app_agegate'); if (app_agegate) { const btn_medium = app_agegate.getElementsByClassName('btn_medium'); if (btn_medium) { for (let i = 0; i < btn_medium.length; i++) { const onclick = btn_medium[i].getAttribute('onclick'); if (onclick && onclick.includes('HideAgeGate')) { HELPERS.click(btn_medium[i]); return HandlerResult.abort; } } } } }], ['ageGate2', () => { const ageYear = document.getElementById('ageYear'); if (ageYear) { ageYear.value = 1985; if (typeof DoAgeGateSubmit === 'function') { DoAgeGateSubmit(); return HandlerResult.abort; } else if (typeof ViewProductPage === 'function') { ViewProductPage(); return HandlerResult.abort; } } }], ['loggedOutCleanup', () => { if (HELPERS.isLoggedOut()) { delete localStorage.SteamDiscoveryQueueAutoSkipper_lastchecked; delete localStorage.SteamDiscoveryQueueAutoSkipper_freesticker_next_claim_time; return HandlerResult.abort; } }], ['discoveryQueue', () => { if (document.getElementsByClassName('btn_next_in_queue').length) { HELPERS.handleQueuePage(); return HandlerResult.abort; } }], ['multiDiscoveryQueueTrigger', () => { const refresh_queue_btn = document.getElementById('refresh_queue_btn'); if (refresh_queue_btn && (HELPERS.getQueueCount(document) >= 1)) { HELPERS.click(refresh_queue_btn); return HandlerResult.abort; } }], ['discoveryQueueDetectAndPrompt', () => { if (HELPERS.isLoggedIn() && (Date.now() - (localStorage.SteamDiscoveryQueueAutoSkipper_lastchecked || 0) > CONSTANTS.HOUR)) { fetch('https://store.steampowered.com/explore/', {credentials: 'include'}).then(r =>r.text().then(body => { const doc = new DOMParser().parseFromString(body, 'text/html'); if (HELPERS.getQueueCount(doc) > 0) ShowConfirmDialog('SteamDiscoveryQueueAutoSkipper', 'You seem to have remaining unlockable trading cards in your discovery queue!\n' + 'Do you want to start auto-exploring the queue now?', 'Yes!', 'No, remind me later.').done(function () { location.href = 'https://store.steampowered.com/explore/startnew'; }); else console.log('Queue count is 0'); localStorage.SteamDiscoveryQueueAutoSkipper_lastchecked = Date.now(); })); return HandlerResult.abort; } }], ['itemRewards', () => { if (HELPERS.isLoggedIn() && (Date.now() - (localStorage.SteamDiscoveryQueueAutoSkipper_freesticker_next_claim_time || 0) > 0)) { // I hope this is at least somewhat correct. At least it feels OK, so that means we're probably halfway there. const ItemRewardProtos = 'syntax="proto3";\ message CanClaimItemResponse {\ bool can_claim = 1;\ int32 next_claim_time = 2;\ }'; const ItemRewardProtoRoot = protobuf.parse(ItemRewardProtos, { keepCase: true }).root; const CanClaimItemResponse = ItemRewardProtoRoot.lookup('CanClaimItemResponse'); // First let's fetch one of the offer pages that we can grab the webapi token from. fetch('https://store.steampowered.com/greatondeck', { credentials: 'include' }).then(r => r.text().then(body => { localStorage.SteamDiscoveryQueueAutoSkipper_freesticker_next_claim_time = Date.now() + CONSTANTS.HOUR; const doc = new DOMParser().parseFromString(body, 'text/html'); const application_config = doc.getElementById('application_config'); const webapi_token = JSON.parse(application_config.getAttribute('data-loyalty_webapi_token')); // There it is! // Now let's actually ask the ISaleItemRewardsService if we can claim the item. fetch(`https://api.steampowered.com/ISaleItemRewardsService/CanClaimItem/v1?access_token=${webapi_token}&origin=https:%2F%2Fstore.steampowered.com&input_protobuf_encoded=CgdlbmdsaXNo`, { credentials: 'omit', mode: 'cors' }).then(r => r.arrayBuffer().then(body => { const response = CanClaimItemResponse.decode(new Uint8Array(body)); if (response.can_claim) { console.log('Claiming freesticker...'); HELPERS.claim_sale_reward(webapi_token).then(() => { ShowConfirmDialog('SteamDiscoveryQueueAutoSkipper', 'Auto-claimed a free sticker! Do you want to check your inventory now?', 'Yes!', 'No.').done(function () { location.href = 'https://steamcommunity.com/my/inventory'; }); }); } else if (typeof response.next_claim_time === 'number') { console.log(`Setting freesticker_next_claim_time to ${response.next_claim_time}`); localStorage.SteamDiscoveryQueueAutoSkipper_freesticker_next_claim_time = response.next_claim_time * 1000; } })); })); return HandlerResult.abort; } }] ]; /// RUN // 1. Setup SETUP.forEach((func, idx) => { console.log(`SETUP #${idx}...`); func(); }); // 2. Handlers for (let idx = 0; idx < HANDLERS.length; ++idx) { const handler = HANDLERS[idx]; const result = handler[1](); console.log(`Handler #${idx} / ${handler[0]} -> ${typeof result === 'symbol' ? result.toString() : result}`); if (result === HandlerResult.abort) { break; } else { continue; } } ================================================ FILE: eslint.config.js ================================================ import eslintJs from '@eslint/js'; import stylistic from '@stylistic/eslint-plugin'; import jsdoc from 'eslint-plugin-jsdoc'; import globals from 'globals'; export default [ eslintJs.configs.recommended, jsdoc.configs['flat/recommended'], { languageOptions: { globals: { ...globals.browser, 'ShowConfirmDialog': true, 'DoAgeGateSubmit': true, 'ViewProductPage': true, 'protobuf': true } } }, { ignores: [ 'dist' ] }, { plugins: { '@stylistic': stylistic }, rules: { '@stylistic/indent': [ 'error', 'tab' ], '@stylistic/linebreak-style': [ 'error', 'unix' ], '@stylistic/quotes': [ 'error', 'single', { 'avoidEscape': true } ], '@stylistic/semi': [ 'error', 'always' ], 'eqeqeq': [ 'error', 'always' ], 'no-unused-vars': [ 'warn', { varsIgnorePattern: '^_' } ], '@stylistic/space-before-function-paren': [ 'error', 'always' ], '@stylistic/function-call-spacing': [ 'error', 'never' ] } } ]; ================================================ FILE: package.json ================================================ { "name": "steamdiscoveryqueueautoskipper", "version": "0.0.0", "description": "https://github.com/PotcFdk/SteamDiscoveryQueueAutoSkipper", "private": true, "dependencies": {}, "devDependencies": { "@stylistic/eslint-plugin": "^2.10.1", "eslint": "^9.14.0", "eslint-plugin-jsdoc": "^50.4.3" }, "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "repository": { "type": "git", "url": "git+https://github.com/PotcFdk/SteamDiscoveryQueueAutoSkipper.git" }, "author": "PotcFdk", "license": "Apache-2.0", "bugs": { "url": "https://github.com/PotcFdk/SteamDiscoveryQueueAutoSkipper/issues" }, "homepage": "https://github.com/PotcFdk/SteamDiscoveryQueueAutoSkipper#readme" }