Created
February 19, 2025 12:52
-
-
Save dreamerchandra/8eaa27efa8f344e779124d3e860f31d8 to your computer and use it in GitHub Desktop.
swiggy, zepto and bb food scrap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
links = | |
`https://www.bigbasket.com/ps/?q=pomegranate&nc=as&page=1&filter=%5B%7B%22name%22%3A%22Categories%22%2C%22type%22%3A%22category%22%2C%22values%22%3A%5B%7B%22id%22%3A1344%2C%22name%22%3A%22Fresh+Fruits%22%2C%22image%22%3A%22%22%2C%22slug%22%3A%22fresh-fruits%22%2C%22level%22%3A1%2C%22url%22%3A%22%2Fpc%2Ffruits-vegetables%2Ffresh-fruits%22%2C%22is_selected%22%3Afalse%7D%5D%7D%5D | |
https://www.bigbasket.com/ps/?q=apple&nc=as&page=1&filter=%5B%7B%22name%22%3A%22Categories%22%2C%22type%22%3A%22category%22%2C%22values%22%3A%5B%7B%22id%22%3A1344%2C%22name%22%3A%22Fresh+Fruits%22%2C%22image%22%3A%22%22%2C%22slug%22%3A%22fresh-fruits%22%2C%22level%22%3A1%2C%22url%22%3A%22%2Fpc%2Ffruits-vegetables%2Ffresh-fruits%22%2C%22is_selected%22%3Afalse%7D%5D%7D%5D`.split( | |
"\n" | |
); | |
const constructValues = (name, pack, price, tag) => { | |
return [ | |
name.replaceAll(",", " ").replaceAll('\n', ' '), | |
pack.replaceAll(",", " ").replaceAll('\n', ' '), | |
price.replaceAll(",", " ").replaceAll('\n', ' '), | |
tag, | |
].join(", "); | |
}; | |
const getBBValues = (c) => { | |
const name = c.querySelector(".break-words")?.innerText; | |
const pack = | |
c.querySelector(".PackSelector___StyledLabel-sc-1lmu4hv-0")?.innerText ?? | |
c.querySelector(".PackChanger___StyledButton-sc-newjpv-0")?.innerText; | |
const price = c | |
.querySelector(".Pricing___StyledLabel-sc-pldi2d-1") | |
?.innerText.replace("₹", ""); | |
return constructValues(name, pack, price, "bb"); | |
}; | |
const getZepto = (card) => { | |
const name = card.querySelector( | |
'[data-testid="product-card-name"]' | |
)?.innerText; | |
const pack = card.querySelector( | |
'[data-testid="product-card-quantity"]' | |
)?.innerText; | |
const price = card | |
.querySelector('[data-testid="product-card-price"]') | |
?.innerText.replace("₹", ""); | |
return constructValues(name, pack, price, "zepto"); | |
}; | |
const getSwiggy = (card) => { | |
const name = card.querySelector( | |
'.novMV' | |
)?.innerText; | |
const pack = card.querySelector( | |
'.FqnWn' | |
)?.innerText; | |
const price = card | |
.querySelector('.JZGfZ') | |
?.innerText.replace("₹", ""); | |
return constructValues(name, pack, price, "swiggy"); | |
}; | |
const getValues = (card) => { | |
if (location.origin.includes("bigbasket")) { | |
return getBBValues(card); | |
} | |
if (location.origin.includes("zepto")) { | |
return getZepto(card); | |
} | |
if (location.origin.includes("swiggy")) { | |
return getSwiggy(card); | |
} | |
}; | |
const getCards = () => { | |
if (location.origin.includes("bigbasket")) { | |
aoi = document | |
.querySelectorAll(".border-silverSurfer-400")[1] | |
.querySelector(".z-10"); | |
cards = [...aoi.querySelectorAll("li")]; | |
return cards; | |
} | |
if (location.origin.includes("zepto")) { | |
return [...document.querySelectorAll('[data-testid="product-card"]')].slice( | |
0, | |
4 | |
); | |
} | |
if(location.origin.includes("swiggy")) { | |
return [...document.querySelectorAll('[data-testid="default_container_ux4"]')].slice( | |
0, | |
4 | |
); | |
} | |
}; | |
seperator = "-------123123-------"; | |
visit = 0; | |
if (window.name?.split(seperator).length === 2) { | |
visit = Number(window.name.split(seperator)[0]); | |
} | |
delete window.name; | |
cards = getCards(); | |
items = cards | |
.map((c) => { | |
return getValues(c); | |
}) | |
.join("\n"); | |
window.name = `${visit + 1}${seperator}${items}`; | |
copy(items); | |
if (visit + 1 > links.length - 1) { | |
setTimeout(() => { | |
location.href = links[visit + 1]; | |
}, 0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment