pes10k / web-api-manager

(Unmaintained) WebExtension based browser extension to manage and block untrusted parts of the Web API.
GNU General Public License v3.0
102 stars 16 forks source link

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

Closed Thorin-Oakenpants closed 6 years ago

Thorin-Oakenpants commented 6 years ago

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 commented 6 years ago

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!

Thorin-Oakenpants commented 6 years ago

Thanks for the insight :kiss: