下黄图

try to take over the world!

  1. // ==UserScript==
  2. // @name 下黄图
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.0
  5. // @description try to take over the world!
  6. // @author You
  7. // @match http://www.177pic.info/*
  8. // @match https://ahri-hentai.com/*
  9. // @match http://493428493428c.monster/*
  10. // @match https://zh.nyahentai.com/*
  11. // @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
  12. // @grant none
  13. // ==/UserScript==
  14.  
  15. (function() {
  16. 'use strict';
  17.  
  18. /**
  19. * 通过图片链接获取base64
  20. * @param url //图片链接
  21. * @param ext //图片格式
  22. * @param callback //回调函数,回调base64
  23. */
  24. function getUrlBase64(url, ext, callback) {
  25. var canvas = document.createElement("canvas"); //创建canvas DOM元素
  26. var ctx = canvas.getContext("2d");
  27. var img = new Image;
  28. img.crossOrigin = 'Anonymous';
  29. img.src = url;
  30. img.onload = function () {
  31. console.log(img.height+","+img.width);
  32. canvas.height = img.height; //指定画板的高度,自定义
  33. canvas.width = img.width; //指定画板的宽度,自定义
  34. ctx.drawImage(img, 0, 0, img.width, img.height); //参数可自定义
  35. var dataURL = canvas.toDataURL("image/" + ext);
  36. callback.call(this, dataURL); //回掉函数获取Base64编码
  37. canvas = null;
  38. };
  39. }
  40. $("body").prepend("<button id='downloadH' style='z-index:999999999;position: absolute;'>开始下H图</button>");
  41. $("#downloadH").click(function(){
  42. var $area = $("#show_image_area");
  43. if(!$area){
  44. $area = $(".single-content");
  45. }
  46. if(!$area || $area.length<10){
  47. $area = $("#image-container");
  48. }
  49. debugger;
  50. var now = new Date().getTime();
  51. var start = prompt("从第几页开始下载?");
  52. $area.find("img").each(function(index){
  53. if(index<start){
  54. return true;
  55. }
  56. var imgurl = $(this).attr("src");
  57. let link = document.createElement('a');
  58. link.download = now+"-"+index+".jpg"; //下载的资源重命名
  59. getUrlBase64(imgurl, 'jpg', function (base64Url) {
  60. link.href = base64Url;
  61. link.click();
  62. if(index%19==0){
  63. alert("暂停一下,继续下载!")
  64. }
  65. });
  66. })
  67. });
  68. })();