ray-lothian / Block-Site

A browser extension to block website access using hostname matching
https://add0n.com/block-site.html
Mozilla Public License 2.0
226 stars 42 forks source link

Feature request: shorter time to close a blocked tab #15

Closed ghost closed 5 years ago

ghost commented 5 years ago

Is it possible to reduce the shortest time to close a blocked tab to about 1 ms? Or "open" it invisible? So it will not appear on the screen...

Thanks for this great AddOn!

ray-lothian commented 5 years ago

What you need is a network-level blocker such as uBlock Origin.

ghost commented 5 years ago

That is not possible, because to block a specific url (matching pattern: ://webmail.freenet.de/Email/Action/ which only opens a popup) I need Block-Site. I don't find any other AddOn that will work as expected. With uBlock you can only block the whole domain (I don't find another solution with uBlock).

There was a legacy AddOn "popup_blocker-1.0.7" that do the job, but this is gone...

ray-lothian commented 5 years ago

I am pretty sure you can find a better solution by using uBlock. Anyhow with this extension, you have two options:

  1. Allow the page to get redirected to the blocked screen which takes time.
  2. Redirect to a local page that automatically closes itself (should be faster)
    <!DOCTYPE html>
    <html>
    <body>
    <script type="text/javascript">window.close()</script>
    </body>
    </html>

To try the second method, place this DATA URI version of the above code in the redirecting box.

data:text/html;charset=utf-8,%3C%21DOCTYPE%20html%3E%0D%0A%3Chtml%3E%0D%0A%3Cbody%3E%0D%0A%20%20%3Cscript%20type%3D%22text%2Fjavascript%22%3Ewindow.close%28%29%3C%2Fscript%3E%0D%0A%3C%2Fbody%3E%0D%0A%3C%2Fhtml%3E

Also, give "Popup Blocker (strict)" a try.

ray-lothian commented 5 years ago

@Thomas-SW the second method doesn't seem to work on FF. Wait for the next release and use the newly introduced close keyword in the Redirect To box for instance closing of the tab.

ghost commented 5 years ago

Thanks for your help.

All suggestions don't work (also #2 not, indeed), tried in the past a lot with Popup Blocker (strict) and Ultimate (and...). The problem is that only this url is to block, it is not really a popup.

So thanks for your development, I will wait for the next release.

ghost commented 4 years ago

Hello Ray. Thanks for the quick implementation!

I am now on v 0.2.3 with the feature: "10. Immediate closing of tabs. This feature is introduced in version 0.2.3 which helps to close annoying popups as soon as the opening request is received."

I use the 'close' keyword in the 'Redirect To' box. But it don't work, redirection is the same (without closing) to: moz-extension://70641fe3-1fb6-4c82-a57e-4eea8e8c6480/data/blocked/index.html?url=https%3A%2F%2Fwebmail.freenet.de%2FEmail%2FAction%2FSecurityPopup%3FisPopup%3D1

It is shown as a PopUp window, not as a new tab. With "Close blocked tab after" set to 1 s the annoying PopUp is closing after about 2 s.

I use FF 68.2.0 ESR on Linux Mint Cinnamon 19.2 (all is up to date).

ray-lothian commented 4 years ago

Have you tried this feature on another domain? Try to block for instance wikipedia and see if it works or not. Can I somehow reproduce this popup that you get?

ghost commented 4 years ago

Clipboard 1 I have tried a domain expression, this works well.

In order to reproduce this pop-up, it is necessary to register with the German email provider freenet.de. In a free basic email account, clicking on "Spam Suspect" (Spamverdacht) or "Virus Suspect" (Virenverdacht) will show this annoying pop-up with advertisements.

See the attached picture.

The full link is "https://webmail.freenet.de/Email/Action/SecurityPopup?isPopup=1" (But I think the method this pop-up is created is your question.)

It is possible to close this pop-up immediately, at least it worked with an older legacy extension that only had this full link as an option.

ghost commented 4 years ago

A addition: the pop-up is opened first with about:blank, then the URL is called.

ray-lothian commented 4 years ago

I justed tested the blocking feature on freenet.de and it works for me on Firefox 70 with the following rule (clicking on Virenverdacht opens a popup window only once per page refresh that gets closed immediately).

Screen Shot

ghost commented 4 years ago

Sorry, but this rule do nothing on my machine... :( Not on Virenverdacht not on Spamverdacht. It does no blocking and no closing of the PopUp.

ray-lothian commented 4 years ago

Can you try the extension on Chrome? Also in Firefox open the browser console (Ctrl + Shift + J) before the page loads and see if you get an error when the popup is opened.

ghost commented 4 years ago

(Sorry, Chrome is not installed)

This is the full output of the console with only ://webmail.freenet.de/Email/Action/ close (no time delay)

created background.js:207:11 Object { id: 16, index: 0, windowId: 34, highlighted: true, active: true, attention: false, pinned: false, status: "complete", hidden: false, discarded: false, … } background.js:208:11 updated: 16 background.js:202:11 Object { isArticle: false } background.js:203:11 updated: 16 background.js:202:11 Object { status: "complete", url: "about:blank" } background.js:203:11 updated: 16 background.js:202:11 Object { status: "loading" } background.js:203:11 updated: 16 background.js:202:11 Object { isArticle: false } background.js:203:11 updated: 16 background.js:202:11 Object { title: "70641fe3-1fb6-4c82-a57e-4eea8e8c6480/data/blocked/index.html?url=https%3A%2F%2Fwebmail.freenet.de%2FEmail%2FAction%2FSecurityPopup%3FisPopup%3D1" } background.js:203:11 updated: 16 background.js:202:11 Object { status: "loading", url: "moz-extension://70641fe3-1fb6-4c82-a57e-4eea8e8c6480/data/blocked/index.html?url=https%3A%2F%2Fwebmail.freenet.de%2FEmail%2FAction%2FSecurityPopup%3FisPopup%3D1" } background.js:203:11 updated: 16 background.js:202:11 Object { title: "Restricted Access" } background.js:203:11 updated: 16 background.js:202:11 Object { status: "complete" } background.js:203:11 [Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIDOMWindowUtils.removeSheet]" nsresult: "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame :: resource://gre/modules/ExtensionCommon.jsm :: runSafeSyncWithoutClone :: line 75" data: no] 2 ExtensionCommon.jsm:75:12 Error: WebExtension context not found! ExtensionParent.jsm:1239:13

ghost commented 4 years ago

And this is the full output of the console with only ://snippet.freenet.de/ close (no time delay)

This window ia not blocked.

created background.js:207:11 Object { id: 21, index: 0, windowId: 39, highlighted: true, active: true, attention: false, pinned: false, status: "complete", hidden: false, discarded: false, … } background.js:208:11 updated: 21 background.js:202:11 Object { isArticle: false } background.js:203:11 updated: 21 background.js:202:11 Object { status: "complete", url: "about:blank" } background.js:203:11 updated: 21 background.js:202:11 Object { status: "loading" } background.js:203:11 updated: 21 background.js:202:11 Object { isArticle: false } background.js:203:11 updated: 21 background.js:202:11 Object { title: "webmail.freenet.de/Email/Action/SecurityPopup?isPopup=1" } background.js:203:11 updated: 21 background.js:202:11 Object { status: "loading", url: "https://webmail.freenet.de/Email/Action/SecurityPopup?isPopup=1" } background.js:203:11 updated: 21 background.js:202:11 Object { favIconUrl: "data:image/x-icon;base64,AAABAAEAICAA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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA///////8f///+B////gP///4B///+AP//5gD//84Af/+OAD//ngAf/x4CH/8+Aw/+PAOH/DwDx/x4AeP4cAHz+OAB8fDAAPjwAAB84AAAHuAAAA/AAAADwAAAAMADgABAD/gAAD/+AAD/8AAD+AAAf4AAB////////////////8=" } background.js:203:11 updated: 21 background.js:202:11 Object { status: "complete" } background.js:203:11 [Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIDOMWindowUtils.removeSheet]" nsresult: "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame :: resource://gre/modules/ExtensionCommon.jsm :: runSafeSyncWithoutClone :: line 75" data: no] 2 ExtensionCommon.jsm:75:12 Error: WebExtension context not found! ExtensionParent.jsm:1239:13

ray-lothian commented 4 years ago

What is this "background.js:203"? Is this from another extension?

ghost commented 4 years ago

Yes, Firefox addon "Geschlossenen Tab wiederherstellen" ("Undo Close Tab")

moz-extension://35360fcf-8f54-4c8a-9026-8c890651ad2b/background.js Firefox addon "Undo Close Tab" Copyright (C) 2019 Manuel Reimer manuel.reimer@gmx.de Copyright (C) 2017 YFdyh000 yfdyh000@gmail.com

It creates a list with shortcuts and favicons to reload the latest closed tabs if needed. But with this AddOn deactivated there is no change in this case.

BTW is ist possible to get a debug version of your AddOn to print some information to the console? May be better than stumbling in the fog...