SteamGifts Trades - Have List Filter

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

目前為 2016-08-12 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 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...");
        }
    });
}