Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Script Profile for ChatGPT | Scripts Sharing #520

Closed
zzzgydi opened this issue Apr 15, 2023 · 7 comments
Closed

Script Profile for ChatGPT | Scripts Sharing #520

zzzgydi opened this issue Apr 15, 2023 · 7 comments

Comments

@zzzgydi
Copy link
Owner

zzzgydi commented Apr 15, 2023

分享一段针对ChatGPT的分组规则,可以根据自己的需求更改regexrulesregex是匹配出能访问ChatGPT节点的正则,rules是clash rules,分组名为ChatGPT

// New Proxy Group for ChatGPT

function main(params) {
  // TODO modify this regex to what you want
  const regex = /美国|新加坡|日本/;
  
  // TODO modify this rules to what you want
  const rules = [
    "DOMAIN-KEYWORD,openai,ChatGPT",
    "DOMAIN-KEYWORD,cloudfare,ChatGPT"
  ];

  const proxies = params.proxies
    .filter((e) => regex.test(e.name))
    .map((e) => e.name);

  const groups = params["proxy-groups"];

  const newGroup = {
    name: "ChatGPT",
    type: "select",
    proxies,
  };

  if (groups.length > 1) {
    groups.splice(1, 0, newGroup);
    params.rules = rules.concat(params.rules);
  }

  return params;
}
@zzzgydi zzzgydi pinned this issue Apr 15, 2023
@together-ds
Copy link

脚本的入参 params 是不是和profile配置文件的结构一致?

@zzzgydi
Copy link
Owner Author

zzzgydi commented Apr 17, 2023

@together-ds 是的,已经将yaml转成json结构

@zzzgydi zzzgydi closed this as completed May 18, 2023
@lainbo
Copy link

lainbo commented Jun 3, 2023

由于一些原因可能导致Chat GPT的封号,所以希望补充一条规则

"DOMAIN-KEYWORD,sentry,ChatGPT"

@Toperlock
Copy link

由于一些原因可能导致Chat GPT的封号,所以希望补充一条规则

"DOMAIN-KEYWORD,sentry,ChatGPT"

sentry.io直接REJECT就不用担心了

@lainbo
Copy link

lainbo commented Jun 7, 2023

由于一些原因可能导致Chat GPT的封号,所以希望补充一条规则

"DOMAIN-KEYWORD,sentry,ChatGPT"

sentry.io直接REJECT就不用担心了

你看看我发的原因这个推特用户的其他推文呢?有提到使用一些技术手段阻止Open AI追踪也会导致封号

@Toperlock
Copy link

由于一些原因可能导致Chat GPT的封号,所以希望补充一条规则

"DOMAIN-KEYWORD,sentry,ChatGPT"

sentry.io直接REJECT就不用担心了

你看看我发的原因这个推特用户的其他推文呢?有提到使用一些技术手段阻止Open AI追踪也会导致封号

我这样子用了很久,亲测没问题

@lainbo
Copy link

lainbo commented Jun 12, 2023

改动了一下这个函数
筛选节点部分的正则更灵活且更容易维护
rules部分的规则是根据ACL4SSR里面的规则加上了个人整合的一部分

function main(params) {
  // 下方两个数组的每一项均为正则,忽略大小写
  const mustHaveKeywords = ['美国', 'United States', '新加坡', 'sg'];
  // 过滤掉美国节点中,包含以下关键字的节点(过滤低质量节点,要过滤哪些根据自己的订阅来)
  const mustNotHaveKeywords = ['实验性', '0\\.', 'b'];

  const regexParts = [];
  mustHaveKeywords.forEach(keyword => {
    const mustNotHavePart = mustNotHaveKeywords.map(k => `(?!.*${k})`).join('');
    regexParts.push(`(?=.*${keyword}${mustNotHavePart}).*`);
  });
  const regex = new RegExp(`^(${regexParts.join('|')})$`, 'i');
  
	const rules = [
    "DOMAIN-KEYWORD,cloudfare,ChatGPT",
    "DOMAIN-KEYWORD,openai,ChatGPT",
    "DOMAIN-KEYWORD,sentry,ChatGPT",
    "DOMAIN-SUFFIX,ai.com,ChatGPT",
    "DOMAIN-SUFFIX,auth0.com,ChatGPT",
    "DOMAIN-SUFFIX,challenges.cloudflare.com,ChatGPT",
    "DOMAIN-SUFFIX,client-api.arkoselabs.com,ChatGPT",
    "DOMAIN-SUFFIX,events.statsigapi.net,ChatGPT",
    "DOMAIN-SUFFIX,featuregates.org,ChatGPT",
    "DOMAIN-SUFFIX,identrust.com,ChatGPT",
    "DOMAIN-SUFFIX,ingest.sentry.io,ChatGPT",
    "DOMAIN-SUFFIX,intercom.io,ChatGPT",
    "DOMAIN-SUFFIX,intercomcdn.com,ChatGPT",
    "DOMAIN-SUFFIX,openai.com,ChatGPT",
    "DOMAIN-SUFFIX,openaiapi-site.azureedge.net,ChatGPT",
    "DOMAIN-SUFFIX,stripe.com,ChatGPT"
  ];

  const proxies = params.proxies
    .filter(i => regex.test(i.name))
    .map(e => e.name);

  const groups = params["proxy-groups"];

  const newGroup = {
    name: "ChatGPT",
    type: "select",
    proxies,
  };

  if (groups.length > 1) {
    groups.splice(1, 0, newGroup);
    params.rules = rules.concat(params.rules);
  }

  return params;
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants