SteamGifts Trades - Have List Filter

Check if you own the games from someone's have list (instant Compare2Steam)

目前為 2016-10-28 提交的版本,檢視 最新版本

// ==UserScript==
// @name         SteamGifts Trades - Have List Filter
// @namespace    Royalgamer06
// @version      0.4
// @description  Check if you own the games from someone's have list (instant Compare2Steam)
// @author       Royalgamer06
// @match        https://www.steamtrades.com/trade/*
// @grant        GM_xmlhttpRequest
// @grant        GM_setValue
// @grant        GM_getValue
// ==/UserScript==

//If you want to set your SteamID64 manually, do it here.
var manual_steamID = "";

//Set your steam sync interval in hours.
var sync_interval = 4;

//Do not touch below :)
$(document).ready(function() {
    $(".have").parent().find(".trade_heading").first().html("I have... (<a href='javascript:void(0)' id='filter' title='Check have-list for owned games. \nWarning: It may become unresponsive for a while.'>Filter</a>)");
    $("#filter").click(function() {
        if (manual_steamID.length == 17) {
            syncHandler(manual_steamID);
        } else if (GM_getValue("steamID") !== undefined) {
            syncHandler(GM_getValue("steamID"));
        } else {
            $.get($(".nav__avatar-outer-wrap").attr("href"), function(data) {
                var steamID = $(".sidebar__shortcut-inner-wrap a", data).attr("href").split("profiles/")[1];
                if (steamID.length == 17) {
                    GM_setValue("steamID", steamID);
                    syncHandler(steamID);
                } else {
                    alert("[Have List Filter] ERROR: Could not fetch steamID automatically. Refresh the page to try again, or set manual steamID");
                }
            });
        }
    });
});

function syncHandler(steamID) {
    var now = new Date().valueOf();
    var last = GM_getValue("lastsync");
    if (last === undefined) {
        GM_setValue("lastsync", now);
        syncHandler(steamID);
    } else if ((now - last) / 3600000 > sync_interval || GM_getValue("ownedGames") === undefined) {
        GM_xmlhttpRequest({
            method: "GET",
            url: "http://steamcommunity.com/profiles/" + steamID + "/games/?xml=1",
            onload: function(data) {
                var xml = $.parseXML(data.responseText);
                var ownedGames = $("name", xml).text().toLowerCase();
                GM_setValue("ownedGames", ownedGames);
                filterHaveList(ownedGames);
            }
        });
    } else {
        filterHaveList(GM_getValue("ownedGames"));
    }
}

function filterHaveList(ownedGames) {
    var have = $(".have").text().trim().toLowerCase().replace(/( *\([^)]*\) *)|\:|\-|\\/g, "").split("\n");
    var have_unowned = "";
    have.forEach(function(game) {
        if (game.length > 1) {
            if (ownedGames.indexOf(game) > -1) { //Game is owned
                $(".have").html($(".have").html().toLowerCase().replace(game, "<i class='fa icon-green fa-check-circle' style='color:green; title='You own this game on steam'></i> " + game));
            } else { //Game is not owned or unknown game
                $(".have").html($(".have").html().toLowerCase().replace(game, "<i class='fa icon-red fa-times-circle' style='color:red;' title='You do not own this game on steam, or unknown game: \nPlease check manually'></i> " + game + " <a href='https://store.steampowered.com/search/?term=" + encodeURIComponent(game) + "' target='_blank'><i class='fa icon-grey fa-external-link' title='Search game on steam'></i></a>"));
                have_unowned += game.replace(/(\"|\')/g, '') + "&#013;";
            }
        }
    });
    $(".have").parent().find("h2").first().html("<i data-clipboard-text='" + have_unowned + "' class='icon_to_clipboard fa fa-fw fa-copy' style='color: rgb(75, 114, 212);' title='Copy unowned/unknown games to clipboard'></i> I have...");
}

QingJ © 2025

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