qazarius

steamcommunity.user.js

Dec 11th, 2012
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name Steam Web Tools Steamcommunity Page MOD
  3. // @include https://steamcommunity.com/id/*
  4. // @include http://steamcommunity.com/id/*
  5. // @include https://steamcommunity.com/profiles/*
  6. // @include http://steamcommunity.com/profiles/*
  7. // ==/UserScript==
  8.  
  9. // init func
  10. function init(){
  11.  
  12.     // for profile page
  13.     if (window.ajaxFriendUrl) {
  14.  
  15.         var steamid = window.invitee
  16.         if(!steamid){
  17.             steamid = window.ajaxFriendUrl.split('/');
  18.             steamid = steamid[steamid.length-1];
  19.         }
  20.        
  21.         // permanent URL
  22.         var el = document.querySelector('#profileBlock');
  23.         el.insertAdjacentHTML('beforeBegin', '<div>Постоянная ссылка:<br/><a href="http://steamcommunity.com/profiles/'+steamid+'">http://steamcommunity.com/profiles/'+steamid+'</a><br/><br/></div>');
  24.  
  25.         var links = [];
  26.  
  27.         // "add friend" & "del friend"
  28.         if(!window.g_steamID) {
  29.             links.push({
  30.                 href: 'steam://friends/add/'+steamid,
  31.                 icon: 'http://cdn.steamcommunity.com/public/images/skin_1/iconAddFriend.png',
  32.                 text: 'Добавить в друзья',
  33.             });
  34.             links.push({hr:true});
  35.         } else if(document.querySelector('#inCommon .YouAreFriends')) {
  36.             window.ajaxFriendUrl = "http://steamcommunity.com/actions/RemoveFriendAjax/"+steamid;
  37.  
  38.             addLinks('<div class="notificationSpacer"><div id="NotificationArea" style="display:none"></div><div class="actionItem" id="AddFriendItem"><div class="actionItemIcon"><a  href="javascript:ajaxAddFriend()"><img src="http://cdn.steamcommunity.com/public/images/skin_1/iconFriends.png" width="16" height="16" border="0" /></a></div><a class="linkActionMinor " href="javascript:ajaxAddFriend()">Удалить из друзей</a></div></div>');
  39.            
  40.         }
  41.  
  42.         // base links
  43.         links = links.concat([
  44.             {
  45.                 href: 'http://check.csmania.ru/#steam:'+steamid,
  46.                 icon: 'http://check.csmania.ru/favicon.ico',
  47.                 text: 'Проверить на Check.CSmania.RU',
  48.             },
  49.             {
  50.                 href: 'http://steamrep.com/profiles/'+steamid,
  51.                 icon: 'http://steamrep.com/favicon.ico',
  52.                 text: 'Проверить на SteamRep.com',
  53.             },
  54.             {hr:true},
  55.             {
  56.                 href: 'http://backpack.tf/id/'+steamid,
  57.                 icon: 'http://backpack.tf/favicon.ico',
  58.                 text: 'Инвентарь Backpack.tf',
  59.             },
  60.             {
  61.                 href: 'http://tf2b.com/tf2/'+steamid,
  62.                 icon: 'http://tf2b.com/favicon.ico',
  63.                 text: 'Инвентарь TF2B.com',
  64.             },
  65.             {
  66.                 href: 'http://tf2outpost.com/id/'+steamid,
  67.                 icon: 'http://tf2outpost.com/favicon.ico',
  68.                 text: 'Инвентарь TF2OutPost.com',
  69.             },
  70.             {
  71.                 href: 'http://tf2outpost.com/user/'+steamid,
  72.                 icon: 'http://tf2outpost.com/favicon.ico',
  73.                 text: 'Трэйды на TF2OutPost.com',
  74.             },
  75.             {
  76.                 href: 'http://steammoney.com/userpage.php?id='+steamid,
  77.                 icon: 'http://steammoney.com/favicon.ico',
  78.                 text: 'Инвентарь SteamMoney.com',
  79.             },
  80.             {hr:true},
  81.  
  82.         ]);
  83.  
  84.         addLinks(links);
  85.  
  86.     } // end for profile page
  87.     else
  88.     // for invetory page
  89.     if (window.BuildHover) {
  90.    
  91.         // multi gifts sending
  92.         document.body.insertAdjacentHTML("beforeBegin",
  93.             '<style>.checkedForSend{background:#366836!important}</style>'
  94.         );
  95.         window.checkedForSend={};
  96.         window.checkForSend = function(giftId){
  97.             var item = window.UserYou.rgContexts[753][1].inventory.rgInventory[giftId];
  98.             if(item.checkedForSend){
  99.                 item.checkedForSend=false;
  100.                 item.element.removeClassName('checkedForSend');
  101.                 delete window.checkedForSend[giftId];
  102.  
  103.             } else {
  104.                 item.checkedForSend=true;
  105.                 item.element.addClassName('checkedForSend');
  106.                
  107.                 window.checkedForSend[giftId]=item.name;
  108.             }
  109.         }
  110.         window.sendChecked = function(){
  111.             var url = 'http://store.steampowered.com/checkout/sendgift/';
  112.             for(var gid in window.checkedForSend){
  113.                 break;
  114.             }
  115.            
  116.             url+=gid+'#multisend='+encodeURIComponent(JSON.stringify(window.checkedForSend))
  117.            
  118.             window.location.href=url;
  119.            
  120.         }
  121.         // end multi gifts sending
  122.        
  123.         var BuildHover_old = window.BuildHover;
  124.  
  125.         window.BuildHover = function(){
  126.             if(window.g_ActiveInventory && (window.g_ActiveInventory.appid == 753)){
  127.                 var item = arguments[1];
  128.                 if (!item.descriptions.withClassid) {
  129.                     item.descriptions.withClassid=true;
  130.                    
  131.                     if(!item.descriptions)
  132.                         item.descriptions = [];
  133.                        
  134.                     item.descriptions.push({value:'ClassID = '+item.classid});
  135.                     item.descriptions.push({value:'<a href="#" onclick="getSubid(event.target,'+item.classid+');return false">Получить SubscriptionID</a>'});
  136.  
  137.                     window.ajaxTarget.descriptions = item.descriptions;
  138.                
  139.  
  140.                     if(item.owner_actions) {
  141.                         item.owner_actions.push({
  142.                             link:'javascript:checkForSend("%assetid%")',
  143.                             name:'Выбрать для отправки'
  144.                         });
  145.                         item.owner_actions.push({
  146.                             link:'javascript:sendChecked()',
  147.                             name:'Отправить выбранные'
  148.                         });
  149.                     }
  150.                 }
  151.             }
  152.             return BuildHover_old.apply(this, arguments);
  153.         }
  154.        
  155.        
  156.         //// Hide Duplicates
  157.         window.hiddenDupGifts = [];
  158.        
  159.         var SelectInventory_old = window.SelectInventory;
  160.         window.SelectInventory = function(){
  161.             // do only if steam items
  162.  
  163.             if (window.localStorage.hideDupGifts && !window.hiddenDupGifts[arguments[0]]) {
  164.  
  165.                 var inventory = window.UserYou.getInventory( arguments[0], arguments[1] );
  166.  
  167.                 var itemsA = [];
  168.  
  169.                 if(inventory.rgChildInventories) {
  170.                     for(var x in inventory.rgChildInventories){
  171.                         itemsA.push(inventory.rgChildInventories[x].rgInventory);
  172.                     }
  173.                 } else {
  174.                     if(inventory.rgInventory)
  175.                         itemsA.push(inventory.rgInventory);
  176.                 }
  177.  
  178.                 if(itemsA.length){
  179.                     window.hiddenDupGifts[arguments[0]] = true;
  180.                     var items, newItems;
  181.                     for(var i=0; i<itemsA.length; i++){
  182.                         items = itemsA[i];
  183.                         newItems=[];
  184.  
  185.                         for ( var j in items ){
  186.                             if(items[j].is_stackable)
  187.                                 continue;
  188.                             if(newItems[items[j].classid]){
  189.                                 newItems[items[j].classid].amount +=1;
  190.                                 delete items[j];
  191.                             } else {
  192.                                 items[j].is_stackable = true;
  193.                                 items[j].amount = 1;
  194.                                 newItems[items[j].classid] = items[j];
  195.                             }
  196.                         }
  197.                     }
  198.                 }
  199.                
  200.             }
  201.  
  202.             return SelectInventory_old.apply(this, arguments);
  203.         }
  204.        
  205.         var HTMLHideDup = '<input type="checkbox" name="hidedup" onchange="window.onchangehidedup(event)" '+((window.localStorage.hideDupGifts)?'checked="true"':'')+'/>Прятать дубликаты, показывая кол-во';
  206.         document.getElementById('inventory_pagecontrols').insertAdjacentHTML("beforeBegin", HTMLHideDup);
  207.        
  208.         window.onchangehidedup = function(e){
  209.             if(e.target.checked){
  210.                 window.localStorage.hideDupGifts = 1
  211.             } else {
  212.                 window.localStorage.removeItem('hideDupGifts')
  213.             }
  214.  
  215.             window.location.reload();
  216.         };
  217.     }
  218.     // end for invetory page
  219. }
  220.  
  221. var state = window.document.readyState;
  222. if((state == 'interactive')||(state == 'complete')) // for chrome
  223.     init();
  224. else
  225.     window.addEventListener("DOMContentLoaded", init,false); //for opera
  226.  
  227. function addLinks(links){
  228.     var out;
  229.     if (typeof links == 'string') {
  230.         out = links;
  231.     } else {
  232.         out='';
  233.         var link;
  234.         for (var i=0; i < links.length; i++){
  235.             link = links[i];
  236.  
  237.             if (link.hr) {
  238.                 out +='<hr/>';
  239.             } else {
  240.                 out += '<div class="actionItem"><div class="actionItemIcon"><a href="'+link.href+'">\
  241.     <img src="'+link.icon+'" width="16" height="16" border="0">\
  242.     </a></div><a class="linkActionMinor" href="'+link.href+'">'+link.text+'</a></div>';
  243.             }
  244.  
  245.         }
  246.     }
  247.     document.querySelector('#rightActionBlock').insertAdjacentHTML("afterBegin", out);
  248. }
  249.  
  250. // for subid detect
  251. window.ajaxTarget = {};
  252.  
  253. window.getSubid = function(target, classid){
  254.  
  255.     window.ajaxTarget.element=target;
  256.  
  257.     document.getElementsByTagName('head')[0].appendChild(document.createElement('SCRIPT')).src='http://v1t.su/projects/steam/class-sub.php?jsonp=setSubID&get=sub&value='+classid;
  258. }
  259.  
  260. window.setSubID=function(subid){
  261.     var str = 'SubscriptionID = ';
  262.  
  263.     if (subid=="0"){
  264.         str += 'не известно';
  265.     } else {
  266.         str += '<a href="http://cdr.thebronasium.com/sub/'+subid+'">'+subid+'</a>';
  267.     }
  268.     window.ajaxTarget.element.outerHTML=str;
  269.     window.ajaxTarget.descriptions[window.ajaxTarget.descriptions.length-1]={value:str};
  270.     window.ajaxTarget.descriptions.withSubid=true;
  271. }
Advertisement
Add Comment
Please, Sign In to add comment