Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
533 views
in Technique[技术] by (71.8m points)

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

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 architecture I am running on. Of course, they also use the browser's user agent, but that was easy to spoof.

Here is the .js in question: http://pastebin.com/f56fd608d. The code responsible for browser detection is at the top. Is there any way of changing the .js file before the site runs, or something similar, so I can eliminate the check?

Using the JavaScript console yields:

>navigator.platform
Linux i686

Evidently I changed the browser's user agent, but navigator.platform does not seem to take it's value from the user agent.

Maybe someone knows how to change the value returned by navigator.platform, because I hate running Windows under VirtualBox to use this site.

EDIT: This could be of interest because Linux users might be artificially denied access to websites, and can do nothing about it.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
var fakePlatformGetter = function () {
  return "your fake platform";
};
if (Object.defineProperty) {
  Object.defineProperty(navigator, "platform", {
    get: fakePlatformGetter
  });
  Object.defineProperty(Navigator.prototype, "platform", {
    get: fakePlatformGetter
  });
} else if (Object.prototype.__defineGetter__) {
  navigator.__defineGetter__("platform", fakePlatformGetter);
  Navigator.prototype.__defineGetter__("platform", fakePlatformGetter);
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...