How can I fool a site that looks at the JavaScript object 'navigator' to see that I'm not on Windows?

后端 未结 6 1121
广开言路
广开言路 2020-12-06 00:04

I am trying to browse a website, however, it only works under Windows and Mac because they use the navigator.platform from JavaScript to find out the architectu

6条回答
  •  不思量自难忘°
    2020-12-06 00:49

    Since you can't directly set navigator.platform, you will have to be sneaky - create an object that behaves like navigator, replace its platform, then set navigator to it.

    var fake_navigator = {};
    
    for (var i in navigator) {
      fake_navigator[i] =  navigator[i];
    }
    
    fake_navigator.platform = 'MyOS';
    
    navigator = fake_navigator;
    

    If you execute this code before the document loads (using GreaseMonkey, an addon or a Chrome extension), then the page will see navigator.platform as "MyOS".

    Note: tested only in Chrome.

提交回复
热议问题