Raw Source
5310 / Steam Play Community Rating Notice

// ==UserScript==
// @name         Steam Play Community Rating Notice
// @version      0.2
// @description  Retrieve and show community rating on Steam's store game pages.
// @author       DanMan
// @match        *://store.steampowered.com/app/*/*
// @grant        GM_xmlhttpRequest
// @connect      spcr.netlify.com
// @license      MIT
// @updateURL    https://openuserjs.org/meta/DanMan/Steam_Play_Community_Rating_Notice.meta.js
// ==/UserScript==

(function(){
	var matches, xhr, memo=JSON.parse(sessionStorage.getItem('spcr'));
	function inject(appId, rating){
		let node = document.createElement('a'),
		img = 'https://support.steampowered.com/images/custom/platform_steamplay.png',
		target = document.querySelector('.game_area_purchase_platform');
		if(target){
			node.textContent = rating[0].toUpperCase();
			node.setAttribute('title', 'Most frequent of '+rating[1]+' rating(s)');
			node.setAttribute('href', 'https://spcr.netlify.com/app/'+appId);
			node.setAttribute('style', [
				'background: #4d4b49 url('+img+') no-repeat -51px center',
				'display:inline-block',
				'line-height: 19px',
				'color: #b0aeac',
				'font-size: 1.4ex',
				'padding: 3px 10px 0 79px',
				'margin-right: 1ex',
	      	'vertical-align:bottom',
				'font-family: "Motiva Sans", sans-serif'
			].join(';'));
			target.insertBefore(node,target.firstChild);
		}
	}
	function reqListener (response) {
		let data=[], scores={}, idx, rating='N/A', target;
		if(response.responseText.charAt(0) !== '<'){
			data = JSON.parse(response.responseText);
			if(data.length>0){
				data.forEach(function(item){
					idx = item.rating;
					scores[idx]=(scores[idx] || 0);
					scores[idx]++;
				});
				rating = Object.keys(scores).reduce((a, b) => scores[a] > scores[b] ? a : b);
			}
		}
		memo[matches[1]]=[rating, data.length];
		sessionStorage.setItem('spcr', JSON.stringify(memo));
		inject(matches[1], memo[matches[1]]);
	}
	if(!document.querySelector('.platform_img.linux') &&
	 	!document.querySelector('.sysreq_tab[data-os=linux]')){
		matches= document.location.pathname.match(/\/(\d+)\//);
		if(matches[1]){
			if((memo === null || !memo[matches[1]])){
	      	if(memo===null) sessionStorage.setItem('spcr','{}');
                GM_xmlhttpRequest ( {
                    method: "GET",
                    url: "https://spcr.netlify.com/data/reports/app/"+matches[1]+".json",
                    headers: {"Accept": "application/json"},
                    onload: reqListener
                } );
			} else if(memo[matches[1]]){
				inject(matches[1], memo[matches[1]]);
			}
		}
	}
}());