Advertisement
Guest User

Untitled

a guest
Aug 26th, 2014
317
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 33.33 KB | None | 0 0
  1. // ==UserScript==
  2. // @name TF2Profiler Script
  3. // @namespace TF2Profiler
  4. // @require http://code.jquery.com/jquery-latest.min.js
  5. // @version 0.63
  6. // @homepage http://www.kugrian.co.uk/tf2profiler
  7. // @description tf2Profiler userscript for tf2Lobby.com/etf2l.org/steamcommunity.com/ucgleague.com/wireplay.co.uk
  8. // @downloadURL https://userscripts.org/scripts/source/169861.user.js
  9. // @updateURL https://userscripts.org/scripts/source/169861.meta.js
  10. // @match http://tf2lobby.com/*id=*
  11. // @match http://etf2l.org/*
  12. // @match http*://steamcommunity.com/id/*
  13. // @match http*://steamcommunity.com/profiles/*
  14. // @match http*://steamcommunity.com/groups/*
  15. // @match http://www.ugcleague.com/players_page.cfm?*
  16. // @match http://tf2.wireplay.co.uk/*
  17. // @match http*://userscripts.org/scripts/show/169861
  18. // @grant unsafeWindow
  19. // @grant GM_setValue
  20. // @grant GM_getValue
  21. // @grant GM_listValues
  22. // @grant GM_deleteValue
  23. // @copyright 2013+, Kugs
  24. // @run-at document-end
  25.  
  26. // ==/UserScript==
  27.  
  28. // Thanks to https://userscripts.org/users/redshift for help and cleaning stuff
  29. // up
  30. var implode = function (glue, pieces) { return ((pieces instanceof Array)? pieces.join (glue): pieces);}
  31. var currentURL = (document.location+'');
  32. console.log(currentURL);
  33. var TF2Profiler_options = false;
  34. var sites = ({
  35. "TF2Profiler" : "http://www.kugrian.co.uk/tf2profiler/index.php?players=",
  36. "ETF2L" : "http://etf2l.org/search/?q=",
  37. "UGC" : "http://www.ugcleague.com/players_page.cfm?player_id=",
  38. "Wireplay" : "http://tf2.wireplay.co.uk/index.php?pg=search",
  39. "ESEA" : "http://play.esea.net/index.php?s=search&query=",
  40. "logs.tf" : "http://logs.tf/profile/",
  41. "tf2logs.com" : "http://www.tf2logs.com/players/",
  42. "SizzlingStats": "http://sizzlingstats.com/player/",
  43. "TF2lobby.com" : "http://tf2lobby.com/profile?fid=",
  44. "TF2stats.net" : "http://tf2stats.net/player_stats/",
  45. "SteamRep" : "http://steamrep.com/search?q=",
  46. "TF2items.com" : "http://www.tf2items.com/profiles/",
  47. "backpack.tf" : "http://backpack.tf/profiles/",
  48. "tf2b.com" : "http://tf2b.com/tf2/",
  49. "bazaar.tf" : "http://bazaar.tf/profiles/",
  50. "tf2tp.com" : "http://tf2tp.com/profile.php?profile=",
  51. });
  52. var TF2Profiler_extraOptions = ({
  53. "Steamcommunity.com" : ({ "show_links" : "Show Links on Profiles",
  54. "show_summary" : "Show Full Summary",
  55. "show_server" : "Show Server Details on Profiles",
  56. "group_link" : "Link to TF2Profiler on Group Pages",
  57. "friend_server_browser" : "Show Friends Playing TF2 Link"}),
  58. "ETF2L" : ({ "show_links" : "Show Links on Profiles",
  59. "team_link" : "Link to TF2Profiler on Team Pages",
  60. "forum_link" : "Show Links Arrow on Forum Profiles"}),
  61. "Wireplay" : ({ "show_links" : "Show Links on Profiles",
  62. "search_fix" : "Show fixes on Search Pages"}),
  63. "TF2Lobby" : ({ "show_links" : "Show Extra Links on Profiles",
  64. "move_links" : "Move Links To Top of Page",
  65. "lobby_link" : "Show TF2Profiler Link in Lobbies"})
  66. });
  67. var TF2Profiler_etf2lPlayers = new Array();
  68.  
  69. function TF2Profiler_optionsLi (name,value ) {
  70. var box = document.createElement('input');
  71. var li = document.createElement('li');
  72. $(box).attr('type','checkbox');
  73. $(box).attr('name',name);
  74. $(box).attr('value',value);
  75.  
  76.  
  77. // if (!GM_getValue('setup'))
  78. // GM_setValue(name,true);
  79. var checked = GM_getValue(name);
  80. console.log(name+" = "+checked);
  81. if (checked==true)
  82. $(box).attr('checked',false);
  83. else
  84. $(box).attr('checked',true);
  85.  
  86.  
  87. $(box).click(function (e) {
  88. if (!$(this).is(':checked'))
  89. GM_setValue($(this).attr('name'),true);
  90. else
  91. GM_deleteValue($(this).attr('name'));
  92. console.log('Checked',$(this).attr('checked'));
  93. //$(this).css({'outline':'3px solid green'});
  94. $("#TF2Profiler_saved").show('fast',function() {
  95. window.setTimeout(function () { $("#TF2Profiler_saved").hide('slow')}, 1000); });
  96.  
  97.  
  98. e.stopPropagation();
  99. });
  100.  
  101. $(li).html($(box));
  102. $(li).css({'padding-left':'15px'});
  103. var label = document.createElement('label');
  104. $(label).css({'padding-left':'5px','color':'#FFFFFF'});
  105. $(label).text(value);
  106. $(label).attr('for',name);
  107. $(li).append($(label));
  108. return $(li);
  109. }
  110.  
  111. function TF2Profiler_createOptions () {
  112. var ulCss = ({'list-style-type':'none','padding':'20px','padding-top':'0px'})
  113. TF2Profiler_options = document.createElement('div');
  114. $(TF2Profiler_options).css({"padding":"10px","color":"#FFFFFF","position":"fixed","top":"50px",
  115. "right":"10px","border":"1px solid #FFFFFF","z-index":"100000","background-color":"#000000",
  116. "border-radius":"5px",'font-size':'12px'});
  117. $(TF2Profiler_options).attr('id',"TF2Profiler_options");
  118. $(TF2Profiler_options).html("<h2 style='float:left;color:#FFFFFF;font-size:14px'>Userscript Options</h2>");
  119. var links = Object.keys(sites);
  120. var linkList = document.createElement('ul');
  121. var siteList = document.createElement('ul');
  122.  
  123. $(linkList).css(ulCss);
  124. $(linkList).css({'float':'left','clear':'both'});
  125. $(linkList).append("<li style='padding-left:5px'><b><u>Links to Show</u></b></li><li>&nbsp;</li>");
  126. $(siteList).css(ulCss);
  127. $(siteList).css({'float':'right'});
  128. $(siteList).append("<li style='padding-left:5px'><b><u>Other Sites</u></b></li>");
  129. for (var x = 0; x < links.length; x++) {
  130. //if (!GM_getValue('setup'))
  131. // GM_setValue(links[x],true);
  132.  
  133. $(linkList).append(TF2Profiler_optionsLi(links[x],links[x]));
  134. }
  135. //$(linkList).append("<li>&nbsp;</li><li style='padding-left:5px'><b><u>Other Sites</u></b></li>");
  136. links = Object.keys(TF2Profiler_extraOptions);
  137. for (var x = 0; x < links.length; x++) {
  138. var newList2 = document.createElement('ul');
  139. $(newList2).css({'padding-left':'10px'});
  140. $(newList2).append("<li>&nbsp;</li>");
  141. $(newList2).append(links[x]);
  142. var linksInner = Object.keys(TF2Profiler_extraOptions[links[x]]);
  143.  
  144. $(newList2).css({'list-style-type':'none','padding-left':'5px'});
  145. for (var y = 0; y < linksInner.length; y++) {
  146.  
  147. $(newList2).append(TF2Profiler_optionsLi(links[x]+"_"+linksInner[y],TF2Profiler_extraOptions[links[x]][linksInner[y]]));
  148. }
  149. $(siteList).append($(newList2));
  150.  
  151. }
  152. if (!GM_getValue('setup'))
  153. GM_setValue('setup',true);
  154. $(TF2Profiler_options).append($(linkList));
  155. $(TF2Profiler_options).append($(siteList));
  156. var resetDiv = document.createElement('div');
  157. $(resetDiv).css({'float':'right'});
  158. var a = document.createElement('a');
  159. $(a).text("Check All");
  160. $(a).css({'color':'#00FF00','position':'absolute','right':'100px'});
  161. $(a).attr('href','#TF2ProfilerCheckAllOptions')
  162. $(a).click(function (e) {
  163. e.stopPropagation();
  164. var keys = GM_listValues();
  165. for (var i=0, key=null; key=keys[i]; i++) {
  166. GM_deleteValue(key);
  167. }
  168. GM_setValue('setup',false);
  169. $(this).parent().parent().remove();
  170. TF2Profiler_createOptions();
  171. $("#TF2Profiler_saved").show('fast',function() {
  172. window.setTimeout(function () { $("#TF2Profiler_saved").hide('slow'); }, 1000); });
  173. });
  174. var close = $(document.createElement('a')).text('X');
  175.  
  176. $(close).css({"color":"red","padding":"3px","position": "absolute",
  177. "right":"2px","top":"0px","font-size": "20px"})
  178. $(close).attr({'href':'#TF2ProfilerCloseOptions','title':'close'});
  179. $(close).click(function (e) { $('#TF2Profiler_options').fadeOut('slow'); e.stopPropagation();});
  180. $(resetDiv).html($(close));
  181. $(resetDiv).append("<br>");
  182. $(resetDiv).append($(a));
  183. $(resetDiv).append("<br><a style='color:#000000'>test</a>");
  184. $($(TF2Profiler_options).find('h2')).after($(resetDiv));
  185.  
  186. var saved = document.createElement('span');
  187. $(saved).css({'position':'absolute','bottom':'5px','left':'10px','display':'none','color':'#00FF00'});
  188. $(saved).text('Saved - Refresh Page to Show');
  189. $(saved).attr('id','TF2Profiler_saved');
  190. $(TF2Profiler_options).append($(saved));
  191. $('body').prepend($(TF2Profiler_options));
  192. }
  193.  
  194. function siteList (ul,sid,longLink,linkClass) {
  195. var pos = 7960265728;
  196. var pre = '7656119';
  197. var val = parseInt(sid.substr(pre.length)) - pos;
  198. var s64 = 'STEAM_0:' + (val & 1) + ':' + (val >> 1);
  199.  
  200. $.each(sites, function(name,url) {
  201. if (!GM_getValue(name) || GM_getValue(name)==false) {
  202.  
  203. var li = document.createElement('li');
  204. var a = document.createElement('a');
  205. $(a).attr('target','_blank');
  206. if (name == "ETF2L" || name=="ESEA") {
  207. if (name == "ESEA")
  208. url += s64.replace("STEAM_","");
  209. else
  210. url += sid;
  211. }
  212. else
  213. url += s64;
  214.  
  215. if (name == "Wireplay") {
  216. var form = document.createElement('form');
  217. $(form).attr({'action':'http://tf2.wireplay.co.uk/index.php?pg=search','method':'post','target':'_blank'});
  218. var input = document.createElement('input');
  219. $(input).attr({'type':'hidden','name':'searchterm','value':s64});
  220. $(form).append($(input));
  221. var input = document.createElement('input');
  222. $(input).attr({'type':'hidden','name':'steamid','value':'true','checked':'true'});
  223. $(form).append($(input));
  224. $(a).click(function () { $(form).submit(); });
  225. $(a).css({'cursor':'pointer'});
  226. } else
  227. $(a).attr('href',url);
  228.  
  229. if (longLink)
  230. $(a).html("View "+name+" Profile");
  231. else
  232. $(a).html(name);
  233.  
  234. if (linkClass)
  235. $(a).addClass(linkClass);
  236. $(li).append($(a));
  237. $(ul).append($(li));
  238. }
  239. });
  240.  
  241. var li = document.createElement('li');
  242. var span = document.createElement('a');
  243. if (linkClass)
  244. $(span).addClass(linkClass);
  245.  
  246. $(span).text("Userscript Options");
  247. $(span).attr('href','#TF2ProfilerOptions');
  248. $(span).click( function (e) {
  249. if (!TF2Profiler_options)
  250. TF2Profiler_createOptions();
  251. else
  252. $(TF2Profiler_options).fadeToggle('slow');
  253. $("body").click(function() { $('#TF2Profiler_options').fadeOut('slow'); });
  254. $(TF2Profiler_options).click(function(e) { e.stopPropagation(); });
  255. e.stopPropagation();
  256. });
  257. $(li).append($(span));
  258. $(ul).append($(li));
  259.  
  260. return s64; // one thing uses it - forget what
  261. }
  262.  
  263. var websites = [
  264.  
  265. //----------------------------------------------------------------
  266. // TF2Lobby
  267. //----------------------------------------------------------------
  268. // Features:
  269. // Add link for players in a lobby
  270. // Add profile links in the player profile
  271. {// Lobby pages
  272. match: function( url )
  273. {
  274. return url.match( "http://tf2lobby.com/lobby?" ) && !GM_getValue('TF2Lobby_lobby_link');
  275. },
  276. script: function( site )
  277. {
  278. var profilerLink = document.createElement('a');
  279. $(profilerLink).html("View these players on TF2Profiler");
  280. $(profilerLink).attr("target","_blank");
  281. $(profilerLink).css({"color":"#000000","font-weight":"bold"});
  282. $(profilerLink).hover( function() {
  283. var tmp = unsafeWindow.lobby["players"];
  284. var st = { "red":[],"blu":[],"spec":[] };
  285.  
  286. for (var x = 0; x < Object.keys(tmp).length; x++) {
  287. var player = tmp[Object.keys(tmp)[x]];
  288. if (!st[player['team']])
  289. st[player['team']] = [player['fid']];
  290. else
  291. {
  292. var tA = st[player['team']];
  293. tA.push(player["fid"]);
  294. st[player['team']] = tA;
  295. }
  296. }
  297. var link = "http://www.kugrian.co.uk/tf2profiler/index.php?";
  298. console.log(st);
  299. for (var x = 0; x < Object.keys(st).length; x++) {
  300. var tt = Object.keys(st)[x];
  301. if (st[tt].length)
  302. link += tt+"="+implode(",",st[tt])+"&";
  303. }
  304.  
  305. $(profilerLink).attr("href",link);
  306. $(profilerLink).css({"text-decoration":"underline","color":"#FFFFFF"});
  307. //window.open("http://www.kugrian.co.uk/tf2profiler/index.php?players="+implode(",",st),'_blank');
  308. },function() { $(profilerLink).css({"text-decoration":"none","color":"#000000"});
  309. });
  310.  
  311. var div = document.createElement('div');
  312. $(div).css({'padding': '5px','border': '1px solid #000000', 'border-radius': '10px', 'float': 'right',
  313. 'background-color':'#9B9CA3'});
  314. $(div).append(profilerLink);
  315. $("#lobbyInfo").parent().append($(div));
  316. console.log("Adding lobby link");
  317. },
  318. },
  319. {// Profile pages
  320. match: function( url )
  321. {
  322. return url.match("http://tf2lobby.com/profile?") && !GM_getValue('TF2Lobby_show_links');
  323. },
  324. script: function( site )
  325. {
  326. var sidLink = $('#otherSites').find('a').attr('href');
  327. var sid = sidLink.replace("http://steamcommunity.com/profiles/","");
  328. var sNames = Object.keys(sites);
  329.  
  330. delete(sites["TF2items.com"]);
  331. delete(sites["TF2stats.net"]);
  332. delete(sites["TF2lobby.com"]);
  333.  
  334. siteList($("#otherSites").children('ul'),sid,false,false);
  335.  
  336. $("#player").find("p").html("<a href="+sidLink+">"+$("#player").find("p").html());
  337.  
  338. if (!GM_getValue('TF2Lobby_move_links')) {
  339. $('#otherSites').find('ul').hide();
  340. $('#otherSites').find('ul').css({"margin":"10px 10px 0px 25px"});
  341. $("#lobbyHistory").addClass("next");
  342. $("#otherSites").removeClass("next");
  343. $("#lobbyHistory").parent().prepend($("#otherSites"));
  344. var h2 = $("#otherSites").find('h2');
  345. $(h2).css({'cursor':'pointer'});
  346. $(h2).html('Other Sites <span style="font-size: 10pt">(Click to show)</span>');
  347. $(h2).click(function() {
  348. $("#otherSites").find('ul').slideToggle('slow');
  349. if ($("#otherSites").find('ul').is(":hidden"))
  350. $(h2).find('span').text('(Click to show)');
  351. else
  352. $(h2).find('span').text('(Click to hide)');
  353. });
  354. }
  355.  
  356.  
  357. $($("#header").find('.wrap').children()[1]).html('<a href=http://tf2lobby.com>'
  358. +$($("#header").find('.wrap').children()[1]).html()+'</a>')
  359. //$("#player").find("img").html("<a href="+sidLink+">"+$("#player").find("img").html()+"</a>");
  360. //console.log(s64);
  361. },
  362. },
  363.  
  364. //----------------------------------------------------------------
  365. // ETF2L
  366. //----------------------------------------------------------------
  367. {// User pages
  368. match: function( url )
  369. {
  370. return url.match("http://etf2l.org/forum/user/") && !GM_getValue('ETF2L_show_links');
  371. },
  372. script: function( site )
  373. {
  374. var teams = $($("#rs-discuss").find('ul')[0]);
  375. var sidLink = $($(".playerinfo").find("a")[0]).attr('href');
  376. var sid = sidLink.replace("http://steamcommunity.com/profiles/","");
  377. var ul = document.createElement('ul');
  378. delete(sites["ETF2L"]);
  379.  
  380. siteList($(ul),sid,true,false);
  381. teams.after($(ul));
  382. teams.after("<h2>Other Sites</h2><p></p>");
  383. },
  384. },
  385. {// Forum pages
  386. match: function( url )
  387. {
  388. return url.match("http://etf2l.org/forum/") && !GM_getValue('ETF2L_forum_link');
  389. },
  390. script: function( site )
  391. {
  392. $.each($('.details'),function(index,details) {
  393. var a = document.createElement('a');
  394. var color;
  395.  
  396. $(a).html('&#9660;');
  397.  
  398. if ($(details).parent().hasClass('post-block-odd'))
  399. color = "#dcddca";
  400. else
  401. color = "#e4e5d4";
  402. $(a).css({'color':'#000000','cursor':'pointer','float':'right'});
  403. $($(details).children()[1]).prepend($(a));
  404. var steamid = $($($(details).children()[2]).find('a')).attr('href').
  405. replace("http://steamcommunity.com/profiles/","").replace("/","");
  406. $(a).click(function(e) {
  407. $('.TF2Profiler_playerLinks').fadeOut('slow');
  408. var links = document.getElementById('TF2Profiler_'+steamid);
  409. console.log(steamid);
  410. // console.log(links);
  411. if (!links) {
  412.  
  413. console.log(steamid);
  414. var ul = document.createElement('ul');
  415. $(ul).css({'list-style-type':'none','padding':'5px','list-style-image':'none'});
  416. var div = document.createElement('div');
  417. $(div).css({'background-color':color,'display':'none','z-index':'200',
  418. 'position':'absolute','border':'1px solid #a0abb4','border-radius':'5px','left':'150px'});
  419. var s64 = siteList($(ul),steamid,false,'whiteLink');
  420. $(div).append($(ul));
  421. $(div).append('<ul style="list-style-type:none;list-style-image:none;padding:5px"><li>'+steamid+'</li><li>'+s64+'</li></ul>');
  422. $(div).attr('id','TF2Profiler_'+steamid);
  423. $(div).addClass('TF2Profiler_playerLinks');
  424. $(this).after($(div));
  425. links = $(div);
  426.  
  427.  
  428. }
  429. $(links).fadeToggle('slow');
  430. if ($(links).is(":visible")) {
  431. $("body").click(function() { $('.TF2Profiler_playerLinks').fadeOut('slow'); });
  432. }
  433.  
  434. e.stopPropagation();
  435.  
  436.  
  437. });
  438. $(a).after(" ");
  439.  
  440. });
  441. },
  442. },
  443. {// Team page
  444. match: function( url )
  445. {
  446. return url.match("http://etf2l.org/teams/") && !GM_getValue('ETF2L_team_link');
  447. },
  448. script: function( site, url )
  449. {
  450. var tid = url.replace("http://etf2l.org/teams/","");
  451. tid = tid.replace("/","");
  452. $(".teamname").append("<a href=http://www.kugrian.co.uk/tf2profiler/index.php?team="+tid+"&org=etf2l "
  453. +"target=_blank> - View on TF2Profiler</a>");
  454. },
  455. },
  456. //----------------------------------------------------------------
  457. // Steam community
  458. //----------------------------------------------------------------
  459. {
  460. match: function( url )
  461. {
  462. return url.match(/^https?\:\/\/steamcommunity.com\/(?:id|profiles)/);
  463. },
  464. script: function( site, url )
  465. {
  466. if (url.match('/friends')) {
  467. var friends = $('.linkFriend_in-game');
  468. if (friends.length && !GM_getValue('Steamcommunity.com_friend_server_browser')) {
  469. var a = document.createElement('a');
  470. $(a).text('Show Friends Playing TF2');
  471. $(a).click( function(e) {
  472. profileDiv = $('body').find('.TF2ProfilerFriendServers');
  473.  
  474. if ($(profileDiv).text())
  475. $(profileDiv).fadeToggle('slow');
  476. else {
  477. console.log('Creating');
  478. var tmp = [];
  479. var out = "";
  480. var loops = 4;
  481.  
  482. $.each( $(friends),
  483. function(a,b){
  484. if ($(b).text().match('Team')) {
  485. var t = $(b).find('.friend_join_game_link').attr('onClick');
  486. if (t) {
  487. t = t.replace("window.location='steam://connect/","");
  488. var friendBlockContent = $(b).parent().parent();
  489. var txt = "<a href="+$($(friendBlockContent).parent().find('a',0)).attr('href')+"><img src="+$($(friendBlockContent).prev().find('img',0)).attr('src')
  490. +" height=24px width=24px><span style='padding-left: 5px'>"+$(friendBlockContent).html().split('<br>')[0]+"</span></a>";
  491.  
  492. t = t.replace("';","");
  493. if (!tmp[t])
  494. tmp[t] = [txt];
  495. else {
  496. var y = tmp[t];
  497. tmp[t].push(txt)
  498. }
  499. }
  500. }
  501. });
  502.  
  503. var div = document.createElement('div');
  504. $(div).addClass('TF2ProfilerFriendServers');
  505. $(div).css({'position':'absolute','top':'250px','left':'0px','right':'0px','border':'1px solid #FFF',
  506. 'z-index':'100000',"background":"#000000",'padding':'10px','width':'1000px','overflow':'hidden',
  507. 'margin-left':'auto','margin-right':'auto','display':'none'});
  508.  
  509. var servers = Object.keys(tmp);
  510. servers.sort(function(a,b) {
  511. var diff = tmp[a].length > tmp[b].length;
  512. return diff;
  513.  
  514. });
  515. servers.reverse();
  516. console.log(servers);
  517. var row = 0;
  518.  
  519. var odd = false;
  520.  
  521. for (var x = 0; x < servers.length; x++) {
  522. var tmpDiv = document.createElement('div');
  523. $(tmpDiv).css({'width':'250px','float':'left','display':'inline','margin-bottom':'20px'});
  524. if (row==0) {
  525. $(tmpDiv).css({'clear':'both'});
  526. }
  527. row++;
  528. var sText = "<iframe src="
  529. +"http://module.game-monitor.com/"+servers[x]+"/website.php?s=compatible.css&f=1 frameborder=0 "
  530. +"scrolling=no height=240 width=200></iframe>";
  531.  
  532. var serverLink = "<a style='color:#00FF00' href=steam://connect"+servers[x]+">"+servers[x]+"</a>";
  533. var players = Object.keys(tmp[servers[x]]);
  534.  
  535. $(tmpDiv).append("<ul style='padding:3px;margin:0px;list-style-type:none;'>"
  536. +"<li>"+implode("</li><li>",tmp[servers[x]])
  537. +"</li></ul></li></ul>");
  538.  
  539. $(tmpDiv).css({'vertical-align':'top','width':'220px','margin':'5px','padding':'5px','border':'1px solid','border-radius':'5px','margin-bottom':'20px'});
  540. if (odd) {
  541. odd = false;
  542. $(tmpDiv).css({'background':'#303030','color':'#FFFFFF'});
  543.  
  544. $(a).css({'color':'#FFFFFF'});
  545. } else {
  546. $(tmpDiv).css({'background':'#404040','color':'#EEEEEE'});
  547.  
  548. $(a).css({'color':'#EEEEEE'});
  549. odd = true;
  550. }
  551. $(tmpDiv).append($(sText));
  552. if (row==loops) {
  553. row = 0;
  554. if (odd)
  555. odd = false;
  556. else
  557. odd = true
  558. }
  559. $(div).append($(tmpDiv));
  560.  
  561. }
  562.  
  563.  
  564. var table = document.createElement('table');
  565.  
  566. $(div).prepend("<h1>Friends playing TF2</h1>");
  567. var close = $(document.createElement('a')).text('X');
  568.  
  569. $(close).css({"color":"red","padding":"3px","position": "absolute",
  570. "right":"2px","top":"0px","font-size": "20px"})
  571. $(close).attr({'href':'#TF2ProfilerCloseFriendServers','title':'close'});
  572. $(close).click(function (e) { $('.TF2ProfilerFriendServers').fadeToggle('slow'); e.stopPropagation();});
  573. $(div).append($(close));
  574. $(div).fadeIn('slow');
  575. $('body').prepend($(div));
  576.  
  577. }
  578. $('.TF2ProfilerFriendServers').click(function(e) { e.stopPropagation(); } );
  579. $("body").click(function() { $('.TF2ProfilerFriendServers').fadeOut('slow'); });
  580. e.stopPropagation();
  581. });
  582. var div = document.createElement('div');
  583. $(div).css({'padding':'5px'});
  584. $(div).append($(a));
  585. $('.maincontent').prepend($(div));
  586. if ($('.manage_friends_header')) // Viewing your own profile
  587. $('.manage_friends_header').after($(a));
  588.  
  589. }
  590. }
  591. var div = document.createElement('div');
  592. var old = false;
  593. $(div).css({'background-color':'#171717','padding':'10px','margin-top':'20px','display':'none','z-index':'200',
  594. 'position':'absolute','right':'280px','border':'2px solid #ffffff','border-radius':'5px'});
  595. $(div).attr('id','TF2Profiler_linkList');
  596. var ul = document.createElement('ul');
  597. $(ul).css({'list-style-type':'none','padding-left':'5px'});
  598.  
  599. if (!unsafeWindow.g_rgProfileData) { // Older style profile
  600. if (!unsafeWindow.ajaxFriendUrl) // Get outa here
  601. throw new Error("Shouldn't be here. Let's go.");
  602. var sid = unsafeWindow.ajaxFriendUrl.replace("http://steamcommunity.com/actions/AddFriendAjax/","");
  603. old = true;
  604. }
  605. else
  606. var sid = unsafeWindow.g_rgProfileData['steamid'];
  607.  
  608. if (!GM_getValue('Steamcommunity.com_show_links')) {
  609. var s64 = siteList($(ul),sid,false,'whiteLink');
  610. $(div).append($(ul));
  611. $(div).append('<ul style="list-style-type:none;padding-left:5px"><li>'+sid+'</li><li>'+s64+'</li></ul>');
  612. var tmp = document.createElement('span');
  613. $(tmp).addClass('whiteLink');
  614. $(tmp).css({'float':'right','padding-right':'5px'});
  615. $(tmp).text('View Links');
  616.  
  617. if (!old) {
  618. $($('.profile_summary_footer').children()[0]).css({'display':'none'});
  619. }
  620. $(tmp).click(function(e) {
  621. $(div).fadeToggle('slow');
  622. if ($(div).is(':hidden'))
  623. $(tmp).text('View Links');
  624. else
  625. $(tmp).text('Hide Links');
  626. $(div).click(function(e) { e.stopPropagation(); });
  627. $('body').click(function(e) { $('#TF2Profiler_linkList').fadeOut('slow'); });
  628. e.stopPropagation();
  629. });
  630. }
  631. if (old) { // Why doesn't jquery work here? Why? - I know why now. @require and chrome. Look at this kugs
  632. if (!GM_getValue('Steamcommunity.com_show_links')) {
  633. $(tmp).attr("onClick","var div = this.nextSibling;console.log(div.style.display); "
  634. +"if (div.style.display=='none' || !div.style.display){"
  635. +"$(this).innerText='View Links';div.style.display='block';} else {$(this).innerText='Hide Links';"
  636. +"div.style.display='none';}");
  637. $(div).css({"right":"450px"});
  638. $(".mainSectionHeader").append($(tmp));
  639. $(".mainSectionHeader").append($(div));
  640. }
  641. var inGame = $("#statusInGameText");
  642. if (inGame && !GM_getValue("Steamcommunity.com_show_server")) {
  643. if ($(inGame).text().match("Team Fortress 2")) {
  644. var link = $($(inGame).children()[1]).attr('href').replace("steam://connect/","");
  645. $('#statusInGameText').append(" <a id=TF2Profiler_gameMonitorToggle"
  646. +" style='color:#ebebeb !important; padding-bottom: 10px'>View Server Info</a>");
  647. $('#OnlineStatus').after(
  648. "<div id=TF2Profiler_gameMonitor style='display:none;padding-top:10px;z-index:1000000'><iframe src="
  649. +"http://module.game-monitor.com/"+link+"/website.php?s=compatible.css&f=1 frameborder=0 "
  650. +"scrolling=no height=240 width=200></iframe></div>");
  651. $('#TF2Profiler_gameMonitorToggle').click( function(e) {
  652. $('#TF2Profiler_gameMonitor').slideToggle('slow'); e. stopPropagation(); });
  653. }
  654. }
  655.  
  656. } else {
  657. if (!GM_getValue('Steamcommunity.com_show_summary')) {
  658. $('.profile_summary_footer').append($(tmp));
  659. $('.profile_summary_footer').append($(div));
  660.  
  661. if (!$(".profile_summary").text().match("No information given.") || $(".profile_summary").find("a")) {
  662. var ps = $(".profile_summary").clone(true);
  663. $(".profile_leftcol").prepend($(ps));
  664. $(ps).css({"padding":"10px",'margin-bottom':'20px'});
  665. $(ps).before("<div class='profile_leftcol_header'><h2>Summary</h2></div>");
  666. }
  667. // The hide event gets triggered before the show in gm (not in tampermonkey). Shrug. This'll do.
  668. window.setInterval(function(){$('.profile_summary_footer').css({'display':'block'});},100);
  669. }
  670. var inGame = $('.profile_in_game_name');
  671. if (inGame && !GM_getValue("Steamcommunity.com_show_server")) {
  672. if ($(inGame).text().match("Team Fortress 2")) {
  673. var link = $($(inGame).next()).attr('href').replace("steam://connect/","");
  674. $($(inGame).parent()).append(" <a id=TF2Profiler_gameMonitorToggle"
  675. +" style='color:#ebebeb !important'>View Server Info</a>"
  676. +"<div id=TF2Profiler_gameMonitor style='display:none;padding-top:10px;'><iframe src="
  677. +"http://module.game-monitor.com/"+link+"/website.php?s=compatible.css&f=1 frameborder=0 "
  678. +"scrolling=no height=240 width=200></iframe></div>");
  679. $('#TF2Profiler_gameMonitorToggle').click( function() { $('#TF2Profiler_gameMonitor').slideToggle('slow') });
  680. }
  681. }
  682. }
  683. },
  684. },
  685. {// Groups
  686. match: function( url )
  687. {
  688. return url.match(/^https?\:\/\/steamcommunity\.com\/groups\//);
  689. },
  690. script: function( site, url )
  691. {
  692. $(".grouppage_header_label").append(" - <a href=http://www.kugrian.co.uk/tf2profiler/index.php?search="+url
  693. +" target=_blank>Search on TF2Profiler</a>");
  694. },
  695. },
  696. //----------------------------------------------------------------
  697. // UGC League
  698. //----------------------------------------------------------------
  699. {
  700. match: function( url )
  701. {
  702. return url.match("http://www.ugcleague.com/players_page.cfm?");
  703. },
  704. script: function( site, url )
  705. {
  706. var sid = $('small').find('i').html();
  707.  
  708. var ul = document.createElement('ul');
  709. $(ul).css({'list-style-type':'none'});
  710. delete(sites["UGC"]);
  711. siteList($(ul),sid,false,false);
  712. $($('small')[0]).parent().next().html(ul);
  713. },
  714. },
  715. //----------------------------------------------------------------
  716. // Wireplay
  717. //----------------------------------------------------------------
  718. {
  719. match: function( url )
  720. {
  721. return url.match("http://tf2.wireplay.co.uk");
  722. },
  723. script: function( site, url )
  724. {
  725. if (url.match('pg=search') && !GM_getValue("Wireplay_search_fix")) {
  726. if ($($('input[name="searchterm"]')[0]).attr('value').match("STEAM_")) {
  727. var link = "";
  728. var searchType = '6v6';
  729. if (url.match('9v9')) {
  730. } else {
  731. link = "9v9/";
  732. searchType = '9v9';
  733. }
  734. link = 'http://tf2.wireplay.co.uk/'+link+'index.php?pg=search';
  735.  
  736. var a = document.createElement('a');
  737. var form = document.createElement('form');
  738. $(form).attr({'action':link,'method':'post'});
  739. var input = document.createElement('input');
  740. $(input).attr({'type':'hidden','name':'searchterm','value':$($('input[name="searchterm"]')[0]).attr('value')});
  741. $(form).append($(input));
  742. var input = document.createElement('input');
  743. $(input).attr({'type':'hidden','name':'steamid','value':'true','checked':'true'});
  744. $(form).append($(input));
  745. $(a).click(function () { $(form).submit(); });
  746. $(a).css({'cursor':'pointer'});
  747. //if ($($("#contentColumn").find('tbody').children()[2]).text().match('No players found'))
  748.  
  749. $(a).html("<p>Search for this steamid in the "+searchType+" section</p>");
  750. $(a).attr("href",'#');
  751. $("#contentColumn").find('table').after($(a));
  752. }
  753. } else
  754. if (url.match('pg=profile&action=viewprofile') && !GM_getValue("Wireplay_show_links")) {
  755. var ul = document.createElement('ul');
  756. $(ul).css({'list-style-type':'none','padding':'0px','margin':'0px'});
  757. var tmp = $('.newsbody').children().children();
  758. var sid = $($(tmp[tmp.length-1]).find('a')[1]).attr('href');
  759. sid = sid.replace("steam://friends/add/","");
  760. delete(sites["Wireplay"]);
  761. console.log(sid);
  762. siteList($(ul),sid,false,false);
  763. var trl = document.createElement('tr');
  764. $(trl).html("<td valign=top><b>Other Sites</b></td><td valign=top class=newsLBlock></td>");
  765. $(trl).find('.newsLBlock').append($(ul));
  766. $($('#tabnav').next().find('tbody')[0]).append($(trl));
  767. }
  768. },
  769. },
  770. //----------------------------------------------------------------
  771. // Homepage - Safe place for options
  772. //----------------------------------------------------------------
  773. {
  774. match: function( url )
  775. {
  776. return url.match(/https?\:\/\/userscripts.org\/scripts\/show\/169861/);
  777. },
  778. script: function( site )
  779. {
  780. var a = document.createElement('a');
  781.  
  782. $(a).text("Userscript Options");
  783. $(a).attr('href','#TF2ProfilerOptions');
  784. $(a).css({'padding-left':'15px'});
  785. $(a).click( function (e) {
  786. if (!TF2Profiler_options)
  787. TF2Profiler_createOptions();
  788. else
  789. $(TF2Profiler_options).fadeToggle('slow');
  790. $("body").click(function() { $('#TF2Profiler_options').fadeOut('slow'); });
  791. $(TF2Profiler_options).click(function(e) { e.stopPropagation(); });
  792. e.stopPropagation();
  793. });
  794. $($('#content').find('.script_summary')[0]).after($(a));
  795. },
  796. },
  797.  
  798.  
  799. ];
  800.  
  801. // Look up a match and dispatch
  802. var found = 0;
  803. for ( var i = 0; i<websites.length; ++i )
  804. {
  805. var site = websites[i];
  806. if ( site.match( currentURL ) )
  807. {
  808. site.script( site, currentURL );
  809. ++found;
  810. }
  811. }
  812. if ( !found ) console.log('No matches for '+currentURL);
  813.  
  814. /*
  815. var a = document.createElement('a');
  816.  
  817. $(a).text("Userscript Options");
  818. $(a).css({'position':'absolute','right':'0px','top':'30px','color':'green'});
  819. $(a).click( function () {
  820. TF2Profiler_options = document.getElementById("TF2Profiler_options");
  821. if (!TF2Profiler_options)
  822. TF2Profiler_createOptions();
  823. else
  824. $(TF2Profiler_options).toggle();
  825. });
  826.  
  827. $('body').append($(a));
  828. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement