In a JavaScript window object, there's a navigator object, which has lots of properties describing the clients browser, one of which is an array called plugins. I'm trying to disable this in my personal browser (chrome) by having JavaScript injected after the execution of every webpage I view. In other words, I don't want my plugins to be exposed to the websites I visit.
So I wrote this to be included with every HTTP(S) response on Chrome:
(function(window) {
delete window.navigator;
}(window));
But the navigator is still there, because in the console when I test it I see:

However, when I manually type delete navigator in the console, it works!

So why is it not working with my JavaScript? It's not a matter of if the script is executing, I've confirmed that it is, its just not removing the navigator object. Any ideas? I've also tried setting it to an empty object, but nothing is unsetting it...
As of now in Chrome, window.navigator and apis exposed via window.navigator seem to be read-only and simply calling delete on them won't have any effect.
For testing purposes I've been using Object.defineProperty to define a getter that returns null. this works well when a script or polyfill on the page tries to test for the existance of a specific browser api:
Object.defineProperty(window, 'navigator', {
get() {
return null;
},
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With