Last active
August 29, 2015 14:07
-
-
Save kiinlam/66fd0ab97615edf228dc to your computer and use it in GitHub Desktop.
chrome extensions/apps manifest.json template
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 谷歌扩展/应用的manifest.json模板 | |
// 扩展——https://developer.chrome.com/extensions, https://developer.chrome.com/extensions/api_index | |
// 应用——https://developer.chrome.com/apps, https://developer.chrome.com/apps/api_index | |
// APIs: http://www.ituring.com.cn/article/75729 | |
{ | |
"app": { // 谷歌应用配置 | |
"background": { // 定义应用后台脚本: http://www.ituring.com.cn/article/74020 | |
"scripts": ["background.js"] // 应用后台脚本,可以创建应用窗口: http://www.ituring.com.cn/article/74058 | |
} | |
}, | |
"manifest_version": 2, // 固定,当前为2 | |
"name": "My Extension", // 扩展名,显示于扩展管理页面 | |
"version": "versionString", // 扩展版本 | |
"default_locale": "en", // | |
"description": "A plain text description", // 扩展描述,显示于扩展管理页面 | |
"icons": { | |
"16": "images/icon16.png", // 右键菜单图标,或Omnibox地址栏图标 | |
"48": "images/icon48.png", | |
"128": "images/icon128.png" | |
}, | |
"browser_action": { // 扩展在工具栏中的行为 | |
"default_icon": { // 不指定时显示默认图标 | |
"19": "images/icon19.png", // 工具栏中的扩展图标,使用chrome.browserAction.setIcon(details, callback)方法可以动态修改图标 | |
"38": "images/icon38.png" // 视网膜屏时使用的图标 | |
}, | |
"default_title": "Extension Title", // 扩展标题,鼠标移到扩展图标上时显示,动态修改:chrome.browserAction.setTitle({title: 'This is a new title'}); | |
"default_popup": "popup.html" // 扩展弹出页面,鼠标点击扩展时显示的页面 | |
// badge: Badge目前只能够通过JavaScript设定显示的内容,同时Chrome还提供了更改badge背景的方法。如果不定义badge的背景颜色,默认将使用红色 | |
// chrome.browserAction对象有两个方法,设置背景色setBadgeBackgroundColor({color: '#0000FF'})、设置文字(最长4字节)setBadgeText({text: 'Dog'}) | |
}, | |
"page_action": { | |
"default_icon": { | |
"19": "images/icon19.png", | |
"38": "images/icon38.png" | |
}, | |
"default_title": "Extension Title", | |
"default_popup": "popup.html" | |
}, | |
"background": { // 常驻后台脚本 | |
"scripts": ["background.js"], // 扩展启动时自动创建一个页面,包含所有指定的脚本 | |
"page": "", // 将指定的HTML文件作为后台页面运行,通常无需设置 | |
"persistent": "" // 常驻后台的方式,true表示一直在后台运行;false表示在后台按需运行,即event-page,如非必要,请将persistent设置为false。persistent的默认值为true。 | |
}, | |
"content_scripts": [ // 页面注入的脚本/样式表 | |
{ | |
"matches": ["http://www.google.com/*"], // 匹配时注入 | |
"exclude_matches": [""], // 匹配时不注入 | |
"run_at": [""], // 何时注入 | |
"all_frames": "", // 是否会注入到嵌入式框架中 | |
"include_globs": [""], // 全局URL匹配 | |
"exclude_globs": [""], // 全局URL匹配 | |
"css": ["mystyles.css"], // 注入的样式表 | |
"js": ["jquery.js", "myscript.js"] // 注入的脚本 | |
} | |
], | |
"options_page": "options.html", // 选项页面,扩展上右键菜单中的选项 | |
"permissions": [ // 权限声明 | |
"<all_urls>", // 允许跨域访问任意地址 | |
"*://www.google.com/*", // 允许跨域访问(包括发异步请求、访问cookie、操作网络请求等) | |
"background", // 打开浏览器之前就让扩展运行,慎用,相当于开机启动 | |
"unlimitedStorage", // 开启localStorage无限存储 | |
"storage", // 启用Chrome存储API,chrome.storage.[[StorageArea]].get、getBytesInUse、set、remove、clear,StorageArea必须指定为local或sync中的一个,chrome.storage.onChanged.addListener | |
"contextMenus", // 右键菜单,含create、update和remove三种方法,可创建普通菜单、复选菜单、单选菜单和分割线 ref:http://www.ituring.com.cn/article/65657, https://developer.chrome.com/extensions/contextMenus | |
"notifications", // 桌面提醒,https://developer.chrome.com/extensions/notifications 桌面提醒窗口提供了四种事件:ondisplay、onerror、onclose和onclick | |
"bookmarks", // 访问书签,书签对象有8个属性,分别是id、parentId、index、url、title、dateAdded、dateGroupModified和children。 ref: http://www.ituring.com.cn/article/65987 | |
"cookies", // 管理cookie, chrome.cookies.get/getAll/set/remove/getAllCookieStores/onChanged.addListener ref: http://www.ituring.com.cn/article/66054 | |
"history", // 访问历史记录 chrome.history.search/getVisits/addUrl/deleteUrl/deleteRange/deleteAll。 ref: http://www.ituring.com.cn/article/66064 | |
"management", // 管理扩展 chrome.management.getAll/get。 ref: http://www.ituring.com.cn/article/66195 | |
"tabs", // 管理标签页。 ref: http://www.ituring.com.cn/article/66275 | |
"activeTab", // 访问活动标签,截图时需要(chrome.tabs.captureVisibleTab) | |
"downloads", // 管理下载行为: http://developer.chrome.com/extensions/downloads | |
"webRequest", // 对网络请求进行操作: http://www.ituring.com.cn/article/72769 , http://developer.chrome.com/extensions/webRequest | |
"webRequestBlocking", // 阻止网络请求 | |
"proxy", // 使用代理: http://www.ituring.com.cn/article/72770 | |
"system.cpu", // 获取cpu信息 | |
"system.memory", // 获取内存信息 | |
"system.storage", // 获取存储设备信息 | |
"system.display", // 显示器 | |
"system.network", // 网卡 | |
"fileSystem", // 在应用中使用FileSystem API: http://www.ituring.com.cn/article/74590 http://www.w3.org/TR/file-system-api/ | |
{"fileSystem": ["write", "directory"]}, // 应用可写入文件和获取目录 | |
{"mediaGalleries": ["read", "allAutoDetected", "delete", "copyTo"]}, // 操作计算机中的媒体库: http://www.ituring.com.cn/article/75449 | |
"usb", // 操作usb: https://crxdoc-zh.appspot.com/apps/usb | |
"tts", // 文字转语音: http://www.ituring.com.cn/article/75450 | |
], | |
"web_accessible_resources": [ // 允许桌面提醒访问的域 | |
"images/*.png" | |
], | |
"omnibox": { // 使用地址栏 方法:setDefaultSuggestion,四种事件:onInputStarted、onInputChanged、onInputEntered和onInputCancelled。rel: https://developer.chrome.com/extensions/omnibox | |
"keyword": "google" // 设置关键词 | |
}, | |
"chrome_url_overrides" : { // override pages,一个扩展只能替换一个页面 | |
"bookmarks": "bookmarks.html", | |
"history": "history.html", | |
"newtab": "newtab.html" | |
}, | |
"sandbox": { // 沙箱 | |
"pages": ["sandboxed.html"] // 设置要在沙箱中运行的页面 | |
}, | |
"sockets": { // 网络通信: http://www.ituring.com.cn/article/74714 | |
"udp": { // 使用udp协议: http://www.ituring.com.cn/article/74723 | |
"send": ["192.168.1.106:8000", ":8001"], // 通过UDP与192.168.1.106的8000端口通信,也可以与任意主机的8001端口通信 | |
"bind": [":8001"], // 绑定本地的8000端口用来接收UDP消息 | |
"multicastMembership": "*" // 多播 | |
}, | |
"tcp" : { // http://www.ituring.com.cn/article/74727 | |
"connect": ["host-pattern1"] | |
}, | |
"tcpServer" : { // 使Chrome应用可以作为TCP服务器: http://www.ituring.com.cn/article/74729 | |
"listen": [":80"] | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment