SteamGifts Region Helper

12/13/2024, 9:41:45 PM

目前為 2024-12-14 提交的版本,檢視 最新版本

// ==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.0
// @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
  });


  const parentElement = $($(".page__heading")[0]);
  parentElement.after(textBox);
}

const inputTextBox = $("<input>", {
  type: "text",
  value: ""
});

function applyGiveaways() {
  console.log("applyGiveaways");
  const list = inputTextBox.val();
  const arr = list.split(" ");
  for (i = 0; i < arr.length; i++) {
    $("div[data-input='country_item_string'] > div")
      .each(function() {
        const name = $(this).data("name");
        if (name.substr(name.length-2) == arr[i])
          $(this).click()
    });
  }
}

function newGiveawayPage() {
  const container = $("<div>", {
    style: "display: block; width: 100%"
  });
  container.append(inputTextBox);
  const applyButton = $("<button>", {
    type: "button",
    text: "Apply"
  }).on("click", applyGiveaways);
  container.append(applyButton);

  const parentElement = $($(".form_list[data-input='country_item_string']")[0]);
  parentElement.after(container);
}


if (window.location.href.includes("region-restrictions")) {
  regionRestrictionsPage();
} else {
  newGiveawayPage();
}

QingJ © 2025

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