Advertisement
SoftJustman

SteamBadgeList [Miped]

Jun 18th, 2016
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name         SteamBadges
  3. // @version      0.1
  4. // @description  List of your steam card sets
  5. // @author       Justman
  6. // @include      *steamcommunity.com/id/*/badges*
  7. // @grant        none
  8. // ==/UserScript==
  9.  
  10. (function() {
  11.     'use strict';
  12.     //function
  13.     function clearName(name) {
  14.       var q = 0;
  15.       while (name.charCodeAt(q) == 10 || name.charCodeAt(q) == 9) {
  16.         q += 1;
  17.       }
  18.       var r = q;
  19.       while (name.charCodeAt(r) != 9) {
  20.         r += 1;
  21.       }
  22.       return name.slice(q, r);
  23.     }
  24.     //-------------
  25.     function clearInfo(info) {
  26.       var q = 0;
  27.       while (info.charCodeAt(q) > 57 || info.charCodeAt(q) < 48) {
  28.         q += 1;
  29.       }
  30.       var r = q + 2;
  31.       while (info.charCodeAt(r) > 57 || info.charCodeAt(r) < 48) {
  32.         r += 1;
  33.       }
  34.       var a = info.slice(q, r + 2);
  35.       if (a.charCodeAt(a.length - 1) > 57 || a.charCodeAt(a.length - 1) < 48) {
  36.           a = a.substring(0, a.length - 1);
  37.       }
  38.       return a;
  39.     }
  40.     //Beginning, creating elements
  41.     var upper = document.getElementsByClassName('profile_xp_block')[0];
  42.     var myblock = document.createElement('div');
  43.     myblock.setAttribute('class', 'BadgeHelper_TamperMonkey');
  44.     myblock.setAttribute('style', 'border: 2px solid #000; padding: 10px; margin: 10px; height: 170px; width: 500px');
  45.     myblock.innerHTML = '<form name="my-form">'+
  46.     '<input name="number" type="checkbox" checked> Show number of set <br>'+
  47.     '<input name="status" type="checkbox" checked> Show status of set <br><br>'+
  48.     '<input name="start_button" type="button" value="Get set info"><br><br>'+
  49.     '<textarea name="my-input" cols="68" rows="5" style="resize: none;">Press the button to get your sets info</textarea></form>';
  50.     upper.insertBefore(myblock, upper.lastChild);
  51.     //Analyze
  52.     document.addEventListener('click', function(event) {
  53.     if(event.target.getAttribute('name') == 'start_button') {
  54.       document.forms["my-form"].elements["my-input"].value = 'Updating';
  55.       var text = '';
  56.       var list = document.getElementsByClassName('badges_sheet')[0];
  57.       var l = list.getElementsByClassName('badge_row is_link').length;
  58.       var i = 0;
  59.       var t = '';
  60.  
  61.       while (i != l) {
  62.         var main = list.getElementsByClassName('badge_row is_link')[i];
  63.  
  64.         if ((main.innerHTML.indexOf('badge_progress_info') != -1 && main.innerHTML.indexOf('badge_title_stats_drops')!=-1) || main.innerHTML.indexOf('badge_craft_button') != -1) {
  65.           t = main.getElementsByClassName('badge_title')[0].innerHTML;
  66.           if (document.forms["my-form"].elements["number"].checked == 1) {
  67.             text = text + (i + 1) + '. ';
  68.           }
  69.           text = text + clearName(t);
  70.           if (document.forms["my-form"].elements["status"].checked == 1) {
  71.             if (main.innerHTML.indexOf('badge_craft_button') != -1) {
  72.               text = text+' [All cards]';
  73.             } else if (main.innerHTML.indexOf('badge_progress_info') != -1) {
  74.               t = main.getElementsByClassName('badge_progress_info')[0].innerHTML;
  75.               text = text + ' [' + clearInfo(t) + ']';
  76.             }
  77.             if (main.innerHTML.indexOf('steam://run/') != -1) {
  78.               text = text + ' [Will drop more cards]';
  79.             }
  80.           }
  81.           text = text +'\n';
  82.         }
  83.         i += 1;
  84.       }
  85.       document.forms["my-form"].elements["my-input"].value = text;
  86.       }
  87.     });
  88. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement