Highlights Cards and Achievements at the top of game pages
目前為
// ==UserScript==
// @name Steam - Quick Cards and Cheevos
// @namespace Lex@GreasyFork
// @version 0.1.2
// @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 cardsNotify = `<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 cheevosNotify = `<span style="cursor:pointer" onclick="document.getElementById('achievement_block').scrollIntoView()">🏆 {0} Achievements</span>`;
const noSingleplayerNotify = `<span style="color:black;background:yellow">No singleplayer!</span>`;
const profileLimitedNotify = `<span title="Game will not give +1">⚙️ Profile Limited</span>`;
const adultOnlyNotify = `🔞 Adult only`;
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']"));
const learningAbout = Boolean(document.querySelector("img.category_icon[src$='ico_learning_about_game.png']"));
const profileLimited = Boolean(document.querySelector("img.category_icon[src$='ico_info.png']"));
const adultOnly = Boolean(document.querySelector("div.mature_content_notice"));
let props = [];
if (hasCards) props.push(cardsNotify);
if (hasAchievements) props.push(cheevosNotify.replace("{0}", getAchievementCount()));
if (!hasSingleplayer) props.push(noSingleplayerNotify);
if (profileLimited || learningAbout) props.push(profileLimitedNotify);
if (adultOnly) props.push(adultOnlyNotify);
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);
})();