Skip to content
This repository has been archived by the owner on Oct 18, 2023. It is now read-only.

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

Closed

Conversation

mankins
Copy link

@mankins mankins commented May 16, 2021

Note this a different approach to #1910, as suggested in the comments by @sublimator #1910 (comment)

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
    • check FF version 94.0.2
      • image

@vercel
Copy link

vercel bot commented May 16, 2021

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

"action": {
"type": "modifyHeaders",
"requestHeaders": [
{ "header": "accept-payment", "operation": "set", "value": "webmon/*;q=0.8" }
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally this set would be an append but apparently there's an open bug that prevents that

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will it matter much in practice do you think ?
There will be races for which extension gets to set it in the case of more than one enabled ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the start it won't matter.

Eventually it could be a race condition. Ideally you'd want an adblock extension to be able to say "no ads" as well as what we have here. I'd think by the time those extensions implement and there's a supporting ux the bug would be fixed.

"rule_resources": [{
"id": "ruleset_1_accept_payment",
"enabled": true,
"path": "static/rules.json"
Copy link
Author

@mankins mankins May 16, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this is the right place for the file. I saw a different approach in https://github.com/coilhq/web-monetization-projects/pull/1659/files, but it wasn't merged.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

static/rules.json seems good to me

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well, I mean I guess you could more specific than "rules", but inside static is good

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated rules.json -> acceptPaymentRules.json

@sublimator
Copy link
Member

@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)

@mankins
Copy link
Author

mankins commented May 18, 2021

@sublimator I could add back #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?

@sublimator
Copy link
Member

sublimator commented May 18, 2021 via email

@mankins mankins marked this pull request as draft May 21, 2021 14:59
@@ -5,7 +5,7 @@
"action": {
"type": "modifyHeaders",
"requestHeaders": [
{ "header": "accept-payment", "operation": "set", "value": "webmon/*;q=0.8" }
{ "header": "accept-monetization", "operation": "set", "value": "webmon/*;q=0.8" }
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's been suggested that "monetization" is a better name, so updating to align with other documents

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

@mankins mankins changed the title feat(coil-extension): add accept-payment via declarativeNetRequest feat(coil-extension): add accept-monetization via declarativeNetRequest May 21, 2021
@sublimator
Copy link
Member

sublimator commented May 27, 2021

@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

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

Successfully merging this pull request may close these issues.

2 participants