GisMeteo Humidex & WindCold

Баллы Humidex и ветрохолода для Gismeteo

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name			GisMeteo Humidex & WindCold
// @version			2021.10.02
// @description		Баллы Humidex и ветрохолода для Gismeteo
// @include			http*://*gismeteo.*
// @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 t = document . querySelectorAll ( '.w_temperature .value > .unit_temperature_c' ),
	t3 = Array . prototype . slice . call ( document . querySelectorAll ( '.page-3-days .chart__temperatureByDay .value > .unit_temperature_c' ) ) . slice ( 0, 12 ),
	tmax = document . querySelectorAll ( '.w_temperature .maxt .unit_temperature_c' ),
	tmin = document . querySelectorAll ( '.w_temperature .mint .unit_temperature_c' ),
	tmid = document . querySelectorAll ( '.w_temperature-avg .unit_temperature_c' ),
	hums = document . querySelectorAll ( 'div[data-widget-id = humidity] .w-humidity' ),
	speeds = document . querySelectorAll ( '.widget__row_wind .w_wind span.unit_wind_km_h' ),
	temp_txt, temp, hum, speed, hdex, wcold,
	digit = 1;

function on_screen ( par ) {
	return ( par > 0 ? '+' : '' ) + par . toFixed ( digit ) . replace ( '-', '−' ) . replace ( '.', ',' );
}

function work ( temps ) {
	for ( var i = 0; i < temps . length; i++ ) {
		temp_txt = ( temps [ i ] !== undefined ) ? temps [ i ] . innerHTML : '0';
		temp = temp_txt . replace ( '+', '' ) . replace ( '−', '-' ) * 1;
		hum = ( hums [ i ] !== undefined ) ? hums [ i ] . innerHTML * 1 : 0;
		speed = ( speeds [ i ] !== undefined ) ? Math . pow ( speeds [ i ] . innerHTML, 0.16 ) : 0;
		hdex = ( 5 / 9 * ( ( 0.06112 * hum * Math . pow ( 10, ( 7.5 * temp / ( 237.7 + temp ) ) ) ) - 10 ) + temp );
		wcold = ( ( 13.12 + 0.6215 * temp - 11.37 * speed + 0.3965 * temp * speed ) - temp );
		if ( temps [ i ] . innerHTML != null ) temps [ i ] . innerHTML += '<span class = "adds">H' + on_screen ( hdex ) + ' W' + ( speed !== 0 ? on_screen ( wcold ) : temp_txt ) + '</span>';
	}
}

work ( t );
work ( t3 );
work ( tmax );
work ( tmin );
work ( tmid );