Skip to content
This repository has been archived by the owner on Apr 6, 2020. It is now read-only.

FYI: Page Visibility (Second Edition) user script #75

Closed
Thorin-Oakenpants opened this issue Feb 12, 2018 · 2 comments
Closed

FYI: Page Visibility (Second Edition) user script #75

Thorin-Oakenpants opened this issue Feb 12, 2018 · 2 comments

Comments

@Thorin-Oakenpants
Copy link

Just a quick question or two. What does Second Edition mean, is there a v2.0 of the API or something? Where can I test this? And lastly, here is a user script I have in my ViolentMonkey - is this the same thing?

Source: https://greasyfork.org/en/scripts/32726-dpvs/code
-can someone beautify this, I suck and am not a coder!, pretty please

Object.defineProperties(document.wrappedJSObject,{ 'hidden': {value: false}, 'visibilityState': {value: 'visible'} });
window.addEventListener( 'visibilitychange', evt => evt.stopImmediatePropagation(), true);

I haven't bothered to test it or use it yet. How does it stack up?

@pes10k
Copy link
Owner

pes10k commented Feb 13, 2018

As far as I can tell, the numbering / titles of the standards are not 100% consistent (though i would be very happy to be corrected if anyone knows). In some cases this is because the new standard is a "pure" upgrade of the previous one (ie HTML 5.1 includes everything in the HTML 5 standard), and in some places there an addition (ie WebGL 2.0 does not include all of the functionality in WebGL 1.0, and both are implemented in browsers). Its a mess…

The script you mentioned is aiming for a few things, but differs in a couple ways:

It doesn't handle the vendor prefixed versions of each feature, so the same information might be accessible through document.mozHidden or document.webkitHidden, etc. In this way, my extensions approach is "better"

More significantly though, my extension actually doesn't prevent / block the Page Visibility API from functioning for the most part. This is because this standard (and maybe only this standard) consists ONLY of properties, and not methods. My approach only works on methods currently. I'm poking at it at #67, but its a difficult thing to do in the common case, since there all kinds of exceptions and one offs needed (and the older standards are defined in outdated WebIDL standards, so I need to write custom tools to parse the now-non-standard definitions).

Getting properties to work is a pretty low priority at the moment to be honest. I'll get it done eventually, but not before the end of March for soon.

TL;DR; if you want to block all of what the Page Visibility API provides to the page, Web API Manager won't do. The code you posted will do most of it though.

Hope that helps!

@pes10k pes10k closed this as completed Feb 13, 2018
@Thorin-Oakenpants
Copy link
Author

Thanks for the insight 💋

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants