Greasy Fork

Back to dealabs

remet la jauge de température sur les deals.

当前为 2017-10-17 提交的版本,查看 最新版本

// ==UserScript==
// @name         Back to dealabs
// @namespace    http://tampermonkey.net/
// @version      0.3
// @description  remet la jauge de température sur les deals.
// @author       Rasmus
// @match        https://www.dealabs.com/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    function addJauge(t) {
        var class_temperature = '';
        var temperature = parseInt(t.find('.vote-box > span').text().replace('°', '').replace('Expiré', '').trim());
        temperature = temperature > 100 ? 100 : temperature;
        if(temperature >= 0) {
            class_temperature = 'deal--start';
            if(temperature >= 100) {
                class_temperature = 'deal--hot';
            }
        } else {
            class_temperature = 'deal--cold';
        }
        temperature = Math.abs(temperature);
        t.append("<div class='jauge' style='width:3em;grid-column: 5;grid-row: 1;grid-row-end: 5;position:relative;'><div class='jauge-fill "+ class_temperature +"' style='z-index:3;position:absolute;margin-top:10px;bottom:10px;width:10px;right:0;background-color:red;height:"+ temperature +"%;'></div><div class='jauge-background' style='height:100%;position:absolute;margin-top:10px;bottom:10px;width:10px;right:0;background-color:grey;'></div></div>");
 }


    $('.thread--deal .threadGrid, .thread--voucher .threadGrid').not('.jauge').each(function() {
        addJauge($(this));
    });

    $( document ).ajaxStop(function() {
        $('.thread--deal .threadGrid, .thread--voucher .threadGrid').not('.jauge').each(function() {
            addJauge($(this));
        });
    });
})();