Open Andrew-J-Larson opened 1 year ago
chrome.tabs.query({ active: true, currentWindow: true })
keeps returning example.com
loaded in the left side. I did try to use { active: true, lastFocusedWindow: true }
, no difference. There doesn't seem a way to get the right side of a tab in split-screen mode.
chrome.tabs.query({ active: true, currentWindow: true })
keeps returningexample.com
loaded in the left side. I did try to use{ active: true, lastFocusedWindow: true }
, no difference. There doesn't seem a way to get the right side of a tab in split-screen mode.
Yeah, looks like Microsoft didn't think it through when releasing the feature: https://github.com/microsoft/MicrosoftEdge-Extensions/discussions/102
I think I figured out a work around.
Using the active tab and window, you should check the results of document.hasFocus()
.
If true, then you're using the main window (or left split tab), but if false, you'll want to check each "inactive" tabs in the current window where document.hasFocus()
ends up as true, being the second tab (main window's right split tab).
Then, you should be able to find the split tab, right?
I did test part of my theory with document.hasFocus()
by checking the values on an interval, and that properly works when using the split tab, but I'm not an extensions dev to try testing the chrome extension API...
I think I figured out a work around.
Using the active tab and window, you should check the results of
document.hasFocus()
.If true, then you're using the main window (or left split tab), but if false, you'll want to check each "inactive" tabs in the current window where
document.hasFocus()
ends up as true, being the second tab (main window's right split tab).Then, you should be able to find the split tab, right?
And if this works, the proposed implementation shouldn't cause any issues once Edge does fix detection of the split tab (since querying the active tab and checking document.hasFocus()
would both come back true).
document.hasFocus()
is not something visible to the main uBO process.
With a breakpoint at https://github.com/gorhill/uBlock/blob/1.55.0/platform/common/vapi-background.js#L650, the focused pane is always the one on the left even after I click on the right pane.
document.hasFocus()
is not something visible to the main uBO process.With a breakpoint at https://github.com/gorhill/uBlock/blob/1.55.0/platform/common/vapi-background.js#L650, the focused pane is always the one on the left even after I click on the right pane.
I see what you mean, but is something more like this possible, where you check all inactive (active: false
) tabs, and then run code on each to confirm which has focus (probably as a separate check after the active tabs check)?
vAPI.tabs.query({ active: false, windowId }).then(tabs => {
if ( tabs.length === 0 ) { return; }
const tab = tabs[0];
chrome.tabs.executeScript(tab.id, {
code: 'document.hasFocus()'
}, function(hasFocus) {
if (hasFocus) {
this.onActivated({ tabId: tab.id, windowId: tab.windowId });
}
});
});
Any news on this? I'd like to split the browser programmatically from an extension, the same as the little split window icon in the menu area.
Thanks,
Hans
Prerequisites
I tried to reproduce the issue when...
Description
When using the split screen functionality built into Edge, the staus of uBlock Origin only shows for the main page (left side), when switching to the second page in the split (right side), the status of uBlock Origin remains unchanged.
However, I can confirm that still appears to block ads, even when the status is appearing incorrectly.
Note: I'm NOT referring to the apps/custom sites toolbar on the right side of the browser.
A specific URL where the issue occurs.
https://youtu.be/dQw4w9WgXcQ
Steps to Reproduce
Expected behavior
The status of uBlock Origin should reflect the currently active page when using split screen mode.
Actual behavior
Status of uBlock Origin only shows the status for the main page, ignoring the split screen.
Configuration