Guest User

Untitled

a guest
Aug 26th, 2014
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 23.57 KB | None | 0 0
  1. // ==UserScript==
  2. // @name TF2 Profile Script
  3. // @namespace tfprofile
  4. // @version 1.1.3
  5. // @description Mouse over profile links (steamcommunity/etf2l/wireplay/teamfortress.tv) to get links their profiles on otherwebsites
  6. // @downloadURL https://github.com/CasualX/UserScripts/raw/master/tfprofile.user.js
  7. // @updateURL https://github.com/CasualX/UserScripts/raw/master/tfprofile.user.js
  8. // @include http://*
  9. // @include https://*
  10. // @grant GM_xmlhttpRequest
  11. // @run-at document-end
  12. // ==/UserScript==
  13.  
  14. // Base conversion of arbitrary precision integers
  15. // Minified from http://danvk.org/hex2dec.html
  16. function convertBase(e,t,n){function r(e,t,n){var r=[];var i=Math.max(e.length,t.length);var s=0;var o=0;while(o<i||s){var u=o<e.length?e[o]:0;var a=o<t.length?t[o]:0;var f=s+u+a;r.push(f%n);s=Math.floor(f/n);o++}return r}function i(e,t,n){if(e<0)return null;if(e==0)return[];var i=[];var s=t;while(true){if(e&1){i=r(i,s,n)}e=e>>1;if(e===0)break;s=r(s,s,n)}return i}function s(e,t){var n=e.split("");var r=[];for(var i=n.length-1;i>=0;i--){var s=parseInt(n[i],t);if(isNaN(s))return null;r.push(s)}return r}var o=s(e,t);if(o===null)return null;var u=[];var a=[1];for(var f=0;f<o.length;f++){if(o[f]){u=r(u,i(o[f],a,n),n)}a=i(t,a,n)}var l="";for(var f=u.length-1;f>=0;f--){l+=u[f].toString(n)}return l}
  17. // Googled this for Chrome compat, minified
  18. function addStyle(e){var t=document.createElement("style");t.type="text/css";t.appendChild(document.createTextNode(e));document.getElementsByTagName("head")[0].appendChild(t)}
  19.  
  20. //----------------------------------------------------------------
  21. // Steam ID container
  22. function CSteamID()
  23. {
  24. this.unAccountID = 0;
  25. this.unAccountInstance = 0;
  26. this.EAccountType = CSteamID.EAccountType.k_EAccountTypeInvalid;
  27. this.EUniverse = CSteamID.EUniverse.k_EUniverseInvalid;
  28. }
  29. CSteamID.prototype.setID = function( sid, type, uni )
  30. {
  31. this.unAccountID = sid;
  32. this.unAccountInstance = 1;
  33. this.EAccountType = type || CSteamID.EAccountType.k_EAccountTypeIndividual;
  34. this.EUniverse = uni || CSteamID.EUniverse.k_EUniversePublic;
  35. }
  36. CSteamID.prototype.setID64 = function( id )
  37. {
  38. var hex = "0000000000000000" + convertBase( id, 10, 16 );
  39.  
  40. // Break down the (hexadecimal) community id
  41. this.unAccountID = parseInt(hex.substr(-8,8),16);
  42. this.unAccountInstance = parseInt(hex.substr(-13,5),16);
  43. this.EAccountType = parseInt(hex.substr(-14,1),16);
  44. this.EUniverse = parseInt(hex.substr(-16,2),16);
  45. }
  46. CSteamID.prototype.render = function()
  47. {
  48. // Old style U:x:y format
  49. return "U:" + (this.unAccountID%2) + ":" + (this.unAccountID>>1);
  50. }
  51. CSteamID.prototype.toString = function()
  52. {
  53. function s( num, len )
  54. {
  55. var str = num.toString(16);
  56. return "0000000000000000".substr(0,len-str.length)+str;
  57. }
  58. var hex = s(this.EUniverse,2) + s(this.EAccountType,1) + s(this.unAccountInstance,5) + s(this.unAccountID,8);
  59. return convertBase( hex, 16, 10 );
  60. }
  61. CSteamID.EUniverse = { k_EUniverseInvalid:0, k_EUniversePublic:1, k_EUniverseBeta:2, k_EUniverseInternal:3, k_EUniverseDev:4, k_EUniverseRC:5, k_EUniverseMax:6 };
  62. CSteamID.EAccountType = { k_EAccountTypeInvalid:0, k_EAccountTypeIndividual:1, k_EAccountTypeMultiseat:2, k_EAccountTypeGameServer:3, k_EAccountTypeAnonGameServer:4, k_EAccountTypePending:5, k_EAccountTypeContentServer:6, k_EAccountTypeClan:7, k_EAccountTypeChat:8, k_EAccountTypeP2PSuperSeeder:9, k_EAccountTypeMax:10 };
  63. CSteamID.parse = function( str )
  64. {
  65. var re, sid = null;
  66. // SteamID old format, 2nd part is how etf2l formats it.
  67. if ( re = /^(?:U)?0\:([01])\:(\d+)$/.exec( str ) )
  68. {
  69. sid = new CSteamID();
  70. sid.setID( parseInt(re[2])*2 + parseInt(re[1]) );
  71. }
  72. // Looks like a standard 64bit steamid
  73. else if ( re = /^\d+$/.exec( str ) )
  74. {
  75. sid = new CSteamID();
  76. sid.setID64( str );
  77. }
  78. return sid;
  79. }
  80. //----------------------------------------------------------------
  81.  
  82. // Find profiles with search engine because they don't have an API...
  83. function searchEngine( site, title, content, fn )
  84. {
  85. function search( engine )
  86. {
  87. GM_xmlhttpRequest( {
  88. method: "GET",
  89. url: engine.qurl + encodeURIComponent( 'site:'+site+' title:"'+title+'" "'+content+'"' ),
  90. onload: function( resp ) { match( resp.responseText, engine ); },
  91. onerror: function( resp ) { match( "", engine ); }
  92. } );
  93. }
  94. function match( text, engine )
  95. {
  96. var r;
  97. while ( r = engine.regex.exec( text ) )
  98. {
  99. // Found a valid result
  100. if ( r[1].indexOf(site)>=0 )
  101. return fn( r );
  102. }
  103. // Not found, try another search engine
  104. if ( engine.next ) search( engine.next );
  105. // Tried all engines, nothing found
  106. else fn( false );
  107. }
  108. var engines = {
  109. qurl: "https://ixquick.com/do/search?q=",
  110. regex: /<a href='([^']*)' id='title_\d'/,
  111. next: {
  112. qurl: "https://startpage.com/do/search?q=",
  113. regex: /<a href='([^']*)' id='title_\d'/,
  114. }
  115. };
  116. search( engines );
  117. }
  118.  
  119. //----------------------------------------------------------------
  120. // Websites supported
  121. //----------------------------------------------------------------
  122. // Each website may have these 3 functions:
  123. // match: Given an url return a non false value if you can handle this profile link
  124. // source: Source the player's steamid from this profile url, directly called after match with its returned value (eg, regex result). Callback player.initialize with the steamid on success.
  125. // query: Find out given the steamid if this player has a profile on this website. Callback player.addLink with the url and description on success.
  126.  
  127. function siteSetLink( p, url, desc, html )
  128. {
  129. var a = document.createElement('a');
  130. a.href = url;
  131. a.target = "_blank";
  132. if ( html ) a.innerHTML = html;
  133. var text = document.createTextNode(desc);
  134. if ( a.firstChild ) a.insertBefore( text, a.firstChild );
  135. else a.appendChild( text );
  136. p.innerHTML = '';
  137. p.appendChild( a );
  138. p.className = 'TFProfile_Done';
  139. }
  140. function siteSetMissing( p )
  141. {
  142. p.className = 'TFProfile_Missing';
  143. // Hide the parent article if it only has missing links...
  144. if ( p.parentNode.children.length==p.parentNode.querySelectorAll(".TFProfile_Missing").length )
  145. p.parentNode.parentNode.removeChild( p.parentNode );
  146. }
  147.  
  148. var sites = {
  149. // Steam community support
  150. "steamcommunity.com": {
  151. group: "steam",
  152. match: function( url ) { return /^https?\:\/\/steamcommunity\.com\/(?:profiles|id)\/[^\/]*\/?$/.exec(url); },
  153. source: function( re, player )
  154. {
  155. GM_xmlhttpRequest( {
  156. method: "GET",
  157. url: re[0] + "?xml=1",
  158. onload: function( resp )
  159. {
  160. var parser = new DOMParser();
  161. var doc = parser.parseFromString( resp.responseText, "text/xml" ).documentElement;
  162. var str = doc.querySelector( "steamID64" ).textContent;
  163. player.initialize( CSteamID.parse( str ) );
  164. },
  165. onerror: function( resp )
  166. {
  167. player.error( resp.responseText );
  168. }
  169. } );
  170. },
  171. query: function( sid, player, el )
  172. {
  173. el.textContent = 'steamcommunity.com';
  174.  
  175. var commid = sid.toString();
  176. GM_xmlhttpRequest( {
  177. method: "GET",
  178. url: "https://steamcommunity.com/profiles/"+commid+"?xml=1",
  179. onload: function( resp )
  180. {
  181. var parser = new DOMParser();
  182. doc = parser.parseFromString( resp.responseText, "text/xml" ).documentElement;
  183.  
  184. // Profiles that haven't been set up do not have a name, in this case, steamID will be empty
  185. var desc = "Steam Community", name = doc.querySelector("steamID"), online = doc.querySelector("onlineState");
  186. if ( name && name.textContent ) desc += " ("+name.textContent+")";
  187. siteSetLink( el, "https://steamcommunity.com/profiles/"+commid, desc, online?'<span style="padding-left:5px;font-size:xx-small;">'+online.textContent+'</span>':undefined );
  188.  
  189. var gameIP = doc.querySelector("inGameServerIP");
  190. var gameName = doc.querySelector("inGameInfo>gameName")
  191. var gameJoin = doc.querySelector("inGameInfo>gameJoinLink");
  192. if ( gameIP && gameIP.textContent && gameName && gameName.textContent && gameJoin && gameJoin.textContent )
  193. {
  194. var a = document.createElement('a');
  195. a.href = gameJoin.textContent;
  196. a.innerHTML = "In-Game: "+gameName.textContent;
  197. el.appendChild( a );
  198. }
  199. }
  200. } );
  201. }
  202. },
  203. // ETF2L Support
  204. "etf2l.org": {
  205. group: "comptf2",
  206. match: function( url ) { return /^http\:\/\/etf2l.org\/forum\/user\/(\d+)\/?$/.exec(url); },
  207. source: function( re, player )
  208. {
  209. GM_xmlhttpRequest( {
  210. method: "GET",
  211. url: "http://etf2l.org/feed/player/?id=" + re[1],
  212. onload: function( resp )
  213. {
  214. var parser = new DOMParser();
  215. var doc = parser.parseFromString( resp.responseText, "text/xml" ).documentElement;
  216. var str = doc.querySelector( "player" );
  217. player.initialize( CSteamID.parse( str ? str.getAttribute("steamid") : "" ) );
  218. },
  219. onerror: function( resp )
  220. {
  221. player.error( resp.responseText );
  222. }
  223. } );
  224. },
  225. query: function( sid, player, el )
  226. {
  227. el.textContent = 'etf2l.org';
  228.  
  229. GM_xmlhttpRequest( {
  230. method: "GET",
  231. url: "http://etf2l.org/feed/player/?steamid=" + sid.render(),
  232. onload: function( resp )
  233. {
  234. try {
  235. var parser = new DOMParser();
  236. var doc = parser.parseFromString( resp.responseText, "text/xml" ).documentElement;
  237. var id = doc.querySelector("player").getAttribute("id");
  238. var name = doc.querySelector("displayname").textContent;
  239. siteSetLink( el, "http://etf2l.org/forum/user/"+id+"/", "ETF2L Profile ("+name+")" );
  240. } catch(e) {
  241. siteSetMissing( el );
  242. }
  243. }
  244. } );
  245. }
  246. },
  247. // Wireplay TF2 League
  248. "tf2.wireplay.co.uk": {
  249. group: "comptf2",
  250. match: function( url ) { return /^https?\:\/\/tf2\.wireplay\.co\.uk\/.*?index\.php\?pg=profile\&action=viewprofile\&aid=(\d+)/.exec(url); },
  251. source: function( re, player )
  252. {
  253. GM_xmlhttpRequest( {
  254. method: "GET",
  255. url: re[0],
  256. onload: function( resp )
  257. {
  258. var r = /<td align=left>(U\:[01]\:\d+)<\/td>/.exec(resp.responseText);
  259. player.initialize( CSteamID.parse( r?r[1]:"" ) );
  260. },
  261. onerror: function( resp )
  262. {
  263. player.error( resp.responseText );
  264. }
  265. } );
  266. },
  267. query: function( sid, player, el )
  268. {
  269. el.textContent = 'tf2.wireplay.co.uk';
  270.  
  271. GM_xmlhttpRequest( {
  272. method: "POST",
  273. url: "http://tf2.wireplay.co.uk/index.php?pg=search",
  274. data: "clantag=false&clanname=false&playername=false&steamid=true&searchterm=" + encodeURIComponent(sid.render()),
  275. headers: { "Content-Type": "application/x-www-form-urlencoded" },
  276. onload: function( resp )
  277. {
  278. try {
  279. var r = /<td><a href="(index.php\?pg=profile\&action=viewprofile\&aid=\d+)">([^<]*)<\/a><\/td>/.exec(resp.responseText);
  280. siteSetLink( el, "http://tf2.wireplay.co.uk/"+r[1], "Wireplay Profile ("+r[2]+")" );
  281. } catch(e) {
  282. siteSetMissing( el );
  283. }
  284. }
  285. } );
  286. }
  287. },
  288. // UGC League
  289. "ugcleague.com": {
  290. group: "comptf2",
  291. match: function( url ) { return /^https?\:\/\/www.ugcleague.com\/players_page\.cfm\?player_id=(\d+)$/.exec(url); },
  292. source: function( re, player ) { player.initialize( CSteamID.parse( re[1] ) ); },
  293. query: function( sid, player, el )
  294. {
  295. el.textContent = 'ugcleague.com';
  296.  
  297. // Assumption: Just check if the player's steamid is on the page, that means he's played in a team.
  298. // FIXME! Use their player search page instead? http://www.ugcleague.com/playersearch.cfm
  299. GM_xmlhttpRequest( {
  300. method: "GET",
  301. url: "http://www.ugcleague.com/players_page.cfm?player_id="+sid.toString(),
  302. onload: function( resp )
  303. {
  304. if ( resp.responseText.indexOf( "<td>"+sid.render().substr(6)+"</td>" )>=0 )
  305. siteSetLink( el, "http://www.ugcleague.com/players_page.cfm?player_id="+sid.toString(), "UGC League Profile" );
  306. else
  307. siteSetMissing( el );
  308. }
  309. } );
  310. }
  311. },
  312. // TF2Lobby.com
  313. "tf2lobby.com": {
  314. group: "lobby",
  315. match: function( url ) { return /^http\:\/\/(?:www.)?tf2lobby\.com\/profile\?(f?id)=(\d+)$/.exec(url); },
  316. source: function( re, player )
  317. {
  318. if ( re[1]==='fid' )
  319. {
  320. player.initialize( CSteamID.parse( re[2] ) );
  321. return;
  322. }
  323.  
  324. GM_xmlhttpRequest( {
  325. method: "GET",
  326. url: "http://www.tf2lobby.com/profile?id="+re[2],
  327. onload: function( resp )
  328. {
  329. var dom = new DOMParser(), doc, el, sid;
  330. if ( ( doc = parser.parseFromString( resp.responseText, "text/xml" ).documentElement ) &&
  331. ( el = doc.querySelector("#otherSites>ul>li>a") ) )
  332. {
  333. sid = CSteamID.parse( /\d+/.exec( el.href )[0] );
  334. }
  335. player.initialize( sid );
  336. },
  337. onerror: function( resp )
  338. {
  339. player.error( resp.responseText );
  340. }
  341. } );
  342. },
  343. query: function( sid, player, el )
  344. {
  345. el.textContent = 'tf2lobby.com';
  346.  
  347. GM_xmlhttpRequest( {
  348. method: "GET",
  349. url: "http://www.tf2lobby.com/profile?fid="+sid.toString(),
  350. onload: function( resp )
  351. {
  352. try {
  353. var dom = new DOMParser();
  354. var doc = dom.parseFromString( resp.responseText, "text/html" ).documentElement;
  355. var name = ( doc.querySelector("#otherSites") && doc.querySelector("#player p") ).textContent;
  356. siteSetLink( el, "http://www.tf2lobby.com/profile?fid="+sid.toString(), "TF2Lobby Profile ("+name+")" );
  357. } catch(e) {
  358. siteSetMissing( el );
  359. }
  360. }
  361. } );
  362. }
  363. },
  364. // TeamFortress.tv profiles (barely works...)
  365. "teamfortress.tv": {
  366. group: "forum",
  367. match: function( url ) { return /^https?\:\/\/teamfortress\.tv\/profile\/user\/[^\/]*\/?$/.exec(url); },
  368. source: function( re, player )
  369. {
  370. GM_xmlhttpRequest( {
  371. method: "GET",
  372. url: re[0],
  373. onload: function( resp )
  374. {
  375. var r = /(U\:[01]\:\d+)/.exec( resp.responseText );
  376. player.initialize( CSteamID.parse( r?r[1]:0 ) );
  377. },
  378. onerror: function( resp )
  379. {
  380. player.error( resp.responseText );
  381. }
  382. } );
  383. },
  384. query: function( sid, player, el )
  385. {
  386. el.textContent = 'teamfortress.tv';
  387.  
  388. // Cannot query by steamid...
  389. searchEngine( "teamfortress.tv", "Profile", sid.render(), function(r) {
  390. try {
  391. var url = r[1];
  392. var name = /profile\/user\/(.*?)\/?$/.exec(url)[1];
  393. siteSetLink( el, url, "TeamFortress.tv ("+name+")" );
  394. } catch(e) {
  395. siteSetMissing( el );
  396. }
  397. } );
  398. }
  399. },
  400. // logs.tf
  401. "logs.tf": {
  402. group: "stats",
  403. match: function( url ) { return /^https?\:\/\/(?:www.)?logs\.tf\/profile\/(\d+)\/?$/.exec(url); },
  404. source: function( re, player ) { player.initialize( CSteamID.parse( re[1] ) ); },
  405. query: function( sid, player, el )
  406. {
  407. el.textContent = 'logs.tf';
  408.  
  409. GM_xmlhttpRequest( {
  410. method: "GET",
  411. url: "http://logs.tf/profile/"+sid.toString(),
  412. onload: function( resp )
  413. {
  414. if ( !(/<h5>None found\.<\/h5>/.test(resp.responseText)) )
  415. siteSetLink( el, "http://logs.tf/profile/"+sid.toString(), "Logs.tf Profile" );
  416. else
  417. siteSetMissing( el );
  418. }
  419. } );
  420. }
  421. },
  422. // SizzlingStats.com (FIXME! Figure out their query api)
  423. "sizzlingstats.com": {
  424. group: "stats",
  425. match: function( url ) { return /^https?\:\/\/(?:www.)?sizzlingstats\.com\/player\/(\d+)\/?$/.exec(url); },
  426. source: function( re, player ) { player.initialize( CSteamID.parse( re[1] ) ); },
  427. query: function( sid, player ) { return false; }
  428. },
  429. // TF2Logs.com (does anyone still use this?)
  430. "tf2logs.com": {
  431. group: "stats",
  432. match: function( url ) { return /^https?\:\/\/(?:www.)?tf2logs\.com\/players\/(\d+)\/?$/.exec(url); },
  433. source: function( re, player ) { player.initialize( CSteamID.parse( re[1] ) ); },
  434. query: function( sid, player, el )
  435. {
  436. el.textContent = 'tf2logs.com';
  437.  
  438. GM_xmlhttpRequest( {
  439. method: "GET",
  440. url: "http://tf2logs.com/players/"+sid.toString(),
  441. onload: function( resp )
  442. {
  443. var re = /<meta name="title" content="([^>]*?) - TF2Logs.com" \/>/.exec(resp.responseText);
  444. if ( re && re[1]!='Welcome' )
  445. siteSetLink( el, "http://tf2logs.com/players/"+sid.toString(), "TF2Logs.com Profile" );
  446. else
  447. siteSetMissing( el );
  448. }
  449. } );
  450. }
  451. },
  452. };
  453.  
  454. //----------------------------------------------------------------
  455. // A link resource
  456. //----------------------------------------------------------------
  457. function linkPlayer( a )
  458. {
  459. this.anchor = a;
  460.  
  461. // Generate html
  462. var div = document.createElement('div');
  463. this.div = div;
  464. div.classList.add( 'TFProfile' );
  465. div.innerHTML = '<p>Pending...</p>';
  466. }
  467. // Initialize from a steamid
  468. linkPlayer.prototype.initialize = function( sid )
  469. {
  470. if ( sid )
  471. {
  472. // Show steam id
  473. var span = this.div.querySelector("p");
  474. span.innerHTML = '';
  475. span.appendChild( document.createTextNode( sid.render() ) );
  476. // Collect information about other websites
  477. for ( var it in sites )
  478. {
  479. var site = sites[it];
  480.  
  481. // Find the group this belongs in
  482. var group = this.div.querySelector("article.TFProfile_"+site.group);
  483. if ( !group )
  484. {
  485. group = document.createElement('article');
  486. group.className = "TFProfile_"+site.group;
  487. this.div.appendChild( group );
  488. }
  489.  
  490. var p = document.createElement('p');
  491. p.className = 'TFProfile_Pending';
  492.  
  493. if ( site.query( sid, this, p )!==false )
  494. {
  495. group.appendChild( p );
  496. }
  497. }
  498. }
  499. else
  500. {
  501. this.error( "Invalid SteamID!" );
  502. }
  503. }
  504. // Error happened
  505. linkPlayer.prototype.error = function( desc )
  506. {
  507. var p = this.div.querySelector("p");
  508. p.innerHTML = '';
  509. p.appendChild( document.createTextNode( 'Error! ' + desc ) );
  510. }
  511. // Delay the query on mouse over
  512. linkPlayer.prototype.source = function( a, re, site )
  513. {
  514. this.show( a, function() {
  515. if ( !this.sourced )
  516. {
  517. this.sourced = true;
  518. site.source( re, this );
  519. }
  520. } );
  521. }
  522. // Show the UI, delay loading as needed
  523. linkPlayer.prototype.show = function( a, fn )
  524. {
  525. var self = this;
  526. function hover()
  527. {
  528. // Begin sourcing
  529. fn.call( self );
  530. // Show our overlay only
  531. Array.prototype.forEach.call( document.querySelectorAll(".TFProfile"), function(div) { div.style.display="none"; } );
  532. clear();
  533. // Compute position of the tooltip
  534. var r = a.getBoundingClientRect();
  535. var bottom = r.bottom + ( document.documentElement.scrollTop || document.body.scrollTop );
  536. var left = r.left + ( document.documentElement.scrollLeft || document.body.scrollLeft );
  537. self.div.style.top = bottom + "px";
  538. self.div.style.left = left + "px";
  539. // Show it
  540. self.div.style.display = "block";
  541. document.body.appendChild( self.div );
  542. }
  543. function clear()
  544. {
  545. if ( self.timer )
  546. {
  547. window.clearTimeout( self.timer );
  548. self.timer = false;
  549. }
  550. }
  551. function timer( fn, ms )
  552. {
  553. clear();
  554. self.timer = window.setTimeout( fn, ms );
  555. }
  556. function leave()
  557. {
  558. self.div.style.display = "none";
  559. clear();
  560. }
  561. function related( parent, child )
  562. {
  563. return !( !child || ( child!==parent && !parent.contains( child ) ) );
  564. }
  565. a.addEventListener( 'mouseover', function(e) { timer( hover, 500 ); }, false );
  566. a.addEventListener( 'mouseout', function(e) { if ( !related(this,e.relatedTarget) ) timer( leave, 500 ); }, false );
  567. this.div.addEventListener( 'mouseover', clear, false );
  568. this.div.addEventListener( 'mouseout', function(e) { if ( !related(this,e.relatedTarget ) ) timer( leave, 200 ); }, false );
  569.  
  570. // Work around for mouseleave not working for chrome...
  571. var img = document.createElement('img');
  572. img.alt = "x";
  573. //img.src = "data:image/gif;base64,R0lGODlhDwAPANUAAAAAAP////7+/v39/fz8/Pv7+/j4+Pf39/X19fHx8e/v7+7u7u3t7evr6+rq6ufn5+bm5uXl5eLi4uDg4N/f39zc3Nra2tnZ2dTU1NPT09LS0tDQ0M/Pz87Ozs3NzbOzs39/f3V1dVdXVz4+PiMjI////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAACUALAAAAAAPAA8AAAaawJKwpJhgPJiJYjg0SCqNg+DQqEgMzc2DMOh2CY8NtiSBFM5oNERCtBwMAIBhHjccLMUIAsEBkBAkABx7EUYNCYgfACMAH4gJDUcMC5QLcQCVCwxIEQ6eIQCgIZ4OEUkVEBAgACIQIgAgqRVKGhQUcba3ALYaSxIZF8HCwhlsJQYeGxjLzBgbHmPHEh4dHNYdHldMQkVHSUtDQQA7";
  574. img.addEventListener( 'click', leave, false );
  575. this.div.insertBefore( img, this.div.firstChild );
  576. }
  577.  
  578. //----------------------------------------------------------------
  579. // Apply to all links in the document
  580. //----------------------------------------------------------------
  581. // FIXME! Does not work on content loaded after page load!
  582. Array.prototype.forEach.call( document.querySelectorAll("a"), function(link)
  583. {
  584. var url = link.href;
  585. for ( var it in sites )
  586. {
  587. var site = sites[it];
  588. var re = site.match && site.match( url );
  589. if ( re )
  590. {
  591. (new linkPlayer( link )).source( link, re, site );
  592. }
  593. }
  594. } );
  595.  
  596. // Make it all look pretty
  597. addStyle('\
  598. div.TFProfile { \
  599. position:absolute !important; \
  600. z-index:9999999 !important; \
  601. background-color:#F8F8FF !important; \
  602. border: solid 1px #C0C0C0 !important; \
  603. min-width:200px !important; \
  604. padding:5px 10px; \
  605. -webkit-box-shadow: 1px 1px 1px 0px rgba(0, 0, 0, 0.3); \
  606. box-shadow: 1px 1px 1px 0px rgba(0, 0, 0, 0.3); } \
  607. \
  608. div.TFProfile img { \
  609. float:right !important;\
  610. margin:-5px 0px 0px 0px !important;\
  611. background-color: #cbcbcb;\
  612. display: block;\
  613. height: 18px;\
  614. width: 36px;\
  615. font-family: Verdana, Arial, Helvetica, sans-serif;\
  616. font-size: 11px;\
  617. font-weight: bold;color: #fff;\
  618. text-decoration: none;\
  619. text-align:center;\
  620. cursor: pointer;\
  621. line-height: 16px;\
  622. border: none;\
  623. -webkit-transition: background 100ms ease-in-out;\
  624. -moz-transition: background 100ms ease-in-out;\
  625. -ms-transition: background 100ms ease-in-out;\
  626. -o-transition: background 100ms ease-in-out;\
  627. transition: background 100ms ease-in-out; } \
  628. \
  629. div.TFProfile img:hover { \
  630. background-color: #de5044;\
  631. } \
  632. \
  633. div.TFProfile p { \
  634. letter-spacing:0px !important; \
  635. text-align:left !important; \
  636. color:#555!important; \
  637. padding:0!important; \
  638. margin:0px!important; \
  639. display: block !important; \
  640. border: none !important; \
  641. font-family: Verdana, Arial, Helvetica, sans-serif; \
  642. font-size: 10px; \
  643. font-style: normal; \
  644. line-height: normal; \
  645. font-weight: normal; \
  646. font-variant: normal; \
  647. color: #4c4c4c; \
  648. text-decoration: none; } \
  649. \
  650. div.TFProfile p.TFProfile_Done>a { \
  651. font-family:Verdana, Arial, Helvetica, sans-serif; \
  652. font-size:9px; \
  653. font-style:normal; \
  654. line-height:normal; \
  655. font-weight:700; \
  656. font-variant:normal; \
  657. text-decoration:none; \
  658. letter-spacing:0 !important; \
  659. text-align:left !important; \
  660. color:#f8f8f8; \
  661. border:1px solid #679bf3; \
  662. background-color:#77a7f9; \
  663. width:auto; \
  664. height:auto; \
  665. display:block!important; \
  666. margin:2px 0px!important; \
  667. padding:5px!important } \
  668. \
  669. div.TFProfile p.TFProfile_Done>a:hover { \
  670. color:#fff; \
  671. border:1px solid #4585f3; \
  672. -webkit-box-shadow:1px 1px 2px 0 rgba(0,0,0,0.1);\
  673. box-shadow:1px 1px 2px 0 rgba(0,0,0,0.1);\
  674. background: #77a7f9;\
  675. background: -moz-linear-gradient(top, #77a7f9 0%, #699cf2 100%);\
  676. background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#77a7f9), color-stop(100%,#699cf2));\
  677. background: -webkit-linear-gradient(top, #77a7f9 0%,#699cf2 100%);\
  678. background: -o-linear-gradient(top, #77a7f9 0%,#699cf2 100%);\
  679. background: -ms-linear-gradient(top, #77a7f9 0%,#699cf2 100%);\
  680. background: linear-gradient(to bottom, #77a7f9 0%,#699cf2 100%);\
  681. filter: progid:DXImageTransform.Microsoft.gradient( startColorstr="#77a7f9", endColorstr="#699cf2",GradientType=0 );} \
  682. \
  683. div.TFProfile p.TFProfile_Pending { \
  684. font-family:Verdana, Arial, Helvetica, sans-serif !important; \
  685. font-size:9px !important; \
  686. font-style:normal !important; \
  687. line-height:normal !important; \
  688. font-weight:700 !important; \
  689. font-variant:normal !important; \
  690. text-decoration:none !important; \
  691. letter-spacing:0 !important; \
  692. text-align:left !important; \
  693. color:#b1b1b1 !important; \
  694. border:1px solid #cbcbcb !important; \
  695. background-color:#e5e5e5 !important; \
  696. width:auto !important; \
  697. height:auto !important; \
  698. display:block !important; \
  699. margin:2px 0px !important;\
  700. padding:5px !important } \
  701. \
  702. div.TFProfile p.TFProfile_Missing { \
  703. display:none!important; \
  704. } \
  705. div.TFProfile article { \
  706. border-bottom: 1px dotted #C0C0C0; \
  707. padding: 5px 0px; \
  708. } \
  709. div.TFProfile article:last-child { \
  710. border-bottom: none; \
  711. } \
  712. ');
Advertisement
Add Comment
Please, Sign In to add comment