Skip to content

Instantly share code, notes, and snippets.

@enomoto
Created April 26, 2024 10:40
Show Gist options
  • Save enomoto/6f3a74d4b264825cdf625d91e08a860b to your computer and use it in GitHub Desktop.
Save enomoto/6f3a74d4b264825cdf625d91e08a860b to your computer and use it in GitHub Desktop.
//
// login_form_hook
//
document.querySelector("#customer_login")?.addEventListener("submit", () => {
const email = document.querySelector('input[name="customer[email]"]')?.value ?? ""
const object = {
"email": email,
}
webkit.messageHandlers.accountLogin.postMessage(object)
})
//
// registration_form_hook
//
document.querySelector("#create_customer")?.addEventListener("submit", () => {
const email = document.querySelector('input[name="customer[email]"]')?.value ?? ""
const firstName = document.querySelector('input[name="customer[first_name]"]')?.value ?? ""
const lastName = document.querySelector('input[name="customer[last_name]"]')?.value ?? ""
const password = document.querySelector('input[name="customer[password]"]')?.value ?? ""
const birthday = document.querySelector("#birthday")?.value ?? ""
const object = {
"email": email,
"firstName": firstName,
"lastName": lastName,
"password": password,
"birthday": birthday
}
webkit.messageHandlers.accountRegister.postMessage(object)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment