Chrome 확장 프로그램에 웹 페이지 (콘텐츠 스크립트 포함)에 jQuery를 삽입하려고합니다.삽입 된 jQuery를 사용할 수 없습니다.
나는 시도하지만 저를 혼란스럽게합니다.
여기 내 manifest.json
입니다 :
{
"name": "test",
"description": "test content script.",
"version": "0.0.1",
"background": {
"scripts": ["jquery-1.10.2.js", "popup.js"]
},
"permissions": ["tabs", "notifications", "http://*/*", "https://*/*"],
"browser_action": {
"default_title": "test",
"default_icon": "icon.png"
},
"options_page": "manage.html",
"content_scripts": [
{
"matches": ["http://*/*", "https://*/*"],
"js": ["jquery-1.10.2.js"]
}
],
"manifest_version": 2
}
JQuery와 - 1.10.2.js :
/*jquery's orign code*/
console.log("end of jquery");
내가 콘솔 메시지를 볼 수 있지만 난 여전히 jQuery를 사용할 수 없습니다.
간단한 웹 사이트를 작성하고 <script>
태그를 추가하는 대신 콘텐츠 스크립트를 통해 jQuery를 포함하려고했습니다.
개발자 도구 콘솔에서 window.jQuery
또는 $("li").siblings()
을 입력합니다.
페이지에 jQuery를 포함하면 작동하지만 콘텐츠 스크립트가 삽입 된 경우 jQuery
은 정의되지 않음으로 표시됩니다.
왜 이런 일이 발생합니까?
jquery 파일 끝에 console.log ("end of jquery")를 추가하면 작동하지만 (jQuery의 메소드는 사용할 수 없음) – mirtac