Skip to content

Instantly share code, notes, and snippets.

@thenoseman
Created September 13, 2016 09:10
Show Gist options
  • Save thenoseman/76a4db959bb98f392e9942df419d9e64 to your computer and use it in GitHub Desktop.
Save thenoseman/76a4db959bb98f392e9942df419d9e64 to your computer and use it in GitHub Desktop.
Form-O-Fill : Extract and use a URL GET parameter
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