Steam Extra Profile Links

Adds extra links to Steam Profile pages.

目前為 2014-10-08 提交的版本,檢視 最新版本

// ==UserScript==
// @name          Steam Extra Profile Links
// @namespace     http://greasyfork.org/users/2240-doodles
// @author        Doodles
// @version       6
// @description   Adds extra links to Steam Profile pages.
// @icon          http://i.imgur.com/c4qvWvz.png
// @icon64        http://i.imgur.com/ZumqrhD.png
// @include       *://steamcommunity.com/id/*
// @include       *://steamcommunity.com/profiles/*
// @exclude       *://steamcommunity.com/id/*/tradeoffers/
// @exclude       *://steamcommunity.com/profiles/*/tradeoffers/
// @grant         none
// @updateVersion 6
// ==/UserScript==

var $, jQuery;
$ = jQuery = window.jQuery;
$.extend({ getSteamId: function(steamXmlUrl) {
	var theResponse = null;
	$.ajax({
		url: steamXmlUrl, type: "GET", dataType: "xml", async: false,
		success: function(respText) { theResponse = respText; },
		error: function(xhr, status, error) { console.log(xhr.responseText); }
	});
	return theResponse;
} });
$("<style></style>").prop("type", "text/css").html("\
div.sel_links {background-color:#202020;padding:2px 5px 2px 5px;margin-bottom:10px;margin-right:10px;font-size:10px;color:#999999;}\
div.sel_links a, div.sel_links a:link {color:#5491cf;text-decoration:none;}\
div.sel_links a:visited {color:#5491cf;}\
div.sel_links a:hover {color:#5491cf;text-decoration:underline;}\
div.sel_links a:active {color:#5491cf;}\
div.sel_links hr {border:0;height:1px;background:#0a0a0a;margin-top:2px;margin-bottom:2px;}\
div.sel_foot {margin:0;padding:0;text-align:center;font-size:10px;color:#444444;}\
div.sel_foot a, div.sel_foot a:link {color:#444444;text-decoration:none;}\
div.sel_foot a:visited {color:#444444;}\
div.sel_foot a:hover {color:#999999;text-decoration:underline;}\
div.sel_foot a:active {color:#444444;}\
span.selG {color:#016401;} span.selY {color:#e1bf00;} span.selR {color:#611515;}").appendTo("head");
// Preface Code ---------------------------------------------
var profileRightColumn = $(".profile_rightcol").first();
if (profileRightColumn.length != 0) {
var s64, s32, sAc, xmlPage;
if(document.URL.indexOf("steamcommunity.com/id/") != -1) {
	xmlPage = $.getSteamId("http://steamcommunity.com/id/" + document.URL.split("/id/")[1].split("/")[0].split("?")[0] + "?xml=1");
	s64 = $(xmlPage).find("steamID64").first().text();
} else {
	s64 = document.URL.split("/profiles/")[1].split("/")[0].split("?")[0];
	xmlPage = $.getSteamId("http://steamcommunity.com/profiles/" + s64 + "?xml=1");
}
if(s64.length == 17) { // only start IF s64 obtained AND right column found
var num = s64.substring(5)  - 197960265728; //76561197960265728;
s32 = "STEAM_0:" + num%2 + ":" +(num - num%2) / 2;
sAc = "[U:1:" + num + "]";
// Prepare Box ---------------------------------------------
var linkDiv = $("<div></div>").addClass("sel_links");
var badgeDiv = $(".profile_badges").first();
if (badgeDiv.length != 0) {
	$(linkDiv).insertBefore(badgeDiv);
	var onlineStatus = $(".profile_in_game").first();
	if (onlineStatus.length != 0) { onlineStatus.css("margin-bottom", "10px"); }
	var banStatus = $(".profile_ban_status").first();
	if (banStatus.length != 0) { banStatus.css("margin-bottom", "10px"); }
} else { profileRightColumn.prepend(linkDiv); }
// - START ---------------------------------------------------
var link_01_01 = "<a title=\"SteamRep\" href=\"http://steamrep.com/profiles/" + s64 + "\">SteamRep</a>";
var link_01_02 = "<a title=\"SteamDB\" href=\"http://steamdb.info/calculator/?player=" + s64 + "\">SteamDB</a>";
var link_01_03 = "<a title=\"Steam Trades\" href=\"http://www.steamtrades.com/user/id/" + s64 + "\">Steam Trades</a>";
var link_01_04 = "<a title=\"Steam Gifts\" href=\"http://www.steamgifts.com/user/id/" + s64 + "\">Steam Gifts</a>";

var link_02_01 = "<a title=\"backpack.tf Backpack\" href=\"http://backpack.tf/profiles/" + s64 + "\">Backpack</a>";
var link_02_02 = "<a title=\"backpack.tf Profile\" href=\"http://backpack.tf/u/" + s64 + "\">Profile</a>";
var link_02_03 = "<a title=\"TF2Outpost.com Backpack\" href=\"http://www.tf2outpost.com/backpack/" + s64 + "\">Backpack</a>";
var link_02_04 = "<a title=\"TF2Outpost.com Profile\" href=\"http://www.tf2outpost.com/user/" + s64 + "\">Profile</a>";
var link_02_05 = "<a title=\"bazaar.tf Backpack\" href=\"http://bazaar.tf/backpack/" + s64 + "\">Backpack</a>";
var link_02_06 = "<a title=\"bazaar.tf Profile\" href=\"http://bazaar.tf/profiles/" + s64 + "\">Profile</a>";
var link_02_07 = "<a title=\"TF2 Trading Post Profile\" href=\"http://tf2tp.com/profile.php?profile=" + s64 + "\">TF2 Trading Post Profile</a>";
var link_02_08 = "<a title=\"TF2 Backpack Examiner\" href=\"http://www.tf2items.com/profiles/" + s64 + "?p=all\">TF2 Backpack Examiner</a>";
var link_02_09 = "<a title=\"TF2B - TF2\" href=\"http://tf2b.com/tf2/" + s64 + "\">TF2</a>";
var link_02_10 = "<a title=\"TF2B - DOTA2\" href=\"http://tf2b.com/d2/" + s64 + "\">DOTA2</a>";
var link_02_11 = "<a title=\"TF2B - CSGO\" href=\"http://tf2b.com/csgo/" + s64 + "\">CSGO</a>";
var link_02_12 = "<a title=\"TF2B - Portal 2\" href=\"http://tf2b.com/tf2/" + s64 + "\">Portal 2</a>";

var link_03_01 = "<a title=\"Achievement Stats\" href=\"http://www.achievementstats.com/index.php?action=profile&playerId=" + s64 + "\">Achievement Stats</a>";
var link_03_02 = "<a title=\"astats.nl\" href=\"http://astats.astats.nl/astats/User_Info.php?steamID64=" + s64 + "\">astats.nl</a>";
var link_03_03 = "<a title=\"Wasted on Steam\" href=\"http://www.wastedonsteam.com/usd/id/" + s64 + "\">Wasted on Steam</a>";

var link_04_01 = "<a title=\"Games\" href=\"http://steamcommunity.com/profiles/" + s64 + "/games/\">Games</a>";
var link_04_02 = "<a title=\"All Games\" href=\"http://steamcommunity.com/profiles/" + s64 + "/games?tab=all\">All Games</a>";
var link_04_03 = "<a title=\"Screenshots\" href=\"http://steamcommunity.com/profiles/" + s64 + "/screenshots/?appid=0&sort=newestfirst&browsefilter=myfiles&view=grid\">Screenshots</a>";
var link_04_04 = "<a title=\"Videos\" href=\"http://steamcommunity.com/profiles/" + s64 + "/videos/\">Videos</a>";
var link_04_05 = "<a title=\"Artwork\" href=\"http://steamcommunity.com/profiles/" + s64 + "/images/\">Artwork</a>";
var link_04_06 = "<a title=\"Reviews\" href=\"http://steamcommunity.com/profiles/" + s64 + "/recommended/\">Reviews</a>";
var link_04_07 = "<a title=\"Guides\" href=\"http://steamcommunity.com/profiles/" + s64 + "/myworkshopfiles/?section=guides\">Guides</a>";
var link_04_08 = "<a title=\"Workshop Items\" href=\"http://steamcommunity.com/profiles/" + s64 + "/myworkshopfiles/\">Workshop Items</a>";
var link_04_09 = "<a title=\"Greenlight Items\" href=\"http://steamcommunity.com/profiles/" + s64 + "/myworkshopfiles/?section=greenlight\">Greenlight Items</a>";
var link_04_10 = "<a title=\"Friends\" href=\"http://steamcommunity.com/profiles/" + s64 + "/friends/\">Friends</a>";
var link_04_11 = "<a title=\"Groups\" href=\"http://steamcommunity.com/profiles/" + s64 + "/groups/\">Groups</a>";
var link_04_12 = "<a title=\"Inventory - TF2\" href=\"http://steamcommunity.com/profiles/" + s64 + "/inventory/#440\">TF2</a>";
var link_04_13 = "<a title=\"Inventory - Dota2\" href=\"http://steamcommunity.com/profiles/" + s64 + "/inventory/#570\">Dota2</a>";
var link_04_14 = "<a title=\"Inventory - Steam\" href=\"http://steamcommunity.com/profiles/" + s64 + "/inventory/#753\">Steam</a>";
var link_04_15 = "<a title=\"Inventory - CSGO\" href=\"http://steamcommunity.com/profiles/" + s64 + "/inventory/#730\">CSGO</a>";
var link_04_16 = "<a title=\"All Comments\" href=\"http://steamcommunity.com/profiles/" + s64 + "/allcomments\">All Comments</a>";
var link_04_17 = "<a title=\"Name History\" href=\"http://steamcommunity.com/profiles/" + s64 + "/namehistory\">Name History</a>";
var link_04_18 = "<a title=\"Friends in Common\" href=\"http://steamcommunity.com/profiles/" + s64 + "/friendscommon\">Friends in Common</a>";
var link_04_19 = "<a title=\"Groups in Common\" href=\"http://steamcommunity.com/profiles/" + s64 + "/groupscommon\">Groups in Common</a>";
var link_04_20 = "<a title=\"Badges\" href=\"http://steamcommunity.com/profiles/" + s64 + "/badges/\">Badges</a>";
var link_04_21 = "<a title=\"Wishlist\" href=\"http://steamcommunity.com/profiles/" + s64 + "/wishlist/\">Wishlist</a>";

var link_05_01 = "<a title=\"CSGO Lounge\" href=\"http://csgolounge.com/profile?id=" + s64 + "\">CSGO Lounge</a>";

var link_foot_1 = "<a title=\"GreasyFork\" target\"_blank\" href=\"https://greasyfork.org/scripts/5148-steam-extra-profile-links\">GreasyFork</a>";
var link_foot_2 = "<a title=\"DoodlesStuff\" target\"_blank\" href=\"http://doodlesstuff.com/?script=sepl\">DoodlesStuff</a>";

// Alter Profile Links ---------------------------------------------
var invCount = "Inventory: ";
var normalLinks = $(".profile_item_links").first();
if(normalLinks.length != 0) {
	var c = $(normalLinks).find("a");
	for (i = 0; i < c.length; i++)
	{
		var spanCount = $(c[i]).find(".profile_count_link_total").first();
		if(spanCount.length != 0) {
			var cv = $(spanCount).text().trim();
			if(cv.length != 0) {
				if (c[i].href.indexOf("/games/") != -1) { link_04_01 = link_04_01.replace("</a>", " (" + cv + ")</a>"); }
				else if (c[i].href.indexOf("/screenshots/") != -1) { link_04_03 = link_04_03.replace("</a>", " (" + cv + ")</a>"); }
				else if (c[i].href.indexOf("/videos/") != -1) { link_04_04 = link_04_04.replace("</a>", " (" + cv + ")</a>"); }
				else if (c[i].href.indexOf("/inventory/") != -1) { invCount = "Inventory (" + cv + "): "; }
				else if (c[i].href.indexOf("/myworkshopfiles/?section=greenlight") != -1) { link_04_09 = link_04_09.replace("</a>", " (" + cv + ")</a>"); }
				else if (c[i].href.indexOf("/images/") != -1) { link_04_05 = link_04_05.replace("</a>", " (" + cv + ")</a>"); }
				else if (c[i].href.indexOf("/myworkshopfiles/?section=guides") != -1) { link_04_07 = link_04_07.replace("</a>", " (" + cv + ")</a>"); }
				else if (c[i].href.indexOf("/recommended/") != -1) { link_04_06 = link_04_06.replace("</a>", " (" + cv + ")</a>"); }
				else if (c[i].href.indexOf("/myworkshopfiles/") != -1) { link_04_08 = link_04_08.replace("</a>", " (" + cv + ")</a>"); }
			}
		}
	}
	normalLinks.remove();
}
// Add Links ---------------------------------------------
linkDiv.append($("<div>" + link_01_01 + " | " + link_01_02 + "</div>"));
	var vac = $(xmlPage).find("vacBanned").first().text();
	if(vac == "1") { vac = "<span class=\"selR\">VAC Banned</span>"; }
	else if(vac == "0") { vac = "<span class=\"selG\">None</span>"; }
	else { vac = "<span class=\"selY\">" + vac + "</span>"; }
linkDiv.append($("<div>VAC Ban: " + vac + "</div>"));
	var trade = $(xmlPage).find("tradeBanState").first().text();
	if(trade == "None") { trade = "<span class=\"selG\">None</span>"; }
	else { trade = "<span class=\"selR\">" + trade + "</span>"; }
linkDiv.append($("<div>Trade Ban: " + trade + "</div>"));
/*var privacy = $(xmlPage).find("privacyState").first().text();
if(privacy == "private") { privacy = "<span class=\"selR\">Private</span>"; }
else if(privacy == "friendsonly") { privacy = "<span class=\"selY\">Friends Only</span>"; }
else if(privacy == "public") { privacy = "<span class=\"selG\">Public</span>"; }
linkDiv.append($("<div>Profile Privacy: " + privacy + "</div>"));*/
var memberSince = $(xmlPage).find("memberSince").first();
if(memberSince.length != 0) { linkDiv.append($("<div>Joined: " + $(memberSince).text() + "</div>")); }
linkDiv.append($("<div>" + s64 + "</div><div>" + sAc + "</div><div>" + s32 + "</div>"));
linkDiv.append($("<hr>"));
linkDiv.append($("<div>backpack.tf: " + link_02_01 + " | " + link_02_02 +"</div>"));
linkDiv.append($("<div>TF2Outpost: " + link_02_03 + " | " + link_02_04 + "</div>"));
linkDiv.append($("<div>bazaar.tf: " + link_02_05 + " | " + link_02_06 + "</div>"));
linkDiv.append($("<div>" + link_02_07 + "</div><div>" + link_02_08 + "</div>"));
linkDiv.append($("<div>TF2B: " + link_02_09 + " | " + link_02_10 + " | " + link_02_11 + " | " + link_02_12 + "</div>"));
linkDiv.append($("<div>" + link_01_03 + " | " + link_01_04 + "</div><div>" + link_05_01 + "</div>"));
linkDiv.append($("<hr>"));
linkDiv.append($("<div>" + link_03_01 + " | " + link_03_02 + " | " + link_03_03 + "</div>"));
linkDiv.append($("<hr>"));
if($(".profile_private_info").length == 0) { // display profile type links IF profile ISNT private
	linkDiv.append($("<div>" + link_04_01 + " | " + link_04_02 + " | " + link_04_21 + "</div>"));
	linkDiv.append($("<div>" + link_04_03 + " | " + link_04_04 + " | " + link_04_05 + "</div>"));
	linkDiv.append($("<div>" + link_04_06 + " | " + link_04_07 + "</div>"));
	linkDiv.append($("<div>" + link_04_08 + " | " + link_04_09 + "</div>"));
	linkDiv.append($("<div>" + link_04_10 + " | " + link_04_11 + " | " + link_04_20 + "</div>"));
	linkDiv.append($("<div>" + invCount + link_04_12 + " | " + link_04_13 + " | " + link_04_14 + " | " + link_04_15 + "</div>"));
	linkDiv.append($("<div>" + link_04_16 + " | " + link_04_17 + "</div>"));
	if($("#account_pulldown").length != 0) { linkDiv.append($("<div>" + link_04_18 + " | " + link_04_19 + "</div>")); }
	
} else {
	linkDiv.append($("<div>" + link_04_16 + " | " + link_04_17 + "</div>"));
}
linkDiv.append($("<hr>"));
linkDiv.append($("<div class=\"sel_foot\">Steam Extra Links: " + link_foot_1 + " | " + link_foot_2 + "</div>"));
// - END -----------------------------------------------------
} }