每日必应壁纸
// ==UserScript==
// @name 每日必应壁纸
// @namespace https://bbs.tampermonkey.net.cn/
// @version 0.1.2
// @description 每天9点-23:59之间运行一次,获取每日必应壁纸,点击打开右键保存即可
// @author 张仨
// @crontab * 9-23 once * *
// @grant GM_xmlhttpRequest
// @grant GM_notification
// @grant GM_openInTab
// @grant GM_log
// @connect biturl.top
// ==/UserScript==
return new Promise((resolve, reject) => {
GM_xmlhttpRequest({
method: "GET",
responseType: "json",
url: "https://bing.biturl.top/",
onload: function (xhr) {
if (xhr.readyState === 4) {
if (xhr.status === 200) {
let copyright = xhr.response.copyright
let imageUrl = xhr.response.url
GM_log(imageUrl,copyright)
GM_notification({
title: copyright,
image: imageUrl,
text: "详情点击查看",
timeout: 8000,
onclick: function () {
GM_openInTab(imageUrl)
},
ondone() {
resolve();
}
})
} else {
GM_notification("数据获取失败")
resolve();
}
}
}
})
});