Fixed popup for Chrome — or so it seems.

This commit is contained in:
Tamius Han 2018-01-27 20:13:23 +01:00
parent e51faaf934
commit 463dcc0692
3 changed files with 38 additions and 7 deletions

View File

@ -122,14 +122,28 @@ var _com_sendToEachFrame = async function(message, tabId) {
// pošlji sporočilce vsakemu okvirju, potisni obljubo v tabelo
// send message to every frame, push promise to array
var promises = [];
for(var frame in frames){
promises.push(browser.tabs.sendMessage(tabId, message, {frameId: frame.frameId}));
for(var frame of frames){
if(Debug.debug)
console.log("[Comms:_com_sendToEachFrame] we sending message to tab with id", tabId, ", frame with id", frame.frameId);
try{
promises.push(browser.tabs.sendMessage(tabId, message, {frameId: frame.frameId}));
}
catch(e){
if(Debug.debug)
console.log("[Comms:_com_sendToEachFrame] we sending message to tab with id", tabId, ", frame with id", frame.frameId);
}
}
// počakajmo, da so obljube izpolnjene.
// wait for all promises to be kept
var responses = await Promise.all(promises);
var responses = [];
for(var promise of promises){
var response = await promise;
if(response !== undefined)
responses.push(response);
}
if(Debug.debug)
console.log("[Comms::_com_sendToEveryFrame] we received responses from all frames", responses);

View File

@ -22,6 +22,7 @@ async function main(){
}
async function _uwbg_onTabSwitched(activeInfo){
BgVars.hasVideos = false;
if(Debug.debug)
console.log("[uw-bg::onTabSwitched] TAB CHANGED, GETTING INFO FROM MAIN TAB");
@ -29,6 +30,9 @@ async function _uwbg_onTabSwitched(activeInfo){
var videoFrameList = await Comms.sendToEach({"cmd":"has-videos"}, tabId);
if(Debug.debug)
console.log("[uw-bg::onTabSwitched] got list of frames and whether they have videos", videoFrameList);
// Pogledamo, če kateri od okvirjev vsebuje video. Da omogočimo pojavno okno je zadosti že
// en okvir z videom.
// <===[///]----------------------------[\\\]===>

View File

@ -101,7 +101,12 @@ function ghettoOnChange(){
var video = document.getElementsByTagName("video")[0];
if(video !== undefined){
GlobalVars.video = video;
Comms.sendToBackgroundScript({"cmd":"register-video"});
// try{
Comms.sendToBackgroundScript({"cmd":"register-video"});
// }
// catch(chromeIsShitError){
// cos firefox won't crap its bed if a promise comes back unfulfilled
}
}
}
@ -193,8 +198,12 @@ function receiveMessage(message, sender, sendResponse) {
if(BrowserDetect.usebrowser == "firefox")
return Promise.resolve({response: {"hasVideos": anyVideos }});
sendResponse({response: {"hasVideos":anyVideos}});
return true;
try{
sendResponse({response: {"hasVideos":anyVideos}});
return true;
}
catch(chromeIsShitError){}
return;
}
else if(message.cmd == "get-config"){
@ -216,7 +225,11 @@ function receiveMessage(message, sender, sendResponse) {
if(BrowserDetect.usebrowser == "firefox")
return Promise.resolve({response: config});
sendResponse({response: config});
try{
sendResponse({response: config});
}
catch(chromeIsShitError){};
return true;
}