Created
March 6, 2025 05:29
-
-
Save superyngo/0b9f894856ea23d790ebdca53317bf39 to your computer and use it in GitHub Desktop.
拼多多导出訂單油猴脚本 PDD order lists export to excel GreaseMonkey script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript== | |
| // @name PDD订单导出表格 | |
| // @namespace https://www.pinduoduo.com/ | |
| // @version 1.1 | |
| // @description 导出拼多多订单信息 | |
| // @AuThor ForkedFrom吾愛破解yiqifeng | |
| // @match https://mobile.yangkeduo.com/orders.html* | |
| // @require https://cdn.staticfile.org/jquery/3.5.0/jquery.min.js | |
| // @grant GM_download | |
| // @run-at document-end | |
| // ==/UserScript== | |
| $('body').append('<div class="pdd-go-to-app" id="export">导出数据</div>') | |
| $('#export').click(function () { | |
| var scrollBottom = setInterval(scrollToBottom, 2000); | |
| 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); | |
| } | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment