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

URL support for disable-newtab-links #2251

Closed
8 tasks done
MasterKia opened this issue Sep 8, 2022 · 12 comments
Closed
8 tasks done

URL support for disable-newtab-links #2251

MasterKia opened this issue Sep 8, 2022 · 12 comments
Labels
enhancement New feature or request

Comments

@MasterKia
Copy link
Member

Prerequisites

I tried to reproduce the issue when...

  • uBO is the only extension
  • uBO with default lists/settings
  • using a new, unmodified browser profile

Description

There are filters like these in the main uBlock Filters:

sendvid.com##+js(nowoif, !/^https:\/\/sendvid\.com\/[0-9a-z]+$/)
shiba-faucoin.com##+js(nowoif, /?sponsor)
lineageos18.com##+js(nowoif, bitcoins-update.blogspot.com)
federleqa.icu,imgair.net,imgblaze.net,imgfrost.net,imguiwe.buzz,imgweika.buzz,imgyear.icu,imgzer.net,opalekr.icu,pixsera.net,rtkenale.icu,vestimage.site,imgwia.buzz
##+js(nowoif, !/prcf.fiyar|themes|pixsense|.jpg/)

So it'd be useful to have the same functionality for the disable-newtab-links scriptlet where uBO would check the link href and close the new tab if it matched the href specified by the filter.
The purpose could be the same as the reason why window.open-defuser has a URL parameter.

##+js(nowoif, !/^https:\/\/sendvid\.com\/[0-9a-z]+$/)
<=>
##+js(disable-newtab-links, !/^https:\/\/sendvid\.com\/[0-9a-z]+$/)

A specific URL where the issue occurs

.

Steps to Reproduce

.

Expected behavior

.

Actual behavior

.

uBlock Origin version

1.44.2

Browser name and version

Firefox

Operating System and version

.

@gwarser
Copy link

gwarser commented Sep 8, 2022

Real world case?

@gwarser gwarser added the enhancement New feature or request label Sep 8, 2022
@gorhill
Copy link
Member

gorhill commented Sep 10, 2022

A scriptlet cannot close another tab. It can maybe prevent it from being opened but then you might as well use a cosmetic filter to hide the target link.

@MasterKia
Copy link
Member Author

Then the website can detect "hiding" that link.

A scriptlet cannot close another tab.

Thanks.

@MasterKia MasterKia closed this as not planned Won't fix, can't repro, duplicate, stale Sep 11, 2022
@gorhill
Copy link
Member

gorhill commented Sep 11, 2022

the website can detect "hiding" that link.

If you don't want to hide, you can style with pointer-events: none.

@MasterKia
Copy link
Member Author

MasterKia commented Sep 11, 2022

Unfortunately can/will be detected too, the only thing uncircumventable¹ is disable-newtab-links with a URL parameter.

====

  1. They can just stop opening in new tabs, in that case they'll lose user interaction since their own site gets closed.

@MasterKia
Copy link
Member Author

AdGuard's close-window scriptlet seems to do the job.

Closes the browser tab immediately using window.close().

@mapx-
Copy link

mapx- commented Sep 11, 2022

@MasterKia
Copy link
Member Author

That works for most of my need, thanks.
Don't know why I missed it, maybe because of "Can be used to close tabs which have been opened from other applications" in the wiki.

@mapx- Can it also close tabs from example.com to somesite.com?
I tested, it didn't.

@mapx-
Copy link

mapx- commented Sep 11, 2022

Some real example ?

@gwarser
Copy link

gwarser commented Sep 11, 2022

AdGuard's close-window scriptlet seems to do the job.

Closes the browser tab immediately using window.close().

AdGuard uses closeByExtension call, uBO does not, and has some quirks with this scriptlet. Check discussion in uBlockOrigin/uAssets#10323

@mapx-
Copy link

mapx- commented Sep 11, 2022

example:

  • go to https://www.farsroid.com/
  • see at the bottom ivahid.com
  • click it => a new tab is opened

to close it:
working filter
ivahid.com##+js(window-close-if, /^/)

@gorhill
Copy link
Member

gorhill commented Sep 11, 2022

example

Even better prevent the tab from being opened:

farsroid.com##a[href*="ivahid.com"]:style(pointer-events:none!important)

The whole conversation here is pointless if I am not given a specific (and representative) cases of what we are trying to solve. When I see the problem, then I will consider all sort of solutions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants