Steam: Automatically check Subscriber Agreement checkboxes

Automatically checks Steam Subscriber Agreement checkboxes

目前为 2021-12-13 提交的版本。查看 最新版本

// ==UserScript==
// @name        Steam: Automatically check Subscriber Agreement checkboxes
// @namespace   zo8dd7kkrrnquyxs5yd2
// @match       https://store.steampowered.com/account/registerkey*
// @match       https://steamcommunity.com/*
// @grant       none
// @version     1.0
// @description Automatically checks Steam Subscriber Agreement checkboxes
// @inject-into content
// @run-at      document-end
// @license     MIT
// ==/UserScript==

(function () {
	"use strict";

	function run(unwrap = (x)=>x, exporter = (f)=>f) {
		const realCheckboxGetter = Reflect.getOwnPropertyDescriptor(unwrap(window.HTMLInputElement.prototype), "checked").get;
		const blockEvent = (event) => { event.preventDefault(); };
		const nop = exporter(() => {});

		const chocolates = ["accept_ssa", "market_sell_dialog_accept_ssa", "market_buyorder_dialog_accept_ssa"];

		for (let box of chocolates) {
			box = document.getElementById(box);

			if (box?.type === "checkbox") {
				box.checked = true;
				box.addEventListener("click", blockEvent);
				Reflect.defineProperty(unwrap(box), "checked", {
					enumerable: false,
					get: realCheckboxGetter,
					set: nop
				});
			}
		}
	}

	if (typeof globalThis.XPCNativeWrapper === "function") {
		// Firefox sandbox
		run(XPCNativeWrapper.unwrap, (f) => exportFunction(f, window));
	} else {
		// Chrome, just inject
		const script = document.createElement("script");
		script.text = `"use strict";(${run})();`;
		(document.head ?? document.documentElement).prepend(script);
		script.remove();
	}
})();

QingJ © 2025

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