Bili动态抽奖助手
Go to file
2021-02-13 11:14:49 +08:00
.github Update clear.yml 2021-02-10 09:21:41 +08:00
.vscode refactor: 模块化代码; feat: 支持多账号 2020-12-24 16:56:01 +08:00
lib feat(lib/HttpRequest.js): 出现不期待响应时重传 2021-02-13 11:14:49 +08:00
test feat(lib/HttpRequest.js): 出现不期待响应时重传 2021-02-13 11:14:49 +08:00
.eslintrc.json fix: dyid重复拼接 2021-01-14 18:47:07 +08:00
.gitignore fix: dyid重复拼接 2021-01-14 18:47:07 +08:00
LICENSE Create LICENSE 2020-12-27 13:52:04 +08:00
main.js feat: 新增pushplus推送功能 2021-02-02 18:45:16 +08:00
package-lock.json fix: dyid重复拼接 2021-01-14 18:47:07 +08:00
package.json feat: 新增pushplus推送功能 2021-02-02 18:45:16 +08:00
README.md fix: 处理获取远程设置时出错的情况 2021-02-09 15:20:07 +08:00

AutoScript

Automatic sweepstakes

Automatic check

Automatic clear dynamic&follow

Automatic sync


动态抽奖

通过Github Actions挂载Nodejs脚本

Actions官方文档

此脚本将在B站专栏草稿中储存转发过的动态id以防止重复转发


操作步骤

★ Star

↓↓

Fork本仓库

fork

↓↓

填入COOKIE

进入B站主页获取Cookie用于登录
Chrome浏览器:

  1. F12打开控制台

  2. 进入Application找到Cookies栏中的SESSDATA将HttpOnly选项取消勾选

    (此步骤是为了方便后续采用JS获取Cookies)

取消httponly

  1. 在Console中复制以下代码回车

    {
        let bilicookie = '';
        document.cookie.split(/\s*;\s*/).forEach(item => {
            const _item = item.split('=');
            if (['DedeUserID', 'bili_jct', 'SESSDATA'].indexOf(_item[0]) !== -1)
                bilicookie += `${_item[0]}=${_item[1]}; `;
        })
        copy(bilicookie); /* 自动复制到粘贴板 */
        console.log(bilicookie)
    }
    
  2. 新建一个COOKIE将获取到的DedeUserID=***;SESSDATA=***;bili_jct=***填入

new secret

new COOKIE

也可以采用其他方式获取所需的Cookie
只需含有 DedeUserID=...;SESSDATA=...;bili_jct=... 三项即可
(分号分割,顺序随意)

↓↓

检测中奖

每两个小时检测一次
通过@信息判断

手动检查

手动触发Automatic check工作流后可在日志中查看 check

微信推送(可选)

Server酱

Server酱是什么?

Repository secrets 中新建一个 SCKEY 并填入对应的值

new secret SCKEY

pushplus

pushplus是什么?

Repository secrets 中新建一个 PUSH_PLUS_TOKEN 并填入对应的值

new secret PUSH_PLUS_TOKEN

↓↓

运行

进入Actions启用工作流

通过手动触发

commit

以上步骤是为了检测是否配置成功

至此程序将会每三小时运行一次

↓↓

完成!

效果

效果


清理动态

只需在 Secret 里添加一个 CLEAR 项并取值为 true

程序便会每30天清理一次动态和关注


其他细节

更新

如果出现

滞后

说明此脚本有更新
通过 Pull Request 更新仓库
注意PR的方向 如下图 如何同步更新Github上Fork的项目

或者
使用GitHub App Pull自动同步

自动更新

须知

This will force sync ALL branches to match source repo. Branches that are created only in the destination repo will not be affected but all the other branches will be hard reset to match source repo.
⚠️ This does mean if upstream ever creates a branch that shares the name, your changes will be gone.

  1. 点我创建 授权令牌

  2. 如图,勾选前两项即可:

如图,勾选前两项即可:

  1. 将 令牌 复制(注意,先复制,一旦关闭网页就不能查看了),再新建Secrets,键名 填入 PAT

  2. 每天与主仓库自动同步一次!

多账号支持

默认支持5个账号

cookies value
COOKIE
COOKIE2
COOKIE3
COOKIE4
COOKIE5
COOKIE*

添加更多的账号
可在文件.github/workflows/node.js.yml
将以下代码中的三处星号(*)改为数字并依次复制粘贴

lottery_*:
runs-on: ubuntu-latest
steps:
  - name: 'Checkout codes'
    uses: actions/checkout@v2
  - name: 'Use Node.js'
    uses: actions/setup-node@v1
    with:
      node-version: '12.18.3'
  - name: 'Run in Nodejs'
    shell: bash
    env:
      NUMBER: *
      COOKIE: ${{ secrets.COOKIE* }}
    run:
      npm start

此时Secrets里就可以添加更多的COOKIE*(简单的找规律问题)

同理须在文件.github/workflows/check.yml
将以下代码中的三处星号(*)改为数字并依次复制粘贴(启用对应的中奖检测)

lottery_*:
  runs-on: ubuntu-latest
  steps:
    - name: 'Checkout codes'
      uses: actions/checkout@v2
    - name: 'Use Node.js'
      uses: actions/setup-node@v1
      with:
        node-version: '12.18.3'
    - name: 'Run in Nodejs'
      shell: bash
      env:
        NUMBER: *
        COOKIE: ${{ secrets.COOKIE* }}
      run:
        npm run check

若使用自动清理功能,还需再.github/workflows/clear.yml

lottery_*:
  runs-on: ubuntu-latest
  steps:
    - name: 'Checkout codes'
      uses: actions/checkout@v2
    - name: 'Use Node.js'
      uses: actions/setup-node@v1
      with:
        node-version: '12.18.3'
    - name: 'Run in Nodejs'
      shell: bash
      env:
        NUMBER: *
        COOKIE: ${{ secrets.COOKIE* }}
      run:
        npm run clear

将以上的三处星号(*)改为数字并依次复制粘贴以清理更多的账号

如何关闭

关闭工作流

部分设置说明

定时运行(UTC+0)

.github/workflows/node.js.yml

schedule:
  - cron: '0 */2 * * *'

如何填写此字段

模式选择

lib/config.js

  • 字段解释
    • model
      • '00'关闭自动抽奖
      • '10'只转发官方抽奖
      • '01'只转发非官方抽奖
      • '11'都转
    • chatmodel
      • '00'关闭自动评论
      • '10'只评论官抽
      • '01'只评论非官抽
      • '11'都评论
    • maxday
      • 开奖时间距离现在的最大天数
      • 默认为-1表示不限制
      • 字符串类型
    • wait
      • 转发间隔时间
      • 单位毫秒
      • 上下浮动30s
      • 字符串类型
    • minfollower
      • up主粉丝数限制
      • 仅限制没有官方认证的up
      • 字符串类型
    • blacklist
      • 防钓鱼uid黑名单
      • 逗号分割字符串
    • blockword
      • 屏蔽词
      • 字符串数组
    • followWhiteList
      • 取关白名单
      • 逗号分割字符串
    • relay
      • 转发评语
      • 字符串数组
    • chat
      • 评论内容
      • 字符串数组

自定义设置

  • 新建一个Repository secrets取名为MY_CONFIG
  • 填入符合JSON语法的内容
  • 字段的名称和对应的值按照字段解释要求填写
  • 需要修改哪项就填入相应的键值对

    例如我要将model值改为'00'就在MY_CONFIG里填入

    {
      "model":"00"
    }