Skip to content

[BUG] @Connect * does not bypass "Script is attempting to access a cross-origin resource" popup #623

Closed

Description

@fireattack

Problem Description

I use a script (https://github.com/qsniyg/maxurl/blob/master/userscript.user.js) that has

// @connect           *

However, ScriptCat still displays the warning and prompts for user action every time a new cross-origin domain is visited. This contradicts the warning’s own statement: "The script can also add the @connect tag to bypass this option."

Reproduction Steps

  1. Install said script
  2. Open https://en.wikipedia.org/wiki/Main_Page
  3. Mouse over any image, and press shift+alt+I (default shortcut from the script) to trigger its popup

ScriptCat Version

v0.18.2

Operating System and Browser Information

Win 10 Chrome 139.0.7258.67 (Official Build) (64-bit) (cohort: Stable)

Additional Information (Optional)

No response

Activity

  1. changed the title [-][BUG] @Connect * does not bypass "Script is attempting to access a cross-origin resource" option[/-] [+][BUG] @Connect * does not bypass "Script is attempting to access a cross-origin resource" popup[/+] on Aug 13, 2025
  2. added a commit that references this issue on Aug 13, 2025
  3. CodFrm commented on Aug 13, 2025

    @CodFrm
    Member

    fix by: https://github.com/scriptscat/scriptcat/actions/runs/16931060104

    Temporary solution:

    1. Script Settings
    Image
    1. Permission Management
    Image
    1. Add *
    Image
  4. added a commit that references this issue on Aug 16, 2025
  5. hmjz100 commented on Aug 20, 2025

    @hmjz100

    在 Tampermonkey 中,使用 @connect * 仅对本地地址(如 127.0.0.1、localhost 等)默认免提示放行,
    而对于未显式声明但有 @connect * 并实际访问的外部地址(如 api.bilibili.com),仍会向用户弹窗。

    完全不提示的话不安全吧?应该加一个设置选项给用户决定非本地地址是否提示才是

    // ==UserScript==
    // @name         跨域示例
    // @namespace    http://tampermonkey.net/
    // @version      0.1
    // @description  Example
    // @author       You
    // @match        https://*.example.com/*
    // @grant        GM_xmlhttpRequest
    // @connect      *
    // ==/UserScript==
    
    (function() {
        'use strict';
    
        // 这么写不会弹窗
        GM_xmlhttpRequest({
            method: 'GET',
            url: 'http://127.0.0.1',
            ...
        });
        
        // 这么写会弹窗(除非声明了 `@connect example.com` 或者用户关闭了提示)
        // 虽然这也有可能会被发送 cookie 到陌生服务器,但是这样至少可以让用户知晓脚本 `@connect` 了那些域名
        // 脚本安装页面应明显显示用户脚本 `@connect` 的域名
        GM_xmlhttpRequest({
            method: 'GET',
            url: 'https://api.example.com',
            ...
        });
    })();
    
  6. CodFrm commented on Aug 21, 2025

    @CodFrm
    Member

    @hmjz100 确实如此会更好一些,可以先开个新issue记录一下

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions