我正在尝试简单地创建Firefox WebExtensions,它将打开我的html页面并在其上执行一些脚本。 据我所知,当我想在页面上使用脚本时,我必须在manifest.json文件中声明content_scripts并为页面地址创建模式。 如何从我的扩展目录中的文件“table.html”中为页面编写模式? 这是我开始这个页面的代码: 的的manifest.json
{
"manifest_version": 2,
"name": "LightDials",
"version": "1.0",
"description": "Something",
"icons": {
"48": "icons/LightDials_48.png",
"96": "icons/LightDials_96.png"
},
"permissions": [
"activeTab",
"alarms",
//"background",
"bookmarks",
"browserSettings",
"browsingData",
//"contentSettings",
"contextMenus",
"contextualIdentities",
"cookies",
//"debugger",
"downloads",
"downloads.open",
"find",
"geolocation",
"history",
"identity",
"idle",
"management",
"menus",
"nativeMessaging",
"notifications",
//"pageCapture",
"pkcs11",
"privacy",
"proxy",
"sessions",
"storage",
"tabs",
"theme",
"topSites",
"webNavigation",
"webRequest",
"webRequestBlocking"
],
"background": {
"scripts": [ "background.js" ]
},
"content_scripts": [
{
"matches": ["*://table.html/*"],
"js": [ "page-eater.js" ]
}
],
"browser_action": {
"default_icon": "icons/LightDials_32.png",
"default_title": "LightDials"
},
"applications": {
"gecko": {
"id": "kloshar13@yahoo.com",
"strict_min_version": "45.0"
}
},
}
background.js
function openPage() {
browser.tabs.update({
url: "table.html"
});
}
browser.browserAction.onClicked.addListener(openPage);
答案 0 :(得分:0)
您只需编辑table.html并添加脚本标记:
<script src="relative/path/filename.js"></script>