Giter Club home page Giter Club logo

popupblocker's Introduction

Popup Blocker by AdGuard

Summary:

Popup Blocker by AdGuard is a userscript that blocks all unwanted pop-up windows in different browsers.

Key features:

  • Cross-browser support

Works in Chrome, Firefox, Edge, Safari, IE10+ etc, basically in any browser that supports userscript managers. Exceptions are some of the oldest browsers that do not support the API we use, the script may not be fully functional there.

  • Advanced pop-up detection

Popup Blocker doesn't apply the filtering rules approach to pop-up detection. Instead, it adds an additional layer on top of browser's native APIs that are used to create pop-ups. This way, these APIs can only be called when caused by a manual input, and not by pop-up/pop-under scripts. That allows to block pop-ups even on websites that try to bypass regular ad blockers by using WebRTC or varying the ad servers.

  • Restores the expected click behavior

Self-explanatory but important: if a click would cause a pop-up to show, not only the pop-up is blocked, but also the initial click is processed as it would be without the pop-up.

  • Invisible to other scripts

Other scripts on the page can not detect that Popup Blocker is being used, other than by actually trying to open a pop-up. This prevents any possible circumvention of Popup Blocker.

Installation

Popup Blocker is being developed by the same team that develops AdGuard, and AdGuard for Windows can serve as a userscript manager. If you are an AdGuard user, go to Settings – Extensions – Add Extension and enter the desired Popup Blocker .js file URL there. This way you can use it in literally any browser.

On the other hand, Popup Blocker is an independent project, you can use it with any other userscript manager like Greasemonkey, Tampermonkey or Violentmonkey. Make sure one of them is installed in your browser to be able to use the Popup Blocker (just enter the script URL into the address bar, it will be automatically detected by the manager).

Options page

You can manage a list of allowlisted domains and silenced domain on a dedicated options page:

Reporting a bug

To report a bug, go to this page and create a new issue.

Translation

You can help us with translating Popup Blocker into other languages! Our project on Crowdin is open for public contributions.

Development build

Development builds have logging enabled and overrides significantly more browser apis to introspect behavior of popup/popunder script. It is not suitable for normal usage.

Unit test for dev build is here.

How to build

To build the project, follow these steps:

Install local dependencies by running the following command in the terminal:

yarn install

To build, run the following command in the terminal:

$ NODE_ENV=<channel> ts-node tasks/builder --target=<target>

Replace channel with the desired channel, which can be dev, beta, or release. Also, replace target with the desired build target, which can be

  • userscript – build userscript for a specified channel;
  • options – build options page, which is a standalone page, that provides the user with convenient way of managing allowed and silenced websites;
  • tests – build tests;
  • bundle – build and bundle all of the above for a specified channel.

Alternatively, you can run the following commands in a minimist style:

yarn userscript-<channel>
yarn options-page
yarn tests
yarn bundle:dev
yarn bundle:beta
yarn bundle:release

If you are building for development, note that the output will not be minified and will contain logs in the browser console.

Beta and release builds will be minified, and all logging codes will be stripped out.

How to debug the options page

Build using the options page, go to the build folder via cd command and run local server of you choice

yarn options-page

Modify isOptionsPage at option-init.ts to allow specific address and port. After that, ensure, that userscript (for example, in AG) contains this address and port too.

To see the options page, ensure, that AG filters your debug page.

How to test

An easy way to test the script is to visit http://code.ptcong.com/better-js-popunder-script/

Just click anywhere on that page to get a popunder, or use specific links to get popup/popunder/tabup/etc.

Expected behavior: new windows get blocked with a notification in the top right corner.

How to deploy options page

Options page is deployed via GitHub Pages with a manual actions Deploy popup blocker beta and Deploy popup blocker release for beta and release versions respectively.

popupblocker's People

Contributors

adbuker avatar adguard-bot-2 avatar alex-302 avatar ameshkov avatar martii avatar maximtop avatar mnaoumov avatar mseada94 avatar northis avatar revbem avatar slavaleleka avatar stanislav-atr avatar tvinzz avatar vbagirov avatar zhelvis avatar zloyden avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

popupblocker's Issues

rapidvideo.com

Script on Rapidvideo.com few week ago working perfect. No popup, no redirects - like Openload, but last weeks something change. Video working when script is active, but no working video scroll slider. When disable script and refresh rapidvideo.com slider of course working, but again opens new windows and redirects. It is possible fix this? Add Rapidvideo to whitelist not resolve problem.
Example link:
https://www.rapidvideo.com/v/FLHD1DY4YV

Extension build

There should be a separate build wrapping userscript into a chromium/webextensions add-on.

Basically, the userscript code should be executed in a context of a web page. Something like this:

content-script.js

var userscriptCode = getUserscriptCode();
var script = document.createElement('script');
script.innerText = userscriptCode;
document.rootElement.appendChild(script);
// Remove it once it has finished its work
document.rootElement.removeChild(script);

GM_ functions should be replaced with your own implementations.

False-positive detection on Gmail

Clicking on a link in a PDF doc viewer causes pop-up blocked alert:
fwd 3a d1 80 d0 b5 d0 b7 d1 8e d0 bc d0 b5 - ay meshkov 40gmail com - gmail 2017-08-23 11-22-47

Issues with it:
Cannot be closed
"Always allow" should show the domain name, not part of the URL
"an attempt to open" should also show the domain name

Implement strict blocking mode

It may --

  • block all window.open calls,
  • block all dispatchEvent on anchors that are disconnected from the document,
  • block all click on anchors that are disconnected from the document.
    It may need to be indicated in alerts that a blocking was triggered by strict blocking.

Exclude common frames

Facebook, Disqus, VK.com use empty frames for server communication.

We should avoid injecting our userscripts to these frames.

Cannot collapse alert on Gmail

VM8872:283 Uncaught TypeError: Cannot read property 'classList' of undefined
    at Alert.$collapse (<anonymous>:283:14)
    at AlertController.collapseAlert (<anonymous>:348:15)
    at <anonymous>:397:27
Alert.$collapse @ VM8872:283
AlertController.collapseAlert @ VM8872:348
(anonymous) @ VM8872:397
setTimeout (async)
applyWithUnproxiedThis @ VM8872:920
o.(anonymous function) @ VM8862:3
(anonymous) @ VM8872:396
AlertController.onMouseOut @ VM8872:388
(anonymous) @ VM8872:316

Renaming

Continuing with the trend of converting everything from 'Adguard' to 'AdGuard'.
Should the userscript be also mentioned as - AdGuard Popup Blocker Beta?

Install directly into Mac Desktop?

The notes imply this can be installed directly into the Mac desktop app. Can it? I know you can use TamperMonkey for Safari. The Desktop v1.5 does not use this v2.1 blocker, correct? Does the desktop blocker even work?

ur.ly

Adguard 6.2.400
Popup Blocker 2.1.7
Sample URL: http://ur.ly/xW5vmeM
Another e.g: http://ur.ly/xDRGQ00
Popups on the site after clicking on generating URL, getting link after timer(5seconds).
And after that it's not redirecting(this maybe a filter issue, not sure though).
Happens in both Chrome and firefox stable releases.

Event delivery issue on pictoa.com(nsfw)

With Chrome 63, when I click on image links in the page, a popup from ExoClick ads are blocked by PopupBlocker, but an underlying link is not clicked.

On a side note, the popup script appears to be abusing fullscreen api for certain old chrome version, we may need to prevent any side-effects caused by it.
Source: AdguardTeam/AdguardFilters#6606

[Firefox]clicknupload.org

Firefox 55.0.3 x64
Adguard 6.2.400
Popup Blocker 2.1.7
Sample URL for testing: https://clicknupload.org/mqmnl7mnqbsg

Proceed to generate download link.

Issue:
When the final download button is present and you click on it, it opens a new tab, download goes to your browser or download manager and the new blank tab remains as it is.

Expected Behavior:
In chrome, although after clicking the final download button, chrome also opens a new tab but as soon as the download start, that new tab closes by itself.

Prepare repo and build scripts for the userscript

The very first task is to create a repo with a userscript meta, empty script, and unit-tests.

Take a look here to get an example:
https://github.com/AdguardTeam/AdguardAssistant

Build configurations

There should be three build configurations. The only difference is downloadURL/updateURL meta attributes.

  • dev -- will be published to gh-pages
  • beta -- will be published to cdn.adguard.com/.../Beta
  • release -- will be published to cdn.adguard.com

Unit-tests

Prepare a file with unit-tests.

Travis-CI auto-build

Just like it's done in the Assistant repo: build, run unit-tests, publish dev build.

Update README.md with the information on how to build and install the userscript.

add an exclusion list view

when using the script in Violentmonkey, if the parrot is blocked, then it is suggested to allow it on some sites, but after permission, I can not find settings with the sites for which I allowed them

Dev build of the popup blocker breaks XenForo forums

For instance, on AdGuard Forum when it is enabled, I cannot post anything inside of a conversion or in the forum thread.

The input box in the "reply" area is invisible.

I have popup blocker installed via ViolentMonkey btw.

[Feature request] Trigger log

Think about implementing some kind of a history log that stores information about the recently blocked pop-ups:

  • original page URL;
  • destination page URL;
  • timestamp;
  • maybe an option to whitelist either of the websites (original/destination).

Partly this is needed in order to circumvent the problem when the pop-up is blocked as you follow a link to another page. The notification will not be shown on the new page.

Pop-up blocker warning alerts

Here is the task for the alerts layout:
#12

Some general notes on the task:

  1. Alerts should be shown inside of a dynamically created iframe (look at how it's done in Assistant) in order to not mess with the websites' own styles.
  2. Instead of generic blocking, we can now simply suppress all the pop-ups and show the alert. The only exception should be the obvious pop-ups.
  3. For every new blocked pop-up, you should show a new alert. Pop-up is new if the URL is different.
  4. The pop-up blocker text will be translated via oneskyapp, so you should not hardcode strings.

Alert state 1

popup blocker extension - page moqups 2017-08-10 12-43-49

Alert is shown when you block an attempt to open a window.

  • example.org: domain of the pop-up window. Clicking on this link opens the popup.
  • Always allow example.org: allows all the pop-up windows leading to example.org from the current website.
  • Allow all pop-ups on this website: that's simple.

Alert state 2

After some time alert collapses into state 2:
popup blocker extension - page c2 b7 moqups f0 9f 94 8a 2017-08-10 13-00-55

Click on the "pop-up" link expands it back to the state 1.

Also, if pop-up is detected by a "generic" algorithm from the first version of an extension, we should show alert in the collapsed state right away.

How alerts are stack

Basically, they are located one under one:
https://monosnap.com/file/PFeTq9dLBERo0DYPbBeadRIcuqg11U

There should be no more than 4 alerts. When fifth emerges, remove the oldest one.

Alert lifecycle

2 seconds in the state 1.
5 seconds in the state 2.
Disappears after that.

Prevent background redirect

Certain popunders open a current page in a new tab and navigates the current tab to an ad page.
Some of them are respectful to the hosting page, in that it does not navigates away the current tab when an attempt to open a new tab was unsuccessful. However, others are not, and they are using window.location.href="..." which we cannot really put any additional check onto.

I can think of following ways:

  • Use beforeunload event to allow users to choose whether to leave the page or not. Although it is not allowed to provide custom texts in beforeunload alerts, when blocked popup alerts are implemented, user may reasonably decide about it.
  • Set window.location.href again on beforeunload event, but it will still cause a refresh of a page. And possibly show a message "This page was refreshed to prevent redirection by popup scripts. Try this option for this website...."
  • Collect more information about the event handler by using Function.caller, and if it can be determined to be a disrespectful popunder, throws on the userscript to abort the popunder script.
  • Allow attempts to open popups with a first-party url, and when a parent window tries to navigate away, close the tab.
  • When a page tries to navigate away shortly after a popup is blocked, open a new window on beforeunload event with the url of the previously blocked popup request.
  • We can provide an option "Throw on suspicious popup attempts", which should not be enabled by default.

Here respectful/disrespectful is obviously about the publisher, not to site users. Popup/popunder scripts are supposed to cooperate with the publisher to earn them money, not sabotage the publisher's website by arbitrarily navigating away.
This issue can be reproduced on https://worldwidetorrents.eu/ with Chrome.

An issue with popup notification and dummy pdf issue

Steps to reproduce:

  • Disable a rule ||odbabo.info^$third-party in English filter.
  • Visit http://legend.az/ with chrome.
  • Click anywhere in the viewport.

Expected result:

  • An alert notification about a blocked popup should be displayed.

Actual result:

  • No notification is displayed.
  • Due to a dummy pdf object created, a browser prompt window Chrome pdf viewer: please wait... is triggered.

This is partly a regression caused by using postMessage inside empty iframes.

Popups attached to anchor, input tags

https://forum.adguard.com/index.php?threads/resolved-mp3fiber-com-anti-adblock-windows.24559/
topboard.org

Such websites attach event listeners on anchor or input submit buttons. When a user clicks on such elements, it calls window.open with an ad url, or swaps the original href attribute to ad url and call window.open with the original href.

I have to think about what we can do to block those; I suppose, no user interaction is meant to trigger 2 navigations at once, and any such attempt is an undue abuse of APIs. We may use this as a guiding principle in detecting unwanted popups.

False-positive on disqus.com/embed/

Steps to reproduce:

Result:
An error is displayed in the devtools console.

We need to wrap every place where we access Function.arguments with try-catch block. Also, we need to include disqus iframe into default exceptions in release versions.

Make build process more modular

Build process is constantly being complicated, I need to make it more organized. I have to bundle up 2 sources separately, one to run on the page's context and the other to run on userscript hosts' sandboxed context (to use GM_getValue api). Below are build task components:

  • Using 2 bundlers (rollup, closure compiler) depending on build channels.
  • Applying preprocess to each of them.
  • Replacing resources placeholder in source files to a respective resources. Currently there is one resource.

Implement alternative popup detection mechanism

The current method almost does not work in FF, because FF does not support window.event, and retrieving event via Function.caller is not reliable, because it cannot be used in strict mode and can't handle recursions in the call stack. An alternative mechanism will provide much benefit for such cases.

ubisoft.com incorrect blocking

Report from the Telegram channel:

I need a bit help. On https://www.ubisoft.com/ apparently AdGuard inteferes with the site function. When I clicked my account management link, Adguard reacted and blocked the pop up. It also asked me on that page if I wanted to allow it. I pressed yes to allow it and clicked the same link again, but adguard again asked me if I want to put it in whitelist and blocks the popup. This happened for another round, so then instead of answering yes, I just disabled adguard from my systray altogether and relogin to the ubisoft account and it worked :<

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.