이 기능이 작동하지 않는 이유는 Chrome 확장 프로그램 (일반적으로 콘텐츠 스크립트)에 의해 추가 된 JavaScript가 페이지가로드되는 JavaScript 환경에 대한 액세스 권한이없는 자체 샌드 박스에서 실행되기 때문입니다 . 당신의 목표는 진정으로 래핑하는 것입니다
Here are some examples of what content scripts can do:
* Find unlinked URLs in web pages and convert them into hyperlinks
* Increase the font size to make text more legible
* Find and process microformat data in the DOM
However, content scripts have some limitations. They cannot:
* Use chrome.* APIs (except for parts of chrome.extension)
* Use variables or functions defined by their extension's pages
* Use variables or functions defined by web pages or by other content scripts
경우/기본 자바 스크립트/DOM 액세스 메소드를 오버라이드 (override) (싸, 나쁜 것), 다음 방법 중 하나 : 여기
는
Chrome Extension에서 온 자바 스크립트의 한계는 페이지의 컨텍스트에서 JavaScript를 실행하려면 외부에서 호스팅되는 JavaScript 파일 인 a 그런 다음 Chrome 확장 프로그램을 사용하여 외부 호스팅 파일을 참조하는 페이지의 DOM에
script
요소를 추가합니다. 이 방식으로 삽입되는 자바 스크립트는 페이지 JavaScript 환경에서 실행됩니다 (즉, Chrome 확장 프로그램에서 사용할 수 없음).
document.body.appendChild(document.createElement("script")).src = "http://externally/hosted/javascript.js";
그런 다음
http://externally/hosted/javascript.js
에있는 파일에 자바 스크립트 코드는 위가 코드 수 :
크롬 확장 자바 스크립트 뭔가 같이 할 것이다.