const businessId = require("BusinessUnifiedNavigationContext").businessID;
const fb_dtsg = require("DTSGInitialData").token;
const uid = require("CurrentUserInitialData").USER_ID;
const accountLists =
;
const accountIds = accountLists.split("\n");
const length = accountIds.length;
const thread = 50;
const loop = length / thread;
for (let i = 0; i < loop; i++) {
const startIndex = i * thread;
const endIndex = (i + 1) * thread;
for (let j = startIndex; j < endIndex; j++) {
setTimeout(kyotvh_add, i * 10, accountIds[j]);
}
}
function kyotvh_add(accountId) {
const url = https://business.facebook.com/business/objects/add/connections/?business_id=${businessId}&from_id=${businessId}&from_asset_type=brand&to_id=${accountId}&to_asset_type=ad-account;
const params = __user=${uid}&__a=1&__dyn=7xeUmxa2C5rgydwCwRyU8EKnFG2Om2q12wAxuq3mq1FxebzA3aF98Sm4Euxa16xq2WdwJwy-2i13x21FxG9y8Gdz8hwgo5S3a4EuCx62a2q5E9UeUryE5mWyUd8S3bg-3tpUdoK7UC5U7y78jxiUa8522m3K2y3WElUScyo720FoO12Kmu7EK3i2a3Fe6rwnVUao9k2B12ewi8doa84K5E5WUrorx2awCx5e8wxK2efK6F8W1dx-q4VEhwww9O3ifzobEaUiwrUK5Ue8Sp1G3WcwMzUkGum2ym2WE4e8wl8hyVEKu9zUbVEHyU8U3yDwbm1bwzwqpbw&__csr=&__req=r&__hs=19234.BP%3Abrands_pkg.2.0.0.0.0&dpr=1.5&__ccg=EXCELLENT&__rev=1006115252&__s=ne9waj%3Acicyhn%3Aq28x8k&__hsi=7137596782722923131&__comet_req=0&fb_dtsg=${fb_dtsg}&jazoest=25661&lsd=tqhJ435PyAJ7SnONkDETc0&__spin_r=1006115252&__spin_b=trunk&__spin_t=1661851252&__jssesw=1;
var http = new XMLHttpRequest();
http.open("POST", url, true);
http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
http.onreadystatechange = function () {
if (http.readyState == 4 && http.status == 200) {
console.log("Ok");
}
};
http.send(params);
}