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

Block the focus, focusin, visibilitychange, and blur events #135

Open
boehs opened this issue Oct 7, 2021 · 7 comments
Open

Block the focus, focusin, visibilitychange, and blur events #135

boehs opened this issue Oct 7, 2021 · 7 comments
Labels
enhancement New feature or request

Comments

@boehs
Copy link

boehs commented Oct 7, 2021

No description provided.

@boehs boehs changed the title Block the focus, focusin, and blur events Block the focus, focusin, visibilitychange, and blur events Oct 7, 2021
@boehs
Copy link
Author

boehs commented Oct 7, 2021

window.onblur = null;
window.blurred = false;

document.hasFocus = function () {return true;};
window.onFocus = function () {return true;};

Object.defineProperty(document, "hidden", { value : false});
Object.defineProperty(document, "mozHidden", { value : false});
Object.defineProperty(document, "msHidden", { value : false});
Object.defineProperty(document, "webkitHidden", { value : false});
Object.defineProperty(document, 'visibilityState', { get: function () { return "visible"; } });

document.onvisibilitychange = undefined;

for (event_name of ["visibilitychange",
                    "webkitvisibilitychange",
                    "blur", // may cause issues on some websites
                    "mozvisibilitychange",
                    "msvisibilitychange"]) {
  window.addEventListener(event_name, function(event) {
        event.stopImmediatePropagation();
    }, true);
}

@polcak
Copy link
Owner

polcak commented Oct 8, 2021

Hello,

Do I understand correctly that these are proposed wrappers?

@polcak polcak added the question Further information is requested label Oct 8, 2021
@boehs
Copy link
Author

boehs commented Oct 8, 2021

Yes. The code in the comment is my description if you will. It's not designed for a extension, it's close to untested (ran on holdd.netlify.app and it disabled the relevant bit), there may be a better way, etc, But a picture is worth a thousand words and this effectively describe what I am going for

I don't have much data on how it could be exploited, but the obvious thing that comes to mind is analytics, and targeted content based on attention span, and I can't figure out how the browser api would be useful to a website

@polcak
Copy link
Owner

polcak commented May 4, 2022

I explicitely mentioned this issue in https://pagure.io/JShelter/webextension/issue/66. We do not modify/filter events, yet. But I think that we should explore the possibilities.

@polcak polcak added enhancement New feature or request and removed question Further information is requested labels May 4, 2022
@boehs
Copy link
Author

boehs commented May 4, 2022

Thank you for taking care to crosslink, it means lots to me

@AWKohler
Copy link

AWKohler commented Dec 4, 2022

some websites might also use mouse in mouse out events as a workaround

polcak pushed a commit that referenced this issue Apr 19, 2024
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

3 participants