-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed email autofill on stripe, fixed some issues with Shopify autofill
- Loading branch information
Showing
6 changed files
with
93 additions
and
14 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
chrome.extension.sendMessage({}, function (response) { | ||
chrome.storage.local.get({ 'profiles': [], 'selectedProfile': null, 'enabled': false }, (results) => { | ||
if (results.enabled) { | ||
let profile = results.profiles.find(profile => profile.id === results.selectedProfile); | ||
|
||
if (profile) { | ||
fill('email', profile.email); | ||
fill('name', `${profile.firstName} ${profile.lastName}`); | ||
|
||
fill('fullName', `${profile.firstName} ${profile.lastName}`); | ||
|
||
fill('first-name', profile.firstName); | ||
fill('firstname', profile.firstName); | ||
fill('firstName', profile.firstName); | ||
|
||
fill('last-name', profile.lastName); | ||
fill('lastname', profile.lastName); | ||
fill('lastName', profile.lastName); | ||
|
||
fill('tel', profile.phoneNumber); | ||
|
||
fill('address-line1', `${profile.address}, ${profile.address2}`); | ||
fill('address-level2', profile.city); | ||
fill('city', profile.city); | ||
fill('state', profile.state); | ||
|
||
fill('postal-code', profile.zipcode); | ||
fill('zipcode', profile.zipcode); | ||
fill('postcode', profile.zipcode); | ||
fill('post-code', profile.zipcode); | ||
} | ||
} | ||
}); | ||
}); | ||
|
||
function fill(name, value) { | ||
fillByAutocomplete(name, value); | ||
fillByName(name, value); | ||
} | ||
|
||
function fillByName(name, value) { | ||
let element = document.getElementsByName(name)[0]; | ||
if (element) { | ||
autofill(element, value); | ||
} | ||
} | ||
|
||
function fillByAutocomplete(name, value) { | ||
let elements = document.querySelectorAll(`[autocomplete=${name}]`); | ||
|
||
elements.forEach(function (element) { | ||
autofill(element, value); | ||
}); | ||
} | ||
|
||
function autofill(element, value) { | ||
let event = document.createEvent("HTMLEvents"); | ||
event.initEvent('change', true, false); | ||
element.focus(); | ||
element.value = value; | ||
element.dispatchEvent(event); | ||
element.blur(); | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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