Здесь у меня самое простое расширение для Chrome. Я заметил, что JQuery, похоже, не выполняется в моем скрипте контента. Тем не менее, обычный JavaScript работает просто отлично. Мне интересно, что может помешать выполнению JQuery.
манифест
{
"manifest_version": 2,
"name": "test",
"version": "1.0",
"description": "test",
"background": {
"scripts": ["popup.js"]
},
"content_scripts": [{
"matches": ["http://*/*", "https://*/*"],
"js": ["jquery.js", "content.js"]
}]
}
popup.js
chrome.runtime.onMessage.addListener(function (response, sender,
sendResponse)
{
alert("test");
alert(response.test.toString());
});
скрипт содержания
chrome.runtime.sendMessage({test:
$(".chapters").first().innerHTML.toString()}, function(response){});
//document.getElementsByClassName("chapters")[0].innerHTML.toString()} works
just fine