這是我的package.json,但我的background.js沒有在後臺運行。我一直在嘗試不同的東西,但一直未能弄清楚。在此先感謝您的幫助,如何獲得Chrome擴展的內容腳本在後臺?
{
"manifest_version": 2,
"name": "Focus",
"version": "1.9.3",
"description": "Block distracting websites and get inspired to focus on what's important",
"background_page": "background.html",
"icons": {
"16": "inspirelogo16.png",
"48": "inspirelogo48.png",
"128": "inspirelogo128.png"
},
"browser_action": {
"default_icon": "inspirelogo19.png",
"default_title": "Inspire Router",
"default_popup": "/pages/popup.html"
},
"permissions": [
"background",
"notifications",
"tabs",
"<all_urls>",
"webRequest",
"*://*.google.com/"
],
"background": {
"scripts": [
"background.js"
],
"content_scripts": [
{
"matches": ["<all_urls>"],
"js": ["background.js"]
}
],
"persistent": true
},
"options_page": "/pages/fieldpage.html",
"content_security_policy": "script-src 'self' 'unsafe-eval' chrome-extension://bjmcjeffnloaojffcbaekmcokegnejlf/pages/inspire.html http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js https://ssl.google-analytics.com/ga.js http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js https://connect.facebook.net https://www.facebook.com https://chrome.google.com https://chrome.google.com; object-src 'self'"
}
謝謝,那麼你如何在瀏覽器中的背景js文件來看,無論哪個頁面。 –
@YoniBinstock帶腳本標籤,照常。看到我的答案。 – minj
更新了回覆,是的,刪除我沒有抓住的'background_page' – Guig