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

GM_xmlhttpRequest unable to set referer in Chrome 72+ #629

Open
gslin opened this Issue Dec 21, 2018 · 1 comment

Comments

Projects
None yet
2 participants
@gslin
Copy link

gslin commented Dec 21, 2018

Expected Behavior

We should be able to use GM_xmlhttpRequest to set Referer.

Actual Behavior

No Referer would be set because Chrome 72+ requires a new option to be enabled (quoting from https://developer.chrome.com/extensions/webRequest):

Starting from Chrome 72, the following request headers are not provided and cannot be modified or removed without specifying 'extraHeaders' in opt_extraInfoSpec:

Specifications

  • Chromium: 72+
  • TM: (i.e. 4.5.5648)
  • OS: Linux, Ubuntu 16.04

Script

                let req = GM_xmlhttpRequest({
                    anonymous: true,
                    data: data,
                    headers: {
                        'Content-Type': 'application/x-www-form-urlencoded',
                        'Referer': 'https://www.exmaple.com/',
                    },
                    method: 'POST',
                    onload: function(res){
                        resolve(res);
                    },
                    url: 'https://www.example.com/',
                });
@derjanb

This comment has been minimized.

Copy link
Member

derjanb commented Dec 22, 2018

This is working fine at TM 4.8.5881

// ==UserScript==
// @name         New Userscript
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       You
// @match        https://*/*
// @grant        GM_xmlhttpRequest
// @connect      example.com
// ==/UserScript==

let req = GM_xmlhttpRequest({
    anonymous: true,
    data: 'a=1',
    headers: {
        'Content-Type': 'application/x-www-form-urlencoded',
        'Referer': 'https://www.exmaple.com/',
    },
    method: 'POST',
    onload: function(res){
        console.log(res);
    },
    url: 'https://www.example.com/',
});

@derjanb derjanb added this to the 4.8 milestone Dec 22, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment