Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] Match by header (e.g. content-type) #252

Open
sjehuda opened this issue Jun 14, 2023 · 1 comment
Open

[Question] Match by header (e.g. content-type) #252

sjehuda opened this issue Jun 14, 2023 · 1 comment

Comments

@sjehuda
Copy link

sjehuda commented Jun 14, 2023

Hello,

I want to open Web Feeds inside browser.

This is the set of rules:

{
  "request": [],
  "sendHeader": [],
  "receiveHeader": [
    {
      "enable": true,
      "name": "XML",
      "ruleType": "modifyReceiveHeader",
      "matchType": "regexp",
      "pattern": "application/xml",
      "exclude": "",
      "group": "Web Feeds",
      "isFunction": false,
      "action": {
        "name": "content-type",
        "value": "text/plain"
      }
    },
    {
      "enable": true,
      "name": "Atom Syndication",
      "ruleType": "modifyReceiveHeader",
      "matchType": "regexp",
      "pattern": "application/atom\\+xml",
      "exclude": "",
      "group": "Web Feeds",
      "isFunction": false,
      "action": {
        "name": "content-type",
        "value": "text/plain"
      }
    },
    {
      "enable": true,
      "name": "RSS Feed",
      "ruleType": "modifyReceiveHeader",
      "matchType": "regexp",
      "pattern": "application/rss\\+xml",
      "exclude": "",
      "group": "Web Feeds",
      "isFunction": false,
      "action": {
        "name": "content-type",
        "value": "text/plain"
      }
    },
    {
      "enable": true,
      "name": "X-Atom",
      "ruleType": "modifyReceiveHeader",
      "matchType": "regexp",
      "pattern": "application/x-atom\\+xml",
      "exclude": "",
      "group": "Web Feeds",
      "isFunction": false,
      "action": {
        "name": "content-type",
        "value": "text/plain"
      }
    },
    {
      "enable": true,
      "name": "X-RSS",
      "ruleType": "modifyReceiveHeader",
      "matchType": "regexp",
      "pattern": "application/x-rss\\+xml",
      "exclude": "",
      "group": "Web Feeds",
      "isFunction": false,
      "action": {
        "name": "content-type",
        "value": "text/plain"
      }
    },
    {
      "enable": true,
      "name": "JSON Feed",
      "ruleType": "modifyReceiveHeader",
      "matchType": "regexp",
      "pattern": "application/feed\\+json",
      "exclude": "",
      "group": "Web Feeds",
      "isFunction": false,
      "action": {
        "name": "content-type",
        "value": "text/plain"
      }
    },
    {
      "enable": true,
      "name": "X-RDF",
      "ruleType": "modifyReceiveHeader",
      "matchType": "regexp",
      "pattern": "application/x-rdf\\+xml",
      "exclude": "",
      "group": "Web Feeds",
      "isFunction": false,
      "action": {
        "name": "content-type",
        "value": "text/plain"
      }
    },
    {
      "enable": true,
      "name": "RDF Vocabulary",
      "ruleType": "modifyReceiveHeader",
      "matchType": "regexp",
      "pattern": "application/rdf\\+xml",
      "exclude": "",
      "group": "Web Feeds",
      "isFunction": false,
      "action": {
        "name": "content-type",
        "value": "text/plain"
      }
    }
  ],
  "receiveBody": []
}

None of the rules work because there is no instruction of content-type.

This single rule does work, but it interrupts HTML web pages (Same for text/html which would render HTML but skip CSS and maybe JS too; I didn't check the latter).

{
  "request": [],
  "sendHeader": [],
  "receiveHeader": [
    {
      "enable": true,
      "name": "Set Content Type Plain Text",
      "ruleType": "modifyReceiveHeader",
      "matchType": "all",
      "pattern": "",
      "exclude": "",
      "group": "Streamburner",
      "isFunction": false,
      "action": {
        "name": "content-type",
        "value": "text/plain"
      },
      "code": ""
    }
  ],
  "receiveBody": []
}

The following rules are working and are of Open in Browser addon:

{
  "mime-mappings": {
    "application/atom+xml": "1text/plain",
    "application/rss+xml": "1text/plain",
    "application/rdf+xml": "1text/plain",
    "application/feed+json": "1text/plain",
    "application/x-atom+xml": "1text/plain",
    "application/x-rss+xml": "1text/plain",
    "application/x-rdf+xml": "1text/plain"
  },
  "sniffed-mime-mappings": {},
  "text-nosniff": false,
  "octet-sniff-mime": true,
  "override-download-type": false
}
@sjehuda
Copy link
Author

sjehuda commented Jun 14, 2023

Just in case you wonder why would I want to do this.

I have wrote a Feed Reader userscript which won't work with pages with xml in header content-type unless headers are modified:
https://greasyfork.org/en/scripts/465932-newspaper-native-rss-reader

I think this is Firefox-only because they attempt to eliminate RSS.

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

No branches or pull requests

1 participant