Я разрабатываю плагин chrome и получаю XXX не определено ... newb ie ошибка ...
мой манифест
"background": { "scripts": ["js/bg.js"] },
"content_scripts": [{
"matches": [
"https://XXXXXX.com/*"
],
"js": ["js/jquery.js", "js/contentParser.js"]
затем мой contentParser ( только порция):
function ContentParser(app){
this.loaded = 0;
this.setting = null;
this.clicking = false;
this.selectedLanguages = false;
this.click = function(object){
var clickEvent = document.createEvent ("MouseEvent");
clickEvent.initMouseEvent (
"click", true, true, window, 0,
0, 0, 0, 0,
false, false, false, false,
0, null
);
object.dispatchEvent (clickEvent);
};
var self = this;
$.get(chrome.runtime.getURL('setting.json'), null, function(data){
self.setting = data;
}, 'json');
}
мой BG. js
function checkForValidUrl(tabId, changeInfo, tab) {
if (tab.url.indexOf('https://xxxxx.xxxxxxxx.xxx') > -1) {
chrome.pageAction.show(tabId);
}
}
chrome.pageAction.onClicked.addListener(function(tab) {
chrome.tabs.executeScript(null, {file: "js/translate.js"});
});
chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab){
checkForValidUrl(tabId, changeInfo, tab);
if(changeInfo.status === 'complete'){
chrome.tabs.executeScript(null, {file: "js/init.js"});
}
});
, тогда ошибка приходит на моем init. js, ContentParser подчеркивается:
Uncaught ReferenceError: ContentParser не определен
if(typeof document.behouse != 'object'){
alert ('creem objecte');
document.contentParser = new ContentParser(this); // ERROR HERE
document.contentParser.loaded++;
}
, как вы можете видеть ContentParser. js уже в content_scripts, что я делаю не так?