Add a badge of ProtonDB Status to Steam store page with shields.io.
当前为
// ==UserScript==
// @name ProtonDB Status Badge
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Add a badge of ProtonDB Status to Steam store page with shields.io.
// @author eggplants
// @homepage https://github.com/eggplants
// @match *://store.steampowered.com/app/*
// @grant none
// @license MIT
// ==/UserScript==
/*jshint esversion: 6 */
(function() {
'use strict';
var D = document;
const appid = D.querySelector("meta[property='og:url']").content.split('/')[4];
const badgeHref = 'https://www.protondb.com/app/' + appid;
const badgeSrc = `https://img.shields.io/badge/dynamic/json.svg\
?uri=https://www.protondb.com/api/v1/reports/summaries/${appid}.json\
&query=$.trendingTier\
&label=ProtonDB\
&colorB=e3e3e3\
&style=flat-square`;
function createElementFromHTML(htmlString) {
var div = document.createElement('div');
div.innerHTML = htmlString.trim();
return div.firstChild;
}
const protonElm = createElementFromHTML(`
<div class="proton_status">
<div class="subtitle column">ProtonDB:</div>
<div class="status">
<a href="${badgeHref}">
<img src="${badgeSrc}" />
</a>
</div>
</div>`);
user=D.querySelector('div.user_reviews');
user.appendChild(protonElm);
})();