May now work on firefox...hopefully

This commit is contained in:
Satsuoni 2021-08-06 18:22:59 +09:00
parent 9e6cc99df8
commit 5cbf7693b6
2 changed files with 8 additions and 4 deletions

View File

@ -30,8 +30,9 @@ function sendMessagePromise( item) {
var event = new CustomEvent("PassToBackground", {detail: {item:item,id:id}});
window.dispatchEvent(event);
window.addEventListener("BackgroundReply_"+id, function(evt) {
if(evt.detail.value) {
resolve(evt.detail.value);
if(evt.detail) {
resolve(evt.detail);
} else {
reject('Something wrong');
}

View File

@ -1,7 +1,10 @@
window.addEventListener("PassToBackground", function(evt) {
chrome.runtime.sendMessage(evt.detail.item,response => {
var event = new CustomEvent("BackgroundReply_"+evt.detail.id, {detail: response});
window.dispatchEvent(event);});
var val=response.value;
if (!val) val=null;
var event = new CustomEvent("BackgroundReply_"+evt.detail.id, {detail: val});
window.dispatchEvent(event);}
);
}, false);
injectScripts();