Process iframe data in the popup, remove vestigal code
This commit is contained in:
parent
269dddc92e
commit
860f075570
@ -171,74 +171,76 @@ export default {
|
|||||||
this.tabs.find(x => x.id === 'changelog').highlight = !this.settings.active?.whatsNewChecked;
|
this.tabs.find(x => x.id === 'changelog').highlight = !this.settings.active?.whatsNewChecked;
|
||||||
},
|
},
|
||||||
async created() {
|
async created() {
|
||||||
this.logger = new Logger();
|
try {
|
||||||
await this.logger.init({
|
this.logger = new Logger();
|
||||||
allowLogging: true,
|
await this.logger.init({
|
||||||
});
|
allowLogging: true,
|
||||||
|
|
||||||
this.settings = new Settings({afterSettingsSaved: () => this.updateConfig(), logger: this.logger});
|
|
||||||
await this.settings.init();
|
|
||||||
this.settingsInitialized = true;
|
|
||||||
|
|
||||||
// const port = chrome.runtime.connect({name: 'popup-port'});
|
|
||||||
// port.onMessage.addListener( (m,p) => this.processReceivedMessage(m,p));
|
|
||||||
// CSM.setProperty('port', port);
|
|
||||||
|
|
||||||
this.eventBus = new EventBus();
|
|
||||||
this.eventBus.subscribe(
|
|
||||||
'set-current-site',
|
|
||||||
{
|
|
||||||
source: this,
|
|
||||||
function: (config, context) => {
|
|
||||||
if (this.site) {
|
|
||||||
if (!this.site.host) {
|
|
||||||
// dunno why this fix is needed, but sometimes it is
|
|
||||||
this.site.host = config.site.host;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.site = config.site;
|
|
||||||
// this.selectedSite = this.selectedSite || config.site.host;
|
|
||||||
this.siteSettings = this.settings.getSiteSettings(this.site.host);
|
|
||||||
|
|
||||||
this.eventBus.setupPopupTunnelWorkaround({
|
|
||||||
origin: CommsOrigin.Popup,
|
|
||||||
comms: {
|
|
||||||
forwardTo: 'active'
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
this.loadFrames(this.site);
|
|
||||||
|
|
||||||
}
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
this.comms = new CommsClient('popup-port', this.logger, this.eventBus);
|
|
||||||
this.eventBus.setComms(this.comms);
|
|
||||||
this.eventBus.setupPopupTunnelWorkaround({
|
|
||||||
origin: CommsOrigin.Popup,
|
|
||||||
comms: {forwardTo: 'active'}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
// ensure we'll clean player markings on popup close
|
|
||||||
window.addEventListener("unload", () => {
|
|
||||||
CSM.port.postMessage({
|
|
||||||
cmd: 'unmark-player',
|
|
||||||
forwardToAll: true,
|
|
||||||
});
|
});
|
||||||
// if (BrowserDetect.anyChromium) {
|
|
||||||
// chrome.extension.getBackgroundPage().sendUnmarkPlayer({
|
|
||||||
// cmd: 'unmark-player',
|
|
||||||
// forwardToAll: true,
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
});
|
|
||||||
|
|
||||||
// get info about current site from background script
|
this.settings = new Settings({afterSettingsSaved: () => this.updateConfig(), logger: this.logger});
|
||||||
while (true) {
|
await this.settings.init();
|
||||||
this.requestSite();
|
this.settingsInitialized = true;
|
||||||
await this.sleep(5000);
|
|
||||||
|
// const port = chrome.runtime.connect({name: 'popup-port'});
|
||||||
|
// port.onMessage.addListener( (m,p) => this.processReceivedMessage(m,p));
|
||||||
|
// CSM.setProperty('port', port);
|
||||||
|
|
||||||
|
this.eventBus = new EventBus();
|
||||||
|
this.eventBus.subscribe(
|
||||||
|
'set-current-site',
|
||||||
|
{
|
||||||
|
source: this,
|
||||||
|
function: (config, context) => {
|
||||||
|
if (this.site) {
|
||||||
|
if (!this.site.host) {
|
||||||
|
// dunno why this fix is needed, but sometimes it is
|
||||||
|
this.site.host = config.site.host;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.site = config.site;
|
||||||
|
// this.selectedSite = this.selectedSite || config.site.host;
|
||||||
|
this.siteSettings = this.settings.getSiteSettings(this.site.host);
|
||||||
|
this.eventBus.setupPopupTunnelWorkaround({
|
||||||
|
origin: CommsOrigin.Popup,
|
||||||
|
comms: {
|
||||||
|
forwardTo: 'active'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
this.loadFrames(this.site);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
this.comms = new CommsClient('popup-port', this.logger, this.eventBus);
|
||||||
|
this.eventBus.setComms(this.comms);
|
||||||
|
this.eventBus.setupPopupTunnelWorkaround({
|
||||||
|
origin: CommsOrigin.Popup,
|
||||||
|
comms: {forwardTo: 'active'}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// ensure we'll clean player markings on popup close
|
||||||
|
window.addEventListener("unload", () => {
|
||||||
|
CSM.port.postMessage({
|
||||||
|
cmd: 'unmark-player',
|
||||||
|
forwardToAll: true,
|
||||||
|
});
|
||||||
|
// if (BrowserDetect.anyChromium) {
|
||||||
|
// chrome.extension.getBackgroundPage().sendUnmarkPlayer({
|
||||||
|
// cmd: 'unmark-player',
|
||||||
|
// forwardToAll: true,
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
});
|
||||||
|
|
||||||
|
// get info about current site from background script
|
||||||
|
while (true) {
|
||||||
|
this.requestSite();
|
||||||
|
await this.sleep(5000);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.error('[Popup.vue::created()] An error happened:', e)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async updated() {
|
async updated() {
|
||||||
@ -288,62 +290,26 @@ export default {
|
|||||||
selectTab(tab) {
|
selectTab(tab) {
|
||||||
this.selectedTab = tab;
|
this.selectedTab = tab;
|
||||||
},
|
},
|
||||||
processReceivedMessage(message, port) {
|
|
||||||
this.logger.log('info', 'popup', '[popup::processReceivedMessage] received message:', message)
|
|
||||||
|
|
||||||
if (message.command === 'set-current-site'){
|
|
||||||
if (this.site) {
|
|
||||||
if (!this.site.host) {
|
|
||||||
// dunno why this fix is needed, but sometimes it is
|
|
||||||
this.site.host = site.tabHostname;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.site = message.site;
|
|
||||||
|
|
||||||
// update activeSites
|
|
||||||
// this.activeSites = this.activeSites.filter(x => x.host !== message.site);
|
|
||||||
|
|
||||||
// add current site
|
|
||||||
// this.activeSites = unshift({
|
|
||||||
// host: message.site.host,
|
|
||||||
// isIFrame: false, // currently unused
|
|
||||||
// });
|
|
||||||
this.selectedSite = this.selectedSite || message.site.host;
|
|
||||||
|
|
||||||
this.loadFrames(this.site);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
},
|
|
||||||
|
|
||||||
isDefaultFrame(frameId) {
|
isDefaultFrame(frameId) {
|
||||||
return frameId === '__playing' || frameId === '__all';
|
return frameId === '__playing' || frameId === '__all';
|
||||||
},
|
},
|
||||||
loadFrames() {
|
loadFrames(videoTab) {
|
||||||
this.activeSites = [{
|
this.activeFrames = [{
|
||||||
host: this.site.host,
|
host: this.site.host,
|
||||||
isIFrame: false, // not used tho. Maybe one day
|
isIFrame: false, // not used tho. Maybe one day
|
||||||
}];
|
}];
|
||||||
this.selectedSite = this.selectedSite || this.site.host;
|
|
||||||
|
|
||||||
// for (const frame in videoTab.frames) {
|
|
||||||
// this.activeFrames.push({
|
|
||||||
// id: `${this.site.id}-${frame}`,
|
|
||||||
// label: videoTab.frames[frame].host,
|
|
||||||
// ...this.frameStore[frame],
|
|
||||||
// })
|
|
||||||
|
|
||||||
// // only add each host once at most
|
for (const frame in this.site.frames) {
|
||||||
// if (!this.activeSites.find(x => x.host === videoTab.frames[frame].host)) {
|
if (!this.activeFrames.find(x => x.host === this.site.frames[frame].host)) {
|
||||||
// this.activeSites.push({
|
this.activeFrames.push({
|
||||||
// host: videoTab.frames[frame].host,
|
id: `${this.site.id}-${frame}`,
|
||||||
// isIFrame: undefined // maybe one day
|
label: this.site.frames[frame].host,
|
||||||
// });
|
host: this.site.frames[frame].host,
|
||||||
// }
|
...this.site.frames[frame],
|
||||||
// }
|
})
|
||||||
|
};
|
||||||
// update whether video tab can be shown
|
}
|
||||||
// this.updateCanShowVideoTab();
|
|
||||||
},
|
},
|
||||||
getRandomColor() {
|
getRandomColor() {
|
||||||
return `rgb(${Math.floor(Math.random() * 128)}, ${Math.floor(Math.random() * 128)}, ${Math.floor(Math.random() * 128)})`;
|
return `rgb(${Math.floor(Math.random() * 128)}, ${Math.floor(Math.random() * 128)}, ${Math.floor(Math.random() * 128)})`;
|
||||||
|
Loading…
Reference in New Issue
Block a user