这是一款可让您使用 JavaScript 自动化 iOS 的应用程序
ios 网络请求分析开发工具
手机安装工具Stream
获取需要的接口信息
安装scriptables小组件开发神器
快复制以下代码体验一下吧!
let url = "https://v2.jinrishici.com/one.json"
let req = new Request(url);
let json = await req.loadJSON();
log(json)
let poem=json.data.origin.content[0]
log(poem)
let dotflag = /。|,|!|?/g
let dot=poem.match(dotflag)
poem=(poem.split(dotflag))
log(poem)
let str1=poem[0]
let str2=poem[1]
let str3=json.data.origin.author
let str4=json.data.origin.title
let widget = new ListWidget()
let lineColor=new LinearGradient()
widget.backgroundColor=new Color("#DC290C")
let bgImg="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fpic1.zhimg.com%2Fv2-29495592247bf74ee0c7116fa3111b15_1440w.jpg%3Fsource%3D172ae18b&refer=http%3A%2F%2Fpic1.zhimg.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1647770412&t=9e16961bba0e777fc6dc443ac732b1a4"
const i = await new Request(bgImg);
const img = await i.loadImage();
widget.backgroundImage=img
let first=widget.addText(str1+dot[1])
first.font=new Font("KaiTi", 15)
first.textColor=new Color("#ffffff")
let second=widget.addText(str2+dot[1])
second.font=new Font("KaiTi", 15)
second.textColor=new Color("#ffffff")
second.rightAlignText()
widget.spacing=14
let author=widget.addText("-"+str3+"《"+str4+"》")
author.textColor=new Color("#ffffff")
author.rightAlignText()
widget.presentMedium()
Script.setWidget(widget)
Script.complete()
|