我開發了一個適用於Windows操作系統的google chrome擴展。但這並不與Mac的工作問題,我想查這個問題,我發現功能Chrome擴展程序「executeScript」不適用於mac
chrome.tabs.executeScript
在Mac上是不行的,這是完全的代碼與Windows不支持Mac工作好。
// 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谷歌瀏覽器沒有啓動。
"content_scripts": [
{
"matches": ["http://*/*","https://*/*"],
"js" : ["jquery.min.js","fix.js","injscript.js"],
"all_frames": false
}
],
操作系統:Mac 10.8山獅 - 谷歌瀏覽器V 32