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

XMLHttpRequest does not set the response cookies to the page #202

Closed
GoogleCodeExporter opened this issue Mar 16, 2015 · 4 comments
Closed

Comments

@GoogleCodeExporter
Copy link

TM version: 3.10.4444
Browser version:39.0.2171.71 m
This is my script
Yes about 2 years later the script works fine.
Yes, and everything is fine.

I make this script for a torrent site what runs on https. I'd like to make a 
function which make a call for a Deluge torrent client to download a torrent 
file. For this deluge has webui_api. The login function send back a security 
Cookie (i.e. Set-Cookie: _session_id=424a8c3fad3d766d9054ce7f56a5833e2253; 
Expires=Tue, 02 Dec 2014 20:01:44 GMT; Path=/json). And I have to send back 
this session_id to identify me.

The expected behavior is every xmlhttpRequest set back this cookies just in TM 
not.

Please find a solution how can I access for it. Or if is not allowed by chrome 
or any standard rules, send back like responseHedaers. Maybe you can call it 
responseCookies.

Best Regards George.


Original issue reported on code.google.com by GChovany...@gmail.com on 2 Dec 2014 at 8:40

@legnaleurc
Copy link

Hi, I recently stomped into this issue too.

A minimal test case on www.example.org :

// ==UserScript==
// @name       My Fancy New Userscript
// @namespace  http://use.i.E.your.homepage/
// @version    0.1
// @description  enter something useful
// @match      http://www.example.org/*
// @copyright  2012+, You
// @grant GM_xmlhttpRequest
// ==/UserScript==

GM_xmlhttpRequest({
    method: "GET",
    // to avoid 304
    url: "http://www.example.com/?" + Math.random(),
    headers: {
        Cookie: "referrer=1",
    },
    onload: function () {
        console.info('got response');
    },
});

Note in GreaseMonkey, the content in Cookie is appended after document.cookie, so the actual header GM_xmlhttpRequest sent is document.cookie + ';' + (string in Cookie option).

I don't know which one is better: directly replace the whole Cookie header or just append it, but I really hope this can act same as GreaseMonkey.

Thank you.

@devnoname120
Copy link

@legnaleurc Meanwhile as a workaround, can't you backup document.cookie, set it to the one you want, send the request, and then restore document.cookie?

@legnaleurc
Copy link

@legnaleurc Meanwhile as a workaround, can't you backup document.cookie, set it to the one you want, send the request, and then restore document.cookie?

AFAIK I can't set cookie for cross domain requests, and unfortunately this is my case.

@derjanb
Copy link
Member

derjanb commented Apr 10, 2016

A first experimental implementation is available at TM Beta 4.1.5188

http://tampermonkey.net/changelog.php?version=4.1.5188&ext=gcal

@derjanb derjanb added this to the 4.1 milestone Apr 10, 2016
@derjanb derjanb closed this as completed Aug 29, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants