web-monetization-projects icon indicating copy to clipboard operation
web-monetization-projects copied to clipboard

feat(coil-extension): add accept-monetization via declarativeNetRequest

Open mankins opened this issue 4 years ago • 5 comments

Note this a different approach to https://github.com/coilhq/web-monetization-projects/pull/1910, as suggested in the comments by @sublimator https://github.com/coilhq/web-monetization-projects/pull/1910#discussion_r633034791

This PR proposes the addition of the Accept-Monetization header which follows the Content Negotiation pattern used by Accept, Accept-Language, etc.

If this PR is merged, the following header will be added to web requests from the client:

Accept-Monetization: webmon/*;q=0.8

HTTP servers can then choose specialized content for the client, or issue a content negotiation sequence: a 402 status code followed by user-facing instructions on how they might pay for the site.

More on the Accept-Monetization proposal.

This is opportunistic and doesn't replace the client-side web monetization standard.

This is a signal, not a guarantee. Well behaved clients can get the benefit of individual content without having to wait for detection / complete page load.

Verify / QA

The see this in action you can build the extension and then inspect the outgoing http headers. There should be a new header:

Accept-Monetization: webmon/*;q=0.8

To test how content negotiation might work you can run the express server at Accept-Monetization proposal and visit the pages referenced for web monetization.

maybe they'll make it available in v2 extensions (as google does) in the near term? v3 support seems a long way out still

  • [ ] Check when declarativeNetRequest is available in FF manifest v2
    • [x] check FF version 94.0.2
      • image

mankins avatar May 16 '21 13:05 mankins

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/coilhq/web-monetization-projects/4Nhv1k3XZ2nJHzF9SHPTzFHRYbUV
✅ Preview: https://web-monetizati-git-fork-mankins-feature-accept-payment-d-175ccc.vercel.app

vercel[bot] avatar May 16 '21 13:05 vercel[bot]

@mankins

Hey, so of course Firefox doesn't support the declarativeNetRequest api/permission :/

It's a pity cause it's a decent API with performance advantages (one assumes at least)

sublimator avatar May 18 '21 02:05 sublimator

@sublimator I could add back https://github.com/coilhq/web-monetization-projects/pull/1910 into this PR?

I haven't looked into how the different builds happen, but you could branch if the browser has support? Or does this make the proposal DOA?

mankins avatar May 18 '21 10:05 mankins

Yes, we could make that work! :) I can look into hacking the build for you. I just forgot before its not impl on FF. A pity Mozilla is so against it.

sublimator avatar May 18 '21 10:05 sublimator

@mankins I guess you saw this: https://blog.mozilla.org/addons/2021/05/27/manifest-v3-update/

Mozilla are implementing declarativeNetRequest :)

edit: maybe they'll make it available in v2 extensions (as google does) in the near term? v3 support seems a long way out still

sublimator avatar May 27 '21 23:05 sublimator