GisMeteo Humidex

Баллы Humidex для Gismeteo

当前为 2020-06-11 提交的版本,查看 最新版本

// ==UserScript==
// @name			GisMeteo Humidex
// @version			2020.06.12
// @description		Баллы Humidex для Gismeteo
// @include			http*://*gismeteo.ru/*
// @exclude			http*://*gismeteo.ru/*/10-days/
// @exclude			http*://*gismeteo.ru/*/2-weeks/
// @icon			https://www.google.com/s2/favicons?domain=gismeteo.ru
// @author			Rainbow-Spike
// @namespace		https://greasyfork.org/users/7568
// @homepage		https://greasyfork.org/ru/users/7568-dr-yukon
// @grant			none
// ==/UserScript==

var temps = document.querySelectorAll ( '.w_temperature .value span:nth-of-type(1)' ),
	hums = document.querySelectorAll ( 'div[data-widget-id = humidity] .w-humidity' ),
	i, temp, hum, humidex, color;

for ( i = 0; i < temps.length; i++ ) {
	temp = temps [ i ].innerHTML.replace ( '+', '' ) * 1;
	hum = hums [ i ].innerHTML * 1;
	humidex = Math.round ( temp + 5 / 9 * ( ( 6.112 * Math.pow ( 10, ( 7.5 * temp / ( 237.7 + temp ) ) ) * hum / 100 ) - 10 ) );
	switch ( true ) {
		case humidex < 0:
			color = 'violet';
			break;
		case humidex < 10:
			color = 'blue';
			break;
		case humidex < 20:
			color = 'darkturquoise';
			break;
		case humidex < 30:
			color = 'green';
			break;
		case humidex < 40:
			color = 'gold';
			break;
		case humidex < 45:
			color = 'orange';
			break;
		case humidex < 54:
			color = 'red';
			break;
		case humidex >= 54:
			color = 'darkred';
			break;
		default:
			color = '';
			break;
	}
	temps [ i ].innerHTML = temps [ i ].innerHTML + '<div style = "font-weight: bold; font-size: 90%; margin: 7px 0 0 12px; color: ' + color + '">' + humidex + '</div>';
}