Files
QuantumultX/Scripts/weather.js
2019-06-26 17:13:01 +08:00

31 lines
1.2 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
const weaapi = "https://www.tianqiapi.com/api/?version=v6"
$request(weaapi, function(error, response, data){
if (error){
console.log(error);
$done();
} else {
var obj = JSON.parse(data);
console.log(obj);
var city = "所在城市: " + obj.city;
var wea = "天气状况: " + obj.wea + " 当前" + obj.tem + "℃ " + obj.tem2 + "℃~" + obj.tem1 + "℃";
var air = "当前风力: " + obj.win + obj.win_speed + " 风速" + obj.win_meter + "\n空气指数 " + obj.air + " " + obj.air_level + "\n友情提示 " + obj.air_tips + "\n更新时间 " + obj.date + " "+ obj.update_time;
let wmation = [city,wea,air];
$notify("Weather Condition:", wmation[0]+ wmation[1]+ wmation[2]);
$done();
}
}
);
/*****************************************************************
修改自https://meetagit.github.io/MeetaRules/Surge/Scripting/hourlyWeather.js
[Script]
# 在每天 8:00-20:00 整点预报天气
cron "0 8-20 * * *" script-path=https://raw.githubusercontent.com/ydzydzydz/Rules/master/js/weather.js
*****************************************************************/