update position

This commit is contained in:
Admin 2025-05-27 17:21:27 +07:00
parent ccdabd9350
commit e211e0e521
7 changed files with 40 additions and 24 deletions

BIN
.DS_Store vendored

Binary file not shown.

BIN
assets/.DS_Store vendored Normal file

Binary file not shown.

View File

@ -20,6 +20,7 @@
display: flex;
flex-direction: column;
gap: 10px;
width: 100%;
}
#bid-extension h2 {

View File

@ -1,6 +1,6 @@
const CONFIG = {
API_BASE_URL: "http://localhost:4000/api/v1",
// API_BASE_URL: "https://bids.apactech.io/api/v1",
// API_BASE_URL: "http://localhost:4000/api/v1",
API_BASE_URL: "https://bids.apactech.io/api/v1",
};
let PREV_DATA = null;
@ -23,34 +23,57 @@ function extractDomain(url) {
}
}
const webs = {
grays: "https://www.grays.com",
langtons: "https://www.langtons.com.au",
lawsons: "https://www.lawsons.com.au",
pickles: "https://www.pickles.com.au",
allbids: "https://www.allbids.com.au",
};
function extractModelId(url) {
switch (extractDomain(url)) {
case "https://www.grays.com": {
case webs.grays: {
const match = url.match(/\/lot\/([\d-]+)\//);
return match ? match[1] : null;
}
case "https://www.langtons.com.au": {
case webs.langtons: {
const match = url.match(/auc-var-\d+/);
return match[0];
}
case "https://www.lawsons.com.au": {
case webs.lawsons: {
const match = url.split("_");
return match ? match[1] : null;
}
case "https://www.pickles.com.au": {
case webs.pickles: {
const model = url.split("/").pop();
return model ? model : null;
}
case webs.allbids: {
const match = url.match(/-(\d+)(?:[\?#]|$)/);
return match ? match[1] : null;
}
}
}
const showPage = async (pageLink = "pages/popup/popup.html") => {
const res = await fetch(chrome.runtime.getURL(pageLink));
const html = await res.text();
const isValidUrl = (url) => {
return !!Object.keys(webs).find((item) => url.includes(webs[item]));
};
const wrapper = document.createElement("div");
wrapper.innerHTML = html;
document.body.appendChild(wrapper);
const showPage = async (pageLink = "pages/popup/popup.html") => {
const url = window.location.href; // sửa lỗi ở đây
if (!isValidUrl(url)) return;
try {
const res = await fetch(chrome.runtime.getURL(pageLink));
const html = await res.text();
const wrapper = document.createElement("div");
wrapper.innerHTML = html;
document.body.appendChild(wrapper);
} catch (err) {
console.error("Failed to load popup page:", err);
}
};
const getKey = () => {
@ -360,13 +383,6 @@ const showInfo = async (model, formElements) => {
style.href = chrome.runtime.getURL("assets/css/index.css");
document.head.appendChild(style);
const script = document.createElement("script");
script.type = "module";
script.src = chrome.runtime.getURL("pages/popup/popup.js");
script.defer = true;
document.body.appendChild(script);
handleSaveKey();
const currentUrl = window.location.href;

View File

@ -1,7 +1,7 @@
{
"manifest_version": 3,
"name": "Bid Extension",
"version": "1.0",
"version": "1.2",
"description": "Bid Extension",
"action": {
"default_popup": "pages/popup/popup.html",

BIN
pages/.DS_Store vendored Normal file

Binary file not shown.

View File

@ -1,6 +1,6 @@
<div
id="bid-toggle-container"
style="position: fixed; bottom: 20px; left: 20px; z-index: 9999"
style="position: fixed; bottom: 100px; right: 20px; z-index: 9999"
>
<button
id="toggle-bid-extension"
@ -80,7 +80,6 @@
<g></g>
<g></g>
</svg>
</button>
</div>
@ -90,8 +89,8 @@
style="
display: none;
position: fixed;
bottom: 90px;
left: 20px;
bottom: 170px;
right: 20px;
z-index: 9999;
background-color: #1e1e1e;
border-radius: 12px;