FlokiTV / Steam

// ==UserScript==
// @name         Steam
// @namespace    http://youtube.com/FlokiTVbr
// @version      0.3
// @description  Script para ajuda na hora de escolher seus jogos na steam =D
// @author       Floki
// @match        http://store.steampowered.com/search
// @match        http://store.steampowered.com/search?*
// @match        http://store.steampowered.com/search/*
// @require http://code.jquery.com/jquery-latest.js
// ==/UserScript==

$(document).ready(function(){
    $("body").append("<div id='dw_steam'></div>");
    $("#dw_steam").css({
        "position":"fixed",
        "bottom": "0",
        "background": "#171A21",
        "padding" : "6px",
        "z-index": "999",
        "width":"100%",
        "text-align":"center"
    });

    $("#dw_steam").append("<button class='btnv6_blue_hoverfade btn_small' id='dw_color' onclick='return false;'><span>Cor %</span></button>");
    $("#dw_steam").append("<button class='btnv6_blue_hoverfade btn_small' id='dw_border' onclick='return false;' style='margin-left: 5px'><span>Marcar compráveis</span></button>");
    $("#dw_steam").append("<button class='btnv6_blue_hoverfade btn_small' id='dw_remove' onclick='return false;' style='margin-left: 5px'><span>Remover caros</span></button>");
    $("#dw_steam").append("<button class='btnv6_blue_hoverfade btn_small' id='dw_10' onclick='return false;' style='margin-left: 5px'><span>Abaixo de $10</span></button>");
    $("#dw_steam").append("<button class='btnv6_blue_hoverfade btn_small' id='dw_20' onclick='return false;' style='margin-left: 5px'><span>Abaixo de $20</span></button>");
    $("#dw_steam").append("<button class='btnv6_blue_hoverfade btn_small' id='dw_carteira' onclick='return false;' style='margin-left: 5px'><span>R$</span></button>");
    $("#dw_steam").append("<p style='margin-top:5px'>by <a href='http://youtube.com/FlokiTVbr' target='_blank'>Floki</a></p>");
    //
    $("#dw_carteira span").text($("#header_wallet_balance").text()).css({
        "color":"#a3ec08 ",
        "background":"#6e8a01",
        "outline": "none"
    });
    //Click Functions
    $("#dw_color").click(function(){
        color();
    });
    $("#dw_border").click(function(){
        border();
    });
    $("#dw_remove").click(function(){
        remove();
    });
    $("#dw_10").click(function(){
        location.href = "http://store.steampowered.com/search/?filter=ut2";
    });
    $("#dw_20").click(function(){
        location.href = "http://store.steampowered.com/search/?filter=ut1";
    });
});

function remove(){
    var carteira = $("#header_wallet_balance").text().replace( /[^\d.]/g, '' );
    carteira = parseInt(carteira);
    $(".search_result_row").each(function(){
        original = $(this).find(".search_price").html();
        $(this).find(".search_price span").remove();
        value = $(this).find(".search_price").text().replace( /[^\d.]/g, '' );
        if(value <= carteira){
            $(this).find(".search_price").html(original);
        }else{
            $(this).remove();
        }
    });
}
function border(){
    var carteira = $("#header_wallet_balance").text().replace( /[^\d.]/g, '' );
    carteira = parseInt(carteira);
    $(".search_result_row").each(function(){
        original = $(this).find(".search_price").html();
        $(this).find(".search_price span").remove();
        value = $(this).find(".search_price").text().replace( /[^\d.]/g, '' );
        if(value < carteira){
            $(this).css("border","2px solid #d6f700");
        }
        $(this).find(".search_price").html(original);
    });
}

function color(){
    $("span").each(function(){
        switch($(this).text()){
            case "-35%":
                $(this).css("background-color","#4c6b22");
                $(this).css("color","#8bc53f");
                break;
            case "-50%":
                $(this).css("background-color","#6a6b16");
                $(this).css("color","#c1c13f");
                break;
            case "-60%":
                $(this).css("background-color","#96640e");
                $(this).css("color","#ffac10");
                break;
            case "-65%":
                $(this).css("background-color","#934f0e");
                $(this).css("color","#ffac10");
                break;
            case "-70%":
                $(this).css("background-color","#bf5d20");
                $(this).css("color","#f78847");
                break;
            case "-75%":
                $(this).css("background-color","#bc4f18");
                $(this).css("color","#ff8851");
                break;
            case "-80%":
                $(this).css("background-color","#e0391f");
                $(this).css("color","#ffb4a8");
                break;
            case "-85%":
                $(this).css("background-color","#e0391f");
                $(this).css("color","#fff");
                break;
            case "-90%":
                $(this).css("background-color","#c12424");
                $(this).css("color","#fff");
                break;
        }
    });
}