浏览Steam时自动领取Steam贴纸

自动领取各种Steam促销活动中的贴纸奖励(如果有)

  1. // ==UserScript==
  2. // @name 浏览Steam时自动领取Steam贴纸
  3. // @name:zh 浏览Steam时自动领取Steam贴纸
  4. // @name:en Auto claim Steam stickers when browsing Steam
  5. // @namespace https://github.com/UnluckyNinja
  6. // @version 0.2.2
  7. // @description 自动领取各种Steam促销活动中的贴纸奖励(如果有)
  8. // @description:en Auto claim sticker rewards in various steam sales (if any)
  9. // @author UnluckyNinja
  10. // @license MIT
  11. // @match https://store.steampowered.com/*
  12. // @icon https://www.google.com/s2/favicons?sz=64&domain=steampowered.com
  13. // @grant none
  14. // ==/UserScript==
  15.  
  16. (async function() {
  17. 'use strict';
  18.  
  19. function log(text){
  20. console.log(`[自动领促销贴纸油猴脚本] ${text}`)
  21. }
  22.  
  23. // 为避免脚本在促销期之外进行不必要的请求,超过时间直接跳过
  24. // 不过请求量一天一次已经很低了,就一直开着吧,也省得手动更新了
  25. // if (Date.now() > new Date('2023-05-24').getTime()) {
  26. // log('为避免不必要的请求自动跳过,你可以手动修改行为(注释脚本内这两行),或者等待下次更新')
  27. // return
  28. // }
  29.  
  30. // before any request, check if there is a web api token on the page, if not, request to a valid page, if no valid response again, take it as not claimable
  31. let webapi_token = null
  32. if( window.application_config?.dataset?.loyalty_webapi_token){
  33. webapi_token = JSON.parse(window.application_config.dataset.loyalty_webapi_token)
  34. } else {
  35. const res = await fetch('/category/action')
  36. const html = await res.text()
  37. const doc = new DOMParser().parseFromString(html, 'text/html')
  38. const token = doc.getElementById('application_config')?.dataset?.loyalty_webapi_token
  39. if (!token){
  40. log('未找到有效api token,是否未登录(不可用)?')
  41. return
  42. }
  43. webapi_token = JSON.parse(token)
  44. }
  45.  
  46. // can claim check
  47. const res = await fetch(`https://api.steampowered.com/ISaleItemRewardsService/CanClaimItem/v1/?access_token=${webapi_token}`)
  48. const json = await res.json()
  49.  
  50. const can_claim = !!json.response?.can_claim
  51. const next_claim_time = json.response?.next_claim_time
  52.  
  53. // request to /ClaimItem
  54. if(can_claim){
  55. await fetch(`https://api.steampowered.com/ISaleItemRewardsService/ClaimItem/v1/?access_token=${webapi_token}`, { method: 'POST'})
  56. log('领取完成')
  57. } else {
  58. if(next_claim_time){
  59. log('今日已领取,下次领取时间在:'+new Date(next_claim_time * 1000).toLocaleString())
  60. } else {
  61. log('无可领取内容,跳过')
  62. }
  63. }
  64. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址