Created
February 7, 2022 02:03
-
-
Save ErikCH/4909e567f5ca3e82f54d35a2d1229730 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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