window.Object!= greasemonkey脚本的对象

时间:2017-01-13 07:21:35

标签: javascript firefox greasemonkey userscripts

以下脚本将<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> <div class="col-lg-3 col-md-3 col-sm-3"> <div class="chat-box-new-div"> <div class="chat-box-new-head">Frequently Asked Questions .. </div> <div class="panel-body chat-box-new"> <ul class="questionsUl"> <li>Who is a public official?&nbsp;</li> <li>My client asked if her son can intern with the company as a favor to her, that isn't a problem is it?&nbsp;</li> <li>My friend works for the client, does that mean I can't give her a gift?&nbsp;</li> <li>Is there certain criteria for gifts and entertainment&nbsp;</li> <li>How do I know if Gift or Entertainment is permissible?&nbsp;</li> <li>can I give gift cards to my team?&nbsp;</li> <li>Do I need approval to give a gift?&nbsp;</li> <li>Are Facilitating Payments” to Public Officials allowed?&nbsp;</li> <li>is there approval needed for gifts to public officials?&nbsp;</li> <li>Who is a public official?&nbsp;</li> <li>My client asked if her son can intern with the company as a favor to her, that isn't a problem is it?&nbsp;</li> <li>My friend works for the client, does that mean I can't give her a gift?&nbsp;</li> <li>Is there certain criteria for gifts and entertainment&nbsp;</li> <li>How do I know if Gift or Entertainment is permissible?&nbsp;</li> <li>can I give gift cards to my team?&nbsp;</li> <li>Do I need approval to give a gift?&nbsp;</li> <li>Are Facilitating Payments” to Public Officials allowed?&nbsp;</li> <li>is there approval needed for gifts to public officials?&nbsp;</li> <li>Who is a public official?&nbsp;</li> <li>My client asked if her son can intern with the company as a favor to her, that isn't a problem is it?&nbsp;</li> <li>My friend works for the client, does that mean I can't give her a gift?&nbsp;</li> <li>Is there certain criteria for gifts and entertainment&nbsp;</li> <li>How do I know if Gift or Entertainment is permissible?&nbsp;</li> <li>can I give gift cards to my team?&nbsp;</li> <li>Do I need approval to give a gift?&nbsp;</li> <li>Are Facilitating Payments” to Public Officials allowed?&nbsp;</li> <li>is there approval needed for gifts to public officials?&nbsp;</li> <li>Who is a public official?&nbsp;</li> <li>My client asked if her son can intern with the company as a favor to her, that isn't a problem is it?&nbsp;</li> <li>My friend works for the client, does that mean I can't give her a gift?&nbsp;</li> <li>Is there certain criteria for gifts and entertainment&nbsp;</li> <li>How do I know if Gift or Entertainment is permissible?&nbsp;</li> <li>can I give gift cards to my team?&nbsp;</li> <li>Do I need approval to give a gift?&nbsp;</li> <li>Are Facilitating Payments” to Public Officials allowed?&nbsp;</li> <li>is there approval needed for gifts to public officials?&nbsp;</li> <li>Who is a public official?&nbsp;</li> <li>My client asked if her son can intern with the company as a favor to her, that isn't a problem is it?&nbsp;</li> <li>My friend works for the client, does that mean I can't give her a gift?&nbsp;</li> <li>Is there certain criteria for gifts and entertainment&nbsp;</li> <li>How do I know if Gift or Entertainment is permissible?&nbsp;</li> <li>can I give gift cards to my team?&nbsp;</li> <li>Do I need approval to give a gift?&nbsp;</li> <li>Are Facilitating Payments” to Public Officials allowed?&nbsp;</li> <li>is there approval needed for gifts to public officials?&nbsp;</li> <li>Who is a public official?&nbsp;</li> <li>My client asked if her son can intern with the company as a favor to her, that isn't a problem is it?&nbsp;</li> <li>My friend works for the client, does that mean I can't give her a gift?&nbsp;</li> <li>Is there certain criteria for gifts and entertainment&nbsp;</li> <li>How do I know if Gift or Entertainment is permissible?&nbsp;</li> <li>can I give gift cards to my team?&nbsp;</li> <li>Do I need approval to give a gift?&nbsp;</li> <li>Are Facilitating Payments” to Public Officials allowed?&nbsp;</li> <li>is there approval needed for gifts to public officials?&nbsp;</li> </ul> </div> </div> </div>记录到控制台。有谁知道它带来了什么或带来了什么好处?

从简短的一瞥到Greasemonkey的源代码,我找不到任何修改false的内容。同时查看Object很难看到任何有意义的差异,所有函数仍然是本机代码。

Object

(在Greasemonkey&amp; Firefox上测试,不确定是否有Scriptish&amp; Chrome,但欢迎任何实验!)。

[注意:这个问题无关// ==UserScript== // @name test // @namespace test // @include * // @grant none // ==/UserScript== console.log(window.Object == Object) 的问题有关,请先阅读问题本身,而不是在投票之前先看一下标题,谢谢!]。

1 个答案:

答案 0 :(得分:3)

这是Mozilla当前沙箱流程的副作用。即使在@grant none模式下,使用Components.utils.Sandbox的Greasemonkey沙箱脚本 - 仅关闭Xrays并在wantExportHelpers处留下false

因此,您的window.Object == Object相当于window.Object == this.Object 但是:在Greasemonkey脚本中,this(root / global this)始终是Sandbox个对象,而不是Window

Firefox可能有充分的理由像这样克隆Object,但我找不到任何引用说法。

Chrome + Tampermonkey不会执行此操作window.Object == Object适用于Tampermonkey脚本,无论@grant设置如何。

Chrome也不会以同样的方式进行沙盒化。