Steam - 添加快速搜索按鈕

Add a quick search button to the Steam store.

当前为 2021-09-25 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 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
}