标签页打开图片增加下载按钮

在新标签页中直接打开图片时,会将图片居中显示并且增加一个下载按钮,点击下载按钮可以直接下载该图片

// ==UserScript==
// @name         标签页打开图片增加下载按钮
// @namespace    http://www.baidu.com/p/%E6%B1%82%E7%9F%A5%E8%80%85wzx
// @version      0.3.1
// @description  在新标签页中直接打开图片时,会将图片居中显示并且增加一个下载按钮,点击下载按钮可以直接下载该图片
// @description  v0.2 下载按钮支持拖动;新增bmp,ico,avif格式图片支持;调整背景和图片边界,是图片不至于和背景融于一体
// @description  v0.3 修改鼠标指向按钮时的样式;透明图片显示格子背景;v0.3.1 修复Firefox中图片到屏幕外的问题
// @author       bluesky
// @include      */*.bmp
// @include      */*.avif
// @include      */*.ico
// @include      */*.jpg
// @include      */*.jpeg
// @include      */*.png
// @include      */*.gif
// @include      */*.webp
// @include      *://desk.zol.com.cn/showpic/*
// @include      *://*.sogou*.com/*.jpg?f=download
// @include      *.bmp?*
// @include      *.avif?*
// @include      *.ico?*
// @include      *.jpg?*
// @include      *.jpeg?*
// @include      *.png?*
// @include      *.gif?*
// @include      *.webp?*
// @license GPLv3
// @grant        none
// @require      http://libs.baidu.com/jquery/1.11.1/jquery.min.js
// ==/UserScript==

var currentUrl = window.location.href;
var body = $("body");
body.css("background-color","#303030");
body.css("text-align","center");
body.css("height","100vh");
var url = "none";
var imgDiv = $("img");
// 添加style标签
var styleTag = document.createElement('style')
styleTag.type = 'text/css'
styleTag.appendChild(document.createTextNode('body>img {border: 1px dotted #959595;background-color: #fff !important;background-image: linear-gradient(45deg, #ccc 25%, transparent 25%, transparent 75%, #ccc 25%),linear-gradient(45deg, #ccc 25%, transparent 25%, transparent 75%, #ccc 25%);background-size: 20px 20px;background-position: 0px 0px, 10px 10px;}'))
var head = document.getElementsByTagName('head')[0]
head.appendChild(styleTag)

var style = "style='width: 42px; height: 42px; margin: 0px 10px; background-position-x: 0px;overflow: hidden;background: transparent url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAVAAAAHjBAMAAACHmFoxAAAAA3NCSVQICAjb4U/gAAAAMFBMVEX///////////////////////////////////////////////////////////////9Or7hAAAAAEHRSTlMAESIzRFVmd4iZqrvM3e7/dpUBFQAAAAlwSFlzAAALEgAACxIB0t1+/AAAABx0RVh0U29mdHdhcmUAQWRvYmUgRmlyZXdvcmtzIENTNui8sowAACAASURBVHic7Z0LcF3Fecf3XD0sWbZ17RCT2AZf8nCagEE0CZ2EEN0AeVGCRJJpCEywoM6TJBbJNKWdDrp0kkIyATsNTdswRA6FhCkJkkOgTQKRTGBK2hQJQxkeaeQE88jDvjK2JVuPu93X9+23e/ZKukb2EWV3xujop8PZ757d/fY73//uHsZ0+ZPvlSv/+XnmlvqvPMj/cGsxIxgyKXctV+WxAqVvKStY+XoWMGhS0ssf/0A+efON/FDe0tP51JdOZS+7YIjfcaQhFAuFSaZQky7m/6IP3sqfRtjEn9MfJncdLx1ZaAvCiy2zJjXzH8DhiXyLOcoNHYSPkmyeKswbTD4puuM38hQSQwE2E4YmJQNjaDPbNGmu//bpNoR1I0/NF6wfUHVPFi2kNvGnjEmUgUmLK/aarK681fz8toVslT7lhcMcWDBZQOgYquFih3FtEuv9DbkmO/kQ/QFFn1MrfI9o5S860Ha9pwG6NnEFe12ma2igN1R+wk75Y2irU/3iqcOAn1G1PErgIlJ7t4GeoRI2eIwrk44fcypim34t/tM0lXdgMlKqGZ5karnXwh5S+biGvk1y4B/vs1+r29zvGtoib3T7PhcqMBNceU/lyUscWA+dr1IE6N6pTgVThu5Ltbxu+xwvuLUrMFDybGqanBEuklZVLqewA6vZD9Dtj79RMGXopLAgVYRJTRNY73m71I++Equr5D2bknLbDND4QuUFDczZ0VwpGOhaNSlh2ibeRrrDttX6p/jgS217liu67YZZ80GE9XuK6ufmLQDFLPw/P3XhelXx8oEdFi4x1iwX1g1qWI8mLlcmFwUkdi83n2PLUgvzif45rMwypY5rQ4Xpy55HQ5fxnernKTsB9nK+t3HYgeqG7mVr1cDScJOuQUDOxzRE76igcI8CWps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NKTFG1nMCizqR1UcnZ2hM4oNjM5MwrLcva2jJxWyafqZ5Rs6MXEpPrTvkz4gi8E0syBGp3q1A1K5IiPJDNwTm1lipPGo2VNqK8vE4bOZRVsa4etdug765x7FUl0GdwL8BVCqfrFg1dTRa9i5lKpf1aDP9QuiuF9+mSpmasyMRX6d6Evy60QXpL9OtLDKDF/QWmil+lfeYoklu/J/RepvlthoqqoAAAAASUVORK5CYII=) no-repeat;background-position: 0 -168px;'";
function getUrl() {
    url = imgDiv.attr("src");
    if (url != "none") {

        //生成下载按钮
        var newA = document.createElement("a");
        newA.title = "点击下载壁纸";
        newA.style = "float:left; position: fixed; top: 15px; left:15px; border-radius:5px; background-color:rgba(99, 99, 99, 0.35);";
        newA.draggable="true";
        newA.href = url;
        var width = document.getElementsByTagName("img")[0].naturalWidth;
        var height = document.getElementsByTagName("img")[0].naturalHeight;
        var fileName = url.substr(url.lastIndexOf('/') + 1,url.lastIndexOf('?')-url.lastIndexOf('/') - 1);
        if(fileName==""){
            fileName = url.substr(url.lastIndexOf('/') + 1);
        }
        var preName = fileName.substr(0,fileName.lastIndexOf('.'));
        var subName = fileName.substr(fileName.lastIndexOf('.'));
        newA.download = preName+"_"+width+"x"+height+subName;
        // 【360极速浏览器】针对自用魔改版360极速浏览器特殊优化
        if(url.indexOf("qhimg.com")!=-1){
            newA.download = "360Chrome_" + preName+"_"+width+"x"+height+subName;
        }
        newA.innerHTML = "<div class='sc_light_1'><div id='downloadPic' " + style + "></div></div>";
        imgDiv.after(newA);

        var downloadPic = $("#downloadPic");

        downloadPic.mouseenter(function() {
            downloadPic.css("margin", "0px 10px");
            downloadPic.css("background-position-x", "-252px");
        });
        downloadPic.mouseout(function() {
            downloadPic.css("margin", "0px 10px");
            downloadPic.css("background-position-x", "0px");
        });
        var isChineseVersionPage = "none";
        //结束计时器
        clearInterval(timer);
        $('body>a').each(function(){
			$(this).dragging({
				move : 'both',
				randomPosition : false
			});
		});
    } else {
        getUrl();
    }
}
var timer = setInterval(getUrl, 500);


$.fn.extend({
		//---元素拖动插件
    dragging:function(data){
		var $this = $(this);
		var xPage;
		var yPage;
		var X;//
		var Y;//
		var xRand = 0;//
		var yRand = 0;//
		var father = $this.parent();
		var defaults = {
			move : 'both',
			randomPosition : true ,
			hander:1
		}
		var opt = $.extend({},defaults,data);
		var movePosition = opt.move;
		var random = opt.randomPosition;

		var hander = opt.hander;

		if(hander == 1){
			hander = $this;
		}else{
			hander = $this.find(opt.hander);
		}


		//---初始化
		father.css({"position":"relative","overflow":"hidden"});
		$this.css({"position":"absolute"});
		//hander.css({"cursor":"move"});

		var faWidth = father.width();
		var faHeight = father.height();
		var thisWidth = $this.width()+parseInt($this.css('padding-left'))+parseInt($this.css('padding-right'));
		var thisHeight = $this.height()+parseInt($this.css('padding-top'))+parseInt($this.css('padding-bottom'));

		var mDown = false;//
		var positionX;
		var positionY;
		var moveX ;
		var moveY ;

		if(random){
			$thisRandom();
		}
		function $thisRandom(){ //随机函数
			$this.each(function(index){
				var randY = parseInt(Math.random()*(faHeight-thisHeight));///
				var randX = parseInt(Math.random()*(faWidth-thisWidth));///
				if(movePosition.toLowerCase() == 'x'){
					$(this).css({
						left:randX
					});
				}else if(movePosition.toLowerCase() == 'y'){
					$(this).css({
						top:randY
					});
				}else if(movePosition.toLowerCase() == 'both'){
					$(this).css({
						top:randY,
						left:randX
					});
				}

			});
		}

		hander.mousedown(function(e){
			father.children().css({"zIndex":"0"});
			$this.css({"zIndex":"1"});
			mDown = true;
			X = e.pageX;
			Y = e.pageY;
			positionX = $this.position().left;
			positionY = $this.position().top;
			return false;
		});

		$(document).mouseup(function(e){
            if(X != e.pageX && Y != e.pageY){
                $("a").click(function(event) {
                    return false;//阻止链接跳转
                });
            } else {
                $("a").unbind("click");//恢复链接跳转
            }
			mDown = false;
		});

		$(document).mousemove(function(e){
			xPage = e.pageX;//--
			moveX = positionX+xPage-X;

			yPage = e.pageY;//--
			moveY = positionY+yPage-Y;

			function thisXMove(){ //x轴移动
				if(mDown == true){
					$this.css({"left":moveX});
				}else{
					return;
				}
				if(moveX < 0){
					$this.css({"left":"0"});
				}
				if(moveX > (faWidth-thisWidth)){
					$this.css({"left":faWidth-thisWidth});
				}
				return moveX;
			}

			function thisYMove(){ //y轴移动
				if(mDown == true){
					$this.css({"top":moveY});
				}else{
					return;
				}
				if(moveY < 0){
					$this.css({"top":"0"});
				}
				if(moveY > (faHeight-thisHeight)){
					$this.css({"top":faHeight-thisHeight});
				}
				return moveY;
			}

			function thisAllMove(){ //全部移动
				if(mDown == true){
					$this.css({"left":moveX,"top":moveY});
				}else{
					return;
				}
				if(moveX < 0){
					$this.css({"left":"0"});
				}
				if(moveX > (faWidth-thisWidth)){
					$this.css({"left":faWidth-thisWidth});
				}

				if(moveY < 0){
					$this.css({"top":"0"});
				}
				if(moveY > (faHeight-thisHeight)){
					$this.css({"top":faHeight-thisHeight});
				}
			}
			if(movePosition.toLowerCase() == "x"){
				thisXMove();
			}else if(movePosition.toLowerCase() == "y"){
				thisYMove();
			}else if(movePosition.toLowerCase() == 'both'){
				thisAllMove();
			}
		});
    }
});