Greasy Fork

Greasy Fork is available in English.

TB、PDD

抓图

当前为 2022-09-20 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==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)


})();