Steam - 添加快速搜索按鈕

Add a quick search button to the Steam store.

目前為 2021-09-25 提交的版本,檢視 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Steam - 添加快速搜索按鈕
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  Add a quick search button to the Steam store.
// @author       CatTime
// @match        http*://store.steampowered.com/app/*
// @icon         https://store.steampowered.com/favicon.ico
// @grant        none
// @require      https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js
// ==/UserScript==

$(function(){
    var getStr = $(".game_area_purchase_game h1:first").text();//取得購買區字串(上方標題會因語言而改變)
    var appName = getStr.substring(3,getStr.length);//從字串中取名稱
    var exStr = ["'"];//排除的字
    var test = $('.game_area_purchase_game h1:first').text();
    console.log("test="+test);
    var SiteSearchUrl = [//網站陣列請保持 名稱,搜索網址
        "IGG","http://igg-games.com/?s=",
        "Online-Fix","https://online-fix.me/index.php?do=search&subaction=search&story="
    ];
    var SSU = SiteSearchUrl;
    var btn = '';
    appName = replacer(appName,exStr);
    console.log("appName="+appName);
    for(var i = 0;i<SSU.length;i+=2){
        btn=btn+'<a href="'+SSU[i+1]+appName+'" class="btn_green_steamui btn_medium"><span>'+SSU[i]+'</span></a>';

    }
    btn='<div class="btn_addtocart">'+btn+'</div>';//加上外層div
    $('.purchase_area_spacer').prepend(btn);//插入到目標的第一元素位置
})

function replacer(str,exStr){//取代掉要排除的字
    if (exStr.length > 0){
        for(var i=0;i<exStr.length;i++){
            str = str.replace(exStr[i],' ')
        }
    }
    return str
}