Greasy Fork is available in English.
抓图
当前为
// ==UserScript==
// @name TB、PDD
// @namespace http://tampermonkey.net/
// @version 0.1
// @description 抓图
// @author You
// @include https://*.yangkeduo.com/*
// @grant GM_xmlhttpRequest
// @grant GM_notification
// @grant GM_download
// @require https://code.jquery.com/jquery-3.6.1.js
// @license MIT
// ==/UserScript==
(function() {
'use strict';
let imgs = [];
setTimeout(()=>{
$("[class*='goods-container'] > div:nth-child(1)").find("img").each( (index,item)=>{
const img_src = $(item).attr('src') ? $(item).attr('src') : $(item).attr('data-src');
imgs.push(img_src.split('?')[0]);
})
let detail_index = -1;
let children = $("[class*='goods-container'] > div:nth-child(2)").children();
Array.from(children).forEach((item,index)=>{
if (item.innerText.indexOf('商品详情')>-1){
detail_index = index + 2;
}
})
var a = $("[class*='goods-container'] > div:nth-child(2) > div:nth-child("+detail_index+")");
console.log(a)
$("body").append("<button id='download_img' style='position:absolute;right:0;top:0'>下载主图</button>")
$("body").append("<button id='download_video' style='position:absolute;right:0;top:20px'>下载视频</button>")
$("#download_img").on('click',function(){
GM_download({
url: imgs[0],
name: "img1.jpg",
saveAs: true,
})
})
$("#download_video").on('click',function(){
let video_url = $("[class*='goods-container'] > div:nth-child(1)").find("video").attr('src');
GM_download({
url: video_url,
name: "img1.mp4",
saveAs: true,
})
})
},2000)
})();