Skip to content

Instantly share code, notes, and snippets.

@ahmetilhn
Created December 9, 2025 20:08
Show Gist options
  • Select an option

  • Save ahmetilhn/3b58c4d87691b45dc479e95a426e03a0 to your computer and use it in GitHub Desktop.

Select an option

Save ahmetilhn/3b58c4d87691b45dc479e95a426e03a0 to your computer and use it in GitHub Desktop.
YemekSepeti Analyzer
const COMMENT_SELECTOR =
"span.bds-c-rating__label-secondary.f-label-small-secondary-font-size.fw-label-small-secondary-font-weight.lh-label-small-secondary-line-height.ff-label-small-secondary-font-family";
const FIRM_LIST_SELECTOR = "div.container.vendors-section > div";
const commentCounts = [];
let vendorCounts = 0;
const parseTotalComments = () => {
document.querySelectorAll(COMMENT_SELECTOR).forEach((item) => {
vendorCounts++;
if (!!item.innerText && item.innerText !== "") {
const numericVal = parseInt(
item.innerText.replace("(", "").replace(")", "").replace("+", "")
);
if (!isNaN(numericVal)) commentCounts.push(numericVal);
else console.error("Invalid number");
}
});
};
async function autoScrollByLastChild(selector, timeout = 600, maxNoChange = 5) {
const list = document.querySelector(selector);
if (!list) {
console.log("List is not found");
return;
}
let prevCount = 0,
same = 0;
while (true) {
const last = list.lastElementChild;
if (last) last.scrollIntoView({ behavior: "auto", block: "end" });
else {
console.log("List is empty");
return;
}
await new Promise((r) => setTimeout(r, timeout));
const count = list.children.length;
if (count === prevCount) {
same++;
if (same >= maxNoChange) {
parseTotalComments();
const totalCommentCounts = commentCounts.reduce(
(acc, newVal) => acc + newVal,
0
);
console.log(
`Son 3 aylık gerçekleşen tahmini toplam sipariş: ${
totalCommentCounts * 10
}, Firma Sayısı: ${vendorCounts}`
);
break;
}
} else {
same = 0;
}
prevCount = count;
}
}
autoScrollByLastChild("div.container.vendors-section > div");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment