Баллы Humidex для Gismeteo
当前为
// ==UserScript==
// @name GisMeteo Humidex
// @version 2020.10.23
// @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' ),
temp, humidex, color, text_shadow, text;
function paint ( h ) {
switch ( true ) {
case h < 0:
color = 'violet';
text_shadow = 'white';
text = 'Нет дискомфорта';
break;
case h == 0:
color = 'blue';
text_shadow = 'violet';
text = 'Нет дискомфорта';
break;
case h < 10:
color = 'blue';
text_shadow = 'white';
text = 'Нет дискомфорта';
break;
case h == 10:
color = 'darkturquoise';
text_shadow = 'blue';
text = 'Нет дискомфорта';
break;
case h < 20:
color = 'darkturquoise';
text_shadow = 'white';
text = 'Нет дискомфорта';
break;
case h == 20:
color = 'green';
text_shadow = 'darkturquoise';
text = 'Нет дискомфорта';
break;
case h < 30:
color = 'green';
text_shadow = 'white';
text = 'Нет дискомфорта';
break;
case h == 30:
color = 'gold';
text_shadow = 'green';
text = 'Нет дискомфорта';
break;
case h < 40:
color = 'gold';
text_shadow = 'white';
text = 'Некоторый дискомфорт';
break;
case h == 40:
color = 'orange';
text_shadow = 'gold';
text = 'Некоторый дискомфорт';
break;
case h < 45:
color = 'orange';
text_shadow = 'white';
text = 'Большой дискомфорт; избегать усилий';
break;
case h == 45:
color = 'red';
text_shadow = 'orange';
text = 'Большой дискомфорт; избегать усилий';
break;
case h < 54:
color = 'red';
text_shadow = 'white';
text = 'Опасно; возможен тепловой удар';
break;
case h == 54:
color = 'darkred';
text_shadow = 'red';
text = 'Опасно; возможен тепловой удар';
break;
case h > 54:
color = 'darkred';
text_shadow = 'white';
text = 'Опасно; возможен тепловой удар';
break;
default:
color = 'black';
text_shadow = 'white';
text = '-';
break;
}
}
for ( var i in temps ) {
if ( temps [ i ].innerHTML != null ) temp = temps [ i ].innerHTML.replace ( '+', '' ).replace ( '−', '-' ) * 1;
humidex = Math.round (
temp
+ 5 / 9 * (
(
0.06112
* ( hums [ i ].innerHTML * 1 )
* Math.pow (
10,
( 7.5 * temp / ( 237.7 + temp ) )
)
)
- 10
)
);
paint ( humidex );
if ( temps [ i ].innerHTML != null ) {
temps [ i ].innerHTML =
temps [ i ].innerHTML + '<div title = "' + text
+ '" style = "border-left: 3px solid ' + color + '; border-right: 3px solid ' + color + '; border-radius: 15px; color: ' + color
+ '; font-size: 90%; font-weight: bold; margin: 10px; text-shadow: 0 0 0 ' + text_shadow + ', 0 0 2px ' + text_shadow + ', 0 0 4px ' + text_shadow
+ '">' + humidex + ' Hx</div>';
}
}