Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name SteamBadges
- // @version 0.1
- // @description List of your steam card sets
- // @author Justman
- // @include *steamcommunity.com/id/*/badges*
- // @grant none
- // ==/UserScript==
- (function() {
- 'use strict';
- //function
- function clearName(name) {
- var q = 0;
- while (name.charCodeAt(q) == 10 || name.charCodeAt(q) == 9) {
- q += 1;
- }
- var r = q;
- while (name.charCodeAt(r) != 9) {
- r += 1;
- }
- return name.slice(q, r);
- }
- //-------------
- function clearInfo(info) {
- var q = 0;
- while (info.charCodeAt(q) > 57 || info.charCodeAt(q) < 48) {
- q += 1;
- }
- var r = q + 2;
- while (info.charCodeAt(r) > 57 || info.charCodeAt(r) < 48) {
- r += 1;
- }
- var a = info.slice(q, r + 2);
- if (a.charCodeAt(a.length - 1) > 57 || a.charCodeAt(a.length - 1) < 48) {
- a = a.substring(0, a.length - 1);
- }
- return a;
- }
- //Beginning, creating elements
- var upper = document.getElementsByClassName('profile_xp_block')[0];
- var myblock = document.createElement('div');
- myblock.setAttribute('class', 'BadgeHelper_TamperMonkey');
- myblock.setAttribute('style', 'border: 2px solid #000; padding: 10px; margin: 10px; height: 170px; width: 500px');
- myblock.innerHTML = '<form name="my-form">'+
- '<input name="number" type="checkbox" checked> Show number of set <br>'+
- '<input name="status" type="checkbox" checked> Show status of set <br><br>'+
- '<input name="start_button" type="button" value="Get set info"><br><br>'+
- '<textarea name="my-input" cols="68" rows="5" style="resize: none;">Press the button to get your sets info</textarea></form>';
- upper.insertBefore(myblock, upper.lastChild);
- //Analyze
- document.addEventListener('click', function(event) {
- if(event.target.getAttribute('name') == 'start_button') {
- document.forms["my-form"].elements["my-input"].value = 'Updating';
- var text = '';
- var list = document.getElementsByClassName('badges_sheet')[0];
- var l = list.getElementsByClassName('badge_row is_link').length;
- var i = 0;
- var t = '';
- while (i != l) {
- var main = list.getElementsByClassName('badge_row is_link')[i];
- if ((main.innerHTML.indexOf('badge_progress_info') != -1 && main.innerHTML.indexOf('badge_title_stats_drops')!=-1) || main.innerHTML.indexOf('badge_craft_button') != -1) {
- t = main.getElementsByClassName('badge_title')[0].innerHTML;
- if (document.forms["my-form"].elements["number"].checked == 1) {
- text = text + (i + 1) + '. ';
- }
- text = text + clearName(t);
- if (document.forms["my-form"].elements["status"].checked == 1) {
- if (main.innerHTML.indexOf('badge_craft_button') != -1) {
- text = text+' [All cards]';
- } else if (main.innerHTML.indexOf('badge_progress_info') != -1) {
- t = main.getElementsByClassName('badge_progress_info')[0].innerHTML;
- text = text + ' [' + clearInfo(t) + ']';
- }
- if (main.innerHTML.indexOf('steam://run/') != -1) {
- text = text + ' [Will drop more cards]';
- }
- }
- text = text +'\n';
- }
- i += 1;
- }
- document.forms["my-form"].elements["my-input"].value = text;
- }
- });
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement