qazarius

steam-store.user.js

Dec 11th, 2012
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name Steam Web Tools Steamstore Page MOD
  3. // @include https://store.steampowered.com/*
  4. // @include  http://store.steampowered.com/*
  5. // @exclude https://store.steampowered.com/checkout/sendgift/*
  6. // @exclude  http://store.steampowered.com/checkout/sendgift/*
  7. // ==/UserScript==
  8.  
  9. window.addEventListener("DOMContentLoaded",function() {
  10.    
  11.     // for age check
  12.     if(window.location.pathname.indexOf('/agecheck')==0){
  13.         document.cookie='birthtime=-1704124799; expires=21-Dec-2112 00:00:00 GMT; path=/';
  14.         window.location.reload();
  15.     }
  16.    
  17.     /*// to top btn
  18.     var tmp='<style>#footer{z-index:2;position: relative;}#totop{padding:10px;background:#000;position:fixed;left:0;width:90px;height:100%;z-index:2;cursor:pointer;opacity:0}#totop:hover{opacity:.5}</style><div id="totop" onclick="document.body.scrollTo()">Наверх</div>'
  19.     document.querySelector('body').insertAdjacentHTML('afterBegin', tmp);
  20.     */
  21.    
  22.     // cc switcher
  23.     var global_action_menu = document.getElementById('global_action_menu');
  24.     if(global_action_menu) {
  25.         var curCC = false;
  26.         if(curCC = document.cookie.match(/fakeCC=(\w+?);/i)){
  27.             curCC = curCC[1];
  28.         }
  29.         var changeCCmenuHTML = '\
  30.         <style>#cc_menu_btn{min-width:59px;z-index:999;position:fixed;right:0;top:0;background-color:#000;opacity:0.5;}#cc_menu_btn:hover{opacity:1}#cc_list .popup_menu_item{white-space:nowrap}</style>\
  31.         <span class="pulldown" id="cc_menu_btn" onclick="ShowMenu(this, \'cc_menu\', \'left\', \'bottom\', true);">CC'+((curCC)?': <img src="http://icons.iconarchive.com/icons/famfamfam/flag/16/'+curCC.toLowerCase()+'-icon.png" /> '+curCC:'')+' </span>\
  32. <div class="popup_block" id="cc_menu" style="display:none;">\
  33. <div class="popup_body popup_menu shadow_content" id="cc_list"></div></div>\
  34.     <div class="popup_block" id="cc_list_edit" style="display:none;">\
  35.     <div class="popup_body popup_menu shadow_content">\
  36.     <input id="ccListEdit" type="text" value="'+_cc.curList+'"/><br/><a title="OK" href="#" id="cc_okbtn">[OK]</a> <a title="Default" href="#" id="cc_defbtn">[D]</a>\
  37.     </div></div>';
  38.    
  39.         global_action_menu.insertAdjacentHTML('afterBegin', changeCCmenuHTML);
  40.    
  41.         _cc.updHTMLccList();
  42.        
  43.         document.getElementById('cc_defbtn').onclick = _cc.setDefCcList;
  44.         document.getElementById('cc_okbtn' ).onclick = _cc.saveNewList;
  45.     }
  46.  
  47. },false);
  48.  
  49. window.setDefCcList = function(){alert(1)};
  50.  
  51. _cc = {
  52.     defList : 'ru us ua fr gb au',
  53.     updHTMLccList : function(){
  54.         var s='';
  55.         var ccListA = _cc.curList.split(' ');
  56.         for(var i=0; i < ccListA.length; i++){
  57.             s += '<a class="popup_menu_item" href="'+_cc.url+ccListA[i]+'"><img src="http://icons.iconarchive.com/icons/famfamfam/flag/16/'+ccListA[i]+'-icon.png" style="width:16px"/> '+ccListA[i].toUpperCase()+'</a>';
  58.         }
  59.         s += '<a class="popup_menu_item" title="Редактировать" href="#" onclick="ShowMenu(this, \'cc_list_edit\', \'right\', \'bottom\', true);return false"><img src="http://cdn.steamcommunity.com/public/images/skin_1/iconEdit.gif" style="width:16px"/></a>';
  60.         document.getElementById('cc_list').innerHTML=s;
  61.     },
  62.     saveNewList : function(){
  63.         _cc.curList=document.getElementById('ccListEdit').value;
  64.         window.localStorage.ccList=_cc.curList;
  65.         _cc.updHTMLccList();
  66.         return false;
  67.     },
  68.     setDefCcList : function(){
  69.         document.getElementById('ccListEdit').value = _cc.defList;
  70.         return false;
  71.     }
  72. };
  73.  
  74. _cc.curList = window.localStorage.ccList || _cc.defList;
  75.  
  76. _cc.url = String(window.location);
  77. if (_cc.url.indexOf('?')==-1) {
  78.     _cc.url += '?';
  79. } else {
  80.     _cc.url = _cc.url.replace(/\?.+/, '?');
  81. }
  82. _cc.url += 'cc=';
  83.  
  84. window._cc=_cc;
Advertisement
Add Comment
Please, Sign In to add comment