EC2 Cost Calculator

Calculates the approximate monthly and yearly price for an instance (based on 30.4369 days/month and 365.2425 days/year)

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         EC2 Cost Calculator
// @namespace    com.epidemico.ec2costcalc
// @version      0.25
// @description  Calculates the approximate monthly and yearly price for an instance (based on 30.4369 days/month and 365.2425 days/year)
// @author       Jesse Jones
// @match        https://aws.amazon.com/ec2/pricing/*
// @grant        none
// ==/UserScript==

var en = true;

$( document ).ajaxComplete(function() { costCalc(); });

var costCalc = function(e) {
    if (Object.keys($(".rate")).length > 0 && en) {
        $(".rate").each(function(i) {
            var txt = $(this).text();
            var hourly = txt.match(/\$(\d+\.\d+) per Hour/);
            if (!!hourly) {
                if (hourly.length > 1) {
                    var monthly = Math.round(hourly[1] * 730.4856); //  30.4369 days * 24 hours =  730.4856 hours per month
                    var yearly = Math.round(hourly[1] * 8765.8200); // 365.2425 days * 24 hours = 8765.8200 hours per  year
                    $(this).attr("title","$" + monthly + " per Month\n$" + yearly + " per Year");
                }
            }
            en = false;
        });
    } else if (en === false) {
        console.log("[[" + GM.info.script.name + "]] Cost calculations complete.");
        costCalc = function() {};
    }
};