Created
January 18, 2017 09:25
-
-
Save stanBienaives/5c5a891e81e541ac2d243ac6a47334b2 to your computer and use it in GitHub Desktop.
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
var query = window.location.search.substring(1); | |
var query = query.split("&"); | |
for(i = 0; i < query.length; i++) { | |
var split = query[i].split('='); | |
var target = split[0]; | |
var value = split[1]; | |
if (target === "full_name") { | |
var split_name = value.split('%20') | |
var first_name = split_name[0]; | |
var last_name; | |
for(k = 1; k < split_name.length; k++) { | |
if(!last_name) | |
last_name = split_name[k]; | |
else | |
last_name = last_name + " " + split_name[k]; | |
} | |
fillForm("first_name", first_name); | |
fillForm("last_name", last_name); | |
} else { | |
fillForm(target, value); | |
} | |
} | |
function fillForm(target, value) { | |
value = decodeURIComponent(value); | |
console.log(target, value); | |
document.getElementById('id_' + target).value= value | |
} |
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
{ | |
"manifest_version": "0.0.1", | |
"name": "Homeloc auto fill form", | |
"description": "This extensionA allows to autofill form fields from query parameter in the url", | |
"version": "1.0", | |
"content_scripts": [ | |
{ | |
"matches": ["https://www.homelocpay.com/fr/dashboard/payments/request/*"], | |
"js": ["fillForm.js"] | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment