Skip to content

Instantly share code, notes, and snippets.

@ErikCH
Created February 7, 2022 02:03
Show Gist options
  • Save ErikCH/4909e567f5ca3e82f54d35a2d1229730 to your computer and use it in GitHub Desktop.
Save ErikCH/4909e567f5ca3e82f54d35a2d1229730 to your computer and use it in GitHub Desktop.
const URL = "https://www.google.com/search?q=";
const FEELING_LUCKY = "&btnI=&sourceid=navclient&gfns=1";
const inputDetails = document.querySelector("input");
const lucky = document.querySelector("button[data-lucky]");
lucky.addEventListener("click", () => {
console.log("here", inputDetails.value);
if (!inputDetails.value) return;
document.location = `${URL}${inputDetails.value}${FEELING_LUCKY}`;
});
function onSubmit(event) {
event.preventDefault();
const { textSearch } = Object.fromEntries(new FormData(event.target));
console.log("text", textSearch);
if (!inputDetails.value) return;
document.location = `${URL}${textSearch}`;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment