{"id":16975522,"url":"https://github.com/xu22web/tech-study-node","last_synced_at":"2025-09-06T19:45:03.400Z","repository":{"id":61071078,"uuid":"530287346","full_name":"Xu22Web/tech-study-node","owner":"Xu22Web","description":"基于Node.js的自动化学习强国工具 40分/天 A tools helps you with xuexiqiangguo based on Node.js.","archived":false,"fork":false,"pushed_at":"2023-11-30T17:10:20.000Z","size":3227,"stargazers_count":75,"open_issues_count":20,"forks_count":18,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-18T12:03:06.549Z","etag":null,"topics":["chrome","headless-chrome","nodejs","puppeteer","puppeteer-core","qiangguo","typescript","vitest","xuexi","xuexiqiangguo"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Xu22Web.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-08-29T15:48:28.000Z","updated_at":"2025-01-11T01:48:55.000Z","dependencies_parsed_at":"2024-10-28T13:22:31.080Z","dependency_job_id":"274b014b-c195-4c4d-87f2-b5dcdf009c01","html_url":"https://github.com/Xu22Web/tech-study-node","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Xu22Web%2Ftech-study-node","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Xu22Web%2Ftech-study-node/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Xu22Web%2Ftech-study-node/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Xu22Web%2Ftech-study-node/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Xu22Web","download_url":"https://codeload.github.com/Xu22Web/tech-study-node/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244972127,"owners_count":20540925,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chrome","headless-chrome","nodejs","puppeteer","puppeteer-core","qiangguo","typescript","vitest","xuexi","xuexiqiangguo"],"created_at":"2024-10-14T01:23:02.157Z","updated_at":"2025-03-22T14:31:39.555Z","avatar_url":"https://github.com/Xu22Web.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# tech-study-node\n\n### 描述 Description\n\n- 基于 `Node.js` 的自动化学习强国工具\n\n- 依赖 `puppeteer` / `puppeteer-core` 实现浏览器控制\n\n- 依赖 `node-schedule` 实现定时任务\n\n- 依赖 `vitest` 完成基础功能的单元测试\n\n- 通过学习强国`PC 网页版`完成学习任务\n\n- 如果感觉配置麻烦，去看看 [油猴插件脚本版](https://github.com/Xu22Web/tech-study-js '油猴插件脚本版') `https://github.com/Xu22Web/tech-study-js`\n\n### 优点 Advantages\n\n- 学习强国 `PC 网页版` 学习任务的完美解决方案\n\n- 基于 `puppeteer` / `puppeteer-core` 的 API 操作浏览器，实现登录二维码捕获、DOM 元素操作以及处理滑动验证的功能\n\n- 基于 `PushPlus` 推送功能，通过微信远程接收学习情况和服务运行情况\n\n- 基于 `node-schedule` 设置定时任务，每天自动运行定时任务\n\n### 安装与运行 Install and Run\n\n1. 安装依赖\n\n```\npnpm install\n```\n\n2. （ `Windows` 跳过）在 `Linux` 上安装 Puppeteer 依赖（[官方 GitHub 说明](https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md#chrome-headless-doesnt-launch-on-unix 'Linux 的 Puppeteer 依赖')）\n\n\u003e 确保安装了所有必要的依赖项。你可以在 Linux 上运行 `ldd chrome | grep not` 来检查缺少哪些依赖项。下面提供常见必要的依赖项：\n\n\u003cdetails\u003e\n\u003csummary\u003eDebian (e.g. Ubuntu) Dependencies\u003c/summary\u003e\n\n```\n apt install \\\n gconf-service \\\n libasound2 \\\n libatk1.0-0 \\\n libc6 \\\n libcairo2 \\\n libcups2 \\\n libdbus-1-3 \\\n libexpat1 \\\n libfontconfig1 \\\n libgcc1 \\\n libgconf-2-4 \\\n libgdk-pixbuf2.0-0 \\\n libglib2.0-0 \\\n libgtk-3-0 \\\n libnspr4 \\\n libpango-1.0-0 \\\n libpangocairo-1.0-0 \\\n libstdc++6 \\\n libx11-6 \\\n libx11-xcb1 \\\n libxcb1 \\\n libxcomposite1 \\\n libxcursor1 \\\n libxdamage1 \\\n libxext6 \\\n libxfixes3 \\\n libxi6 \\\n libxrandr2 \\\n libxrender1 \\\n libxss1 \\\n libxtst6 \\\n ca-certificates \\\n fonts-liberation \\\n libappindicator1 \\\n libnss3 \\\n lsb-release \\\n xdg-utils \\\n wget\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eCentOS Dependencies\u003c/summary\u003e\n   \n  ```bash\n   yum install -y \\\n   alsa-lib.x86_64 \\\n   atk.x86_64 \\\n   cups-libs.x86_64 \\\n   gtk3.x86_64 \\\n   ipa-gothic-fonts \\\n   libXcomposite.x86_64 \\\n   libXcursor.x86_64 \\\n   libXdamage.x86_64 \\\n   libXext.x86_64 \\\n   libXi.x86_64 \\\n   libXrandr.x86_64 \\\n   libXScrnSaver.x86_64 \\\n   libXtst.x86_64 \\\n   pango.x86_64 \\\n   xorg-x11-fonts-100dpi \\\n   xorg-x11-fonts-75dpi \\\n   xorg-x11-fonts-cyrillic \\\n   xorg-x11-fonts-misc \\\n   xorg-x11-fonts-Type1 \\\n   xorg-x11-utils\n  ```\n\n\u003c/details\u003e\n\n3. 安装 `Google Chrome` 浏览器（注意：`Chromium` 无法使用，`视听学习` 的网页会打开错误），并配置 `executablePath`\n\n\u003cdetails\u003e\n\u003csummary\u003eCentOS\u003c/summary\u003e\n\n- 配置 yum 源\n\n  - 在目录 `/etc/yum.repos.d/` 下新建文件 `google-chrome.repo`\n\n    ```bash\n     cd /etc/yum.repos.d/\n     vim /ect/yum.repos.d/google-chrome.repo\n    ```\n\n  - 编辑文件 `google-chrome.repo` ，保存并退出\n\n    ```\n     [google-chrome]\n     name=google-chrome\n     baseurl=http://dl.google.com/linux/rpm/stable/$basearch\n     enabled=1\n     gpgcheck=1\n     gpgkey=https://dl-ssl.google.com/linux/linux_signing_key.pub\n    ```\n\n- 安装 `Google Chrome` 浏览器\n\n  - Google 官方源安装：\n\n    ```bash\n     yum -y install google-chrome-stable\n    ```\n\n  - Google 官方源可能在中国无法使用，需添加参数:\n\n    ```bash\n     yum -y install google-chrome-stable --nogpgcheck\n    ```\n\n- 测试运行 `Google Chrome` 浏览器\n\n```bash\n google-chrome\n # 或\n google-chrome-stable\n```\n\n- 在 Puppeteer 配置中，将 `executablePath` 字段值改为 `google-chrome` 或 `google-chrome-stable`\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eWindows\u003c/summary\u003e\n\n- 下载安装 `Google Chrome` 浏览器\n\n  - 官网安装：[Google Chrome 网络浏览器](https://www.google.cn/intl/zh-CN/chrome 'Google Chrome 网络浏览器')\n\n- 准备可执行文件 `Google Chrome` 浏览器\n\n  - 在项目根目录，新建文件夹 `.local_chromium`\n\n    ```\n     md .local_chromium\n    ```\n\n  - `Google Chrome` 安装根目录 `C:/Program Files/Google/Chrome/Application` （不一定是这个路径，根据自身情况而定），安装根目录里的 `chrome.exe` 等文件（不含文件夹）、 文件夹 `1xx.0.xxx.xxx` 里的 `1xx.0.xxx.xxx.manifest` 等文件（不含文件夹）以及 `1xx.0.xxx.xxx`里的`Locales` 文件夹（即标记 `✔` 的文件及文件夹），复制到 `.local_chromium`\n\n    ```\n     Application\n      │  chrome.exe                          ✔\n      │  chrome.VisualElementsManifest.xml   ✔\n      │  chrome_proxy.exe                    ✔\n      │  master_preferences                  ✔\n      │\n      └─1xx.0.xxx.xxx\n         │  1xx.0.xxx.xxx.manifest           ✔\n         │  1xx.0.xxx.xxx.manifest           ✔\n         │  chrome.dll                       ✔\n         │  ... ...                          ✔\n         │\n         └─Locales                           ✔\n    ```\n\n- 在 Puppeteer 配置中，将 `executablePath` 字段值改为 `.local_chromium/chrome.exe`\n\n\u003c/details\u003e\n\n4. 完善基础配置\n\n   1. 查看更改 `Puppeteer 配置`（`src/config/pup.ts`），需要注意的配置项\n\n      - `headless` 无头模式，即是否非图形界面显示\n\n      - `executablePath` 可执行文件路径，由于项目采用 `Google Chrome` + `puppeteer-core` 的形式，需要手动下载浏览器并配置此项\n\n   2. 查看更改 `Schedule 配置`（`src/config/schedule.ts`），单或多个定时任务配置\n\n      ```js\n      [\n        {\n          // 若 `Push 配置`中 `enabled` 为 true，任务配置的用户 `token` 为必填项\n          /**\n           * @description 用户昵称\n           */\n          nick: '用户昵称',\n          /**\n           * @description 自己或者好友 token  (-)\n           */\n          token: '用户 token',\n          /**\n           * @description cron 表达式\n           * @example '0 0 12 * * ?' 表示12点, ['0 0 12 * * ?', '0 0 13 * * ?'] 表示十二点和十三点\n           */\n          cron: '0 0 12 * * ?',\n          /**\n           * @description 学习项目配置\n           * @example  [文章选读, 视听学习, 每日答题]\n           */\n          taskConfig: [true, true, true],\n          /**\n           * @description 专项练习 答题失败（由于答完结算，仅包含答题异常或无答案）退出不提交\n           * @example true 退出答题不提交 false 继续答题\n           */\n          paperExitAfterWrong: false,\n        },\n      ];\n      ```\n\n      ```\n        # 关于`node-schedule`定时任务的`cron`表达式\n\n        *    *    *    *    *    *\n        ┬    ┬    ┬    ┬    ┬    ┬\n        │    │    │    │    │    │\n        │    │    │    │    │    └ 星期 (0 - 7) (0 或 7 是星期天)\n        │    │    │    │    └───── 月 (1 - 12)\n        │    │    │    └────────── 日 (1 - 31)\n        │    │    └─────────────── 时 (0 - 23)\n        │    └──────────────────── 分 (0 - 59)\n        └───────────────────────── 秒 (0 - 59，可选)\n      ```\n\n   3. 查看更改 `Study 配置`（`src/config/study.ts`），需要注意的配置项\n\n      - `qrcodeLocalEnabled` 登录二维码本地保存，便于在无头模式登录（开启推送后，自行关闭）\n\n   4. 启用 `PushPlus` 推送步骤（不需要推送请跳过）\n\n      - 在 [PushPlus 官网](https://www.pushplus.plus/ 'PushPlus 官网') 上，注册登录账号。若有其他用户，可添加其他用户为好友。（[PushPlus 好友消息](https://www.pushplus.plus/liaison.html 'PushPlus 好友消息')，官方默认采用 `微信公众号` 推送）\n\n      - 更改 `Push 配置`（`src/config/push.ts`），设置`enabled`为`true`，添加管理员`token`（`管理员`能接收到服务推送以及错误推送，`用户`只能接受到自己的学习通知）\n\n        ```js\n          {\n            /**\n             * @description 启用推送\n             * @example true 启用推送 false 禁用推送\n             */\n            enabled: true,\n            /**\n             * @description 发送服务消息昵称\n             */\n            nick: '管理员',\n            /**\n             * @description 发送服务消息来源\n             */\n            from: 'tech-study-node',\n            /**\n             * @description 管理员的 token\n             */\n            token: '管理员 token',\n          }\n\n        ```\n\n        ![管理员token](./images/administrator.png)\n\n      - 更改 `Schedule 配置`（`src/config/schedule.ts`），添加用户`token`\n\n        ```js\n        [\n          {\n            /**\n             * @description 管理员或者好友 token\n             */\n            token: '用户 token',\n          },\n        ];\n        ```\n\n        ![管理员token](./images/administrator.png)\n\n        ![好友消息token](./images/user.png)\n\n5. 运行\n\n```\npnpm start\n```\n\n6. 定时任务开启时，`学习强国 APP` 扫码登录\n\n   - 未开启 `PushPlus` 推送\n\n     \u003e 注意：`Puppeteer 配置`（`src/config/pup.ts`）中的 headless 字段（new 非图形界面，false 图形界面）\n\n     - 对于图形界面，可直接扫码登陆\n\n     - 对于非图形界面，扫描 src/qrcode 目录下的二维码\n\n   - 开启 `PushPlus` 推送，保存微信公众发送消息里的二维码，扫码登录\n\n### 配置 Configuration\n\n- Puppeteer 配置 `src/config/pup.ts` （[官方文档配置](https://pptr.dev/api/puppeteer.launchoptions 'Puppeteer 使用和配置')）\n\n- Study 配置 `src/config/study.ts` （学习配置）\n\n- PushPlus 配置 `src/config/push.ts` （推送配置）\n\n- API 配置 `src/config/api.ts` （接口配置）\n\n- URL 配置 `src/config/url.ts` （链接配置）\n\n- Schedule 配置 `src/config/schedule.ts` （定时任务配置）\n\n### 附加 Addition\n\n- 在 `test` 文件夹下，依赖 `vitest` 完成基础功能的单元测试\n\n  - `login` 用户登录\n\n  - `watch` 文章选读，视听学习\n\n  - `exam` 每日答题，专项练习\n\n  - `error` 错误测试\n\n  - `api` 测试 API 可用性\n\n  - `log` 测试日志生成保存和自动删除\n\n  - `extension` 浏览器插件测试\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxu22web%2Ftech-study-node","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxu22web%2Ftech-study-node","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxu22web%2Ftech-study-node/lists"}