Steam - Quick Cards and Cheevos

Highlights Cards and Achievements at the top of game pages

目前為 2020-05-28 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==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);
})();