Chrome扩展内容脚本

Chrome extension content script

本文关键字:脚本 扩展 Chrome      更新时间:2023-09-26

我想在内容页面上使用一个插件,这是我的代码:

清单

{
    "manifest_version": 2,
    "name": "Test",
    "description": "foo",
    "version": "1.0",
    "browser_action": {
        "default_icon": "icon.png",
        "default_popup": "popup.html"
    },
    "options_ui": {
        "page": "options.html",
        "chrome_style": true
    },
    "permissions": [
        "activeTab",
        "storage",
        "https://google.com/*"
    ],
    "content_scripts": [{
        "matches": ["http://google.com/*"],
        "js": ["jquery-3.1.0.min.js", "simply-toast.min.js"],
        "css": ["simply-toast.min.css"],
        "run_at": "document_end"
    }]
}

content.js

...
$.simplyToast('success', 'This is a success message!'); // Line 72

jQuery运行良好,但我在尝试simpleToast content.js:72 Uncaught TypeError: $.simplyToast is not a function时遇到此错误。不确定我在这里错过了什么。

我猜语法不对!

$.simplyToast('This is a success message', 'success'); // Line 72