// ==UserScript== // @name [Steam] Steam Search // @namespace https://github.com/kevingrillet // @author Kevin GRILLET // @description Add menu commands to search the current Steam game on HowLongToBeat, Steam Charts, SteamDB, SteamHunters, DLCompare, G2A, InstantGaming and Kinguin // @copyright https://github.com/kevingrillet // @license GPL-3.0 License // @tag kevingrillet // @tag steampowered.com // @version 1.0.4 // @homepageURL https://github.com/kevingrillet/Userscripts/ // @supportURL https://github.com/kevingrillet/Userscripts/issues // @downloadURL https://raw.githubusercontent.com/kevingrillet/Userscripts/main/user.js/[Steam]%20Steam%20Search.user.js // @updateURL https://raw.githubusercontent.com/kevingrillet/Userscripts/main/user.js/[Steam]%20Steam%20Search.user.js // @match https://store.steampowered.com/app/*/* // @icon https://www.google.com/s2/favicons?sz=64&domain=steampowered.com // @grant GM_registerMenuCommand // @grant GM_openInTab // @run-at document-end // ==/UserScript== (function () { 'use strict'; // Get the game name from the Steam page function getGameName() { const el = document.querySelector('.apphub_AppName'); return el ? el.textContent.trim() : ''; } // Get the AppID from the Steam URL function getAppId() { const match = window.location.pathname.match(/\/app\/(\d+)\//); return match ? match[1] : ''; } // Open a new tab with the given URL function openInTab(url) { if (typeof GM_openInTab === 'function') { GM_openInTab(url, { active: true }); } else { window.open(url, '_blank'); } } // Generate search URLs for each site function getUrls(gameName, appId) { const encoded = encodeURIComponent(gameName); return [ { label: 'HowLongToBeat', url: `https://howlongtobeat.com/?q=${encoded}` }, { label: 'Steam Charts', url: `https://steamcharts.com/app/${appId}` }, { label: 'SteamDB', url: `https://steamdb.info/app/${appId}/` }, { label: 'SteamHunters', url: `https://steamhunters.com/apps/${appId}/achievements` }, { label: 'DLCompare', url: `https://www.dlcompare.fr/search?q=${encoded}` }, { label: 'G2A', url: `https://www.g2a.com/search?query=${encoded}` }, { label: 'InstantGaming', url: `https://www.instant-gaming.com/fr/rechercher/?q=${encoded}` }, { label: 'Kinguin', url: `https://www.kinguin.net/listing?production_products_bestsellers_desc%5Bquery%5D=${encoded}` }, ]; } // Register Tampermonkey menu commands for each site function registerMenuCommands() { const gameName = getGameName(); const appId = getAppId(); if (!gameName || !appId) return; getUrls(gameName, appId).forEach(({ label, url }) => { GM_registerMenuCommand(`🔎 Search on ${label}`, () => openInTab(url)); }); } window.addEventListener('DOMContentLoaded', registerMenuCommands); })();