if (typeof instance === "undefined") {
var instance = {
SetVar: function (name, value) {
console.log("Simulating instance.SetVar: " + name + " = " + value);
},
Log: function (message) {
console.log("Simulating instance.Log: " + message);
}
};
}
function fetchSMSValue() {
return new Promise(function (resolve, reject) {
var formdata = new FormData();
formdata.append("orderid", "IVT7LHWX");
formdata.append("key", "MxB9N1RSYtGalRFtNv6j5Mz6HoZjmNBh");
var xhr = new XMLHttpRequest();
xhr.open("POST", "https://api.smspool.net/sms/check", true);
xhr.onload = function () {
if (xhr.status === 200) {
var data = JSON.parse(xhr.responseText);
console.log(data);
if (data.status === 3) {
var smsValue = data.sms;
console.log("SMS value:", smsValue);
resolve(smsValue);
} else {
console.log("Status is not 3. Current status:", data.status);
resolve(null);
}
} else {
console.log("Server returned status:", xhr.status);
console.log("Response text:", xhr.responseText);
reject(new Error("Request failed with status: " + xhr.status));
}
};
xhr.onerror = function () {
reject(new Error("Request failed"));
};
xhr.send(formdata);
});
}
function main() {
fetchSMSValue()
.then(function (smsValue) {
if (smsValue) {
console.log("Fetched SMS value:", smsValue);
if (typeof instance !== "undefined") {
instance.SetVar("SMSValue", smsValue);
} else {
console.log("SMS value (not in ZennoPoster):", smsValue);
}
} else {
console.log("Failed to fetch SMS value.");
}
})
.catch(function (error) {
console.log("Error:", error);
});
}
main();
I want to ask why after I output this, the result is not directly stored in the variable? Is there someone who can help me with this?
var instance = {
SetVar: function (name, value) {
console.log("Simulating instance.SetVar: " + name + " = " + value);
},
Log: function (message) {
console.log("Simulating instance.Log: " + message);
}
};
}
function fetchSMSValue() {
return new Promise(function (resolve, reject) {
var formdata = new FormData();
formdata.append("orderid", "IVT7LHWX");
formdata.append("key", "MxB9N1RSYtGalRFtNv6j5Mz6HoZjmNBh");
var xhr = new XMLHttpRequest();
xhr.open("POST", "https://api.smspool.net/sms/check", true);
xhr.onload = function () {
if (xhr.status === 200) {
var data = JSON.parse(xhr.responseText);
console.log(data);
if (data.status === 3) {
var smsValue = data.sms;
console.log("SMS value:", smsValue);
resolve(smsValue);
} else {
console.log("Status is not 3. Current status:", data.status);
resolve(null);
}
} else {
console.log("Server returned status:", xhr.status);
console.log("Response text:", xhr.responseText);
reject(new Error("Request failed with status: " + xhr.status));
}
};
xhr.onerror = function () {
reject(new Error("Request failed"));
};
xhr.send(formdata);
});
}
function main() {
fetchSMSValue()
.then(function (smsValue) {
if (smsValue) {
console.log("Fetched SMS value:", smsValue);
if (typeof instance !== "undefined") {
instance.SetVar("SMSValue", smsValue);
} else {
console.log("SMS value (not in ZennoPoster):", smsValue);
}
} else {
console.log("Failed to fetch SMS value.");
}
})
.catch(function (error) {
console.log("Error:", error);
});
}
main();
I want to ask why after I output this, the result is not directly stored in the variable? Is there someone who can help me with this?