• Login
    • Search
    • Categories
    • Recent
    • Tags
    • Users
    • Groups
    • Rules
    • Help

    Do more on the web, with a fast and secure browser!

    Download Opera browser with:

    • built-in ad blocker
    • battery saver
    • free VPN
    Download Opera

    Opera extensions fail to modify requestHeaders on google.com ...

    Opera for Windows
    2
    5
    667
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • escape75
      escape75 last edited by

      There is a fairly serious issue that's affecting Opera 109.x and earlier editions, and it surfaces when an extension is installed that modifies the User-Agent header. For v2 extensions that use chrome.webRequest.onBeforeSendHeaders, as well as v3 extensions chrome.declarativeNetRequest via modifyHeaders, the extension is able to modify all requestHeaders as expected except headers on google.com domain, but the issue is only with the initial request, all subsequent modifications are fine. This causes unexpected service issues with Google websites, as google receives different User-Agent header responses. Allow access to search page results is already enabled. This also includes not being able to add other headers, cookies, etc. If more information is needed please contact me. This issue does not exist in Chrome or Edge browsers. A quick way to test for this error is to search "what is my user agent" on google.com and notice how the UA is never modified as expected.

      Reply Quote 0
        burnout426 2 Replies Last reply
      • burnout426
        burnout426 Volunteer @escape75 last edited by

        @escape75 said in Opera extensions fail to modify requestHeaders on google.com ...:

        A quick way to test for this error is to search "what is my user agent" on google.com and notice how the UA is never modified as expected.

        I've noticed that too for a long time with https://addons.opera.com/en/extensions/details/user-agent-switcher-5/ for example (when set to Chrome for Windows and then clicking the pencil icon (edit) to set the string to Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36 (what Chrome Stable says at the URL chrome://version)).

        "Allow access to search page results" doesn't help and neither does going to the URL opera://browserjs and disabling browser.js (to disable any user-agent workarounds Opera might have for Google that might override an extension's).

        I figured it might have to do with client hints that the extension isn't modifying or something to do with some Javascript navigator.stuff that the extension neglects to change., but not sure.

        What does seem to work though is starting Opera like this:

        "opera.exe" "--user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36"
        

        and not using an extension at all. Downside with that is it messes with Opera's sites.

        Reply Quote 0
          1 Reply Last reply
        • burnout426
          burnout426 Volunteer @escape75 last edited by

          @escape75 said in Opera extensions fail to modify requestHeaders on google.com ...:

          extension is installed that modifies the User-Agent header. For v2 extensions that use chrome.webRequest.onBeforeSendHeaders, as well as v3 extensions chrome.declarativeNetRequest via modifyHeaders, the extension is able to modify all requestHeaders as expected except headers on google.com domain, but the issue is only with the initial request, all subsequent modifications are fine.

          Do you have minimal test extensions (v2 and v3) that show this?

          Reply Quote 0
            escape75 1 Reply Last reply
          • escape75
            escape75 @burnout426 last edited by

            This would be one way to have a v2 example:

            manifest.json

            {
               "background": {
                  "persistent": true,
                  "scripts": [ "background.js" ]
               },
               "description": "Header Test",
               "homepage_url": "https://sermak.ca",
               "icons": {
                  "128": "icon.png"
               },
               "manifest_version": 2,
               "name": "Header Test",
               "permissions": [ "webRequest", "webRequestBlocking", "tabs", "http://*/*", "https://*/*", "file:///*" ],
               "short_name": "HT",
               "version": "31.6"
            }
            

            background.js

            // override User Agent
            var OBSHOption = ["requestHeaders", "blocking"];
            if (chrome.webRequest.OnBeforeSendHeadersOptions.hasOwnProperty("EXTRA_HEADERS")) OBSHOption.push("extraHeaders");
            chrome.webRequest.onBeforeSendHeaders.addListener(function(details)
            {
            	details.requestHeaders = details.requestHeaders.filter(function(elem) { return !elem.name.toLowerCase().includes("sec-ch-ua"); });
            	details.requestHeaders.find(function(elem) { if (elem.name.toLowerCase() == "user-agent") elem.value = "New Agent"; });
            
            	return {requestHeaders:details.requestHeaders};
            }, {urls:["<all_urls>"]}, OBSHOption);
            

            It's not fixed in v3 either,- I'm guessing it has to do with the "allow access to search results" and a bug in the Opera code that does sets this permission too late for headers to be modified, or something like that ...

            In the meantime I've switched to Brave, but submitted a bug report.

            Reply Quote 0
              burnout426 1 Reply Last reply
            • burnout426
              burnout426 Volunteer @escape75 last edited by

              @escape75 Confirmed. Everything is correct with the extension and it works in other Chromium-based browsers. I filed DNA-116030 for it to see if it's a bug or something intentional Opera does for some reason.

              Reply Quote 0
                1 Reply Last reply
              • Locked by  leocg leocg 
              • First post
                Last post

              Computer browsers

              • Opera for Windows
              • Opera for Mac
              • Opera for Linux
              • Opera beta version
              • Opera USB

              Mobile browsers

              • Opera for Android
              • Opera Mini
              • Opera Touch
              • Opera for basic phones

              • Add-ons
              • Opera account
              • Wallpapers
              • Opera Ads

              • Help & support
              • Opera blogs
              • Opera forums
              • Dev.Opera

              • Security
              • Privacy
              • Cookies Policy
              • EULA
              • Terms of Service

              • About Opera
              • Press info
              • Jobs
              • Investors
              • Become a partner
              • Contact us

              Follow Opera

              • Opera - Facebook
              • Opera - Twitter
              • Opera - YouTube
              • Opera - LinkedIn
              • Opera - Instagram

              © Opera Software 1995-2025