diff --git a/index.html b/index.html
index c87a0df..665ba58 100644
--- a/index.html
+++ b/index.html
@@ -6,7 +6,7 @@
T3 Search
-
+
diff --git a/src/main.ts b/src/main.ts
index 3992e63..d42da13 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -2,29 +2,31 @@ import { bangs } from "./bang";
const defaultBang = bangs.find((b) => b.t === "g");
-function doBangRedirect() {
+function getBangredirectUrl() {
const url = new URL(window.location.href);
const query = url.searchParams.get("q")?.trim() ?? "";
if (!query) return null;
+
const match = query.match(/!([a-z]+)/i);
if (!match) return null;
+
const bangCandidate = match[1].toLowerCase();
const selectedBang = bangs.find((b) => b.t === bangCandidate) ?? defaultBang;
- return selectedBang;
+ // Remove the first bang from the query
+ const cleanQuery = query.replace(/![a-z]+\s*/i, "").trim();
+
+ // Format of the url is:
+ // https://www.google.com/search?q={{{s}}}
+ const searchUrl = selectedBang?.u.replace(
+ "{{{s}}}",
+ encodeURIComponent(cleanQuery)
+ );
+ if (!searchUrl) return null;
+
+ return searchUrl;
}
-const bang = doBangRedirect();
-if (bang) {
- console.log("bang", bang);
+const searchUrl = getBangredirectUrl() ?? "https://www.google.com";
- // window.location.replace(bang.d + "?q=" + encodeURIComponent(query));
-}
-
-document.querySelector("#app")!.innerHTML = `
-
-
T3 Search
-
-`;
-
-setupCounter(document.querySelector("#counter")!);
+window.location.replace(searchUrl);
diff --git a/src/style.css b/src/style.css
deleted file mode 100644
index f9c7350..0000000
--- a/src/style.css
+++ /dev/null
@@ -1,96 +0,0 @@
-:root {
- font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
- line-height: 1.5;
- font-weight: 400;
-
- color-scheme: light dark;
- color: rgba(255, 255, 255, 0.87);
- background-color: #242424;
-
- font-synthesis: none;
- text-rendering: optimizeLegibility;
- -webkit-font-smoothing: antialiased;
- -moz-osx-font-smoothing: grayscale;
-}
-
-a {
- font-weight: 500;
- color: #646cff;
- text-decoration: inherit;
-}
-a:hover {
- color: #535bf2;
-}
-
-body {
- margin: 0;
- display: flex;
- place-items: center;
- min-width: 320px;
- min-height: 100vh;
-}
-
-h1 {
- font-size: 3.2em;
- line-height: 1.1;
-}
-
-#app {
- max-width: 1280px;
- margin: 0 auto;
- padding: 2rem;
- text-align: center;
-}
-
-.logo {
- height: 6em;
- padding: 1.5em;
- will-change: filter;
- transition: filter 300ms;
-}
-.logo:hover {
- filter: drop-shadow(0 0 2em #646cffaa);
-}
-.logo.vanilla:hover {
- filter: drop-shadow(0 0 2em #3178c6aa);
-}
-
-.card {
- padding: 2em;
-}
-
-.read-the-docs {
- color: #888;
-}
-
-button {
- border-radius: 8px;
- border: 1px solid transparent;
- padding: 0.6em 1.2em;
- font-size: 1em;
- font-weight: 500;
- font-family: inherit;
- background-color: #1a1a1a;
- cursor: pointer;
- transition: border-color 0.25s;
-}
-button:hover {
- border-color: #646cff;
-}
-button:focus,
-button:focus-visible {
- outline: 4px auto -webkit-focus-ring-color;
-}
-
-@media (prefers-color-scheme: light) {
- :root {
- color: #213547;
- background-color: #ffffff;
- }
- a:hover {
- color: #747bff;
- }
- button {
- background-color: #f9f9f9;
- }
-}
diff --git a/src/typescript.svg b/src/typescript.svg
deleted file mode 100644
index d91c910..0000000
--- a/src/typescript.svg
+++ /dev/null
@@ -1 +0,0 @@
-
\ No newline at end of file