Skip to content

Commit

Permalink
fix: :)
Browse files Browse the repository at this point in the history
  • Loading branch information
artemskii-dev committed Dec 10, 2021
1 parent 4dcd509 commit 6148b4a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Ebay research",
"version": "0.0.3",
"version": "0.0.4",
"manifest_version": 2,
"author": "rollun.com",

Expand Down
27 changes: 17 additions & 10 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function Control() {
.querySelector('.category-selection-lightbox-dialog__footer-apply')
?.click();

await wait(3000)
await wait(4000)
}

async function runSearch(searchString) {
Expand Down Expand Up @@ -160,6 +160,10 @@ function Control() {
const header = curr.querySelector('.metric-title').innerText.trim();
const snakeCaseHeader = toSnakeCase(header);

if (!(snakeCaseHeader in parseStrategy)) {
return acc;
}

return {
...acc,
...(parseStrategy[snakeCaseHeader](value, snakeCaseHeader)),
Expand All @@ -175,7 +179,7 @@ function Control() {

const stats = getStatsFromMetricContainer(metricsContainer);
const currentDate = formatDate(new Date())

return {
id,
input,
Expand All @@ -188,8 +192,9 @@ function Control() {
const rows = document.querySelectorAll('.research-table-row');

function parseRow(row) {
const linkEl = row.querySelector('.research-table-row__product-info a');
const link = linkEl.href;
console.log(row);
const linkEl = row.querySelector('.research-table-row__product-info-name');
const link = linkEl?.href || null;

const titleEl = linkEl.querySelector('span');
const id = titleEl.dataset.itemId;
Expand All @@ -203,18 +208,20 @@ function Control() {

const totalSoldEl = row.querySelector('.research-table-row__totalSoldCount');

const lastDateSoldEl = row.querySelector('.research-table-row__dateLastSold');
const lastDateSold = new Date(lastDateSoldEl.innerText);
const lastDateSoldText = row.querySelector('.research-table-row__dateLastSold')?.innerText;
const lastDateSold = lastDateSoldText ? formatDate(new Date(lastDateSoldText)) : null;

const currentDate = formatDate(new Date());

return {
id,
return {
listing_id: id,
title,
link,
avg_sold_price: price,
avg_shipping: shipPrice,
total_sold: +totalSoldEl.innerText,
last_date_sold: formatDate(lastDateSold),
parsed_at: formatDate(new Date()),
last_date_sold: lastDateSold,
parsed_at: currentDate,
request_id: statId
};
}
Expand Down

0 comments on commit 6148b4a

Please sign in to comment.