diff --git a/src/custom-bang.ts b/src/custom-bang.ts index dd85203..d9a388d 100644 --- a/src/custom-bang.ts +++ b/src/custom-bang.ts @@ -22,6 +22,6 @@ export const bangs: Bang[] = [ s: "Mercado Libre", sc: "Search", t: "ml", - u: "https://www.mercadolibre.com.ar/search?q={{{s}}}", + u: "https://listado.mercadolibre.com.ar/{{{s}}}", }, ]; diff --git a/src/global.css b/src/global.css index 3d41ed6..b306bab 100644 --- a/src/global.css +++ b/src/global.css @@ -129,6 +129,36 @@ textarea { background: #28a745; } +/* Test query styles */ +.test-query-container { + margin-top: 24px; + padding-top: 10px; + border-top: 1px solid #eee; + width: 100%; +} + +.test-button { + padding: 8px 16px; + background-color: #4285f4; + color: white; + border-radius: 4px; + transition: all 0.2s; +} + +.test-button:hover { + background-color: #3367d6; +} + +.test-button:active { + background-color: #2a56c6; +} + +.query-hint { + color: #666; + font-size: 14px; + margin-top: 8px; +} + /* Add footer styles */ .footer { position: fixed; diff --git a/src/main.ts b/src/main.ts index f079865..09f88e0 100644 --- a/src/main.ts +++ b/src/main.ts @@ -4,6 +4,11 @@ import { bangs as customBangs } from "./custom-bang"; import "./global.css"; import fuzzysort from "fuzzysort"; +const bangs = [ + ...defaultBangs.filter((bang) => !customBangs.some((c) => c.t === bang.t)), + ...customBangs, +]; + function noSearchDefaultPageRender() { const app = document.querySelector("#app")!; app.innerHTML = ` @@ -22,6 +27,19 @@ function noSearchDefaultPageRender() { + +
+
+ + +
("#bang-search")!; const bangList = app.querySelector(".bang-list")!; + // Test query functionality + const testQueryInput = + app.querySelector("#test-query-input")!; + const testQueryButton = + app.querySelector("#test-query-button")!; + + testQueryButton.addEventListener("click", () => { + const query = testQueryInput.value.trim(); + if (query) { + // Redirect to the current site with the query parameter + window.location.href = `${window.location.origin}/?q=${encodeURIComponent( + query + )}`; + } + }); + + // Allow pressing Enter to submit + testQueryInput.addEventListener("keydown", (e) => { + if (e.key === "Enter") { + testQueryButton.click(); + } + }); + copyButton.addEventListener("click", async () => { await navigator.clipboard.writeText(urlInput.value); copyIcon.src = "/clipboard-check.svg"; @@ -91,11 +132,6 @@ function noSearchDefaultPageRender() { }); } -const bangs = [ - ...defaultBangs.filter((bang) => !customBangs.some((c) => c.t === bang.t)), - ...customBangs, -]; - const LS_DEFAULT_BANG = localStorage.getItem("default-bang") ?? "g"; const defaultBang = bangs.find((b) => b.t === LS_DEFAULT_BANG);