如何覆盖 javascript 中的 navigator.plugins?

How to override navigator.plugins in javascript?

如何在 javascript 中覆盖 navigator.plugins?
有一个网站使用 navigator.plugins 读取我的插件列表,我不想让他们读取我的插件,我想向他们展示伪造的插件列表。
我怎样才能做到这一点?

我知道这是重复的,但我对这个不满意:
How to override navigator.plugins in javascript or how to set it null?

为了重写 javascript 中的函数,我们可以这样做:

<script type="text/javascript">
    window.DoStuff = function () {
        alert("bar");   //this is the override
    };

    function DoStuff() {
        alert("foo");   //this is the original, occuring later in the page
    };
</script>

但是navigator.plugins呢?
这是我们阅读这些插件列表的方式:

if (navigator.plugins && navigator.plugins.length) {
    for (var v = "", w = 0; w < navigator.plugins.length; w++) {
        var x = navigator.plugins[w].name; -1 != x.indexOf("Java") && (t = !0);
        v += x + "\r\n"
    }
 alert(v);
}

如您所见,该网站是一个恶意网站,出于某些原因想知道已安装的插件。
我怎样才能绕过它们?


根据第一个答案编辑:
那么我们如何用js函数更改他们的代码并用主列表替换新的插件列表呢?
这样就不用改只读了window.navigator.plugins!

根据 MDNWindow.navigator.plugins 属性 是只读的,这可能意味着您无法更改它。

https://developer.mozilla.org/es/docs/Web/API/Navigator