Chrome 扩展(插件) 开发教程

    官方中文版教程

    Blog

    Github

    官方中文版教程

    Blog

    Github

    ## # Manifest 文件格式 每个扩展都有一个 JSON 格式的 manifest 文件,名为 manifest.json,来提供重要信息。 ### # 字段摘要 以下代码显示了扩展支持的 manifest 字段,以及指向讨论每个字段的页面的链接 (查看链接:manifest)。
    1. {
    2. // Required
    3. "manifest_version": 2,
    4. "name": "My Extension",
    5. "version": "versionString",
    6. // Recommended
    7. "default_locale": "en",
    8. "description": "A plain text description",
    9. "icons": {…},
    10. // Pick one (or none)
    11. "browser_action": {…},
    12. "page_action": {…},
    13. // Optional
    14. "action": …,
    15. "author": …,
    16. "automation": …,
    17. "background": {
    18. // Recommended
    19. "persistent": false,
    20. // Optional
    21. "service_worker":
    22. },
    23. "chrome_settings_overrides": {…},
    24. "chrome_ui_overrides": {
    25. "bookmarks_ui": {
    26. "remove_bookmark_shortcut": true,
    27. "remove_button": true
    28. }
    29. },
    30. "chrome_url_overrides": {…},
    31. "commands": {…},
    32. "content_capabilities": …,
    33. "content_scripts": [{…}],
    34. "content_security_policy": "policyString",
    35. "converted_from_user_script": …,
    36. "current_locale": …,
    37. "declarative_net_request": …,
    38. "devtools_page": "devtools.html",
    39. "event_rules": [{…}],
    40. "externally_connectable": {
    41. "matches": ["://.example.com/*"]
    42. },
    43. "file_browser_handlers": […],
    44. "file_system_provider_capabilities": {
    45. "configurable": true,
    46. "multiple_mounts": true,
    47. "source": "network"
    48. },
    49. "homepage_url": "http://path/to/homepage",
    50. "import": [{"id": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}],
    51. "incognito": "spanning, split, or not_allowed",
    52. "input_components": …,
    53. "key": "publicKey",
    54. "minimum_chrome_version": "versionString",
    55. "nacl_modules": […],
    56. "oauth2": …,
    57. "offline_enabled": true,
    58. "omnibox": {
    59. "keyword": "aString"
    60. },
    61. "optional_permissions": ["tabs"],
    62. "options_page": "options.html",
    63. "options_ui": {
    64. "chrome_style": true,
    65. "page": "options.html"
    66. },
    67. "permissions": ["tabs"],
    68. "platforms": …,
    69. "replacement_web_app": …,
    70. "requirements": {…},
    71. "sandbox": […],
    72. "short_name": "Short Name",
    73. "signature": …,
    74. "spellcheck": …,
    75. "storage": {
    76. "managed_schema": "schema.json"
    77. },
    78. "system_indicator": …,
    79. "tts_engine": {…},
    80. "update_url": "http://path/to/updateInfo.xml",
    81. "version_name": "aString",
    82. "web_accessible_resources": […]
    83. }
    - - - 关注 微信公众号「程序化思维」 获取最新 Chrome 插件开发教程。 mp_wechat 总览 使用后台脚本管理事件