4

我有一个chrome扩展,它包含一个已打包的userscript,以便Chrome用户不必担心使用Tampermonkey。用户脚本不再运行在iframe上,在Chrome中27

在其上运行脚本由多个帧,例如,如果你浏览到网站/ game.php页面,该页面是由3帧像这样的:

  • game.php
    • menu.php
    • msgframe.php
    • main.php

在Firefox和之前的Chrome中,我可以将“main.php”添加到包含球体,并且每当我在顶层加载game.php时,脚本就会在该帧上运行。但是,在最新版本(Chrome 27.0.1453.93米)中,我只能在顶层“game.php”上运行脚本。浏览器甚至不打算尝试在任何帧上运行。我怀疑这是删除"unsafeWindow" hack的同一组安全增强的一部分。

有没有办法迫使Chrome实际上再次注意我的include_globs在清单中,还是我真的必须改变脚本,以便我在game.php中浪费时间检查所有框架并查看哪一个是我想运行的那个?

game.php并不总是具有相同的框架,url根据用户点击的位置而改变,所以我必须检查每个框架以找出我的位置,这是我更喜欢的开销避免。

感谢

编辑:似乎在扩展清单可能与下content_scripts this bug

回答

2

集“all_frames”为真,显然这现在默认为false。

{ 
"manifest_version": 2, 
"icons": { "48": "logo48.png", "128": "logo128.png" }, 
"name": "My Script", 
"description": "I do stuff.", 
"converted_from_user_script": true, 
"version": "1.0", 
"content_scripts": [ { 
    "all_frames" : true, 
    "exclude_globs": [ ], 
    "exclude_matches": [ ], 
    "include_globs": [ "http*://*.example.com/main.php*" ], 
    "js": [ "my_script_name.user.js" ], 
    "matches": [ "http://*.example.com/*", "https://*.example.com/*" ], 
    "run_at": "document_end" 
} ] 
} 
+0

请确保接受您的答案。 – galambalazs

相关问题