일치에 JS를로드하지 content_script, 아무것도 내가 확장을 만들려고하고, 지금 거기에 대해 해요 ...Google 크롬에도 스택 오버 플로우의 주제를 많이 검색 한 후 URL
을이 오류를 해결하기 위해 저를 도왔 안타깝게도 콘솔에 'Hello, world!'가 기록되지 않습니다. content_scripts 파일에서.
manifest.json을
{
"manifest_version": 2,
"name": "Example",
"shortname": "exmpl",
"description": "__MSG_appDesc__",
"version": "0.0.1",
"default_locale": "en",
"author": "Mateus Akino",
"icons": {
"16": "i16x.png",
"48": "i48x.png",
"128": "i128x.png"
},
"homepage_url": "http://example.com/",
"browser_action": {
"default_icon": "i32x.png",
"default_popup": "popup.html"
},
"update_url": "http://example.com/update.xml",
"chrome_url_overrides": {
"newtab": "newtab.html"
},
"content_scripts": [{
"matches": ["*://*.youtube.com/*"],
"js": ["execute.js"],
"run_at": "document_end"
}],
"background": {
"scripts": ["background.js"]
},
"permissions": [
"activeTab", "tabs", "i18n", "management", "webNavigation", "<all_urls>"
]
}
execute.js
console.log("Hello, world!");
background.js
chrome.webNavigation.onHistoryStateUpdated.addListener(function (details) {
chrome.tabs.executeScript(null, {
file: "execute.js"
});
});
배경 페이지가 전혀 필요 없기 때문에 ['spfdone' 이벤트] (http://stackoverflow.com/a/32277150/)가 더 나은 해결책이라고 생각합니다. – wOxxOm
테스트 할 페이지가 있으며 'chrome.webNavigation.onHistoryStateUpdated.addListener'가 호출되도록 할 수 있습니까? –
@HaibaraAi 'console.log ("Test"); "를 추가하고 호출하지 않는 것 같습니다. – Mateus