// ==UserScript== // @name c5 extension // @namespace // @version 0.2 // @description tiao zhan G fat // @author out // @match *://www.c5game.com/* // @grant GM_xmlhttpRequest // @require https://cdn.bootcss.com/jquery/2.2.4/jquery.min.js // @connect steamcommunity.com // @namespace out // @downloadURL none // ==/UserScript== (function() { 'use strict'; // Your code here... $(document).ready(function(){ if($(".right_steam").length!==0){ var hash_name = $(".right_steam a").attr("href").slice(47); GM_xmlhttpRequest({ method: "GET", url: "http://steamcommunity.com/market/priceoverview/?currency=23&appid=730&market_hash_name="+hash_name, onload: addprice }); } function addprice(res){ $("div.hero > span:first").hide(); $("div.hero > div.right_steam").css("float","none"); if(res.responseText!=="null"){ var d = JSON.parse(res.responseText); console.log(res.responseText); if(d.success){ var steam_price = getFloat(d.lowest_price); var text = "Steam参考价:"+d.lowest_price+" 税后:"+(steam_price/1.15).toFixed(2); if($(".sale-item-lists span.ft-orange").lenght!==0){ var c5_price=getFloat($(".sale-item-lists span.ft-orange:first").text()); text += "("+(c5_price*1.15/steam_price).toFixed(1)+"折)"; } $(".right_steam a").text(text); } } } function getFloat(str){ if(str.indexOf(".")!=-1){ var xs = str.length-str.indexOf(".")-1; var price = parseFloat(str.replace(/[^0-9]/ig,"")); while(xs){ price/=10; xs--; } console.log(price); return price; } console.log(parseFloat(str.replace(/[^0-9]/ig,""))); return parseFloat(str.replace(/[^0-9]/ig,"")); } }); })();