I have problem, how send message to ContentScript after attach in PageMod.
this script in index.js
pageMod.PageMod({
include: "*.pinterest.com",
contentStyleFile:[
self.data.url("css/css.css"),
self.data.url("css/loading.css")
],
contentScriptFile:
[
self.data.url("plugins/jquery-2.2.0.min.js"),
self.data.url("plugins/zepto.js"),
self.data.url("plugins/jquery.waterfall.js"),
self.data.url("myscript.js")
],
attachTo: ["existing", "top"],
onAttach: function(worker) {
worker.port.emit('pre-html', {
modal: self.data.load('html/modal.html')
});
}
});
this script in myscript.js
self.port.on("modal", function (nows) {
now = nows;
if(now.flag == null){
now.flag = false;
}else{
if(done == null){
now.flag = false;
}
}
done = now.flag;
if (now.now == 'open') {
card = now.card;
$(modal).addClass("tp-modal-open");
$('body').addClass("tp-no-scroll");
if ( ! done) {
$('.tp-count-card').text(0);
firstPaginate(function() {
handleAjaxPaging();
handleEventModal();
handleReload();
handleScroll();
handleFilter();
});
}
else {
$("#thepin-modal").find(".tp-modal-box").addClass("tp-show-results");
setTimeout(function() {
$('#grid-modal').addClass('tp-grid-show');
}, 600);
}
}
});
how to send message to myscript.js but without attach file myscript.js again.
this part script in index.js
var worker = tabs.activeTab.attach({
contentScriptWhen: "start",
contentScriptFile: [
self.data.url("myscript.js")
]
});
worker.port.emit("modal", {now: 'open', card:self.data.load('html/card.html'), flag:flag});