SpartanJ / ImgurViewer

ImgurViewer is a little image viewer to open image links from external applications in the fastest way possible.
108 stars 7 forks source link

Some header control settings #85

Open brian6932 opened 2 months ago

brian6932 commented 2 months ago

Some sites like danbooru (cdn.donmai.us) require a browser user-agent, pixiv (i.pximg.net) requires a referer be set to https://pixiv.net, some sites like gyazo, photobucket, imgur, reddit, and tumblr just require the accept header to be deleted on their cdn links. Typically on browsers, I use a web-ext called simple-modify-headers. I think such a feature could be kinda neat in ImgurViewer, and can potentially make it have a simpler default rule set for some sites and an easier route to PRs. Within the web-ext it imports and exports rules from JSON.

{
    "format_version": "1.2",
    "target_page": "",
    "headers": [
        {
            "url_contains": "i.gyazo.com",
            "action": "delete",
            "header_name": "accept",
            "header_value": "",
            "comment": "",
            "apply_on": "req",
            "status": "on"
        },
        {
            "url_contains": ".photobucket.com",
            "action": "delete",
            "header_name": "accept",
            "header_value": "",
            "comment": "",
            "apply_on": "req",
            "status": "on"
        },
        {
            "url_contains": "i.redd.it",
            "action": "delete",
            "header_name": "accept",
            "header_value": "",
            "comment": "",
            "apply_on": "req",
            "status": "on"
        },
        {
            "url_contains": "preview.redd.it",
            "action": "delete",
            "header_name": "accept",
            "header_value": "",
            "comment": "",
            "apply_on": "req",
            "status": "on"
        },
        {
            "url_contains": "i.imgur.com",
            "action": "delete",
            "header_name": "accept",
            "header_value": "",
            "comment": "",
            "apply_on": "req",
            "status": "on"
        },
        {
            "url_contains": "media.tumblr.com",
            "action": "delete",
            "header_name": "accept",
            "header_value": "",
            "comment": "",
            "apply_on": "req",
            "status": "on"
        },
        {
            "url_contains": "i.pximg.net",
            "action": "add",
            "header_name": "referer",
            "header_value": "https://pixiv.net",
            "comment": "",
            "apply_on": "req",
            "status": "on"
        }
    ],
    "debug_mode": false,
    "show_comments": true,
    "use_url_contains": true
}
SpartanJ commented 2 months ago

Sounds cool, I haven't found in my personal use the necessity to fake an HTTP header to be able to see an image (but ImgurViewer always fakes the user-agent for videos since it's almost always required). I won't particularly develop it myself but feel free to send a PR and I'll gladly accept it. Thanks