我正在尝试为谷歌浏览器制作一个主题,但我希望在安装时出现一个弹出窗口。我不确定这是否可能,因为主题与扩展不同。
所以我想用这个清单文件我可以用一个扩展名来做到这一点:
{
"background": {
"persistent": false,
"scripts": [ "script.js" ]
},
"description": "Een test",
"manifest_version": 2,
"name": "Test Extension",
"version": "0.0.2"
}
在 script.js 中,我得到了以下代码:
chrome.runtime.onInstalled.addListener(function(){
window.open('http://www.example.com','','width=800,height=500');
});
这一切都很好。现在困难的部分是将其用于主题。问题是当我将主题对象添加到清单文件中时,事情似乎无法正常工作:脚本将不再执行。所以此时我的清单文件如下所示:
{
"background": {
"persistent": false,
"scripts": [ "script.js" ]
},
"description": "Een test",
"manifest_version": 2,
"name": "Test Extension",
"theme": {
"colors": {
"bookmark_text": [ 255, 255, 255 ],
"frame": [ 12, 20, 30 ],
"ntp_background": [ 11, 21, 35 ],
"ntp_header": [ 40, 40, 40 ],
"ntp_link": [ 0, 0, 0 ],
"ntp_section": [ 255, 255, 255, 0.5 ],
"ntp_section_link": [ 0, 0, 0 ],
"ntp_section_text": [ 0, 0, 0 ],
"ntp_text": [ 255, 255, 255 ],
"tab_background_text": [ 10, 10, 10 ],
"tab_text": [ 255, 255, 255 ],
"toolbar": [ 6, 13, 21 ]
},
"images": {
"theme_frame": "img/frame.jpg",
"theme_frame_overlay": "img/frame_overlay.png",
"theme_ntp_attribution": "img/ntp_attribution.png",
"theme_ntp_background": "img/ntp_background.jpg",
"theme_tab_background": "img/tab_background.jpg",
"theme_tab_background_incognito": "img/tab_background.jpg",
"theme_toolbar": "img/toolbar.jpg"
},
"properties": {
"ntp_background_alignment": "bottom right",
"ntp_background_repeat": "no-repeat"
},
"tints": {
"buttons": [ 1, 1, 1 ]
}
},
"version": "0.0.2"
}
我想它不再起作用了,因为该文件现在将被归类为主题。不过,我想我可以在这里发布这个问题。希望大家给点建议。