Steam Cracked Category with Deals

Adds buttons to Steam pages that searches for games on different websites on a new tab.

// ==UserScript==
// @name Steam Cracked Category with Deals
// @description Adds buttons to Steam pages that searches for games on different websites on a new tab.
// @version 1.2
// @license MIT
// @match https://store.steampowered.com/app/*
// @icon https://i.imgur.com/8CoJnwB.png
// @namespace
// @namespace https://gf.qytechs.cn/users/1167434
// ==/UserScript==

(function () {
  'use strict';

  let gameName = decodeURIComponent(window.location.pathname.split("/")[3].replace(/_/g, " "));
  let ignoreButton = document.querySelector("#ignoreBtn");

  function createContainer() {
    let container = document.createElement("div");
    container.style.marginTop = "50px";
    container.style.padding = "20px";
    container.style.background = "rgba(0, 0, 0, 0.2)";
    container.style.borderRadius = "10px";
    container.style.display = "flex";
    container.style.flexDirection = "column";
    container.style.gap = "30px";
    return container;
  }

  function createHeader(text) {
    let header = document.createElement("div");
    header.style.fontWeight = "bold";
    header.style.fontSize = "21px";
    header.style.marginBottom = "15px";
    header.style.textTransform = "uppercase";
    header.textContent = text;
    return header;
  }

  function createGridContainer() {
    let grid = document.createElement("div");
    grid.style.display = "grid";
    grid.style.gridTemplateColumns = "repeat(auto-fit, minmax(160px, 1fr))";
    grid.style.gap = "10px";
    return grid;
  }

  function createButton(url, buttonText, isRemovable = false) {
    let buttonContainer = document.createElement("div");
    buttonContainer.style.display = "flex";
    buttonContainer.style.alignItems = "center";
    buttonContainer.style.position = "relative";

    let button = document.createElement("a");
    button.className = "btnv6_blue_hoverfade btn_medium";
    button.style.display = "flex";
    button.style.alignItems = "center";
    button.style.justifyContent = "center";
    button.style.minWidth = "160px";
    button.style.height = "40px";
    button.style.textAlign = "center";
    button.style.cursor = "pointer";
    button.style.backgroundColor = "rgba(103, 193, 245, 0.2)";
    button.style.color = "#67c1f5";
    button.style.fontSize = "14px";
    button.style.borderRadius = "6px";
    button.href = url + encodeURIComponent(gameName);
    button.target = "_blank";
    button.textContent = buttonText;

    buttonContainer.appendChild(button);

    if (isRemovable) {
      let deleteButton = document.createElement("button");
      deleteButton.textContent = "✖";
      deleteButton.style.position = "absolute";
      deleteButton.style.top = "-5px";
      deleteButton.style.right = "-5px";
      deleteButton.style.background = "red";
      deleteButton.style.color = "white";
      deleteButton.style.border = "none";
      deleteButton.style.width = "20px";
      deleteButton.style.height = "20px";
      deleteButton.style.borderRadius = "50%";
      deleteButton.style.cursor = "pointer";

      deleteButton.onclick = () => buttonContainer.remove();

      buttonContainer.appendChild(deleteButton);
    }

    return buttonContainer;
  }

  function createInputSection(category, grid) {
    let isAdding = false;

    let addButton = document.createElement("button");
    addButton.textContent = "➕ Add";
    addButton.style.background = "#67c1f5";
    addButton.style.color = "white";
    addButton.style.border = "none";
    addButton.style.padding = "5px 10px";
    addButton.style.cursor = "pointer";
    addButton.style.borderRadius = "4px";

    let inputContainer = document.createElement("div");
    inputContainer.style.display = "none";
    inputContainer.style.gap = "5px";
    inputContainer.style.marginTop = "10px";

    let inputName = document.createElement("input");
    inputName.placeholder = "Site Name";
    inputName.style.flex = "1";

    let inputURL = document.createElement("input");
    inputURL.placeholder = "Search URL (use ?s= or ?q=)";
    inputURL.style.flex = "2";

    let confirmButton = document.createElement("button");
    confirmButton.textContent = "✅ Save";
    confirmButton.style.background = "green";
    confirmButton.style.color = "white";
    confirmButton.style.border = "none";
    confirmButton.style.padding = "5px 10px";
    confirmButton.style.cursor = "pointer";
    confirmButton.style.borderRadius = "4px";

    let cancelButton = document.createElement("button");
    cancelButton.textContent = "❌";
    cancelButton.style.background = "red";
    cancelButton.style.color = "white";
    cancelButton.style.border = "none";
    cancelButton.style.padding = "5px 10px";
    cancelButton.style.cursor = "pointer";
    cancelButton.style.borderRadius = "4px";

    addButton.onclick = () => {
      isAdding = !isAdding;
      inputContainer.style.display = isAdding ? "flex" : "none";
    };

    confirmButton.onclick = () => {
      let name = inputName.value.trim();
      let url = inputURL.value.trim();
      if (name && url) {
        let newButton = createButton(url, name, true);
        grid.appendChild(newButton);
        inputName.value = "";
        inputURL.value = "";
        inputContainer.style.display = "none";
        isAdding = false;
      }
    };

    cancelButton.onclick = () => {
      inputContainer.style.display = "none";
      isAdding = false;
    };

    inputContainer.appendChild(inputName);
    inputContainer.appendChild(inputURL);
    inputContainer.appendChild(confirmButton);
    inputContainer.appendChild(cancelButton);

    let section = document.createElement("div");
    section.appendChild(addButton);
    section.appendChild(inputContainer);
    return section;
  }

  let categoryContainer = createContainer();

  let crackedHeader = createHeader("CRACKED:");
  let crackedGrid = createGridContainer();
  [
    { url: "https://www.skidrowreloaded.com/?s=", text: "SkidrowReloaded" },
    { url: "https://igg-games.com/?s=", text: "IGG-Games" },
    { url: "https://x1337x.ws/srch?search=", text: "x1337x" },
    { url: "https://game3rb.com/?s=", text: "Game3rb" },
    { url: "https://online-fix.me/index.php?do=search&subaction=search&story=", text: "Onlinefix" },
    { url: "https://fitgirl-repacks.site/?s=", text: "Fitgirl Repacks" },
    { url: "https://dodi-repacks.site/?s=", text: "Dodi Repack" }
  ].forEach(site => crackedGrid.appendChild(createButton(site.url, site.text)));

  let dealsHeader = createHeader("DEALS:");
  let dealsGrid = createGridContainer();
  [
    { url: "https://store.epicgames.com/en-US/browse?q=", text: "Epic Games" },
    { url: "https://www.gog.com/en/games?query=", text: "GOG" },
    { url: "https://www.humblebundle.com/store/search?sort=discount&search=", text: "Humble Store" },
    { url: "https://www.gamestop.com/search/?q=", text: "GameStop" },
    { url: "https://www.cdkeys.com/catalogsearch/result/?q=", text: "CDKeys" },
    { url: "https://store.ubi.com/us/search?q=", text: "UPlay" },
    { url: "https://www.origin.com/store/search?fq=search&searchString=", text: "Origin" },
    { url: "https://www.greenmangaming.com/search?query=", text: "Green Man Gaming" },
    { url: "https://www.fanatical.com/en/search?search=", text: "Fanatical" },
    { url: "https://www.microsoft.com/en-us/store/search/games?q=", text: "Microsoft Store" }
  ].forEach(site => dealsGrid.appendChild(createButton(site.url, site.text)));

  categoryContainer.appendChild(crackedHeader);
  categoryContainer.appendChild(crackedGrid);
  categoryContainer.appendChild(createInputSection("cracked", crackedGrid));
  categoryContainer.appendChild(dealsHeader);
  categoryContainer.appendChild(dealsGrid);
  categoryContainer.appendChild(createInputSection("deals", dealsGrid));

  if (ignoreButton) {
    ignoreButton.parentNode.insertBefore(categoryContainer, ignoreButton.nextSibling);
  }
})();

QingJ © 2025

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