Skip to content

Instantly share code, notes, and snippets.

@agusibrahim
Created February 1, 2024 09:22
Show Gist options
  • Save agusibrahim/03a20d2ec1164d137c1460529fd5cec6 to your computer and use it in GitHub Desktop.
Save agusibrahim/03a20d2ec1164d137c1460529fd5cec6 to your computer and use it in GitHub Desktop.
get pelni ports
var token = document.querySelector("input[name='_token']").value;
var options = Array.from(document.querySelectorAll("select[name='ticket_org'] option")).filter(x => x.getAttribute("value") != "");
var results = [];
for (const option of options) {
var ids = option.getAttribute("value");
var b = option.innerText;
var dest=""
try {
var f = await fetch("https://www.pelni.co.id/getdes", {
"headers": {
"content-type": "application/x-www-form-urlencoded;",
},
"referrer": "https://www.pelni.co.id/",
"referrerPolicy": "strict-origin-when-cross-origin",
"body": "ticket_org=" + ids + "&_token=" + token,
"method": "POST",
"mode": "cors",
"credentials": "include"
});
var div = document.createElement('div');
div.innerHTML = await f.text();
var dest = Array.from(div.querySelectorAll("option")).filter(x => x.getAttribute("value") != "").map(x => x.getAttribute("value")).join(",");
await new Promise(resolve => setTimeout(resolve, 100));
} catch (e) {
}
var result = {
"name": b.split("|")[1].split("-")[1].trim(),
"code": b.split("|")[1].split("-")[0].trim(),
"city": b.split("|")[0].trim(),
"id": parseInt(ids),
"dest": dest
};
results.push(result);
}
document.body.outerText=JSON.stringify(results)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment