Skip to content

Commit

Permalink
feat: emag
Browse files Browse the repository at this point in the history
  • Loading branch information
stefa-n committed May 3, 2024
1 parent 5a2edf7 commit 454196d
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 2 deletions.
7 changes: 6 additions & 1 deletion extension/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
"matches": ["https://*.pcgarage.ro/*"],
"js": ["stores/pcgarage.js"],
"run_at": "document_idle"
}
},
{
"matches": ["https://*.emag.ro/*"],
"js": ["stores/emag.js"],
"run_at": "document_idle"
}
]
}
35 changes: 35 additions & 0 deletions extension/stores/emag.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
let price = document.getElementsByClassName("product-new-price")[0];
if (price) {
let element = document.createElement("span");
element.innerHTML = `<img src="http://localhost:3000/logo_black.png" alt="vezipret" style="width: auto; height: 70px; margin-top: -30px; margin-bottom: -25px;"/>`;

price = price.innerText;
price = parseFloat(
price.replace(/\./g, "").replace(".", "").replace(",", ".")
);

let produs = document.getElementsByClassName("product-code-display")[0]
.innerText;
produs = produs.replace("Cod produs: ", "");

element.onclick = function () {
window.open(
"http://localhost:3000/price?marketplace=emag&product=" + produs
);
};

document
.getElementsByClassName("product-page-pricing")[0]
.appendChild(element);

fetch(`http://localhost:3001/emag/${produs}`, {
method: "POST",
headers: {
"Content-Type": "application/json",
price: price,
},
})
.then((response) => response.json())
.then((data) => console.log(data))
.catch((error) => console.error("Error:", error));
}
7 changes: 6 additions & 1 deletion frontend/components/Chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,12 @@ export default function Chart({ prices }) {

return (
<div>
<Line height={300} options={options} data={{ labels, datasets }} />
<Line
height={400}
width={500}
options={options}
data={{ labels, datasets }}
/>
</div>
);
}
Binary file added frontend/public/logo_black.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 454196d

Please sign in to comment.