// ==UserScript==
// @name SteamBadgeShowNext
// @namespace SteamBadgeShowNext@Byzod.user.js
// @description 在徽章页面查看下一级徽章图标
// @include /^https?:\/\/steamcommunity\.com\/(profiles|id)\/[^\/]+\/badges/
// @version 2017-6-19
// @grant GM_xmlhttpRequest
// jshint esversion:6
// ==/UserScript==
// Steam CDN 主机
const STEAM_CDN_HOST = "cdn.steamstatic.com.8686c.com";
// LAZY_LOAD_DISTANCE 像素内的徽章图标才会加载
const LAZY_LOAD_DISTANCE = 500;
// Steam loading 图标
const STEAM_LOADING_INDICATOR_URL = "http://steamcommunity-a.akamaihd.net/public/images/login/throbber.gif";
// SCE 徽章页面前缀 ( + appId )
const SCE_BADGES_URL_PREFIX = "http://www.steamcardexchange.net/index.php?gamepage-appid-";
// 升到顶级的提示图标,PNG最佳
// const HIGHEST_LEVEL_INDICATOR_URL = "https://steamcommunity-a.akamaihd.net/public/images/badges/generic/ValveEmployee_80.png";
const HIGHEST_LEVEL_INDICATOR_URL = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFAAAABQCAYAAACOEfKtAAAACXBIWXMAAAsTAAALEwEAmpwYAAABZWlDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjaldC/axMBGMbxzyVKRSMVzeBQ5IbqpCLqUBwjmEVF0ghJdEkuuXbIJeHupIOroGPBQXTx1+A/ILoKLi6CIChC8G8QRRcp55BKitDB512+PO8PXh5K54dRku05QzLK00a9FrbanXBhqvK3ulE2ubJ6qWlX/fokgI+nhlGS+T8d6A+yiGAfTkeTNCdYwYWNfJIT5KhG690+wT2cTFvtDsFLVHszfofq2oynqKbNxkWCbwjXdnBvB0fraULpEJaT4a1o+58AlcHo+ioOY8k1V9WFMg11Ndhl/hiWxEbGUn2hzFgst6ErNYBWuxP+m1sWnzs7u1apsfdrUfw4zsJ9tjaL4vfToth6RnnKm9F8f/yElZ+UN+fe8mMW7/Dq7dzrPeD1XY5+mXTTLiijFMd8f8HBNkc+sP/GLJPtvuefad7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YkAy0tqR2jG8swg+MeEkCLSwnahSqnlx+QsyY+53t00imTGPT7sFMQQI5bRM8owFqktnGqQIfnG1Mc/nK+3WOI2g9JhAppoy/ctowBgNrQ0yY6AzDSHVDEips7RaNNP3Nmb3db93i06ktvbL3jnf7fVUZiS0M/BCJr1zw8QorVPGbJBpq05WBPgmuRAgj1PGENoNRNKnPFOS8aJduc4QUjVKifQZa6u/q5372t23E2EGSbm36PYu7hbdZ5CSj1NSXyiVukiA7i+1RHfZbKOl2nUAbSkjcHzwdrPGwIC1DB8Cgnd3eOe+E0K4yXl3k6/dX1XT8rNVOflLbnrsU42CZ6wTmS2IOCpAS5lBaX2ulOoCpeQDMm0erKSSRPI8pdT9SJIi0H0bYzyLlLqnINojie5BCmcL4I7I/DMAtwO4nSPfyhx/xsy3eM8/srX/Pvv6Bz74W4J333cufIuD+3vvw80h+J/x0XI2ItAvUBEeF8B/PO4Gncj/T8f/HQBcFSc05vPPHgAAAABJRU5ErkJggg==";
// “差不多这个意思”版延迟加载类
// targets: 需要lazy load的目标们
// callback: 目标可见后的回调处理
// 有一个参数target,为状态变为可见的目标
function LazyLoader(targets, callback){
// 监视对象Set
this.Targets = targets ? new Set(targets) : new Set();
// 回调函数
this.Callback = (callback && typeof(callback)==="function") ? callback : null;
// Lazy load距离 (像素)
this.Distance = 0;
// 初始化
this.Init = function(win){
win = win ? win : window;
win.addEventListener("scroll", ScrollEventHandler, false);
// 先调用一次,处理目前可视区域
ScrollEventHandler(null);
}
let ScrollEventHandler = e => {
// console.log('[LazyLoader] 处理Scroll event, 例遍 %o 个目标...', this.Targets.size) // DEBUG
this.Targets.forEach(target => {
// target 可见
if(this.Callback
&& typeof(this.Callback)==="function"
&& LazyLoader.IsElementVisible(target, this.Distance)){
// console.log('[LazyLoader] 正在处理 ' + target.innerText) // DEBUG
// 回调
this.Callback(target);
// 从Set里移除已回调的target
this.Targets.delete(target);
}
});
}
}
// Static function
// 对象是否可见?(在视野distance像素内)
LazyLoader.IsElementVisible = function IsElementVisible(elem, distance){
if(!distance){
distance = 0;
}
if(elem){
let viewport = {
width : window.innerWidth,
height : window.innerHeight
};
// console.log("[IsElementVisible]: viewport %o" + viewport); // DEBUG
let rect = elem.getBoundingClientRect();
// console.log("[IsElementVisible]: rect %o" + rect); // DEBUG
return (
rect.left < viewport.width + distance
&& rect.right > 0 - distance
&& rect.top < viewport.height + distance
&& rect.bottom > 0 - distance
);
} else {
throw("[IsElementVisible]: Element not exist");
}
}
// 插入样式
let badgeImageCSS = document.createElement("style");
badgeImageCSS.innerHTML = `
.badge_next {
position: absolute;
overflow: hidden;
width: 100px;
top: -5px;
left: -120px;
bottom: -5px;
padding: 5px;
background: linear-gradient( to bottom, #232424 5%, #141414 95%);
}
.badge_next_loading {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.showcase-element {
position: absolute;
left: 0;
right: 0;
}
.element-image {
width: 80px;
height: 80px;
margin: 0px auto 0px auto;
display: block;
float: none;
}
.element-text {
text-align: center;
display: block;
padding-top: 2px;
}
.element-experience {
text-align: center;
display: block;
padding-top: 2px;
color: #8F98A0;
}
.badge_highest_level{
padding-top: 20px;
box-shadow:0 1px 4px rgba(255, 255, 255, 0.3), 0 0 20px 5px rgba(255, 255, 255, 0.1);
}
`
document.head.appendChild(badgeImageCSS);
// 插入下一级徽章图
let badgeRows = document.querySelectorAll(".badge_row");
// console.log("[Steam+]: badgeRows: " + badgeRows.length); // DEBUG
// 延迟附加徽章图
let lazyLoader = new LazyLoader(
badgeRows,
row => {
let appIdMatch = row.querySelector(".badge_row_overlay").href.match(/gamecards\/(\d+)(\/\?border=1)?/);
let appId = appIdMatch ? appIdMatch[1] : 0;
let foil = appIdMatch && appIdMatch.length > 2 && appIdMatch[2] ? true : false;
let currentLevelInfo = row.querySelector(".badge_info_title + div");
let currentLevel = currentLevelInfo ? parseInt(currentLevelInfo.innerText.match(/\d+/)[0]) : 0;
// console.log(`[Steam+]: 处理 ${appId} (lv.${currentLevel}${foil?" foil":""})`); // DEBUG
// 获取徽章数据
if(appId !== 0){
let badgeNextShowcase = document.createElement("a");
badgeNextShowcase.className = "badge_next";
badgeNextShowcase.href = SCE_BADGES_URL_PREFIX + appId;
badgeNextShowcase.target = "_blank";
badgeNextShowcase.innerHTML = '<img class="badge_next_loading" src="' + STEAM_LOADING_INDICATOR_URL + '" alt="Loading" />';
GM_xmlhttpRequest({
method: "GET",
url: SCE_BADGES_URL_PREFIX + appId,
onload: function (response) {
let badgeData = PraseBadgeData(response.responseText);
if(badgeData){
let showcase = GetNextLevelBadgeShowcase(
foil ? badgeData.FoilBadgeShowcases : badgeData.BadgeShowcases,
currentLevel
);
// 停止转圈圈
badgeNextShowcase.innerHTML = '';
if(showcase){
// 一切正常就显示徽章
// console.log("[Steam+]: showcase (foil: %o): %o: ", foil, showcase); // DEBUG
badgeNextShowcase.appendChild(showcase);
} else {
// 找不到showcase,已经最高级了
// 随便恭喜一下
badgeNextShowcase.classList.add("badge_highest_level");
badgeNextShowcase.innerHTML = '<div class="showcase-element badge_info"><img class="element-image badge_info_image" src="' + HIGHEST_LEVEL_INDICATOR_URL + '" alt="Top Level"><span class="element-text badge_info_description badge_info_title">已升至顶级</span></div>';
}
}
}
});
// 添加徽章展柜
row.appendChild(
badgeNextShowcase
);
}
}
);
// 设置lazy loader参数
// 可视范围外额外lazy load的范围 (像素)
lazyLoader.Distance = LAZY_LOAD_DISTANCE;
lazyLoader.Init(window);
// 处理SCE数据
function PraseBadgeData(data){
// SCE 文档碎片
let sceFrag;
// Badge 数据
let badgeData = null;
// 徽章选择器
let badgeSelector = ".badge>.showcase-element";
// 将 SCE 页面中的链接替换成支持 https 的域名
data = data.replace(/https?:\/\/(community\.edgecast\.steamstatic\.com|steamcommunity-a\.akamaihd\.net|cdn\.steamcommunity\.com)\//g, "//steamcommunity-a.akamaihd.net/");
data = data.replace(/https?:\/\/(cdn\.edgecast\.steamstatic\.com|steamcdn-a\.akamaihd\.net|cdn\.akamai\.steamstatic\.com)\//g, "//steamcdn-a.akamaihd.net/");
// 先去除又臭又长的下拉菜单选项……
data = data.replace(/<select[^]+<\/select>/,"");
// 替换为Steam样式的class
data = data.replace(/class="showcase-element"/g, 'class="showcase-element badge_info"');
data = data.replace(/class="element-image"/g, 'class="element-image badge_info_image"');
data = data.replace(/class="element-text"/g, 'class="element-text badge_info_description badge_info_title"');
data = data.replace(/class="element-experience"/g, 'class="element-experience badge_info_description"');
// 转为DOM
sceFrag = document.createRange().createContextualFragment(data);
// 普通徽章
let badgeRows = ClosetParentNode(
sceFrag.querySelector(".showcase-element-container.badge"), // 第一个.badge 父节点即为普通徽章box
".content-box"
);
// 闪亮徽章
let foilBadgeRows = badgeRows ? badgeRows.nextSibling : null; // 好兄弟排排坐
if(badgeRows && foilBadgeRows){
badgeData = {
BadgeShowcases : badgeRows.querySelectorAll(badgeSelector),
FoilBadgeShowcases : foilBadgeRows.querySelectorAll(badgeSelector)
};
} else {
badgeData = null;
}
// console.log("[Steam+]: badgeData: %o: ", badgeData); // DEBUG
return badgeData;
}
// 简单实现JQuery的closet
function ClosetParentNode(elem, selector){
let parent = null;
while (elem) {
parent = elem.parentElement;
if (parent && parent.matches(selector)) {
return parent;
}
elem = parent;
}
return null;
}
// 获取下一等级徽章showcase
function GetNextLevelBadgeShowcase(badgeShowcases, currentLevel){
let showcase = null;
const LEVEL_SELECTOR = ".element-experience";
// {level} or {level low} - {level high} or {level low} - ???
const LEVEL_REGEX = /Level (\d+)(?: - (\d+|\?\?\?))?/;
for(let badge of badgeShowcases){
let levelElem = badge.querySelector(LEVEL_SELECTOR);
// 没有level也不要慌,showcase有很多空的,略过就是
if(levelElem){
let levelMatch = levelElem.innerText.match(LEVEL_REGEX);
// 只有low的时候取low,有low和high时取high
let level = levelMatch
? (levelMatch.length > 2 && levelMatch[2]
? levelMatch[2]
: levelMatch[1]
)
: 0;
// 转为Int
level = isNaN(level)
? (level === "???" ? Infinity : 0) // 特别的,high=???代表该徽章可无限升级。给夏促大佬递女装
: parseInt(level);
if(level > currentLevel){
// 找到下一级了,走起
showcase = badge;
break;
}
}
}
return showcase;
}