{
    "manifest": {
        "manifest_version": 2,
        "name": "Yomichan",
        "version": "20.12.31.0",
        "description": "Japanese dictionary with Anki integration",
        "author": "Alex Yatskov",
        "icons": {
            "16": "mixed/img/icon16.png",
            "19": "mixed/img/icon19.png",
            "32": "mixed/img/icon32.png",
            "38": "mixed/img/icon38.png",
            "48": "mixed/img/icon48.png",
            "64": "mixed/img/icon64.png",
            "128": "mixed/img/icon128.png"
        },
        "browser_action": {
            "default_icon": {
                "16": "mixed/img/icon16.png",
                "19": "mixed/img/icon19.png",
                "32": "mixed/img/icon32.png",
                "38": "mixed/img/icon38.png",
                "48": "mixed/img/icon48.png",
                "64": "mixed/img/icon64.png",
                "128": "mixed/img/icon128.png"
            },
            "default_title": "Yomichan",
            "default_popup": "bg/context.html"
        },
        "background": {
            "page": "bg/background.html",
            "persistent": true
        },
        "content_scripts": [
            {
                "matches": [
                    "http://*/*",
                    "https://*/*",
                    "file://*/*"
                ],
                "js": [
                    "mixed/js/core.js",
                    "mixed/js/yomichan.js",
                    "mixed/js/comm.js",
                    "mixed/js/api.js",
                    "mixed/js/dynamic-loader.js",
                    "mixed/js/frame-client.js",
                    "mixed/js/text-scanner.js",
                    "mixed/js/document-util.js",
                    "fg/js/dom-text-scanner.js",
                    "fg/js/popup.js",
                    "fg/js/text-source-range.js",
                    "fg/js/text-source-element.js",
                    "fg/js/popup-factory.js",
                    "fg/js/frame-offset-forwarder.js",
                    "fg/js/popup-proxy.js",
                    "fg/js/popup-window.js",
                    "fg/js/frontend.js",
                    "fg/js/content-script-main.js"
                ],
                "match_about_blank": true,
                "all_frames": true
            }
        ],
        "minimum_chrome_version": "57.0.0.0",
        "options_ui": {
            "page": "bg/settings.html",
            "open_in_tab": true
        },
        "sandbox": {
            "pages": [
                "bg/template-renderer.html"
            ],
            "content_security_policy": "sandbox allow-scripts; default-src 'self'; script-src 'self' 'unsafe-eval'"
        },
        "permissions": [
            "<all_urls>",
            "storage",
            "clipboardWrite",
            "unlimitedStorage",
            "nativeMessaging",
            "webRequest",
            "webRequestBlocking"
        ],
        "optional_permissions": [
            "clipboardRead"
        ],
        "commands": {
            "toggleTextScanning": {
                "suggested_key": {
                    "default": "Alt+Delete"
                },
                "description": "Toggle text scanning on/off"
            },
            "openHelpPage": {
                "description": "Open the help page"
            },
            "openSettingsPage": {
                "description": "Open the settings page"
            },
            "openSearchPage": {
                "suggested_key": {
                    "default": "Alt+Insert"
                },
                "description": "Open the search page"
            },
            "openPopupWindow": {
                "description": "Open the popup window"
            }
        },
        "web_accessible_resources": [
            "fg/float.html",
            "bg/template-renderer.html"
        ],
        "content_security_policy": "default-src 'self'; style-src 'self' 'unsafe-inline'; media-src *; connect-src *"
    },
    "variants": [
        {
            "name": "chrome",
            "fileName": "yomichan-chrome.zip",
            "excludeFiles": [
                "sw.js",
                "bg/js/simple-dom-parser.js",
                "mixed/lib/parse5.js"
            ]
        },
        {
            "name": "chrome-dev",
            "fileName": "yomichan-chrome-dev.zip",
            "modifications": [
                {
                    "action": "replace",
                    "path": ["name"],
                    "pattern": "^.*$",
                    "patternFlags": "",
                    "replacement": "$& (development build)"
                },
                {
                    "action": "replace",
                    "path": ["description"],
                    "pattern": "^(.*)(?:\\.\\s*)?$",
                    "patternFlags": "",
                    "replacement": "$1. This is a development build; get the stable version here: https://tinyurl.com/yaatdjmp"
                }
            ],
            "excludeFiles": [
                "sw.js",
                "bg/js/simple-dom-parser.js",
                "mixed/lib/parse5.js"
            ]
        },
        {
            "name": "chrome-mv3",
            "fileName": "yomichan-chrome-mv3.zip",
            "modifications": [
                {"action": "set",    "path": ["manifest_version"], "value": 3},
                {"action": "move",   "path": ["browser_action"], "newPath": ["action"]},
                {"action": "delete", "path": ["background", "page"]},
                {"action": "delete", "path": ["background", "persistent"]},
                {"action": "set",    "path": ["background", "service_worker"], "value": "sw.js"},
                {"action": "move",   "path": ["content_security_policy"], "newPath": ["content_security_policy_old"]},
                {"action": "set",    "path": ["content_security_policy"], "value": {}},
                {"action": "move",   "path": ["content_security_policy_old"], "newPath": ["content_security_policy", "extension_pages"]},
                {"action": "move",   "path": ["sandbox", "content_security_policy"], "newPath": ["content_security_policy", "sandbox"]},
                {"action": "remove", "path": ["permissions"], "item": "<all_urls>"},
                {"action": "remove", "path": ["permissions"], "item": "webRequest"},
                {"action": "remove", "path": ["permissions"], "item": "webRequestBlocking"},
                {"action": "add",    "path": ["permissions"], "items": ["declarativeNetRequest", "scripting"]},
                {"action": "set",    "path": ["host_permissions"], "value": ["<all_urls>"], "after": "optional_permissions"},
                {"action": "move",   "path": ["web_accessible_resources"], "newPath": ["web_accessible_resources_old"]},
                {"action": "set",    "path": ["web_accessible_resources"], "value": [{"resources": [], "matches": ["<all_urls>"]}], "after": "web_accessible_resources_old"},
                {"action": "move",   "path": ["web_accessible_resources_old"], "newPath": ["web_accessible_resources", 0, "resources"]}
            ],
            "excludeFiles": [
                "bg/background.html",
                "bg/js/native-simple-dom-parser.js"
            ]
        },
        {
            "name": "firefox",
            "fileName": "yomichan-firefox.xpi",
            "modifications": [
                {
                    "action": "remove",
                    "path": ["web_accessible_resources"],
                    "item": "bg/template-renderer.html"
                },
                {
                    "action": "delete",
                    "path": ["sandbox"]
                },
                {
                    "action": "set",
                    "path": ["content_security_policy"],
                    "value": "default-src 'self'; script-src 'self' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *; connect-src *"
                },
                {
                    "action": "set",
                    "path": ["browser_specific_settings"],
                    "value": {
                        "gecko": {
                            "id": "alex@foosoft.net",
                            "strict_min_version": "57.0"
                        }
                    }
                }
            ],
            "excludeFiles": [
                "sw.js",
                "bg/js/simple-dom-parser.js",
                "mixed/lib/parse5.js"
            ]
        },
        {
            "name": "firefox-dev",
            "inherit": "firefox",
            "fileName": "yomichan-firefox-dev.xpi",
            "modifications": [
                {
                    "action": "replace",
                    "path": ["name"],
                    "pattern": "^.*$",
                    "patternFlags": "",
                    "replacement": "$& (development build)"
                },
                {
                    "action": "replace",
                    "path": ["description"],
                    "pattern": "^(.*)(?:\\.\\s*)?$",
                    "patternFlags": "",
                    "replacement": "$1. This is a development build; get the stable version here: https://tinyurl.com/yaatdjmp"
                },
                {
                    "action": "set",
                    "path": ["browser_specific_settings", "gecko", "id"],
                    "value": "alex.testing@foosoft.net"
                }
            ],
            "excludeFiles": [
                "sw.js",
                "bg/js/simple-dom-parser.js",
                "mixed/lib/parse5.js"
            ]
        }
    ]
}