您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
12/13/2024, 9:41:45 PM
当前为
// ==UserScript== // @name SteamGifts Region Helper // @namespace Violentmonkey Scripts // @match https://www.steamgifts.com/giveaway/*/region-restrictions* // @match https://www.steamgifts.com/giveaways/new // @grant none // @version 1.3 // @author Lex // @description 12/13/2024, 9:41:45 PM // @license MIT // ==/UserScript== function regionRestrictionsPage() { const countryCodes = $("p.table__column__heading") .map((_, el) => $(el).text()) .map((_, el) => el.match(/\((\w{2})\)/)?.[1]) .get() .filter(code => code !== null) .join(" "); const textBox = $("<input>", { type: "text", value: countryCodes }); $(".page__heading").first().after(textBox); } const inputTextBox = $("<input>", { type: "text", style: "margin-bottom: 0.5em" }); function getCountryCodesInput() { const arr = inputTextBox.val().split(/[\s,]+/).filter(Boolean); const sgCodes = getSGCountryCodes(); const difference = (new Set(arr)).difference(new Set(sgCodes.keys())); if (difference.size) { alert("Some of your input country codes were not found in Steam Gifts!\n" + "Please fix this and try again.\nInvalid country codes: " + [...difference].join(", ")); return []; } return arr; } var _sgCountryCodes; function getSGCountryCodes() { if (_sgCountryCodes) return _sgCountryCodes const validCodes = new Map(); $("div[data-input='country_item_string'] > div").each(function(){ const name = $(this).data("name"); const code = name.substr(name.length-2); validCodes.set(code, $(this)); }) _sgCountryCodes = validCodes; return validCodes; } function addRegions() { const sgCodes = getSGCountryCodes(); getCountryCodesInput().forEach(code => { const regionElement = sgCodes.get(code); if (!regionElement.hasClass('is-selected')) regionElement.click(); }) } function removeRegions() { const sgCodes = getSGCountryCodes(); getCountryCodesInput().forEach(code => { const regionElement = sgCodes.get(code); if (regionElement.hasClass('is-selected')) regionElement.click(); }) } function newGiveawayPage() { const container = $("<div>", { style: "display: block; width: 100%; margin-top: 0.5em;", class: "is-hidden" }); container.append(inputTextBox); const applyButton = $("<button>", { type: "button", text: "Add Regions", style: "border: 1px solid black; padding: 1px 3px; border-radius: 3px" }).on("click", addRegions); const removeButton = $("<button>", { type: "button", text: "Remove Regions", style: "margin-left: 1.5em; border: 1px solid black; padding: 1px 3px; border-radius: 3px" }).on("click", removeRegions); container.append(applyButton); container.append(removeButton); const parentElement = $(".form_list[data-input='country_item_string']").first(); parentElement.after(container); // add onclick handlers to the Yes/No buttons const checkboxContainer = $("div:has(> input[name=region_restricted])").first(); const yesBox = checkboxContainer.find("div[data-checkbox-value=1]"); yesBox.on("click", function() { $(this).closest(".form__row").find(".is-hidden").removeClass("is-hidden").addClass("is-shown"); }) const noBox = checkboxContainer.find("div[data-checkbox-value=0]"); noBox.on("click", function() { $(this).closest(".form__row").find(".is-shown").removeClass("is-shown").addClass("is-hidden"); }) } if (window.location.href.includes("region-restrictions")) { regionRestrictionsPage(); } else { newGiveawayPage(); }
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址