Cosplay
// ==UserScript==
// @name Cosplay
// @namespace https://bbs.tampermonkey.net.cn/
// @description Cosplay小姐姐图片(API接口应用)
// @version 1.0.3
// @author shuaima
// @crontab * once * * *
// @grant GM_xmlhttpRequest
// @grant GM_notification
// @grant GM_openInTab
// @grant GM_download
// @grant GM_log
// @connect oiapi.net
// ==/UserScript==
return new Promise((resolve, reject) => {
GM_xmlhttpRequest({
method: "GET",
url: "https://oiapi.net/API/Cosplay",
onload: xhr => {
let data = JSON.parse(xhr.responseText)
GM_log(data.data.images[0],data.data.title)
GM_notification({
title: data.data.title,
image: data.data.images[0],
text: "详情点击查看",
onclick: function () {
for (var i = 0; i < data.data.images.length; i++) {
GM_download(data.data.images[i], i+".jpg")
}
},
ondone() {
resolve();
}
})
},
onerror: xhr => {
GM_notification("接口请求失败")
}
})
});