Greasy Fork is available in English.

下载抖音商城商品图片

使用步骤:打开抖音,进入抖音商城,随便选择一款商品点击分享,然后打开商品链接,此时浏览器可视窗口中会出现两个按钮分别为“下载全部轮播图”、“下载全部详情图”

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください。
// ==UserScript==
// @name         下载抖音商城商品图片
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  使用步骤:打开抖音,进入抖音商城,随便选择一款商品点击分享,然后打开商品链接,此时浏览器可视窗口中会出现两个按钮分别为“下载全部轮播图”、“下载全部详情图”
// @author       Aman
// @match       *://haohuo.jinritemai.com/*
// @icon        data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFoAAABaCAYAAAA4qEECAAAACXBIWXMAACE4AAAhOAFFljFgAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAB+6SURBVHgBxV0LrGZVdf7Wuf88mGHu8HJABhHTRqpgsQq2alIxpdVaH0SNjm+sVapG0BZqtK2ANk1ETUFr1VojWlIjbUU0bU1sArRV4xN8oGgVedzRATQOc4dh5j7O6n6s1z7/P3P/e0fthrnn/Ofssx9rr/2tb629//MTfg7pqJTWLW48F6AziHEKwI8G0VGUbuX7ROmM2fLTeBFMKJnkU/qvPoR6keQxDk/7ec7KfV+e4ZQoH/V++qzZmGuBuS5GzVHrapp0e7p0ew++OeW8eWYZN+7av+t2HGYirDFl4Y4WNl6YSjg7FXJ2LUx6dJAKmsqkgyTnRETDhlVBqODCeT5aRheufCyyrUOWR5dsgNJVrkIG4kDx2N+x483p2SsWk9B3r1HoqxZ0EfDSxgu5x4VZY4lqD0h6aB3WB8q1Tq5VcVlnQ/7mmYM1VmYG12HKIiQePMcuIwrXmnmA5pwHn0uzfHZ0+eh50/GqJPDLVivwVQn6uE0nXJIa8PpU4VEkOkdWkHWlCLLczQOAIiDTKr2BCdo/+BxUrmimCRYGNVUoZbDlf+ZGcCxIkaDFIUQL93xalWl+bbvUx6EtOgjp5NJ79u26DFOmqQR91MYTTh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TWew1PjditcqEaGdrOjGam4WrYxYB7hGDA+nfQ3zyzTs6f58d+pdifuX9q7O+H2lZsylDA/SbgS3CZJpwf4rY0LGANVa5ZYSu2WJxVfUEJ51pmEIIEFskAYwpGrv+NwgAqBBubhO96iA2LVCXXT13BkfPpZevLtP9l39wv3JtlgijSVRsck2n1Jqu+82h/tBYdC216RM8TmfXphpCwzrdCkVirtT5mSTK7ohMCFpxMEorEBstyNjtoc6aCMd1r243cvjPZfIVHPqdOqBa0pCzz/UE5q1IWpi2eQNZn0HRZwa+RkDM1nTa6YVXigqM/MLbZPQI2mJMVbDJBGB2BsJqBlMCpb1B+2yGXdkNT4xoX1+69crYBD9YefTkhCXy6/TkRnpEY9OuHRKanVpwwqsJd9GwODzgVWGyPXKQgMJiGjaoDRRH3CjEFzsU3cGF4fDr9Pu5OLuzsdb07F5x9h/0ZeGFmrcGP6P1+9Udf9LAr5AAAAAElFTkSuQmCC
// @license     GPL
// @grant       GM_xmlhttpRequest
// @grant       GM_download
// @grant       GM_addStyle
// ==/UserScript==

(function() {
    'use strict'

    const timer = setInterval(() => {
        try {
            if (isItLoaded()) {
                clearInterval(timer)
                // start...
                createButtonDownloadArea()
                createCarouselDownloadButton()
                createDetailDownloadButton()
                // style
                applyStyle()
            }
        } catch (ignore) {
            // ignore...
        }
    }, 200)

    /**
     * 轮播图和详情图是否已经加载完毕
     * @returns {boolean}
     */
    const isItLoaded = () => {
        const parents = document.querySelector('#container > div.head-figure.default_container > div.head-figure__media-view > div > div').children
        const detailImageUrls = document.querySelectorAll('#container > div.detail-container__components > div.detail-container__sold-content > div.partial-detail-wrapper > div.product-big-img-list img')
        return parents !== undefined && detailImageUrls !== undefined
    }

    /**
     * 创建一个区域,用于存放下载按钮
     */
    const createButtonDownloadArea = () => {
        const buttonDownloadArea = document.createElement('div')
        buttonDownloadArea.id = 'buttonDownloadArea'
        document.documentElement.appendChild(buttonDownloadArea)
    }

    /**
     * 创建轮播图下载按钮
     */
    const createCarouselDownloadButton = () => {
        const downloadButton = document.createElement('button')
        downloadButton.id = 'downloadCarouselImagesButton'
        downloadButton.innerText = '下载全部轮播图'
        downloadButton.onclick = () => {
            downloadCarouselImages()
        }

        const buttonDownloadArea = document.getElementById('buttonDownloadArea')
        buttonDownloadArea.appendChild(downloadButton)
    }

    /**
     * 创建详情图下载按钮
     */
    const createDetailDownloadButton = () => {
        const downloadButton = document.createElement('button')
        downloadButton.id = 'downloadDetailImagesButton'
        downloadButton.innerText = '下载全部详情图'
        downloadButton.onclick = () => {
            downloadDetailImages()
        }

        const buttonDownloadArea = document.getElementById('buttonDownloadArea')
        buttonDownloadArea.appendChild(downloadButton)
    }

    /**
     * 下载轮播图
     */
    const downloadCarouselImages = () => {
        const parents = document.querySelector('#container > div.head-figure.default_container > div.head-figure__media-view > div > div').children
        const arrayChildren = Array.from(parents).map(parent => Array.from(parent.children))
        const imgUrls = arrayChildren.map(item => item.map(i => i.style.backgroundImage))
        const urlRegex = /url\("(.+)"\)/

        imgUrls.forEach(imgUrl => {
            imgUrl.forEach(img => {
                const [, url] = img.match(urlRegex)
                setTimeout(() => {
                    downloadImage2(url, randomFilename('轮播图'))
                }, 600)
            })
        })
    }

    /**
     * 生成一个随机字符串文件名
     * @param prefix 文件名前缀
     * @returns {string}
     */
    const randomFilename = (prefix) => {
        return prefix + '-' + Math.random().toString(36).substring(2, 10)
    }

    /**
     * 下载详情图
     */
    const downloadDetailImages = () => {
        const detailImageUrls = document.querySelectorAll('#container > div.detail-container__components > div.detail-container__sold-content > div.partial-detail-wrapper > div.product-big-img-list img')

        Array.from(detailImageUrls).forEach(detailImage => {
            setTimeout(() => {
                downloadImage2(detailImage.src, randomFilename('详情图'))
            }, 600)
        })
    }

    /**
     * 点击超链接,下载
     */
    const downloadImage2 = (url, filename) => {
        console.log('准备下载文件 ==>>> ', url)
        if (filename === undefined || filename === '') {
            filename = Date.now() + '-file'
        }
        GM_download(url, filename)
    }

    const applyStyle = () => {
        GM_addStyle(
            `
    #buttonDownloadArea {
      position: fixed;
      top: 20%;
      left: 10px;
      z-index: 99999;
      text-align: center;
    }

    #downloadDetailImagesButton, #downloadCarouselImagesButton {
      background-color: #099cee; /* 设置背景颜色 */
      border: none; /* 去掉边框 */
      color: white; /* 设置文字颜色 */
      padding: 10px 20px; /* 设置内边距 */
      text-align: center; /* 文字居中 */
      text-decoration: none; /* 去掉下划线 */
      display: block; /* 设置为行内块级元素 */
      font-size: 16px; /* 设置字体大小 */
      border-radius: 5px; /* 设置圆角 */
      box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.2); /* 设置阴影 */
      cursor: pointer; /* 鼠标悬停时显示手型 */
      margin: 10px auto;
    }

    #downloadCarouselImagesButton:hover, #downloadDetailImagesButton:hover {
      background-color: #3e8e41; /* 鼠标悬停时改变背景颜色 */
    }
  `
        )
    }
})();