Trimps tools

Trimps tools (visual)

目前为 2017-03-11 提交的版本。查看 最新版本

// ==UserScript==
// @name         Trimps tools
// @namespace    trimps.github.io
// @version      1.003
// @description  Trimps tools (visual)
// @author       Anton
// @match        https://trimps.github.io
// @require      http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
// ==/UserScript==

(function() {
    'use strict';

    var tMain;

    var _getBarWidthPercent = function(barSelector) {
        return jQuery(barSelector).width() / jQuery(barSelector).parent().width() * 100;
    }

    var _checkProgress = function() {
        var maxProgress = 0;
        var food = _getBarWidthPercent('#foodBar');
        var wood = _getBarWidthPercent('#woodBar');
        var metal = _getBarWidthPercent('#metalBar');
        if (food > maxProgress) maxProgress = food;
        if (wood > maxProgress) maxProgress = wood;
        if (metal > maxProgress) maxProgress = metal;
        document.title = '' + maxProgress + '%';
    };
    
    setTimeout(function() {
        tMain = setInterval(_checkProgress, 500);
    }, 1000);

})();