Open pp-koch opened 2 years ago
Something else I pondered might warrant Return of the Monetization
is some kind of field to do provider attestation ...
but then I wondered if that could just be a field on the monetization event ?
A developer can now check: if ("MonetizationEvent" in window)
instead of navigator.
Ugly. But it works. This is something that has to be improved in the next version.
Alternative:
var link = document.querySelector("link[rel='monetization']")
|| document.createElement("link");
if (link.relList.supports("monetization")) {
// ...supported...
}
manifest?
Oops, copy/pasta
Fixed
So that would need to be gorilla glued in the coil extension too I guess
Yes. Right now it doesn't work with the CoilPreview 0.0.72 extension: it always returns false.
About (link.relList.supports("monetization")) as a feature detection ...
IF a browser natively supports web monetization BUT the user is not signed in to any payment provider will this return true or false?
I assume we can't tell yet, but if we use this line as a general feature detection and it starts to misbehave later we have a problem ...
The "browser" related checks (MonetizationEvent, relList) tell a page that the User Agent (browser or extension) supports monetization, but not if the User is Web Monetized (has a Web Monetization provider / payment pointer and can pay). The triggering of the load event on the link is what informs the page that the User is Web Monetized. And that's because if the User Agent doesn't have a way to pay, it won't process the payment pointer found on the page.
So I wrote a really simple example script that plays a video and shows premium content onmonetization. https://quirksmode.org/coil/testsuite/example-script.html
Requires CoilPreview 0.0.70. Only one is supported here, so wait for the video to play, then use the button to move the link tag.
One conclusion is obvious: we MUST have a simple way for the web developer to figure out immediately if web monetization is possible at all.
If it isn't there should be a message 'Enabled web monetization to view video' or something. That text is not a default placeholder, though: if monetization IS supported but not yet running nothing should happen.
So we need a replacement for
if (!navigator.monetization) { // monetization not supported }