Windows OS와 잘 작동하는 Google 크롬 확장 프로그램을 개발했습니다. 하지만 맥에서 작동하지 않는 문제가, 내가 Mac에서 작동하지 않는 기능을 Chrome 확장 프로그램 'executeScript'가 Mac에서 작동하지 않습니다.
chrome.tabs.executeScript
을 발견,이 문제를 확인하려고,이 창하지 맥과 함께 좋은 일을 완전히 코드입니다.
// The onClicked callback function.
function onClickHandler(info, tab) {
// the problem in injecting code
chrome.tabs.executeScript
(null,{code:"var activeElm = document.activeElement; var inp_text = activeElm.value; console.log(activeElm.value);"});
};
chrome.contextMenus.onClicked.addListener(onClickHandler);
// Set up context menu tree at install time.
chrome.runtime.onInstalled.addListener(function() {
// Intentionally create an invalid item, to show off error checking in the
// create callback.
console.log("About to try creating an invalid item - an error about " +
"duplicate item child1 should show up");
chrome.contextMenus.create({"title": "consoleMe", "id": "child523", "contexts":["selection"]}, function() {
if (chrome.extension.lastError) {
console.log("Got expected error: " + chrome.extension.lastError.message);
}
});
});
힌트 :
나는 매니페스트 파일에 content_scripts 주입 파일을 사용하지만, Mac의 경우 Google 크롬에 활성화되지 않은 것 같다.
"content_scripts": [
{
"matches": ["http://*/*","https://*/*"],
"js" : ["jquery.min.js","fix.js","injscript.js"],
"all_frames": false
}
],
OS : 맥 10.8 산 사자 - 구글 크롬 V (32)