必应每日一图一键下载-Bing Wallpaper Download

必应每日一图一键下载,自动命名.

// ==UserScript==
// @name         必应每日一图一键下载-Bing Wallpaper Download
// @name:zh      必应每日一图一键下载
// @name:zh-CN   必应每日一图一键下载
// @namespace    http://tampermonkey.net/
// @version      0.3
// @description  必应每日一图一键下载,自动命名.
// @author       pruidong
// @match        http*://www.bing.com/?*
// @match        http*://www.bing.com/
// @match        http*://cn.bing.com
// @icon         data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyZpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNS1jMDIxIDc5LjE1NTc3MiwgMjAxNC8wMS8xMy0xOTo0NDowMCAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENDIDIwMTQgKFdpbmRvd3MpIiB4bXBNTTpJbnN0YW5jZUlEPSJ4bXAuaWlkOjFFQkQ3QTNENEZCMTExRTZBNEFERERBQjI3RTJGQ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grant        GM_download
// @grant        GM_getValue
// @grant        GM_setValue
// @grant        GM_registerMenuCommand
// @grant        GM_unregisterMenuCommand
// @grant        GM_openInTab
// @grant        GM_log
// @grant        GM_notification
// @noframes
// @connect     cdn.bootcdn.net
// @license     GPL
// @run-at      document-end
// ==/UserScript==

(function() {
    'use strict';
    ///
    /// 如果Windows 10 看不到通知,可能需要在右下角点通知,右上角管理通知,开启[获取来自应用和其他发送者的通知].
    ///
    /// 获取当前日期时间为文件名.
    function getCurrDateTime() {
      let dateTime;
      let yy = new Date().getFullYear();
      let mm = new Date().getMonth() + 1;
      let dd = new Date().getDate();
      let hh = new Date().getHours();
      let mf = new Date().getMinutes() < 10 ? '0' + new Date().getMinutes():new Date().getMinutes();
      let ss = new Date().getSeconds() < 10 ? '0' + new Date().getSeconds():new Date().getSeconds();
      dateTime = yy + '-' + mm + '-' + dd + ' ' + hh + ':' + mf+':'+ss ;
      return dateTime;
    }
    /// 下载
    function download(){
        let currDateTime=getCurrDateTime();
        try{
            const imgUrl=$("#preloadBg").prop("href");
            if(imgUrl && imgUrl.lastIndexOf(".")!=-1){
                const fileExt=imgUrl.substr(imgUrl.lastIndexOf("."),imgUrl.length-1);
                currDateTime=currDateTime.replace(" ","-");
                currDateTime=currDateTime.replaceAll(":","-");
                const downloadFileName=`${currDateTime}${fileExt}`;
                GM_download(imgUrl,downloadFileName);
            }
        }catch(e){
            GM_notification({text:"图片下载出现了一点问题,请稍候重试~",title:"错误提示",timeout:3000});
            GM_log(`[${currDateTime}]错误信息:${e}`);
        }finally{
            GM_notification({text:"图片下载成功",title:"提示",timeout:3000});
        }
    }
    $("body").append("<div id='BillWallPaperDownloadDiv' style='width:50px;height:50px;position:fixed;top:50%;border-radius:5px;background-color:#fff;'><div style='width:48px;height:48px;background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAABjBJREFUaEPtWU1S21gQ/lqYMDtkKvuBqtjbkBPEW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QouktCDoMt4nnBHIuBLcByAlkhY+1mjarxu7AjnQfzspQDyeNBLWBx4wsW2zAqLAK7+JOI/AHzTj1lw8cDHaSKx03fY1ISIc2PiMgcQKt9ZAQRFj+kUYD2IKBKuR6um18BRwF0mlt+3k4qTl8jjEbHIaaWTxo4AQLnnDKSxkpczA/D7mKzPG7oZZUl7T4w2zgg3eHF6r0Uho1zL5C0pSb1idf+RCJ+zFspMEdAPWXgrvXOeIma8k/UdSUgG1fO05yKrMj8sY8e8DoT6/7wqJPQD8dNVvXvQdeYoan5h0zKqCLfu64q9vA6E+6Cchcz0MCBcJvXuwYwBnEpiripm4f+Xe87Un00WuuNYK+G4aY1TavHxHZCUD6IqALl52/NwKwHGcRx8tJkLSakq0Eon5YPXJnODqbSftz0P839ZnkXb6VA7sQxtlrDH80E8uEHq/QNbiVNVqmJt3V+mNZgLPUu550xkR6NXG35Lm8XwQONFJrfuZR2yDZD08vWizeHj3peOIm9LkUTNxZEypEZFhxrdyzyatRnYZ/Ag6x4p0ld5w811sFhI2IosH+r9KGjkaww2eSIXfza8k0orlAlrldBgX5BK6xgf3Unx52mzGlkmL60Dix7wqx8xWGHE3zdf/MjFVmLiRrciK3dSqYNHeDfDwJDvSof/Jgh/0XsmvPfpG2zskgCnAtAVdut+aBZM8V3mOjSJvxtf32ddqK0c/RZBwGWittksrwvCX52cmM9UWT1v7l0JQB6Mr7/lb3nXJQse94Z10fhgeaD3sKBG1hWMnJkJwHwQ0eOjfFXZNn8LPtgxX6zaI4kjsPVwQOB62OOeQ/CJqdTI22rkApAUjbB3Jdl9z4xAcJkhEmibeTkeCf+7Q6dIscsdgUillOWremjLR4/Ur5Bxi4kBJr3jKVqlM9WBPMlphnaWD91g26hWQDPiW7D0RTxRjCGszWFeqhSS0TwgftazuXPgZxn6fwR+Nc/nKmS/qvFi1z/lTAJtJnJeVgAAAABJRU5ErkJggg==) no-repeat #fff;background-size: auto;' id='downloadDiv'></div></div>");
    $("#downloadDiv").click(download);
    $('#BillWallPaperDownloadDiv,#downloadDiv').hover(
               function () {
                  $("#BillWallPaperDownloadDiv,#downloadDiv").css({"background-color":"#ccc"});
               },
               function () {
                  $("#BillWallPaperDownloadDiv,#downloadDiv").css({"background-color":"#fff"});
               }
     );
    let menu_feedBack_ID=null;
    registerMenuCommand();
    // 注册脚本菜单
    function registerMenuCommand() {
        if (menu_feedBack_ID) { // 如果反馈菜单ID不是 null,则删除所有脚本菜单
            GM_unregisterMenuCommand(menu_feedBack_ID);
        }
        menu_feedBack_ID = GM_registerMenuCommand(' 反馈 & 建议 [Github]', function () {window.GM_openInTab('https://github.com/pruidong/UserScript', {active: true,insert: true,setParent: true});window.GM_openInTab('https://greasyfork.org/zh-CN/scripts/431609/feedback', {active: true,insert: true,setParent: true});});
    }
    

})();