Search code examples
greasemonkeytampermonkey

How to modify the HTTP request headers using Greasemonkey before a new page is loaded?


I know about the GM_xmlhttpRequest api, but it's not what I'm asking about.

For instance, I want to visit Stack Overflow with a new UA(user-agent), can I do it with a Greasemonkey script?


Solution

  • Greasemonkey and Tampermonkey only fire after the initial page request is made.
    They cannot alter the user-agent.

    Modern browsers let you change the reported user-agent in the settings. In addition, there are a plethora of extensions that assist in changing the UA.
    (Or you can write your own extension.)

    Search Superuser for more information. Here's a list of likely Q&As there.