Extension is not enabled for this site.
@@ -23,7 +22,7 @@
Extension is disabled for this site.
Controls will only work on content embedded from the following sites:
- {{frameSite.host}}
+ {{frameSite.host}}
@@ -118,17 +117,17 @@ export default {
'settings',
'siteSettings',
'eventBus',
- 'frames'
+ 'hosts'
],
data() {
return {
exec: null,
ExtensionMode: ExtensionMode,
- enabledFrames: [],
+ enabledHosts: [],
};
},
watch: {
- frames(val) {
+ hosts(val) {
this.filterActiveSites(val);
}
},
@@ -140,6 +139,7 @@ export default {
function: (config) => this.handleConfigBroadcast(config)
}
);
+ this.filterActiveSites(this.hosts);
},
mounted() {
this.eventBus.sendToTunnel('get-ar');
@@ -149,13 +149,13 @@ export default {
},
methods: {
filterActiveSites(val) {
- this.enabledFrames = [];
+ this.enabledHosts = [];
- for (const site of val) {
- const siteSettings = new SiteSettings(this.settings, site.host);
+ for (const host of val) {
+ const siteSettings = new SiteSettings(this.settings, host);
if (siteSettings.isEnabledForEnvironment(false, true) === ExtensionMode.Enabled) {
- this.enabledFrames.push(site);
+ this.enabledHosts.push(host);
}
}
}
diff --git a/src/ext/UWServer.ts b/src/ext/UWServer.ts
index 072bb78..f0e5a26 100644
--- a/src/ext/UWServer.ts
+++ b/src/ext/UWServer.ts
@@ -93,12 +93,16 @@ export default class UWServer {
}
}
+
+
async _promisifyTabsGet(browserObj, tabId){
return new Promise( (resolve, reject) => {
browserObj.tabs.get(tabId, (tab) => resolve(tab));
});
}
+ //#region CSS managemeent
+
async injectCss(css, sender) {
if (!css) {
return;
@@ -167,6 +171,7 @@ export default class UWServer {
this.injectCss(newCss, sender);
}
}
+ //#endregion
extractHostname(url){
var hostname;
@@ -214,7 +219,6 @@ export default class UWServer {
}
//TODO: change extension icon based on whether there's any videos on current page
-
}
registerVideo(sender) {
@@ -288,7 +292,6 @@ export default class UWServer {
const tabHostname = await this.getCurrentTabHostname();
this.logger.info('getCurrentSite', 'Returning data:', {site, tabHostname});
-
this.eventBus.send(
'set-current-site',
{
@@ -318,9 +321,12 @@ export default class UWServer {
return {
host: 'INVALID SITE',
frames: [],
+ hostnames: [],
}
}
+ const hostnames = await this.comms.listUniqueFrameHosts();
+
if (this.videoTabs[ctab.id]) {
// if video is older than PageInfo's video rescan period (+ 4000ms of grace),
// we clean it up from videoTabs[tabId].frames array.
@@ -343,6 +349,7 @@ export default class UWServer {
return {
...this.videoTabs[ctab.id],
host: this.extractHostname(ctab.url),
+ hostnames,
selected: this.selectedSubitem
};
}
@@ -352,7 +359,8 @@ export default class UWServer {
return {
host: this.extractHostname(ctab.url),
frames: [],
- selected: this.selectedSubitem
+ hostnames,
+ selected: this.selectedSubitem,
}
}
diff --git a/src/ext/lib/comms/CommsServer.ts b/src/ext/lib/comms/CommsServer.ts
index 2d98315..d6d903f 100644
--- a/src/ext/lib/comms/CommsServer.ts
+++ b/src/ext/lib/comms/CommsServer.ts
@@ -122,6 +122,36 @@ class CommsServer {
//#endregion
+ /**
+ * Lists all unique hosts that are present in all the frames of a given tab.
+ * This includes both hostname of the tab, as well as of all iframes embedded in it.
+ * @returns
+ */
+ async listUniqueFrameHosts() {
+ const aTab = await this.activeTab;
+
+ const tabPort = this.ports[aTab.id];
+ const hosts = [];
+
+ for (const frame in tabPort) {
+ for (const portName in tabPort[frame]) {
+ const port = tabPort[frame][portName];
+
+ const host = port.sender.origin.split('://')[1];
+
+ // if host is invalid or already exists in our list, skip adding it
+ if (!host || hosts.includes(host)) {
+ continue;
+ }
+
+ hosts.push(host);
+ }
+ }
+
+ console.log('uniq hosts:', hosts)
+ return hosts;
+ }
+
sendMessage(message, context?) {
this.logger.debug('sendMessage', `preparing to send message ${message.command ?? ''} ...`, {message, context});
// stop messages from returning where they came from, and prevent