[
  {
    "path": ".eslintrc.js",
    "content": "module.exports = {\n  env: {\n    browser: true,\n    es2021: true,\n  },\n  overrides: [\n    {\n      env: {\n        node: true,\n      },\n      files: ['.eslintrc.{js,cjs}'],\n      parserOptions: {\n        sourceType: 'script',\n      },\n    },\n  ],\n  parserOptions: {\n    ecmaVersion: 'latest',\n    sourceType: 'module',\n  },\n  extends: ['eslint:recommended', 'plugin:prettier/recommended'],\n  rules: {\n    eqeqeq: 'error', // 必须使用全等\n    'no-nested-ternary': 'error', // 禁止嵌套三元表达式\n    'react-native/no-inline-styles': 'off', // 关闭行内样式检测\n    'react/display-name': 'off', // 关闭display-name检测，打开会导致无法定义箭头函数组件\n    curly: 'error', // 强制要求if换行\n    'no-unused-vars': ['warn'],\n  },\n}\n"
  },
  {
    "path": ".github/workflows/main.yml",
    "content": "name: Build&Deploy\n\non:\n    push:\n        branches:\n            - master\n    schedule:\n        - cron: '0 0 * * *'\n\npermissions:\n  contents: read\n  pages: write\n  id-token: write\n\njobs:\n  build:\n    runs-on: ubuntu-latest\n\n    environment:\n      name: github-pages\n\n    steps:\n    - name: Setup Node.js\n      uses: actions/setup-node@v4.0.2\n\n    - name: Checkout Project\n      uses: actions/checkout@v4.1.1\n\n    - name: Build\n      run: |\n        sudo npm i yarn -g\n        yarn\n        yarn run build\n\n    - name: Copy Files\n      run: |\n        cp CNAME dist/CNAME\n        cp README.MD dist/README.MD\n\n    - name: Upload Artifact\n      uses: actions/upload-pages-artifact@v3\n      with:\n        path: ./dist\n\n    - name: Deploy to GitHub Pages\n      uses: actions/deploy-pages@v4.0.4\n"
  },
  {
    "path": ".gitignore",
    "content": "# Created by .ignore support plugin (hsz.mobi)\n### Node template\n# Logs\nlogs\n*.log\nnpm-debug.log*\nyarn-debug.log*\nyarn-error.log*\nlerna-debug.log*\n\n# Diagnostic reports (https://nodejs.org/api/report.html)\nreport.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json\n\n# Runtime data\npids\n*.pid\n*.seed\n*.pid.lock\n\n# Directory for instrumented libs generated by jscoverage/JSCover\nlib-cov\n\n# Coverage directory used by tools like istanbul\ncoverage\n*.lcov\n\n# nyc test coverage\n.nyc_output\n\n# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)\n.grunt\n\n# Bower dependency directory (https://bower.io/)\nbower_components\n\n# node-waf configuration\n.lock-wscript\n\n# Compiled binary addons (https://nodejs.org/api/addons.html)\nbuild/Release\n\n# Dependency directories\nnode_modules/\njspm_packages/\n\n# Snowpack dependency directory (https://snowpack.dev/)\nweb_modules/\n\n# TypeScript cache\n*.tsbuildinfo\n\n# Optional npm cache directory\n.npm\n\n# Optional eslint cache\n.eslintcache\n\n# Microbundle cache\n.rpt2_cache/\n.rts2_cache_cjs/\n.rts2_cache_es/\n.rts2_cache_umd/\n\n# Optional REPL history\n.node_repl_history\n\n# Output of 'npm pack'\n*.tgz\n\n# Yarn Integrity file\n.yarn-integrity\n\n# dotenv environment variables file\n.env\n.env.test\n\n# parcel-bundler cache (https://parceljs.org/)\n.cache\n.parcel-cache\n\n# Next.js build output\n.next\nout\n\n# Nuxt.js build / generate output\n.nuxt\ndist\n\n# Gatsby files\n.cache/\n# Comment in the public line in if your project uses Gatsby and not Next.js\n# https://nextjs.org/blog/next-9-1#public-directory-support\n# public\n\n# vuepress build output\n.vuepress/dist\n\n# Serverless directories\n.serverless/\n\n# FuseBox cache\n.fusebox/\n\n# DynamoDB Local files\n.dynamodb/\n\n# TernJS port file\n.tern-port\n\n# Stores VSCode versions used for testing VSCode extensions\n.vscode-test\n\n# yarn v2\n.yarn/cache\n.yarn/unplugged\n.yarn/build-state.yml\n.yarn/install-state.gz\n.pnp.*\n\n.idea/"
  },
  {
    "path": ".prettierrc.js",
    "content": "module.exports = {\n  arrowParens: 'avoid', // 箭头函数是否使用括号，avoid是尽可能不用，always是全都用\n  bracketSameLine: true, // >符号是否拆行放置\n  jsxBracketSameLine: true, // jsx内>符号是否拆行放置\n  bracketSpacing: true, // 对象内是否添加空格\n  singleQuote: true, // 是否使用单引号\n  jsxSingleQuote: true, // jsx中是否使用单引号\n  trailingComma: 'all', // 多行时尽可能添加逗号\n  endOfLine: 'auto', // 配置换行符是cr还是lf，auto是自动配置\n  useTabs: false, // 是否使用tab，true使用tab，false使用空格替换tab\n  tabWidth: 2, // 缩进长度\n  semi: false, // 是否强制分号结尾\n}\n"
  },
  {
    "path": "CNAME",
    "content": "adguard.yojigen.tech"
  },
  {
    "path": "LICENSE",
    "content": "MIT License\n\nCopyright (c) 2021 某亚瑟\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n"
  },
  {
    "path": "README.MD",
    "content": "# ChinaListForAdGuardHome\n\n**注意，闪存较小设备不建议使用本项目，规则文件较大，可能会爆闪存**\n\n基于`googlehosts`和`dnsmasq-china-list`生成的`AdGuardHome`上游DNS配置\n\n## 配置文件说明\n\n### ChinaList\n\n基于`dnsmasq-china-list`，使用`腾讯云`的`DoH`解析的配置\n\n### GoogleHostsList\n\n基于`googlehosts`，使用`Cloudflare`的`DoH`解析的配置\n\n### ChinaWhiteList\n\n在融合了前二者的基础上，添加了\n - `Quad9`\n - `Quad101`\n - `OpenDNS`\n - `Google`\n - `Cloudflare`\n的`DoH`作为基础解析的配置，如果需要`除大陆白名单以外全部使用国外DNS`，则可以选择此方案\n\n### ChinaBlackList\n\n在融合了前二者的基础上，添加了\n - `阿里云`\n - `腾讯云`\n - `rubyfish`\n的`DoH`作为基础解析的配置，如果需要`除GoogleHosts以外全部使用大陆DNS`，则可以选择此方案\n\n## 去广告规则\n### HalfLifeList\n[https://github.com/o0HalfLife0o/list](https://github.com/o0HalfLife0o/list)\n> 合并自乘风视频广告过滤规则、EasylistChina、EasylistLite、CJX'sAnnoyance，以及补充的一些规则\n\n### AntiAD\n\n[https://github.com/privacy-protection-tools/anti-AD](https://github.com/privacy-protection-tools/anti-AD)\n> 致力于成为中文区命中率最高的广告过滤列表，实现精确的广告屏蔽和隐私保护。anti-AD现已支持AdGuardHome，dnsmasq， Surge，Pi-Hole，smartdns等网络组件。完全兼容常见的广告过滤工具所支持的各种广告过滤列表格式\n\n### AdRulesDNSList\n[https://github.com/Cats-Team/AdRules](https://github.com/Cats-Team/AdRules)\n\n> List for blocking ads in the Chinese region\n\n\n## 使用方式\n将文件内容复制到`DNS 设置 / 上游 DNS 服务器`中，保存即可\n\n[HalfLifeList.txt](#HalfLifeList)与[AntiAD](#AntiAD)是目前两个比较适合大陆的广告屏蔽表，推荐大家使用\n\n[AdRulesDNSList](#AdRulesDNSList)是更加激进一些的广告屏蔽表，可能会导致误杀，建议大家酌情使用\n\n### 配置文件地址\n\n| 配置文件               | 地址                                                                                                   |\n|--------------------|------------------------------------------------------------------------------------------------------|\n| ChinaList          | [https://adguard.yojigen.tech/ChinaList.txt](https://adguard.yojigen.tech/ChinaList.txt)             |\n| GoogleHostsList    | [https://adguard.yojigen.tech/GoogleHostsList.txt](https://adguard.yojigen.tech/GoogleHostsList.txt) |\n| ChinaWhiteList     | [https://adguard.yojigen.tech/ChinaWhiteList.txt](https://adguard.yojigen.tech/ChinaWhiteList.txt)   |\n| ChinaBlackList     | [https://adguard.yojigen.tech/ChinaBlackList.txt](https://adguard.yojigen.tech/ChinaBlackList.txt)   |\n\n### 去广告规则地址\n\n| 去广告规则              | 地址                                                                                                   |\n|--------------------|------------------------------------------------------------------------------------------------------|\n| HalfLifeList.txt   | [https://adguard.yojigen.tech/HalfLifeList.txt](https://adguard.yojigen.tech/HalfLifeList.txt)       |\n| AntiAD.txt         | [https://adguard.yojigen.tech/AntiAD.txt](https://adguard.yojigen.tech/AntiAD.txt)                   |\n| AdRulesDNSList.txt | [https://adguard.yojigen.tech/AdRulesDNSList.txt](https://adguard.yojigen.tech/AdRulesDNSList.txt)   |\n"
  },
  {
    "path": "index.js",
    "content": "#!/usr/bin/env node\nimport fs from 'node:fs'\n\nconst DIST_PATH = 'dist/'\n\nconst DNSPOD = 'https://1.12.12.12/dns-query'\nconst AliDNS = 'https://223.5.5.5/dns-query'\nconst RubyFish = 'https://dns.rubyfish.cn/dns-query'\n\nconst Quad9 = 'https://dns10.quad9.net/dns-query'\nconst Cloudflare = 'https://1.0.0.1/dns-query'\nconst Google = 'https://dns.google/dns-query'\nconst Quad101 = 'https://dns.twnic.tw/dns-query'\nconst OpenDNS = 'https://doh.opendns.com/dns-query'\n\nconst ChinaDNS = DNSPOD\nconst GlobalDNS = Cloudflare\n\nconst makeDist = async () => {\n  try {\n    fs.mkdirSync(DIST_PATH)\n    return Promise.resolve()\n  } catch (e) {\n    console.error('dist目录创建失败')\n    console.error(e)\n    return Promise.resolve()\n  }\n}\n\nconst getChinaList = async () => {\n  let chinaListResponse = await fetch(\n    'https://raw.githubusercontent.com/felixonmars/dnsmasq-china-list/master/accelerated-domains.china.conf',\n  )\n  let chinaList = await chinaListResponse.text()\n  chinaList = chinaList.replace(/#.+/g, '')\n  chinaList = chinaList.replace(\n    /server=\\/(.+)\\/[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+/g,\n    `[/$1/]${ChinaDNS}`,\n  )\n  chinaList = chinaList.replace(/(\\s)\\s*/g, '$1')\n  chinaList = chinaList.trim()\n  fs.writeFileSync(DIST_PATH + 'ChinaList.txt', chinaList, 'UTF-8')\n  let googleHostsListResponse = await fetch(\n    'https://raw.githubusercontent.com/googlehosts/hosts/master/hosts-files/dnsmasq.conf',\n  )\n  let googleHostsList = await googleHostsListResponse.text()\n  googleHostsList = googleHostsList.replace(/#.+/g, '')\n  googleHostsList = googleHostsList.replace(\n    /address=\\/(.+)\\/[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+/g,\n    `[/$1/]${GlobalDNS}`,\n  )\n  googleHostsList = googleHostsList.replace(`[/localhost/]${GlobalDNS}`, '')\n  googleHostsList = googleHostsList.replace(/(\\s)\\s*/g, '$1')\n  googleHostsList = googleHostsList.trim()\n  fs.writeFileSync(DIST_PATH + 'GoogleHostsList.txt', googleHostsList, 'UTF-8')\n  const chinaWhiteList = `${chinaList}\n  ${googleHostsList}\n  ${Quad9}\n  ${Quad101}\n  ${Google}\n  ${Cloudflare}\n  ${OpenDNS}\n  `\n  fs.writeFileSync(DIST_PATH + 'ChinaWhiteList.txt', chinaWhiteList, 'UTF-8')\n  const chinaBlackList = `${chinaList}\n  ${googleHostsList}\n  ${AliDNS}\n  ${DNSPOD}\n  ${RubyFish}\n  `\n  fs.writeFileSync(DIST_PATH + 'ChinaBlackList.txt', chinaBlackList, 'UTF-8')\n}\n\nconst getHalfLifeList = async () => {\n  let halfLifeListResponse = await fetch(\n    'https://raw.githubusercontent.com/o0HalfLife0o/list/master/ad.txt',\n  )\n  let halfLifeList = await halfLifeListResponse.text()\n  halfLifeList = halfLifeList.replace(/! Checksum: (.+)/, '')\n  halfLifeList = halfLifeList.replace(/! Title: (.+)/, '! Title: HalfLifeList')\n  halfLifeList = halfLifeList.trim()\n  fs.writeFileSync(DIST_PATH + 'HalfLifeList.txt', halfLifeList, 'UTF-8')\n}\n\nconst getAntiAD = async () => {\n  let antiADResponse = await fetch('https://anti-ad.net/easylist.txt')\n  let antiAD = await antiADResponse.text()\n  antiAD = antiAD.replace(/!Title: (.+)/, '!Title: AntiAD')\n  antiAD = antiAD.trim()\n  fs.writeFileSync(DIST_PATH + 'AntiAD.txt', antiAD, 'UTF-8')\n}\n\nconst getAdRulesDNSList = async () => {\n  let adRulesDNSListResponse = await fetch('https://adrules.top/dns.txt')\n  let adRulesDNSList = await adRulesDNSListResponse.text()\n  adRulesDNSList = adRulesDNSList.replace(\n    /!Title: (.+)/,\n    '!Title: AdRulesDNSList',\n  )\n  adRulesDNSList = adRulesDNSList.trim()\n  fs.writeFileSync(DIST_PATH + 'AdRulesDNSList.txt', adRulesDNSList, 'UTF-8')\n}\n\nconst main = async () => {\n  await makeDist()\n  await getChinaList()\n  await getHalfLifeList()\n  await getAntiAD()\n  await getAdRulesDNSList()\n}\n\nmain()\n  .then(() => {\n    console.log('规则创建完成')\n  })\n  .catch(reason => {\n    console.error('规则创建错误', reason)\n  })\n"
  },
  {
    "path": "package.json",
    "content": "{\n  \"name\": \"ChinaListForAdGuardHome\",\n  \"version\": \"1.0.0\",\n  \"main\": \"index.js\",\n  \"license\": \"MIT\",\n  \"scripts\": {\n    \"build\": \"node index.js\",\n    \"lint\": \"eslint \\\"**/*.{js,ts,jsx,tsx}\\\"\"\n  },\n  \"type\": \"module\",\n  \"dependencies\": {\n    \"node-fetch\": \"^3.3.2\"\n  },\n  \"devDependencies\": {\n    \"eslint\": \"^8.0.1\",\n    \"eslint-config-prettier\": \"^9.1.0\",\n    \"eslint-plugin-prettier\": \"^5.1.3\",\n    \"prettier\": \"^3.2.5\"\n  }\n}\n"
  }
]