Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extension Doesn't Display Correct Status in Edge (split screen) #2945

Open
7 tasks done
Andrew-J-Larson opened this issue Nov 8, 2023 · 8 comments
Open
7 tasks done
Labels
Edge specific to Edge

Comments

@Andrew-J-Larson
Copy link

Prerequisites

I tried to reproduce the issue when...

  • uBO is the only extension.
  • using a new, unmodified browser profile.

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

  1. Make sure you're in the Edge browser.
  2. Open a page that is normally not blocking ads (you've set this page to not be blocked for example. (this will end up on the left side)
  3. Click on the split screen button and open another page that is set to block ads. (this will end up on the right side)
  4. Click onto the main page (left), notice the status of ublock being grayed out (as it should be).
  5. Click onto the second page (right), notice that the status remains unchanged, even though AD blocking is indeed in effect on the page.

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

uBlock Origin: 1.52.2
Chromium: 119
filterset (summary):
 network: 104192
 cosmetic: 43397
 scriptlet: 18850
 html: 0
listset (total-discarded, last-updated):
 default:
  user-filters: 0-0, never
  easylist: 75145-16, 3h.33m
  easyprivacy: 32851-64, 3h.33m
  plowe-0: 3720-1073, 3h.33m
  ublock-badware: 7430-135, 3h.33m
  ublock-filters: 35166-149, 3h.33m
  ublock-privacy: 660-6, 3h.32m
  ublock-quick-fixes: 146-89, 3h.32m
  ublock-unbreak: 2134-32, 3h.33m
  urlhaus-1: 10900-0, 3h.32m
filterset (user): [empty]
trustedset:
 added: [array of 16 redacted]
userSettings: [none]
hiddenSettings: [none]
supportStats:
 allReadyAfter: 493 ms (selfie)
 maxAssetCacheWait: 134 ms
@gwarser gwarser added the Edge specific to Edge label Nov 8, 2023
@gorhill
Copy link
Member

gorhill commented Nov 15, 2023

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.

@Andrew-J-Larson
Copy link
Author

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.

Yeah, looks like Microsoft didn't think it through when releasing the feature: microsoft/MicrosoftEdge-Extensions#102

@Andrew-J-Larson
Copy link
Author

Andrew-J-Larson commented Feb 9, 2024

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?

@Andrew-J-Larson
Copy link
Author

Andrew-J-Larson commented Feb 9, 2024

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...

@Andrew-J-Larson
Copy link
Author

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).

@gorhill
Copy link
Member

gorhill commented Feb 14, 2024

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.

@Andrew-J-Larson
Copy link
Author

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 });
      }
    });
});

@zaunere
Copy link

zaunere commented Oct 5, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Edge specific to Edge
Projects
None yet
Development

No branches or pull requests

4 participants