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