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()
}

才藝展示

參考

Scriptable Docs


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM