IsThereAnyDeal with thumbnails

Displaying game thumbnails next to the deals

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         IsThereAnyDeal with thumbnails
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  Displaying game thumbnails next to the deals
// @author       Zoltan Wacha - steampeek.hu (find similar games)
// @match        https://isthereanydeal.com/*
// @exclude      https://isthereanydeal.com/waitlist/*
// @exclude      https://isthereanydeal.com/collection/*
// @grant        none
// ==/UserScript==

var refreshTimer = null;

let observer = new MutationObserver(mutationsList => {
	for (let mutation of mutationsList)
	{
		if (mutation.type === 'childList')
		{
			clearTimeout(refreshTimer);
            refreshTimer = setTimeout(function () {
                updateThumbs();
            }, 250);
		}
	}
});

observer.observe(document, {childList: true, subtree: true});

function GM_main ($) {
    $("body").prepend("<style>.itadthumb{width:96px;height:36px;background-repeat:no-repeat;background-position:center;background-size:contain;display:inline-block;margin:0 10px 0 0;flex:none;} .itadthumb.nothumb{background-color: #6f6f6f;background-size: 50%;opacity: 0.1;background-image:url(https://d2uym1p5obf9p8.cloudfront.net/images/logo.png)} .itadthumb.placeholder{opacity: 0.3;background-size: 65%;} .gameinfocontainer{flex:1;}</style>");

    clearTimeout(refreshTimer);
    refreshTimer = setTimeout(function () {
        updateThumbs();
    }, 250);
}

function updateThumbs() {
    let thumbadded = false;
    let lnk = null;
    let steamid = null;

    $("#games > .game:not(.thumbnailhandled)").each(function(index) {
        {
            thumbadded = false;
            lnk = $(this).find('.noticeable').attr('href');

            $(this).wrapInner("<div class='gameinfocontainer'></div>");

            if($(this).data("steamid") && $(this).data("steamid").startsWith('app'))
            {
                steamid = $(this).data("steamid");
                steamid = steamid.replace("app", "apps");

                if(steamid)
                {
                    $(this).prepend("<a href='"+lnk+"' class='itadthumb' style='background-image:url(https://steamcdn-a.akamaihd.net/steam/"+steamid+"/capsule_184x69.jpg)'></a>");
                    thumbadded = true;
                }
            }

            if(!thumbadded)
            {
                $(this).prepend("<a href='"+lnk+"' class='itadthumb nothumb'></a>");
            }

            $(this).css("display", "flex");
            $(this).css("align-items", "center");

            $(this).addClass("thumbnailhandled");
        }
    });
}

if (typeof jQuery === "function") {
    GM_main(jQuery);
}