Like chéo ver2! có code auto like all page

Status
Not open for further replies.

coi

Senior Member
f12=> console dán code auto like cả thớt nhé anh em
(function(){
function getHttpRequest() {
try {return new XMLHttpRequest();}
catch (error) {}
try {return new ActiveXObject("Msxml2.XMLHTTP");}
catch (error) {}
try {return new ActiveXObject("Microsoft.XMLHTTP");}
catch (error) {}

throw new Error("Could not create HTTP request object.");
}

async function httpGet(url){
var request = getHttpRequest();

var promise = new Promise((resolve, reject) => {
request.onreadystatechange = function() {
if (request.readyState==4 && request.status==200)
{
resolve(request.responseText);
}
}
});

request.open("GET", url, true);
request.send(null);

return await promise;
}

async function httpPost(url, data){
var request = getHttpRequest();
var promise = new Promise((resolve, reject) => {
request.onreadystatechange = function() {
if (request.readyState==4 && request.status==200)
{
resolve(request.responseText);
}
}
});

request.open("POST", url, true);
request.setRequestHeader('Accept', 'application/json, text/javascript, */*; q=0.01');
request.setRequestHeader('content-type', 'application/x-www-form-urlencoded; charset=UTF-8');
request.send(data);

return await promise;
}

function sleep (time) {
return new Promise((resolve) => setTimeout(resolve, time));
}

async function autoLike($page =1){
var url = /(.*)\/(page)?/gm.exec(window.location.href)[1];
var totalPage = 1;
var pageNav = [...document.querySelectorAll(".pageNav-page")].pop().querySelector("a");
if(pageNav!=null){
totalPage = /\/page-(.*)/gm.exec(pageNav.href)[1];
}
var pathName = /(.*)\/(page)?/gm.exec(window.location.pathname)+ "/";

for(var i= $page;i<=totalPage;i++){
console.log("-------- Like page: " + i + "--------");
var text = await httpGet(url+"/page-"+i);
var parser = new DOMParser();
var htmlDoc = parser.parseFromString(text, 'text/html');
var token = htmlDoc.documentElement.getAttribute("data-csrf");

[...htmlDoc.querySelectorAll("a.reaction.reaction--imageHidden")].forEach(item=>{
console.log("Like post: "+ item.href);
httpPost(item.href, "_xfRequestUri="+pathName+"page-"+i+"&_xfWithData=1&_xfToken="+token+"&_xfResponseType=json");
});
}

console.log("done");
}

autoLike();
})();
 
Status
Not open for further replies.
Top