// ==UserScript== // @name 亚马逊导出SKU成本 // @namespace http://tampermonkey.net/ // @version 0.0.3 // @description 在询盘页面，搜索按钮后面插入一个下载按钮，点击可以从头开始记录每个客户的分配记录，最终输出成JSON文件自动下载。 // @author Mike // @icon http://is.alicdn.com/favicon.ico // @match https://sellercentral.amazon.com/skucentral?mSku=* // @grant GM_addStyle // ==/UserScript== 'use strict'; function copy(e, textContent = true) { let obj = document.createElement('textarea'); document.body.appendChild(obj); obj.value = textContent ? e.textContent : e; obj.select(); console.log(e); document.execCommand('copy', false); obj.remove(); return obj.value } function getStrings() { var container = document.getElementsByClassName('amz-fees-tableV3-container') var text = container[0].innerText //var s = "最近 30 天总计每件商品平均销售价格 $9.49已售商品数量 4退货商品数量 0已售商品净数量 4销售额 $37.96净销售额 $37.96亚马逊收取的总费用-$22.35 亚马逊物流配送费用-$11.88商品推广费用-$6.21销售佣金-$4.26非亚马逊总费用- 编辑所售商品成本 x 已售商品数量-杂项费用 x 已售商品数量-净收入 $15.61复制数据"; text = text.replace(//g,'').replace(//g,'').replace(/\n/g,'') console.log(text); var averageSalesPrice = mymatch(/平均销售价格[-.$\s\d]+/g,text); var unitsSsold = mymatch(/已售商品数量[.$\s\d]+/g,text); var unitsReturned = mymatch(/退货商品数量[.$\s\d]+/g,text); var sales = mymatch(/[净]?销售额[.,$\s\d]+/g,text); var sponsored = mymatch(/商品推广费用[-.$\s\d]+/g,text); var fba = mymatch(/亚马逊物流配送费用[-.$\s\d]+/g,text); var referral = mymatch(/销售佣金[-.$\s\d]+/g,text); var abandon = mymatch(/亚马逊物流弃置订单费用[-.$\s\d]+/g,text); var longterm = mymatch(/长期仓储费[-.$\s\d]+/g,text); var monthly = mymatch(/月度库存仓储费[-.$\s\d]+/g,text); var refundFee = mymatch(/退款管理费用[-.$\s\d]+/g,text); var value = averageSalesPrice + '\n' + unitsSsold + '\n' + unitsReturned + '\n' + sales + '\n' + sponsored + '\n' + fba + '\n' + referral + '\n' + abandon + '\n' + longterm + '\n' + monthly + '\n' + refundFee console.log(value); copy(value,false); mymatch(/已售商品净数量[.$\s\d]+/g,text); mymatch(/亚马逊收取的总费用[-.$\d]+/g,text); //copy(text,false) } //与元数据块中的@grant值相对应，功能是生成一个style样式 GM_addStyle('#down_contacts_btn{color:#fb7d3c;}'); //下载按钮的html代码 var down_btn_html = ''; down_btn_html += '复制数据'; down_btn_html += ''; var inner = document.createElement('span'); inner.innerHTML = down_btn_html; console.log(inner); function mymatch(pat,s){ var a = s.match(pat); console.log('-----------'); console.log(a); var p = /[-.\d]+/g; if (a == null){ return '' }else if (a.length == 1) { var aa = a[0].replace(/\$/g,''); console.log(aa); //console.log(aa.match(p)); return aa.match(p) }else{ var a1 = a[0].replace(/\$/g,''); console.log(a1); var a2 = a[1].replace(/\$/g,''); console.log(a2); //console.log(aa.match(p)); return a1.match(p) + '\n' + a2.match(p) } } var $, jQuery; loading(); function loading(){ setTimeout(function () { console.log('延迟加载') //将以上拼接的html代码插入到网页标签中 var ul_tag = document.getElementsByClassName('amz-fees-sales-table-title'); console.log('ul_tag'); if (ul_tag) { console.log(ul_tag[0].parentNode); ul_tag[0].parentNode.append(inner); console.log(ul_tag[0]); } var btn = document.getElementById('down_contacts_btn'); console.log(btn) btn.onclick = function(){ getStrings() btn.innerHTML = "Copied"; window.setTimeout(function () { btn.innerHTML = '复制数据'; }, 1500) } },3000) }
// ==UserScript== // @name 阿里巴巴国际站产品辅助脚本 // @namespace http://www.alibaba.com // @author Lepturus // @version 0.0.9 // @icon http://is.alicdn.com/favicon.ico // @description 1. 添加【零效果产品页】【产品运营工作台页】【产品分析页】编辑及数据效果查看按钮 2. 添加【产品详情页】编辑及数据查看按钮,修改图片链接为原图，添加显示产品关键词,添加视频链接与封面链接 3. 添加【图片银行页】直接下载原图按钮 4. 添加【关键词指数页】搜索按钮 5. 添加【产品关键词搜索页】显示公司名按钮 6.添加【产品列表页】序列和效果按钮 7. 显示阿里巴巴标签页名称 8. 【产品编辑页】增强 // @match *://www.alibaba.com/* // @match *://data.alibaba.com/* // @match *://*.alibaba.com/trade/search* // @match *://*.alibaba.com/product-detail/* // @match *://keywordIndex.alibaba.com/* // @match *://photobank.alibaba.com/* // @match *://post.alibaba.com/* // @match *://hz-productposting.alibaba.com/* // @match *.alibaba.com/product/* // @grant GM_addStyle // @license MIT // ==/UserScript== ////********************************************** //// 1. 添加【产品运营工作台页】产品编辑及查看产品效果按钮 //// 2. 添加【产品分析页】含【零效果产品页】页 编辑及查看产品分层按钮 //// 3. 添加【产品详情页】编辑查看产品效果按钮,修改图片链接为原图，添加显示产品关键词(点击关键词可复制),添加视频链接与封面链接 //// 4. 添加【图片银行页】直接下载原图按钮 //// 5. 添加【关键词指数页】内 【关键词分析】搜索按钮 //// 6. 添加【产品关键词搜索页】显示公司名按钮,若出现供应商名称顺序对不上的情况，一般重新刷新页面可正确显示，或者重新刷新页面后使用强制显示供应商名称模式(注意先开启该按钮再开启左边ON/OFF按钮) //// 7. 添加【产品列表页】序列(点击可复制询盘链接)和产品效果按钮 //// 8. 显示阿里巴巴标签页名称 //// 9. 【产品编辑页】增强, 添加关键词直接搜索按钮，添加导航快捷按钮(上传图片 质量分检测【当阿里质量分按钮不存在时也可检测】 提交产品)，辅助添加标题单词首字母转大写功能 ////********************************************** (function () { 'use strict'; GM_addStyle( ".switch{position:relative;width:45px;height:17px;display:inline-block} .switch input{display:none}.d_slider{position:absolute;cursor:pointer;top:0;left:0;right:0;bottom:0;background-color:#ca2222;transition:.4s}.d_slider:before{position:absolute;content:'';height:13px;width:13px;left:2px;bottom:2px;background-color:#fff;transition:.4s}input:checked+.d_slider{background-color:#2ab934}input:checked+.d_slider:before{transform:translateX(28px)}.on{display:none}.off,.on{color:#fff;position:absolute;transform:translate(-50%,-50%);top:50%;left:50%;font-size:8px}input:checked+.d_slider .on{display:block} input:checked+.d_slider .off{display:none}.d_slider.round{border-radius:17px}.d_slider.round:before{border-radius:50%}" ); // 工具函数 -- 添加元素属性 function setAttributes(el, attrs) { for (let key in attrs) { el.setAttribute(key, attrs[key]); } } // 工具函数 -- 复制 function copy(e, textContent = true) { let obj = document.createElement('input'); document.body.appendChild(obj); obj.value = textContent ? e.textContent : e; obj.select(); document.execCommand('copy', false); obj.remove(); return obj.value } // 工具函数 -- 序数 function addCounter(productList, margin) { var cssText = "position:absolute;z-index:1;margin-left:" + margin + "px;display:inline-block;background:SlateGray;color:WhiteSmoke;font-family:'微软雅黑';font-size:14px;text-align:center;width:20px;line-height:20px;border-radius:50%;"; var div = document.createElement('div'); var idx = 1; for (var i = 0; i < productList.length; i++) { if (productList[i].getAttribute('data-index')) { continue; } else { productList[i].setAttribute('data-index', idx); div.innerHTML = " " + idx + " "; productList[i].innerHTML = div.innerHTML + productList[i].innerHTML; idx++; } } } // 工具函数 -- 首字母大写 function Capitalize(str) { return str.replace(/\w\S*/g, function (txt) { return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase(); }); } function productList() { if (document.querySelector(".product-info")) { addCounter(document.querySelectorAll(".product-info"), -80); } let productList = document.querySelectorAll(".product-info"); for (var i = 0; i < productList.length; i++) { var el = document.getElementsByClassName('product-id')[i]; var el2 = document.getElementById("product_" + i); var product_id = el.innerText.replace(/[^0-9]/ig, ""); let inquiry_url = "https://message.alibaba.com/msgsend/contact.htm?action=contact_action&domain=1&id=" + product_id; var similar_url = "https://post.alibaba.com/product/publish.htm?pubType=similarPost&itemId=" + product_id; el2.onclick = function () { copy(inquiry_url, false) alert(`${inquiry_url}\n……Copy The Inquiry URL Done……`); } el.setAttribute('data-href', inquiry_url) let product_a = productList[i].parentNode.querySelector(".next-col.next-col-3>span>div") if (product_a){ let product_analysis = document.createElement("span"); product_analysis.innerHTML = ` 效果`; if (!product_a.textContent.match("效果")) { // 动态加载fix product_a.appendChild(product_analysis); } } } } // 添加产品运营工作台产品编辑按钮 function productEdit() { let products, products_cell; if (document.querySelector('.upgrade-products-article-item')) { products_cell = '.upgrade-products-article-item'; products = document.querySelectorAll(products_cell); } else { products_cell = '.upgrade-products-grid-record'; products = document.querySelectorAll(products_cell); } let ln = products.length; // 非已经存在编辑按钮 if (ln && !document.querySelector(products_cell).textContent.match("编辑")) { for (let i = 0; i < ln; i++) { let product_title = products[i].querySelector(".product-subject").title; let product_container = products[i].querySelector(".product-id"); let product_id = product_container.textContent.match(/\d+/)[0]; // 产品ID // console.log(product_title, product_id); let product_href = ` 编辑 数据 效果明细` if (!product_container.textContent.match("编辑")) { // 动态加载fix product_container.innerHTML += product_href; } } console.log("添加产品运营工作台产品编辑按钮成功!!!"); } } // 添加产品分析页面按钮 function productAnalyse() { let product_tab = document.querySelector(".Product_tab .next-tabs-nav li[aria-selected='true']").textContent let products = document.querySelectorAll('tbody>tr') let ln = products.length; // 非已经存在产品分层按钮 if (product_tab =="我的产品"){ if (ln && !document.querySelector('tbody>tr:last-child').textContent.match("分层")) { for (let i = 0; i < ln; i++) { let product_title = products[i].querySelector(".media-content").textContent; let product_url = products[i].querySelector(".custom-td-content>a").href; let product_id = product_url.match(/_(\d+)\.htm(l)?/)[1]; // 产品ID // console.log(product_title, product_id); let product_newURL = "https://post.alibaba.com/product/publish.htm?spm=a2747.manage.0.0.8e9071d2H60Rr7&pubType=similarPost&itemId=" + product_id + "&behavior=copyNew"; let product_href = ` 复制 分层`; // 非产品不可编辑状态 if (products[i].querySelector(".action-enabled")) { let product_container = products[i].querySelector(".action-enabled").parentElement; // 插入span 编辑 ... if (!product_container.textContent.match("分层")) { // fix动态加载js，指选择日期产品后排序会重复添加的 product_container.innerHTML += product_href; } } // product_container.parentNode.insertBefore(document.createElement("br"), product_container.nextSibling); // document.querySelector('col:last-child').style.setProperty("width", "180px", "important"); // 设置表格最后一栏宽度 } console.log("添加产品分析页面按钮成功!!!"); }} else{ // 零效果产品 // 非对不起，未能查询到符合您要求的产品，建议重新设置查询条件或者已经存在复制按钮 if (!document.querySelector('.ineffective-product tbody>tr').textContent.match("未能查询到") && !document.querySelector('.ineffective-product tbody>tr').textContent .match("复制")) { products = document.querySelectorAll('.ineffective-product tbody>tr') ln = products.length; for (let i = 0; i < ln; i++) { let product_info = products[i].querySelectorAll('.next-table-cell-wrapper'); // 表格每一行产品 // console.log(product_info); let product_url = product_info[1].querySelector("a").href; let product_container = product_info[6].querySelector(".edit-delete-off"); // ... let product_id = product_url.match(/_(\d+)\.htm(l)?/)[1]; // http://www.alibaba.com/product-detail//XXX_123456789.html?spm=a2... // 产品ID let product_newURL = "https://post.alibaba.com/product/publish.htm?spm=a2747.manage.0.0.8e9071d2H60Rr7&pubType=similarPost&itemId=" + product_id + "&behavior=copyNew"; let product_HTML = document.createElement("span"); product_HTML.innerHTML = `复制 数据 效果`; if (!product_container.textContent.match("数据")) { // 动态加载fix product_container.appendChild(product_HTML); } } console.log("零效果产品页复制按钮添加成功!!!"); } } } // 添加产品页按钮 function productDetail() { let product_id; if (!document.querySelector('.ali_product_keywords')) { if (document.querySelector(".module-pdp-title") || document.querySelector(".product-title")) { let product_title; let product_title_container; let product_image_container; if (document.querySelector(".module-pdp-title")){ product_title = document.querySelector(".module-pdp-title").textContent; product_title_container = ".module-pdp-title"; product_image_container = ".main-image-thumb-item img"; } else{ product_title = document.querySelector(".product-title h1").textContent; product_title_container = ".product-title h1"; product_image_container = ".main-list>.main-item>img"; } // 在不同浏览器或设备显示代码不一样 // console.log(product_title); if (/\/product\//.test(document.URL)) { product_id = document.URL.match(/(\d+)-(\d+)/)[1];; // 产品ID } else if (/chinese\.alibaba/.test(document.URL)) { product_id = document.URL.match(/-(\d+)\.htm(l)?/)[1]; // 中文网页产品ID } else { product_id = document.URL.match(/_(\d+)\.htm(l)?/)[1]; // 产品ID } // 产品标题 - Buy () on Alibaba.com let product_keywords = document.title.match(/- Buy (.*) Product/)[1]; // 产品关键词 let product_keywords_html = product_keywords.split(",").map(item => ( ` ${item}` )).join(""); // overwriting the innerHTML is not a good idea indeed, will gone event listener so using appendChild here. let product_html = document.createElement("div"); product_html.innerHTML = ` ${product_keywords_html} `; document.querySelector(product_title_container).parentElement.appendChild(product_html); // 同标题class let kws = document.getElementsByClassName("product_keyword"); for (let i = 0; i < kws.length; i++) { kws[i].onclick = function () { let kkws = copy(kws[i]); kws[i].innerHTML = "Copied"; window.setTimeout(function () { kws[i].innerHTML = kkws; }, 1500) } } console.log("添加产品分析页面按钮成功!!!"); document.querySelectorAll(product_image_container).forEach(v => (v.src = v.src.replace( /_50x50\.(jpg|png)/, "").replace(/_100x100xz\.(jpg|png)/, ""))); // 修改图片轮播链接为原图 } } // 动态加载 window.addEventListener('load', function () { if (document.querySelector(".details-user-actions")) { let container = document.querySelector(".details-user-actions"); let product_tool = document.createElement("span"); if (document.querySelector('.image-d_slider video')) { if (!document.querySelector('.details-user-actions').textContent.match("视频")) { let video_link = document.querySelector('video').src; // 产品视频链接 let video_poster = document.querySelector('video').poster; // 产品视频封面链接 let video_html = `视频链接 视频封面` product_tool.innerHTML = video_html; } } let product_edit_style = document.querySelector(".is-magic") ? "智能编辑" : document.querySelector( "#J-rich-text-description>div:only-child") ? "旧版智能编辑" : "普通编辑"; product_tool.innerHTML += ` ${product_edit_style} 编辑 数据 效果明细 复制`; if (!document.querySelector('.details-user-actions').textContent.match("数据")) { container.appendChild(product_tool); } } }) } // 添加图片银行直接下载原图按钮 function productPhoto() { let products = document.querySelectorAll('.photo-grid-item') // 获取图片容器 let ln = products.length; // 非已存在下载原图链接按钮 if (!document.querySelector('.image-info').textContent.match("下载原图")) { for (let i = 0; i < ln; i++) { let product_src = products[i].querySelector(".photo-grid-img-wrapper img").src; // 获取图片链接 let product_picforamt = product_src.match(/_350x350\.(jpg|png)/)[1]; let product_picLink = product_src.replace(/_350x350\.(jpg|png)/, ""); let product_picName = products[i].querySelector(".display-name button").textContent; // 获取图片文件名 // console.log(product_picName); let product_picContainer = products[i].querySelector(".image-info"); let product_picHTML = document.createElement("a"); setAttributes(product_picHTML, { "href": `${product_picLink}?attachment=${product_picName}.${product_picforamt}`, "target": "_blank", "rel": "noopener noreferrer" }); product_picHTML.innerHTML = "下载原图"; product_picContainer.appendChild(product_picHTML); } // console.log("添加图片银行直接下载原图按钮成功!"); } } //添加关键词指数页搜索按钮 function productKeywordIndex() { let keywords = document.querySelectorAll('.next-table-row'); let ln = keywords.length; // 非已经存在搜索按钮 if (ln && !document.querySelector('.next-table-row a i')) { for (let i = 0; i < ln; i++) { let kws_container = keywords[i].querySelectorAll(".next-table-cell-wrapper")[1].querySelector( "span"); let kw = kws_container.querySelector("a").textContent; let alibaba_link = document.createElement("a"); setAttributes(alibaba_link, { "href": `https://www.alibaba.com/products/${kw}.html?viewtype=G`, "target": "_blank", "rel": "noopener noreferrer", "title": "在阿里巴巴搜索" }); alibaba_link.innerHTML = ` `; let product_link = document.createElement("a"); setAttributes(product_link, { "href": `https://hz-productposting.alibaba.com/product/manage_products.htm?#/product/all/1-10/productKeyword=${kw}`, "target": "_blank", "rel": "noopener noreferrer", "title": "在发布产品列表搜索" }); product_link.innerHTML = ` `; if (!kws_container.querySelector('.next-table-row a i')) { // 动态加载fix kws_container.appendChild(alibaba_link); kws_container.appendChild(product_link); } } console.log("添加关键词指数页搜索按钮成功!!!"); } } // 产品编辑页增强 function productPublish() { let product_keywords; product_keywords = document.querySelectorAll(".posting-field-keywords li"); function alibaba_link(kw) { let kw_search_link = document.createElement("a"); setAttributes(kw_search_link, { "href": `https://www.alibaba.com/products/${kw}.html?viewtype=G`, "target": "_blank", "rel": "noopener noreferrer", "title": "在阿里巴巴搜索", "class": "alibaba_search", }); kw_search_link.innerHTML = ``; return kw_search_link; } for (let i = 0; i < product_keywords.length; i++) { let kw_container = product_keywords[i].querySelector(".next-input-control"); kw_container.appendChild(alibaba_link(product_keywords[i].querySelector("input").value)); product_keywords[i].querySelector("input").addEventListener('change', function (e) { kw_container.replaceChild(alibaba_link(this.value), kw_container.querySelector( '.alibaba_search')); }); } if (document.querySelectorAll("#productsm").length < 1) { let product_menu = document.querySelector('.next-menu-content') product_menu.insertAdjacentHTML('beforeend', ' 上传图片 ' ); document.querySelector('#productpic').onclick = function () { let img_uploadButton = document.getElementsByClassName('upload-select-inner')[0].getElementsByTagName( "button")[0] if (img_uploadButton.disabled) { alert("产品图片已满，请删除部分图片后重新尝试上传！") } else { img_uploadButton.click(); // document.querySelector('#productpic span').style.color = "orange" } } product_menu.insertAdjacentHTML('beforeend', ' 检测质量分</li' ); document.querySelector('#productsc').onclick = function () { let rate = document.getElementById('struct-pinbar').getElementsByClassName('block-text default')[0]; // 产品质量分 if (rate) { rate.click() } else if (document.getElementById('struct-pinbar').getElementsByClassName('block-text')) { document.getElementById('struct-pinbar').getElementsByClassName('block-text')[0].click(); } else { alert("检测出错！") } let product_score = document.getElementById('struct-pinbar').getElementsByClassName('number'); window.setTimeout(function () { if (product_score.length) { document.querySelector('#productsc span').textContent = `检测质量分(${product_score[0].textContent})`; } }, 2500); let product_title = document.getElementById('productTitle').value; let product_titleCapitalize = document.createElement("span"); product_titleCapitalize.className = "product_titleCapitalize"; product_titleCapitalize.innerHTML = ` ${Capitalize(product_title)}`; let product_title_container = document.getElementById('productTitle').parentNode.parentNode; product_title_container.appendChild(product_titleCapitalize); product_title_container.replaceChild(product_titleCapitalize, product_title_container.querySelector( '.product_titleCapitalize')); product_titleCapitalize.onclick = function () { copy(product_titleCapitalize); product_titleCapitalize.innerHTML = " Copied"; window.setTimeout(function () { product_titleCapitalize.innerHTML = ` ${Capitalize(product_title)}`; }, 1500); } } product_menu.insertAdjacentHTML('beforeend', ' 提交产品</li' ); document.querySelector('#productsm').onclick = function () { document.getElementsByClassName("next-btn next-btn-primary next-btn-large step-buttons")[0].click(); // 提交按钮 } } } // 搜索关键词显示公司名 function productSupplierDisplay() { let products; if (document.querySelector('.seb-refine-ctb__viewtype>a').classList.contains('active')) { products = document.querySelectorAll('.app-organic-search__list>div.J-offer-wrapper'); } else { products = document.querySelectorAll('.organic-gallery-offer-outter'); } let ln = products.length; function fireMouseEvents(element, eventNames) { if (element && eventNames && eventNames.length) { for (let index in eventNames) { let eventName = eventNames[index]; if (element.fireEvent) { element.fireEvent('on' + eventName); } else { let eventObject = document.createEvent('MouseEvents'); eventObject.initEvent(eventName, true, false); element.dispatchEvent(eventObject); } } } } let supplier_idx = 0 for (let i = 0; i < ln; i++) { let supplier_container; // 视图切换按钮 if (document.querySelector('.seb-refine-ctb__viewtype>a').classList.contains('active')) { supplier_container = products[i].querySelector(".list-no-v2-decisionsup__row"); } else { supplier_container = products[i].querySelector(".organic-gallery-offer_bottom-align-section"); } if (supplier_container && document.getElementById("d_switch").checked) { if (products[i].querySelector('.gallery-theme-card-default__image-ctn') || products[i].querySelector( '.offer-theme-search')) { continue; // 跳过广告位Discover Now } else { supplier_idx = supplier_idx + 1; if (!products[i].querySelector(".alisupplier_name")) { let product_link = products[i].querySelector('a').href; // 获取产品链接 let product_title = products[i].querySelector('.elements-title-normal').textContent; // 获取产品名 // 控制台输出产品标题 测试使用 //console.log(i, product_title); let product_inq, supplier_link, supplier_id = ""; if (document.querySelector('.seb-refine-ctb__viewtype>a').classList.contains('active')) { product_inq = products[i].querySelector('.contact-supplier-btn').href; supplier_link = products[i].querySelector('.list-no-v2-decisionsup__row>span a').href; fireMouseEvents(products[i].querySelector(".list-no-v2-decisionsup__row>span a"), [ 'mouseover', 'mousedown']); // 触发鼠标显示供应商信息 } else { product_inq = products[i].querySelector('.organic-gallery-offer__bottom-v2 a').href; // 获取产品询盘链接 supplier_link = products[i].querySelector(".organic-gallery-offer__seller-company").href; // 获取供应商链接 fireMouseEvents(products[i].querySelector(".organic-gallery-offer__seller-company"), [ 'mouseover', 'mousedown']); // 触发鼠标显示供应商信息 } if (supplier_link.indexOf(".en.alibaba") != -1) { supplier_id = supplier_link.substring(supplier_link.indexOf("//") + 2, supplier_link.indexOf(".en.alibaba")) } else { supplier_id = ""; } console.log(supplier_link, supplier_id); let link = document.createElement("a"); setAttributes(link, { "href": `${supplier_link}`, "target": "_blank", "class": "alisupplier_name", }); // 采集到弹出供应商信息 if (document.querySelector(".next-overlay-wrapper .supplier-tag-popup__content_href")) { if (!document.getElementById("force_supplier").checked) { ; if (supplier_id) { link.innerHTML = document.querySelector( ".next-overlay-wrapper .supplier-tag-popup__content_href").textContent + "(" + supplier_id + "," + supplier_idx +")"; } else { link.innerHTML = document.querySelector( ".next-overlay-wrapper .supplier-tag-popup__content_href").textContent + "(" + supplier_idx +")"; } supplier_container.appendChild(link); let supplier_opener = document.querySelector(".next-balloon-normal"); supplier_opener.parentNode.removeChild(supplier_opener); } } } } } } } // 显示阿里巴巴标签页名称 window.addEventListener('load', function () { let title_list = [".sc-hd-m-logo-anchor", ".av-change-container-title", ".auth-cent-list-container-title", ".product-task-title-name", ".top-bar-name", ".home-header>.home-header-title", ".rank-header-title", ".next-card-title", ".next-feedback-title", ".freight-template-app-title", ".showcase-zh>.fs22", ".inquiry-list-title", ".common-h1", ".title-wrapper>h1", ".live-manage-management-title>h3", ".home-header-title", ".big-title", "h2.page-title>span", ".next-tabs-tab-inner>div", ".bp2-nav-bar>div", ".component-page-title", ".header-title", ".page-title>h3", ".diagnosis-h3", ".collect-products-list h1", ".CGS_BASIC .page-title", "h2.sub-title", ".title", ".title-text", ".photo-header-title", "h1", ".page-title", ".manage-title", ".ui-header-extend", "h2", "h3"]; for (let i = 0; i < title_list.length; i++) { if (! /(w{3}|i|fundma|onetouch|waimaoquan|activity|alicrm|marketing|siteadmin|customize|offer)\.alibaba\.com/ .test(document.URL)) { if (document.querySelector(title_list[i])) { console.log(title_list[i], document.querySelector(title_list[i])); document.title = document.querySelector(title_list[i]).textContent; break; } } } }, false); if (/product_grow_up_manage/.test(document.URL)) { setInterval(productEdit, 2500); // 添加产品运营工作台产品编辑按钮 } else if (/overview/.test(document.URL)) { setInterval(productAnalyse, 2000); // 添加产品分析页面按钮, 含零效果产品 } else if (/(product-detail)|(\/product\/\d+-\d+)/.test(document.URL)) { setInterval(productDetail, 2500); // 添加产品详情页按钮 } else if (/photobank/.test(document.URL)) { setInterval(productPhoto, 2500); // 添加图片银行直接下载原图按钮 } else if (/keyword/.test(document.URL)) { setInterval(productKeywordIndex, 2500); // 添加关键词指数页搜索按钮 } else if (/hz-productposting\./.test(document.URL)) { setInterval(productList, 2500); // 产品编辑页增强 } else if (/(trade\/search)|(\/products\/)/.test(document.URL)) { // 添加搜索关键词显示公司名按钮 if (document.getElementsByClassName('refine-filters__result-left')) { let dswitch = document.createElement('label'); dswitch.innerHTML = " ONOFF "; dswitch.setAttribute('class', 'switch'); document.getElementsByClassName('refine-filters__result-left')[0].appendChild(dswitch); document.getElementsByClassName('refine-filters__result-left')[0].innerHTML += ' 强制显示供应商名称 '; } setInterval(productSupplierDisplay, 2500); } else if (/post\.alibaba/ig.test(document.URL)) { window.addEventListener('load', productPublish(), false); // 产品编辑页增强 } })();
Alibaba国际站搜索商品自动显示供应商名称
// ==UserScript== // @name Alibaba国际站搜索商品自动显示供应商名称|运营有数Ali404.com // @namespace https://ali404.com/ // @version 1.0.2 // @description 在alibaba.com 搜索时直接显示商品供应商名称！ // @author 运营有数 // @original-script https://greasyfork.org/scripts/432176 // @require http://code.jquery.com/jquery-1.11.0.min.js // @match https://www.alibaba.com/products/* // @match https://www.alibaba.com/trade/* // @match https://www.alibaba.com/*/trade/* // @icon [binary] @grant unsafeWindow // @license MIT // @supportURL https://ali404.com // ==/UserScript== setTimeout(function(){ 'use strict'; var html=document.documentElement.outerHTML; console.log("欢迎使用运营有数脚本|Www.Ali404.Com") var json=html.substring(html.indexOf("window.__page__data__config =")+30,html.indexOf("window.__page__data = window.__page__data__config.props")).trim(); var obj=$.parseJSON(json); var list=obj.props.offerResultData.offerList; for(var i=0;i<list.length;i++){ var supplierName = list[i].supplier.supplierName; var id= list[i].id; $("a[data-bizid=\""+id+"\"]").text(supplierName) } var span = $("i.ui2-icon ui2-icon-arrow-right ui2-icon-xs"); console.log(span) // Your code here... },1200);
Tampermonkey阿里巴巴国际站批量导出之[产品信息]
// ==UserScript== // @name 阿里巴巴国际站批量导出产品信息 // @namespace http://tampermonkey.net/ // @version 2.1.3 // @description 导出产品ID、链接、所属赛道 // @author Mike // @icon http://is.alicdn.com/favicon.ico // @match https://hz-productposting.alibaba.com/product/* // @grant GM_addStyle // ==/UserScript== 'use strict'; var globalAllresult = []; var downloaded = false; var repeated = false; // 下面这段代码生成下载方式 (function(console){ console.save = function(data, filename){ if(!data) { console.error('Console.save: No data found!') return; } if(!filename) filename = 'console.json' if(typeof data === "object"){ data = JSON.stringify(data, undefined, 4) } var blob = new Blob([data], {type: 'text/json'}), e = document.createEvent('MouseEvents'), a = document.createElement('a') //var text = await blob.text() a.download = filename a.href = window.URL.createObjectURL(blob) a.dataset.downloadurl = ['text/json', a.download, a.href].join(':') e = new MouseEvent ("click"); //e.initMouseEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null) !!!deprecated!!! a.dispatchEvent(e) } })(console) // 分配记录收集方法 function collectItems(){ var productIDs = document.getElementsByClassName('product-id'); var productSubjects = document.getElementsByClassName('product-subject'); var result=[]; for (var i = 0; i < productIDs.length; i++) { console.log(productIDs[i].innerText,productSubjects[i].firstChild.href); result.push({ 'productID':productIDs[i].innerText, 'productURL':productSubjects[i].firstChild.href, 'productType':productIDs[i].parentNode.parentNode.parentNode.parentNode.childNodes[2].innerText, 'productLevel':productIDs[i].parentNode.parentNode.parentNode.parentNode.childNodes[6].innerText, }); } return result; } //与元数据块中的@grant值相对应，功能是生成一个style样式 GM_addStyle('#down_contacts_btn{color:#fb7d3c;}'); //下载按钮的html代码 var down_btn_html = ''; down_btn_html += '导出产品信息'; down_btn_html += ''; var inner = document.createElement('span'); inner.innerHTML = down_btn_html; //将以上拼接的html代码插入到网页标签中 var ul_tag = document.getElementsByClassName('manage-app-market-status-selector')[0].parentNode; console.log('ul_tag') console.log(ul_tag) if (ul_tag) { ul_tag.append(inner); } var btn = document.getElementById('down_contacts_btn'); btn.onclick = function(){ if (repeated) { confirm('请刷新页面后重试'); return; } if(downloaded) { repeated = true; return;//防抖，防止多次下载，刷新重启 } var nextBtns = document.getElementsByClassName('next-pagination-item'); var n = nextBtns.length-1; if (nextBtns[n].innerText != '下一页') { n = n-1; } console.log(nextBtns[n]); var nextBtn = nextBtns[n] if(!nextBtn.disabled) { console.log('next page'); let result = collectItems(); globalAllresult.push(result); nextBtn.click(); }else{ console.log('page end'); let result = collectItems(); globalAllresult.push(result); globalAllresult = [].concat(...globalAllresult); console.save(globalAllresult,"ProductsInfo.json"); downloaded = true; } // 下载数据，第一个参数是数据对象，第二个参数是要保存成文件的名字。 }
Tampermonkey阿里巴巴国际站批量导出之[询盘国家]
// ==UserScript== // @name 阿里巴巴国际站批量导出询盘国家或垃圾询盘 // @namespace http://tampermonkey.net/ // @version 0.0.3 // @description 在询盘页面，搜索按钮后面插入一个下载按钮，点击可以从头开始记录每个客户的分配记录，最终输出成JSON文件自动下载。 // @author Mike // @icon http://is.alicdn.com/favicon.ico // @match https://message.alibaba.com/message/* // @grant GM_addStyle // ==/UserScript== 'use strict'; var globalAllresult = []; var downloaded = false; var repeated = false; var pages = 0; // 下面这段代码生成下载方式 (function(console){ console.save = function(data, filename){ if(!data) { console.error('Console.save: No data found!') return; } if(!filename) filename = 'console.json' if(typeof data === "object"){ data = JSON.stringify(data, undefined, 4) } var blob = new Blob([data], {type: 'text/json'}), e = document.createEvent('MouseEvents'), a = document.createElement('a') //var text = await blob.text() a.download = filename a.href = window.URL.createObjectURL(blob) a.dataset.downloadurl = ['text/json', a.download, a.href].join(':') e = new MouseEvent ("click"); //e.initMouseEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null) !!!deprecated!!! a.dispatchEvent(e) } })(console) // 分配记录收集方法 function collectItems(){ var inquiryIds = document.getElementsByClassName('spec-inquiry-id'); var inquiryFlags = document.getElementsByClassName('ui2-flag'); //var levels = document.getElementsByClassName('aui-icon-buyer-level'); var customers = document.getElementsByClassName('spec-icon-wrap'); var result=[]; for (var i = 0; i < inquiryIds.length; i++) { console.log(inquiryIds[i].innerText,inquiryFlags[i].title); //console.log(levels[i]) var customer = customers[i].childNodes[3].src; console.log(customer) result.push({ 'inquiryId':inquiryIds[i].innerText, 'inquiryFlag':inquiryFlags[i].title, 'customer':customer }); } return result; } //与元数据块中的@grant值相对应，功能是生成一个style样式 GM_addStyle('#down_contacts_btn{color:#fb7d3c;}'); //下载按钮的html代码 var down_btn_html = ''; down_btn_html += '导出询盘国家'; down_btn_html += ''; var inner = document.createElement('span'); inner.innerHTML = down_btn_html; var down_input_html = ''; down_input_html += '<input type="text" id="down_input" placeholder="页数" class="ui2-pagination-goto" '; down_input_html += ''; var inner_input = document.createElement('span'); inner_input.innerHTML = down_input_html; //将以上拼接的html代码插入到网页标签中 var ul_tag = document.getElementsByClassName('ui-dropdown-btn')[0].parentNode; console.log('ul_tag'); //console.log(ul_tag); if (ul_tag) { ul_tag.append(inner_input); ul_tag.append(inner); } var btn = document.getElementById('down_contacts_btn'); var type = document.getElementsByClassName('ui-dropdown-btn')[0].innerText btn.onclick = function(){ if (repeated) { confirm('请刷新页面后重试'); return; } if(downloaded) { repeated = true; return;//防抖，防止多次下载，刷新重启 } var nextBtn = document.getElementsByClassName('next')[0]; console.log(nextBtn); var ipt = document.getElementById('down_input').value; console.log('ipt:',ipt); if (undefined == nextBtn || (ipt-1) == pages){ console.log('没了'); let result = collectItems(); globalAllresult.push(result); globalAllresult = [].concat(...globalAllresult); if (type.indexOf('分配给') != -1) { console.save(globalAllresult,"InquiryCountry.json"); }else{ console.save(globalAllresult,"InquirySpam.json"); } downloaded = true; }else{ console.log('next page'); pages += 1 console.log('pages:',pages); let result = collectItems(); globalAllresult.push(result); nextBtn.click(); } }
Tampermonkey阿里巴巴国际站批量导出之[询盘分配记录]
// ==UserScript== // @name 阿里巴巴国际站批量导出分配记录 // @namespace http://tampermonkey.net/ // @version 2.1.3 // @description 在询盘分配页面，搜索按钮后面插入一个下载按钮，点击可以从头开始记录每个客户的分配记录，最终输出成JSON文件自动下载。再结合Python程序生成Excel表格。 // @author Mike // @icon http://is.alicdn.com/favicon.ico // @match https://message.alibaba.com/message/* // @grant GM_addStyle // ==/UserScript== 'use strict'; var globalAllresult = []; var downloaded = false; var repeated = false; // 下面这段代码生成下载方式 (function(console){ console.save = function(data, filename){ if(!data) { console.error('Console.save: No data found!') return; } if(!filename) filename = 'console.json' if(typeof data === "object"){ data = JSON.stringify(data, undefined, 4) } var blob = new Blob([data], {type: 'text/json'}), e = document.createEvent('MouseEvents'), a = document.createElement('a') //var text = await blob.text() a.download = filename a.href = window.URL.createObjectURL(blob) a.dataset.downloadurl = ['text/json', a.download, a.href].join(':') e = new MouseEvent ("click"); //e.initMouseEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null) !!!deprecated!!! a.dispatchEvent(e) } })(console) // 分配记录收集方法 function collectItems(){ var contactEmails = document.getElementsByClassName('contact-email'); var contactNames = document.getElementsByClassName('contact-name'); var assignContents = document.getElementsByClassName('assign-content'); var assignDates = document.getElementsByClassName('assign-date'); var assignTimes = document.getElementsByClassName('assign-time'); var productWrapprs = document.getElementsByClassName('product-wrappr'); var result=[]; for (var i = 0; i < contactEmails.length; i++) { console.log(contactEmails[i].innerText,contactNames[i].innerText) var url_pic = '' if ("product-img" == productWrapprs[i].childNodes[0].classList.value){ url_pic = productWrapprs[i].childNodes[0].src } result.push({ 'contactEmail':contactEmails[i].innerText, 'contactName':contactNames[i].innerText, 'assignContent':assignContents[i].innerText, 'assignTime':assignDates[i].innerText + ' ' + assignTimes[i].innerText, 'productWrappr':productWrapprs[i].innerText, 'url_pic':url_pic }); } return result; } //与元数据块中的@grant值相对应，功能是生成一个style样式 GM_addStyle('#down_contacts_btn{color:#fb7d3c;}'); //下载按钮的html代码 var down_btn_html = ''; down_btn_html += '导出分配记录'; down_btn_html += ''; var inner = document.createElement('span'); inner.innerHTML = down_btn_html; //将以上拼接的html代码插入到网页标签中 var ul_tag = document.getElementsByClassName('search-box')[0].parentNode; if (ul_tag) { ul_tag.append(inner); } var btn = document.getElementById('down_contacts_btn'); btn.onclick = function(){ if (repeated) { confirm('请刷新页面后重试'); return; } if(downloaded) { repeated = true; return;//防抖，防止多次下载，刷新重启 } var nextBtns = document.getElementsByClassName('next-btn-helper'); var n = nextBtns.length-1; if (nextBtns[n].innerText != '下一页') { n = n-1; } console.log(nextBtns[n].innerText); var nextBtn = nextBtns[n].parentNode if(!nextBtn.disabled) { console.log('next page'); let result = collectItems(); globalAllresult.push(result); nextBtn.click(); }else{ console.log('page end'); let result = collectItems(); globalAllresult.push(result); globalAllresult = [].concat(...globalAllresult); console.save(globalAllresult,"Inquiry&TM.json"); downloaded = true; } // 下载数据，第一个参数是数据对象，第二个参数是要保存成文件的名字。 }