How can I mimic Greasemonkey/Firefox's unsafeWindow functionality in Chrome?

后端 未结 5 533
孤城傲影
孤城傲影 2020-12-05 16:53

I\'m just fiddling around with user scripts in chrome right now, so please bear with my potential ignorance/idiocy.

In the page I\'m writing a script for, there is a

5条回答
  •  -上瘾入骨i
    2020-12-05 17:39

    This will give you a reference to the window object (as p):

    var p = unsafeWindow;
    
    if(window.navigator.vendor.match(/Google/)) {
        var div = document.createElement("div");
        div.setAttribute("onclick", "return window;");
        p = div.onclick();
    };
    

提交回复
热议问题