update position
This commit is contained in:
parent
ccdabd9350
commit
e211e0e521
Binary file not shown.
|
|
@ -20,6 +20,7 @@
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 10px;
|
gap: 10px;
|
||||||
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
#bid-extension h2 {
|
#bid-extension h2 {
|
||||||
|
|
|
||||||
54
content.js
54
content.js
|
|
@ -1,6 +1,6 @@
|
||||||
const CONFIG = {
|
const CONFIG = {
|
||||||
API_BASE_URL: "http://localhost:4000/api/v1",
|
// API_BASE_URL: "http://localhost:4000/api/v1",
|
||||||
// API_BASE_URL: "https://bids.apactech.io/api/v1",
|
API_BASE_URL: "https://bids.apactech.io/api/v1",
|
||||||
};
|
};
|
||||||
|
|
||||||
let PREV_DATA = null;
|
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) {
|
function extractModelId(url) {
|
||||||
switch (extractDomain(url)) {
|
switch (extractDomain(url)) {
|
||||||
case "https://www.grays.com": {
|
case webs.grays: {
|
||||||
const match = url.match(/\/lot\/([\d-]+)\//);
|
const match = url.match(/\/lot\/([\d-]+)\//);
|
||||||
return match ? match[1] : null;
|
return match ? match[1] : null;
|
||||||
}
|
}
|
||||||
case "https://www.langtons.com.au": {
|
case webs.langtons: {
|
||||||
const match = url.match(/auc-var-\d+/);
|
const match = url.match(/auc-var-\d+/);
|
||||||
return match[0];
|
return match[0];
|
||||||
}
|
}
|
||||||
case "https://www.lawsons.com.au": {
|
case webs.lawsons: {
|
||||||
const match = url.split("_");
|
const match = url.split("_");
|
||||||
return match ? match[1] : null;
|
return match ? match[1] : null;
|
||||||
}
|
}
|
||||||
case "https://www.pickles.com.au": {
|
case webs.pickles: {
|
||||||
const model = url.split("/").pop();
|
const model = url.split("/").pop();
|
||||||
return model ? model : null;
|
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 isValidUrl = (url) => {
|
||||||
const res = await fetch(chrome.runtime.getURL(pageLink));
|
return !!Object.keys(webs).find((item) => url.includes(webs[item]));
|
||||||
const html = await res.text();
|
};
|
||||||
|
|
||||||
const wrapper = document.createElement("div");
|
const showPage = async (pageLink = "pages/popup/popup.html") => {
|
||||||
wrapper.innerHTML = html;
|
const url = window.location.href; // sửa lỗi ở đây
|
||||||
document.body.appendChild(wrapper);
|
|
||||||
|
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 = () => {
|
const getKey = () => {
|
||||||
|
|
@ -360,13 +383,6 @@ const showInfo = async (model, formElements) => {
|
||||||
style.href = chrome.runtime.getURL("assets/css/index.css");
|
style.href = chrome.runtime.getURL("assets/css/index.css");
|
||||||
document.head.appendChild(style);
|
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();
|
handleSaveKey();
|
||||||
|
|
||||||
const currentUrl = window.location.href;
|
const currentUrl = window.location.href;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"manifest_version": 3,
|
"manifest_version": 3,
|
||||||
"name": "Bid Extension",
|
"name": "Bid Extension",
|
||||||
"version": "1.0",
|
"version": "1.2",
|
||||||
"description": "Bid Extension",
|
"description": "Bid Extension",
|
||||||
"action": {
|
"action": {
|
||||||
"default_popup": "pages/popup/popup.html",
|
"default_popup": "pages/popup/popup.html",
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -1,6 +1,6 @@
|
||||||
<div
|
<div
|
||||||
id="bid-toggle-container"
|
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
|
<button
|
||||||
id="toggle-bid-extension"
|
id="toggle-bid-extension"
|
||||||
|
|
@ -80,7 +80,6 @@
|
||||||
<g></g>
|
<g></g>
|
||||||
<g></g>
|
<g></g>
|
||||||
</svg>
|
</svg>
|
||||||
|
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
@ -90,8 +89,8 @@
|
||||||
style="
|
style="
|
||||||
display: none;
|
display: none;
|
||||||
position: fixed;
|
position: fixed;
|
||||||
bottom: 90px;
|
bottom: 170px;
|
||||||
left: 20px;
|
right: 20px;
|
||||||
z-index: 9999;
|
z-index: 9999;
|
||||||
background-color: #1e1e1e;
|
background-color: #1e1e1e;
|
||||||
border-radius: 12px;
|
border-radius: 12px;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue