Created
September 13, 2016 09:10
-
-
Save thenoseman/76a4db959bb98f392e9942df419d9e64 to your computer and use it in GitHub Desktop.
Form-O-Fill : Extract and use a URL GET parameter
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
var rules = [{ | |
// Go to https://www.amazon.com/s/ref=nb_sb_noss_2?url=search-alias%3Daps&field-keywords=rainbow+pony | |
// URL parameters are: url=search-alias%3Daps&field-keywords=rainbow+pony | |
"url": /www.amazon.com/, | |
"name": "Demo : Extract parameters from URL", | |
"fields": [{ | |
"selector": "input[name=field-keywords]", | |
"value": function($element) { | |
// Construct via this nice helper : https://developer.mozilla.org/de/docs/Web/API/URLSearchParams | |
var params = new URLSearchParams(window.location.search); | |
// Extract one of the parameters: | |
var keywords = params.get("field-keywords"); | |
return keywords + " some other term just to show it works"; | |
} | |
}] | |
}]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment