steamgifts rating and platforms

Show rating and supported platforms on site steamgifts.com according information from store.steampowered.com

目前为 2015-06-22 提交的版本。查看 最新版本

// ==UserScript==
// @name         steamgifts rating and platforms
// @namespace    Gidden
// @version      0.98
// @description  Show rating and supported platforms on site steamgifts.com according information from store.steampowered.com
// @require      http://code.jquery.com/jquery.min.js
// @author       Gidden
// @include      http://www.steamgifts.com/
// @include      http://www.steamgifts.com/giveaways/search?*
// @grant        GM_xmlhttpRequest
// ==/UserScript==

function getColor(value){
    //value from 0 to 1
    var hue=((value)*120).toString(10);
    return ["hsl(",hue,",100%,42%)"].join("");
}

$("head link:last").append("<link rel=stylesheet type=text/css href=https://steamstore-a.akamaihd.net/public/css/v6/store.css>");

var headers = $("div.giveaway__summary h2.giveaway__heading");

headers.each(function() {
    var header = $(this);
    var steamURL = header.find( "a.giveaway__icon" ).attr("href").trim();

    GM_xmlhttpRequest({
        method: "GET",
        url: steamURL,
        onload: function(response) {
            a_tag = header.find( "a.giveaway__icon" );
            a_tag.attr("style", "opacity:1");

            var ppl = false;
            var perc = false;

            var ratingFull = $(response.responseText).find("div.glance_ctn div[itemprop=aggregateRating]").attr("data-store-tooltip");
            if (ratingFull.length > 0) {
                ratingFull = ratingFull.trim().split(" ");
                $.each(ratingFull, function(i, val) {
                    var rat = val.replace(",", ".");
                    if ($.isNumeric(rat)) {
                        ppl = rat;}
                    if (rat.slice(-1) == "%") {
                        perc = rat.slice(0,-1);
                    }
                });
                rating = perc + '%(' + ppl + ')';
                a_tag.append(" <span style=\"color:" + getColor(perc /100.0) + "\">" + rating + "</span>");
            }

            var platform = $(response.responseText).find("div.game_area_purchase_platform");
            if (platform.length) {
                a_tag.append(" <span style=\"background-color: black; height:20px; display: inline-block; opacity: 0.35;\">" + platform.html() + "</span>");
            }   

        }
    });

}); 

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址