下黄图

下黄图,自用

Verze ze dne 14. 05. 2021. Zobrazit nejnovější verzi.

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name         下黄图
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  下黄图,自用
// @author       You
// @match        http://www.177pic.info/*
// @icon         data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    /**
     * 通过图片链接获取base64
     * @param url   //图片链接
     * @param ext   //图片格式
     * @param callback  //回调函数,回调base64
     */
    function getUrlBase64(url, ext, callback) {
        var canvas = document.createElement("canvas");   //创建canvas DOM元素
        var ctx = canvas.getContext("2d");
        var img = new Image;
        img.crossOrigin = 'Anonymous';
        img.src = url;
        img.onload = function () {
            console.log(img.height+","+img.width);
            canvas.height = img.height; //指定画板的高度,自定义
            canvas.width = img.width; //指定画板的宽度,自定义
            ctx.drawImage(img, 0, 0, img.width, img.height); //参数可自定义
            var dataURL = canvas.toDataURL("image/" + ext);
            callback.call(this, dataURL); //回掉函数获取Base64编码
            canvas = null;
        };
    }
    $("body").prepend("<button id='downloadH' style='z-index:999999999;position: absolute;'>开始下H图</button>");
    $("#downloadH").click(function(){
       $(".single-content").find("img").each(function(){
          var imgurl = $(this).attr("src");
	      let link = document.createElement('a');
          link.download = imgurl.substring(imgurl.lastIndexOf("/")+1); 	//下载的资源重命名
          getUrlBase64(imgurl, 'jpg', function (base64Url) {
          link.href = base64Url;
          link.click();
          });
    })
    });
})();