在'document_start'运行的内容脚本会阻止网页上的JS脚本?

时间:2016-09-19 16:01:06

标签: javascript google-chrome google-chrome-extension content-script

我正在使用扩展程序在Chrome中处理网络脚本。我发现了这个:

<!DOCTYPE hibernate-configuration PUBLIC
        "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
        "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
    <session-factory>
        <property name="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</property>
        <property name="hibernate.connection.driver_class">org.postgresql.Driver</property>
        <property name="hibernate.connection.username">postgres</property>
        <property name="hibernate.connection.password">root</property>
        <property name="hibernate.connection.url">jdbc:postgresql://192.168.1.3:5432/my_database</property>
        <property name="connection_pool_size">1</property>
        <property name="hbm2ddl.auto">update</property>
        <property name="show_sql">false</property>
        <property name="hibernate.enable_lazy_load_no_trans">true</property>


    </session-factory>
</hibernate-configuration>

在我的Js脚本中,只有两行代码:

"content_scripts": [{
    "js": [.....],
    "matches": ["http://*/*", "https://*/*"],
    "run_at": "document_start"
}]

我试图在这种情况下打开我的网页:

  1. 在没有打开chrome devtool的情况下,我打开了一个新标签并转到我的网页
  2. 我检查了我的代码中的console.log显示在我的控制台中。 但是,当我继续进入window.test或test时,我发现两者的结果都是未定义的。
  3. P.S。

    1. 我试图将'document_start'更改为'document_end',并定义了这两个全局变量,没有错误。
    2. 对于内容脚本,我尝试编写一个新的视频内容脚本或内容'console.log ...',但这种方式不起作用,所以它不是内容脚本内容的问题
    3. 我需要询问您的想法,如果您愿意,可以尝试使用Chrome和扩展程序。

1 个答案:

答案 0 :(得分:1)

感谢您的回答! @wOxxOm 正如你在评论中所说的那样,我会把这个作为答案让别人来防止这一点很容易但很难找到。

使用devtools控制台时,请务必在控制台上方选择正确的上下文 顶部 作为网页,“您的扩展程序”对于内容脚本。