Scriptable制作iOS14小组件(4)微博热搜
打开微博才能看热搜?在桌面看热搜不是梦!🖖
“微博热搜”小组件代码
let g = new LinearGradient()
g.locations = [0, 1]
g.colors = [
new Color("#8B4513"),
new Color("#FF8C00")
]
const url = "https://www.tophub.fun:8888/v2/GetAllInfoGzip?id=58&page=0"
const i = new Request(url);
const json=await i.loadJSON()
log(json.Data.data)
const w = new ListWidget()
const len = json.Data.data.length
w.spacing=10
w.backgroundGradient=g
if (json.Data.data){
if (!config.runsInWidget) {
for(let i=1;i<11;i++){
// log(json)
let arr=["🥇","🥈","🥉","4️⃣","5️⃣","6️⃣","7️⃣","8️⃣","9️⃣","🔟" ]
let stack = w.addStack()
stack.layoutVertically()
let text = stack.addText(arr[i-1]+" "+json.Data.data[i].Title)
stack.url = json.Data.data[i].Url
text.textColor=new Color("#ccc")
// text.shadowRadius=0.5
// text.shadowColor=Color.white()
// let offset=new Point(2, 2)
// text.shadowOffset=offset
}
w.presentLarge()
} else {
Safari.open("https://s.weibo.com/top/summary")
}
}else{
let text=w.addText("请求次数超过限制")
w.presentLarge()
}