//========================= 显示当前时间 =========================
function CurentTime() {
var now = new Date();
var year = now.getFullYear(); //年
var month = now.getMonth() + 1; //月
var day = now.getDate(); //日
var hh = now.getHours(); //时
var mm = now.getMinutes(); //分
var ss = now.getSeconds(); //秒
var hs = now.getMilliseconds();
clock = hh + ":" + mm + ":" + ss + ":" + hs;
clock2 = year + '-' + month + '-' + day + ' ' + hh + ":" + mm + ":" + ss
return(clock2);
}
var list = [1, 2, 3, 4, 5]
// for(var i = 0; i < 5; i++) {
// // (function(i) {
// // setTimeout(function() {
// // console.log(CurentTime())
// // }, (i + 1) * 3000);
// // })(i)
// setTimeout(function() {
// console.log(CurentTime())
// setTimeout(function() {
// console.log(CurentTime())
// console.log('--------------------')
// }, 2000);
// }, (i + 1) * 3000);
// }
// function upLoadPic(imgData){
// if (typeof imgData == 'string' && imgData.length > 2) {
// console.log('【设置群头像 成功】:', imgData.length)
// } else {
// console.log(typeof(imgData))
// console.log(imgData.length)
// }
// }
// upLoadPic('6')
function Start(){
console.log('【666】')
}
var nowList = ['1', '2', '3', '4', '5']
function Test(nowList){
var list = nowList
for(i = 0, len = list.length; i < len; i++) {
(function(i) {
setTimeout(function() {
console.log('删除前list',list)
console.log('删除前nowList',nowList)
list.shift()
console.log(list)
console.log(list.length)
console.log('--------------------')
if (list.length == 0) {
Start()
}
}, (i + 1) * 3000);
})(i)
}
}
// Test(nowList)
function returnJson() {
var errCount = 0
var errJson = {}
errJson['status'] = 200
try {
throw new Error("errTest1")
} catch (err) {
errCount += 1
errJson['err1'] = String(err)
console.log('err: ', String(err))
}
console.log('--------------------')
try {
throw new Error("errTest2")
} catch (err) {
errCount += 1
errJson['err2'] = String(err)
console.log('err: ', String(err))
// alert(err.name + ": " + err.message)
}
console.log('--------------------')
if (errCount > 0) {
console.log('失败')
console.log(errJson)
} else {
console.log('成功')
console.log(errJson)
}
}
// returnJson()
async function WaitTime(sleepTime) {
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
var waitTime = 2
if (typeof sleepTime == 'number' && sleepTime > 0) {
waitTime = sleepTime
}
for(i = 0, len = nowList.length; i < len; i++) {
await sleep(waitTime * 1000).then(console.log('【sleep结束】'));
console.log('当前:',i)
}
}
// WaitTime(2)
//========================= 获取主页联系方式 =========================
var contactObj = {};
var otherLinksArray = [];
var str = "简介\n查看全部\nTrain with your favorite instructors from Daily Burn, Grokker, Aaptiv, Jillian Michaels, FitFusion & more ����\nhttp://sweatfactor.com\n154,104位用户赞了\n156,753位用户关注了\n+233 59 290 1252\nhttp://www.mikedfitness.com/\nbiz.mikedfitness@gmail.com\n健康与保养网站 · 企业家 · 健身教练\nhttp://instagram.com/mikedfitness\nhttp://twitter.com/mikedonavanik\nhttp://youtube.com/mikedfitness\nhttps://www.snapchat.com/add/mikedfitness\n照片\n查看全部\n视频\n查看全部\n0:27\ncurrent life status ������ instagram.com/mikedfitness snapchat.com/add/mikedfitness (original videos courtesy of instagram.com/breadfaceblog)\n11 万\n11 万\n5,583.5 万次播放\n \n · 5年前\n公共主页信息公示\n查看全部\nFacebook 会公示有助于你了解公共主页用途的信息,你可以据此了解内容管理与发布人员的操作记录。\n公共主页创建日期:2011年6月28日\n借助 Facebook 发展业务\n展示你的业务内容、创建广告并与客户或支持者建立联系。\n创建公共主页\n隐私权政策\n \n · 服务条款\n \n · 广告\n \n · Ad Choices \n \n · Cookie\n \n · 更多\n \n · Facebook © 2021";
var contactTextArray = str.split('\n');
var phoneReg = /\+[\d]/;
var emailReg = /[\w]@[\w]/;
for (var i=0; i<contactTextArray.length; i++) {
if(phoneReg.test(contactTextArray[i])) {
contactObj['phone'] = contactTextArray[i]
} else if (emailReg.test(contactTextArray[i])) {
contactObj['email'] = contactTextArray[i]
} else if (contactTextArray[i].substr(0, 4) == "http") {
if (contactTextArray[i].includes("twitter.com")) {
contactObj['twitter'] = contactTextArray[i]
} else if (contactTextArray[i].includes("youtube.com")) {
contactObj['youtube'] = contactTextArray[i]
} else if (contactTextArray[i].includes("instagram.com")) {
contactObj['instagram'] = contactTextArray[i]
} else {
otherLinksArray.push(contactTextArray[i])
}
}
}
if (otherLinksArray.length > 0) {
contactObj['otherLinks'] = otherLinksArray;
}
console.log(contactObj)
//========================= facebook获取用户信息方法 =========================
var testStr = '72,052人對此讚好';
var countReg = /([\d]{1,3}([\,][\d]{1,3})*)/;
console.log(testStr.match(countReg));
console.log(testStr.match(countReg)[0].replace(/,/g, ''))
function getContact(messageid) {
//联系方式json
var contactObj = {};
//其他链接
var otherLinksList = '';
var contactText = document.querySelector('[class="lpgh02oy"]').innerText;
var contactTextArray = contactText.split('\n');
// var phoneReg = /\+[\d]/;
var phoneReg = /(?<!\w)\+[\d]/;
var emailReg = /[\w]@[\w]/;
var likeReg = /(like|赞|讚)/;
var followReg = /(follow|关注|追蹤)/;
var countReg = /([\d]{1,3}([\,][\d]{1,3})*)/;
contactObj['name'] = document.querySelector('[class="bi6gxh9e aov4n071"]').innerText;
contactObj['website'] = document.URL;
for (var i=0; i<contactTextArray.length; i++) {
if(phoneReg.test(contactTextArray[i])) {
contactObj['phone'] = contactTextArray[i];
} else if (emailReg.test(contactTextArray[i])) {
contactObj['email'] = contactTextArray[i];
} else if (likeReg.test(contactTextArray[i])) {
var likeCountArr = contactTextArray[i].match(countReg);
setTimeout(function() {
console.log(likeCountArr[0]);
contactObj['likeCount'] = likeCountArr[0].replace(/,/g, '');
}, 1000);
//contactObj['likeCount'] = contactTextArray[i].match(countReg)[0].replace(/,/g, '');
} else if (followReg.test(contactTextArray[i])) {
var followCountArr = contactTextArray[i].match(countReg);
setTimeout(function() {
console.log(followCountArr[0]);
contactObj['followCount'] = followCountArr[0].replace(/,/g, '');
}, 1000);
//contactObj['followCount'] = contactTextArray[i].match(countReg)[0].replace(/,/g, '');
} else if (contactTextArray[i].substr(0, 4) == "http") {
if (contactTextArray[i].includes("twitter.com")) {
contactObj['twitter'] = contactTextArray[i];
} else if (contactTextArray[i].includes("youtube.com")) {
contactObj['youtube'] = contactTextArray[i];
} else if (contactTextArray[i].includes("instagram.com")) {
contactObj['instagram'] = contactTextArray[i];
} else {
//otherLinksArray.push(contactTextArray[i]);
if (otherLinksList == '') {
otherLinksList = contactTextArray[i];
} else {
otherLinksList += ',' + contactTextArray[i];
};
};
};
};
var personPagesArray = document.querySelector('[class="lpgh02oy"]').querySelectorAll('a');
for (var i=0; i<personPagesArray.length; i++) {
if(personPagesArray[i].href.includes("http") && personPagesArray[i].href.includes("twitter.com")) {
if (contactObj.hasOwnProperty('twitter') == false) {
contactObj['twitter'] = personPagesArray[i].href
};
} else if(personPagesArray[i].href.includes("http") && personPagesArray[i].href.includes("youtube.com")) {
if (contactObj.hasOwnProperty('youtube') == false) {
contactObj['youtube'] = personPagesArray[i].href
};
} else if(personPagesArray[i].href.includes("http") && personPagesArray[i].href.includes("instagram.com")) {
if (contactObj.hasOwnProperty('instagram') == false) {
contactObj['instagram'] = personPagesArray[i].href
};
};
};
if (otherLinksList != '') {
contactObj['otherLinks'] = otherLinksList;
};
console.log(contactObj);
};
//========================= while循环延时 =========================
const sleep = (milliseconds) => {
return new Promise(resolve => setTimeout(resolve, milliseconds))
}
const doSomething = async () => {
var i = 0;
while (i < 5) {
console.log(i)
i++;
await sleep(2000)
}
console.log('循环结束')
}
// doSomething()
function DeleteGroups() {
setTimeout( function() {
const sleep = (milliseconds) => {
return new Promise(resolve => setTimeout(resolve, milliseconds))
}
const doSomething = async () => {
for (var i=0;i<5;i++) {
console.log(i);
await sleep(2000);
}
console.log('循环结束')
}
doSomething()
},3000);
};
DeleteGroups()
//=======================================================
console