Steam: Automatically check Subscriber Agreement checkboxes

Automatically checks Steam Subscriber Agreement checkboxes

当前为 2021-12-13 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Steam: Automatically check Subscriber Agreement checkboxes
  3. // @namespace zo8dd7kkrrnquyxs5yd2
  4. // @match https://store.steampowered.com/account/registerkey*
  5. // @match https://steamcommunity.com/*
  6. // @grant none
  7. // @version 1.0
  8. // @description Automatically checks Steam Subscriber Agreement checkboxes
  9. // @inject-into content
  10. // @run-at document-end
  11. // @license MIT
  12. // ==/UserScript==
  13.  
  14. (function () {
  15. "use strict";
  16.  
  17. function run(unwrap = (x)=>x, exporter = (f)=>f) {
  18. const realCheckboxGetter = Reflect.getOwnPropertyDescriptor(unwrap(window.HTMLInputElement.prototype), "checked").get;
  19. const blockEvent = (event) => { event.preventDefault(); };
  20. const nop = exporter(() => {});
  21.  
  22. const chocolates = ["accept_ssa", "market_sell_dialog_accept_ssa", "market_buyorder_dialog_accept_ssa"];
  23.  
  24. for (let box of chocolates) {
  25. box = document.getElementById(box);
  26.  
  27. if (box?.type === "checkbox") {
  28. box.checked = true;
  29. box.addEventListener("click", blockEvent);
  30. Reflect.defineProperty(unwrap(box), "checked", {
  31. enumerable: false,
  32. get: realCheckboxGetter,
  33. set: nop
  34. });
  35. }
  36. }
  37. }
  38.  
  39. if (typeof globalThis.XPCNativeWrapper === "function") {
  40. // Firefox sandbox
  41. run(XPCNativeWrapper.unwrap, (f) => exportFunction(f, window));
  42. } else {
  43. // Chrome, just inject
  44. const script = document.createElement("script");
  45. script.text = `"use strict";(${run})();`;
  46. (document.head ?? document.documentElement).prepend(script);
  47. script.remove();
  48. }
  49. })();