FirefoxBar / HeaderEditor

Manage browser's requests, include modify the request headers and response headers, redirect requests, cancel requests

Home Page:https://he.firefoxcn.net/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

sjehuda opened this issue · comments

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
}

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.