I am trying to append few extra parameters to the url that user typed (before the page gets loaded). Is it possible to do?
For example, if user types www.google.co
This is an old question still I am answering it for future readers.
Modification of query parameters is a little tricky because you can endup in infinite loop and chrome/firefox may detect it and process whatever is the current state of request Url.
I have faced this situation in my chrome extension Requestly where Users used Replace Rule
and replaced www.google.com
with www.google.com?q=query
or did something similar.
Problem with this approach is browser may intercept the request url after adding query parameter so the parameter will be added multiple times and corrupt the url. So you have to ensure either of the following :-
As correctly pointed out by @apsillers in his answer, you have to use webRequest API to perform any modifications to URL. Please have a look at his answer and write your code accordingly.
Just in case, you are looking for an already available solution, consider trying Requestly's Query Parameter Rule. Here is a screenshot on how it looks like :-
For Firefox, you can download Requestly from its home page.