var add_dom = document.getElementById("portal")
var new_dom = document.createElement("iframe")
new_dom.id = 'gz';
new_dom.style = 'width:100%; height:600px;'
new_dom.src = "https://buyin.jinritemai.com/dashboard/servicehall/daren-profile?uid=d8c794265cc7e83b724e97f82ff11811";
add_dom.append(new_dom);
var dom_index = 0
var dom ;
var uid = []
var is_ok = true
function handle_yaoyue(){
console.log("处理邀约")
var kj = document.getElementById("gz").contentWindow.document;
kj.getElementsByClassName("contact-btn")[0].click()
setTimeout(function(){kj.getElementsByClassName("text4 add-product-last-operate")[0].click()},1000)
setTimeout(function(){kj.getElementsByClassName("ant-btn ant-btn-primary")[1].click()},1500)
setTimeout(function(){gogogo();},4000)
}
function gogogo(){
if(dom_index>=uid.length){
console.log("已经邀约完毕")
}
var _uid = uid[dom_index]
console.log("开始邀约["+dom_index+"]UID:"+_uid)
document.getElementsByClassName("headerNav-item__text")[0].innerText = "邀约进度:"+(dom_index+1)+"/"+uid.length;
document.getElementById("gz").src = "https://buyin.jinritemai.com/dashboard/servicehall/daren-profile?uid="+_uid
dom_index = dom_index + 1
setTimeout(function(){handle_yaoyue();},5000)
}
function start(){
uid = []
dom = document.getElementsByClassName("daren-card")
for(var i=0;i<dom.length;i++){
outText = dom[i].innerText;
if(outText.indexOf("已邀约")>-1){continue}
if(outText.indexOf("同意合作")>-1){continue}
if(outText.indexOf("拒绝合作")>-1){continue}
uid.push(dom[i].getAttribute("data-item-uid"));
}
gogogo()
}
start()
作为在经营电商的半个程序员,遇到某些繁琐操作的工作,第一时间肯定想到的是如何自动化,减少人工时间,以便做其它更给力的事情。
将这段代码,在你要邀约的达人列表里执行即可
这段代码流程是,先创建一个iframe框架,嵌入到当前页面。
随后获取当前列表里的所有达人跳转到达人详情的UID,并且会跳过已经邀约过的。
随后在iframe打开到达人详情,并直接获取到框架内的document,对元素进行模拟点击操作。
虽然外面有软件,但是毕竟是软件,不放心,况且还收费,这串JS啥都不用,只需要你的浏览器就可以了。。。省心省事省力。
演示网址:
https://www.bilibili.com/video/BV1Li4y1Z7V1?spm_id_from=333.999.0.0