0
Chrome拡張機能の作成方法はまだ習っていますが、デスクトップ通知で問題が発生しています。私は通知をトリガすることができますが、例えばコンテンツスクリプト1のデスクトップ通知をトリガするときに発生します。デスクトップ通知はコンテンツスクリプト2のトリガも行います。同時にそれらがトリガしないようにする方法彼らが呼ばれた時だけ?一度にChrome拡張機能のデスクトップ通知を1つ送信する
背景ページ
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;
});
は非推奨とのonMessageとのsendMessageに交換する必要がされている私は –
onRequestとのsendRequestを達成しようとしたまさにあなたに感謝します – DivZero