Tampermonkey / tampermonkey

Tampermonkey is the most popular userscript manager, with over 10 million users. It's available for Chrome, Microsoft Edge, Safari, Opera Next, and Firefox.
GNU General Public License v3.0
4.37k stars 428 forks source link

GM_download adding Referer to headers will cause failure #2262

Open BloodlineL opened 5 days ago

BloodlineL commented 5 days ago

Expected Behavior

Execute Download

Actual Behavior

Works successfully in Firefox, fails in Chrome. It works without adding Referer.

Specifications

Script

// ==UserScript==
// @name         New Userscript
// @namespace    http://tampermonkey.net/
// @version      2024-11-24
// @description  try to take over the world!
// @author       You
// @match        https://*/*
// @grant        GM_download
// ==/UserScript==

(function() {
    GM_download({
        headers: {
            Referer: ""
        },
        url: "https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png",
        name: "download.png",
        onload: () => console.log("success"),
        onerror: error => console.log(error),
    });
})();