拼多多导出訂單油猴脚本 PDD order lists export to excel GreaseMonkey script

导出拼多多订单信息

目前为 2025-03-07 提交的版本。查看 最新版本

// ==UserScript==
// @name         拼多多导出訂單油猴脚本 PDD order lists export to excel GreaseMonkey script 
// @namespace    https://www.pinduoduo.com/
// @version      1.2
// @description  导出拼多多订单信息
// @author       ForkedFrom吾愛破解yiqifeng
// @match        https://mobile.yangkeduo.com/orders.html*
// @match        https://mobile.pinduoduo.com/orders.html*
// @require https://update.gf.qytechs.cn/scripts/494892/1376206/jquery-351.js
// @grant        GM_download
// @run-at       document-end
// @license MIT
// ==/UserScript==
$('body').append('<div class="pdd-go-to-app" id="export">导出数据</div>')
$('#export').click(function () {
    var scrollBottom = setInterval(scrollToBottom, 800);
    function scrollToBottom() {
        var tisp = $('.loading-text').text();
        console.log(tisp)
        if (tisp == "您已经没有更多的订单了") {
            var order = [];
            clearInterval(scrollBottom);
            var listOrder = $('#base-list0>.react-base-list').children();
            $.each(listOrder, function (index, row) {
                order.push($(row)[0].innerText.split('\n\n'))
                if (index == listOrder.length - 1) {
                    let orderlist = '店铺名称,交易状态,商品名称,型号分类,价格,数量,实际付款\r\n'
                    $.each(order, function (index1, row1) {
                        console.log(row1)
                        
                        let isPrice = row1[3] && row1[3].charAt(0) === "¥";
                        // Clean all cells in row1 first
                        row1 = row1.map(cell => cell.replace(/\r|\n|\r\n|\n\r|\t|,|¥/ig, ""));

                        if (isPrice) {
                            // Extract numeric price and quantity using regex
                            let priceMatch = row1[3].match(/(\d+\.?\d*)(×|x)(.*)/);
                            let price = priceMatch ? [priceMatch[1], priceMatch[3]] : [row1[3], ''];
                            let fields = [
                                row1[0],
                                row1[1],
                                row1[2],
                                'null',
                                price[0],
                                price[1],
                                row1[5]
                            ];
                            orderlist += fields.join(',') + '\r\n';
                        } else {
                            let priceMatch = row1[4].match(/(\d+\.?\d*)(×|x)(.*)/);
                            let price = priceMatch ? [priceMatch[1], priceMatch[3]] : [row1[4], ''];
                            let fields = [
                                row1[0],
                                row1[1],
                                row1[2],
                                row1[3],
                                price[0],
                                price[1],
                                row1[6]
                            ];
                            orderlist += fields.join(',') + '\r\n';
                        }
                        if (index1 == order.length - 1) {
                            const uri = 'data:text/csv;charset=utf-8,\ufeff' + encodeURIComponent(orderlist);
                            const link = document.createElement("a");
                            link.href = uri;
                            link.download = `${'拼多多订单数据' + '.csv'}`;
                            link.click();
                        }
                    })
                }
            })
        }
        $("html, body").animate({ scrollTop: $(document).height() }, 500);
    }
})

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址