217 字
1 分钟
解决新版Infinity无法修改天气中的所在城市的脚本

前言#

Infinity标签页是一款不错的chrome插件,我一直在用但是在最近(发文时间为2018/02/24)的某次更新后天气标签栏的所在城市不能改了,似乎是为了引流用户到新的pro版本做了限制。搞得有点不爽,我也不想用pro版本,所以就有了如下脚本。

使用方法#

把文中的代码全部复制,新建标签页后,打开chrome的控制台console粘贴进去,然后输入updateWeather('你所在的城市名字')后回车,最后刷新新标签页即可。

代码#

function updateWeather(key) {
const xhr = new XMLHttpRequest();
key = encodeURIComponent('"' + key + '"');
xhr.open(
'GET',
`https://query.yahooapis.com/v1/public/yql?q=select+*+from+weather.forecast+where+woeid+in+(select+woeid+from+geo.places(1)+where+text%3D${key})&format=json`,
true
);
xhr.addEventListener(
'load',
function() {
const res = JSON.parse(this.response);
if (res.query.count === 0) {
console.log('not founded');
return;
}
const channel = res.query.results.channel;
saveWeather(channel);
const { country, city } = channel.location;
$setting.set('wcountry', country);
$setting.set('wcity', city);
console.log('current country: ', country);
console.log('current city:', city);
}
);
xhr.send();
}
解决新版Infinity无法修改天气中的所在城市的脚本
https://darknesschaser.github.io/2018/01/24/解决新版infinity无法修改天气中的所在城市的脚本/
作者
漆黑菌
发布于
2018-01-24
许可协议
CC BY-NC-SA 4.0