SteamGifts Trades - Have List Filter

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

当前为 2016-08-12 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

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

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

//Do not touch below :)
$(document).ready(function() {
    if (manual_steamID.length > 0) {
        filterHaveList(manual_steamID);
    } else {
        $.get($(".nav__avatar-outer-wrap").attr("href"), function(data) {
            var steamID = $(".sidebar__shortcut-inner-wrap a", data).attr("href").split("profiles/")[1];
            filterHaveList(steamID);
        });
    }
});

function filterHaveList(steamID) {
    var have = $(".have").text().trim().toLowerCase().replace(/ *\([^)]*\) */g, "").split("\n");
    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();
            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' 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' 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...");
        }
    });
}