admin管理员组

文章数量:1122832

I have an issue similar to this one, except—as far as I can tell—my directives are correct as per the answer on that question.

My header is as follows:

// ==UserScript==
// @name         My Userscript
// @namespace    com.example.my-userscript
// @version      0.2.14
// @description  Do things
// @author       Doktor J
// @match        .php?id=*
// @icon         ;domain=example
// @require      .5.1/jquery.min.js
// @require      .min.js
// @license      Mozilla Public License 2.0
// @grant        GM_addStyle
// @grant        GM_xmlhttpRequest
// @connect      example
// ==/UserScript==

However, when I call the following:

GM_xmlhttpRequest({
    method: "GET",
    url: ".csv",
    onload: function (response) {
        console.log(response.status);
        myData = $.csv.toObjects(response.responseText);
    }
});

I still get the following error:

VM122:10 injected: Refused to connect to ".csv": URL is not permitted

I have an issue similar to this one, except—as far as I can tell—my directives are correct as per the answer on that question.

My header is as follows:

// ==UserScript==
// @name         My Userscript
// @namespace    com.example.my-userscript
// @version      0.2.14
// @description  Do things
// @author       Doktor J
// @match        https://example.com/index.php?id=*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=example.com
// @require      https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js
// @require      https://example.org/path/jquery-csv.min.js
// @license      Mozilla Public License 2.0
// @grant        GM_addStyle
// @grant        GM_xmlhttpRequest
// @connect      example.org
// ==/UserScript==

However, when I call the following:

GM_xmlhttpRequest({
    method: "GET",
    url: "https://example.org/path/data.csv",
    onload: function (response) {
        console.log(response.status);
        myData = $.csv.toObjects(response.responseText);
    }
});

I still get the following error:

VM122:10 injected: Refused to connect to "https://example.org/path/data.csv": URL is not permitted
Share Improve this question asked Nov 22, 2024 at 19:15 Doktor JDoktor J 1,1091 gold badge14 silver badges34 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 2

Fun fact, apparently when you don't have the @connect tag and that warning dialog comes up, if you don't respond quickly enough it blacklists the URL, and the blacklist appears to override the @connect directive.

If this happens:

  1. go to your userscript in Tampermonkey, go to its "Settings" sub-tab (in the left-aligned tab bar below the main Tampermonkey tab bar, otherwise you'll end up in the Tampermonkey settings rather than your userscript's settings).
  2. Scroll down to "XHR Security" and check the "User domain blacklist" box
  3. Select your newly-blacklisted domain in there and click "Remove"

本文标签: javascriptconnect tag not working in TamperMonkeyChromeStack Overflow