Highlights Cards and Achievements at the top of game pages
目前為
// ==UserScript==
// @name Steam - Quick Cards and Cheevos
// @namespace Lex@GreasyFork
// @version 0.1.1
// @description Highlights Cards and Achievements at the top of game pages
// @author Lex
// @match https://store.steampowered.com/app/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
const cards = `<span style="cursor:pointer" onclick="document.getElementById('category_block').scrollIntoView()"><img width="28" src="https://steamstore-a.akamaihd.net/public/images/v6/ico/ico_cards.png"> Cards</span>`;
const cheevos = `<span style="cursor:pointer" onclick="document.getElementById('achievement_block').scrollIntoView()">🏆 {0} Achievements</span>`;
const noSingleplayer = `<span style="color:black;background:yellow">No singleplayer!</span>`;
const hasCards = Boolean(document.querySelector("img.category_icon[src$='ico_cards.png']"));
const hasAchievements = Boolean(document.querySelector("#achievement_block"));
const getAchievementCount = () => document.querySelector("#achievement_block .block_title").textContent.match(/(\d+) Steam/)[1];
const hasSingleplayer = Boolean(document.querySelector("img.category_icon[src$='ico_singlePlayer.png']"));
let props = [];
if (hasCards) props.push(cards);
if (hasAchievements) props.push(cheevos.replace("{0}", getAchievementCount()));
if (!hasSingleplayer) props.push(noSingleplayer);
if (!props.length) props.push("No cards or achievements");
const div = document.createElement("div");
div.style.fontSize = "110%";
div.innerHTML = props.join(" ");
document.querySelector(".glance_ctn").prepend(div);
})();