0

I'm trying to debug a Chrome extension that uses chrome.runtime.getPlatformInfo() to choose which codepath to execute depending on the OS. Functionality is different depending on the operating system (this is not something I agree with, but I do not control the extension's development). While I could try to replace each instance in the source code, returning false data instead of actually calling the browser-provided function, I find such a solution inelegant and prone to human error.

I'm doing my testing on a computer running macOS. I want the extension to think I'm running ChromeOS (where the returned object has the "os" property set to "cros"). How would I go about spoofing the returned object to have the properties set to my desired values?

I've tried searching for command line startup flags, but I couldn't find one for this purpose. I tried using the User-Agent flag, but as one may expect, that only affects the User-Agent header and not the data returned from chrome.runtime.getPlatformInfo().

A. Owl
  • 51
  • 1
  • 6
  • You'll have to make a copy of the extension, modify it, and load in developer mode: [more info](https://stackoverflow.com/a/16688027). – wOxxOm Aug 27 '22 at 19:55
  • @wOxxOm I’m aware I can do that. However, I’d prefer to be able to not modify the extension itself and just return different fields for navigator/runtime – A. Owl Aug 27 '22 at 20:48
  • Well, it's the only solution. – wOxxOm Aug 28 '22 at 06:11

0 Answers0