Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
62
rated 0 times [  67] [ 5]  / answers: 1 / hits: 15507  / 15 Years ago, sat, january 30, 2010, 12:00:00

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.


More From » browser

 Answers
65

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.


[#97712] Wednesday, January 27, 2010, 15 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
feliciarainak

Total Points: 104
Total Questions: 91
Total Answers: 83

Location: Greenland
Member since Thu, Oct 27, 2022
2 Years ago
;