Greasy Fork

Greasy Fork is available in English.

Humble Bundle - Steam Links Adder

Adds steam links to Humble Bundle games (http://greasyfork.icu/en/scripts/26273-steam-store-game-owned-checker COMPATIBLE!)

当前为 2017-06-08 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Humble Bundle - Steam Links Adder
// @icon         https://humblebundle-a.akamaihd.net/static/hashed/47e474eed38083df699b7dfd8d29d575e3398f1e.ico
// @namespace    Royalgamer06
// @version      1.1.2
// @description  Adds steam links to Humble Bundle games (http://greasyfork.icu/en/scripts/26273-steam-store-game-owned-checker COMPATIBLE!)
// @author       Royalgamer06
// @include      *://www.humblebundle.com/*
// @grant        GM_xmlhttpRequest
// @run-at       document-idle
// @connect      api.steampowered.com
// @require      http://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.js
// ==/UserScript==

// ==Configuration==
var selectors = ["em",
                 ".entity-title",
                 ".deal-title",
                 ".product-name",
                 ".text-holder > h2",
                 ".product-title > h2",
                 "h1[data-entity-kind=product]",
                 ".desktop:has(.hb-steam) .dd-image-box-caption",
                 ".humble-original-title",
                 ".game-name > h4",
                 ".sr-key-heading > span"];
// ==/Configuration==

// ==Code==
this.$ = this.jQuery = jQuery.noConflict(true);
var applist = [];
var selector = selectors.join(":not(.steamified):not(a):not(:has(a)), ") + ":not(.steamified):not(a):not(:has(a))";
GM_xmlhttpRequest({
    method: "GET",
    url: "https://api.steampowered.com/ISteamApps/GetAppList/v2/",
    onload: function(response) {
        applist = JSON.parse(response.responseText).applist.apps;
        $(document).on("contentchanged", selector, function() {
            steamify(this);
        }).ready(function() {
            var domwatcher = setInterval(function() {
                $(selector).each(function() {
                    steamify(this);
                }, 100);
            });
        });
    }
});

function steamify(titleElem) {
    $(titleElem).addClass("steamified");
    setTimeout(function() {
        var title = $(titleElem).text().toLowerCase().replace(/\(early access\)|\(pre\-order\)|\:|\-|\–|\\|\/|\™|\®| |\'|\.|\?|\!/g, "").trim();
        var obj = applist.filter(function(v) { return v.name.toLowerCase().replace(/\:|\-|\–|\\|\/|\™|\®| |\'|\.|\?|\!/g, "").trim() == title; })[0];
        if (obj !== undefined) {
            var appID = obj.appid;
            $(titleElem).replaceWith("<a href='http://store.steampowered.com/app/" + appID + "/'>" + titleElem.outerHTML + "</a>");
        }
    }, 0);
}
// ==/Code==