Chrome 拡張機能の作成方法をまだ学習中ですが、問題はデスクトップ通知にあります。通知をトリガーすることはできますが、たとえば、コンテンツ スクリプト 1 のデスクトップ通知をトリガーします。コンテンツ スクリプト 2 のデスクトップ通知もトリガーします。同時にトリガーしないようにするにはどうすればよいですか。呼ばれた時だけ?
背景ページ
chrome.extension.onRequest.addListener(function(request, sender, sendResponse) {
// Create a simple text notification
var notifyWinner = webkitNotifications.createNotification('48.png', 'Notification', request.winnerMessage);
notifyWinner.show();
setTimeout(function(){ notifyWinner.cancel(); },10000);
});
chrome.extension.onRequest.addListener(function(request, sender, sendResponse) {
// Create a simple text notification
var notifyVideo = webkitNotifications.createNotification('48.png', 'Notification', request.videoMessage);
notifyVideo.show();
setTimeout(function(){ notifyVideo.cancel(); },10000);
});
コンテンツ スクリプト 1
chrome.extension.sendRequest({winnerMessage: "You won!!!"}, function(response) {
return response;
});
コンテンツ スクリプト 2
chrome.extension.sendRequest({videoMessage: "There is a video" + videoURL}, function(response) {
return response;
});