<|start_filename|>commands/tasks/unicom/gameYearBox.js<|end_filename|>
const { default: PQueue } = require("p-queue");

var transParams = (data) => {
  let params = new URLSearchParams();
  for (let item in data) {
    params.append(item, data["" + item + ""]);
  }
  return params;
};

var gameYearBox = {
  games: async (axios, options) => {
    const useragent = `Mozilla/5.0 (Linux; Android 7.1.2; SM-G977N Build/LMY48Z; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/75.0.3770.143 Mobile Safari/537.36; unicom{version:android@8.0100,desmobile:${options.user}};devicetype{deviceBrand:samsung,deviceModel:SM-G977N};{yw_code:}    `;
    let { data, config } = await axios.request({
      headers: {
        "user-agent": useragent,
        referer:
          "https://img.client.10010.com/newyeargame/index.html?channelID=04",
        origin: "https://img.client.10010.com",
      },
      url: `https://m.client.10010.com/game_year_activity`,
      method: "POST",
      data: transParams({
        methodType: "games",
        clientVersion: "8.0102",
        deviceType: "Android",
      }),
    });
    return {
      games: data.data,
      jar: config.jar,
    };
  },
  query_box_info: async (axios, options) => {
    const useragent = `Mozilla/5.0 (Linux; Android 7.1.2; SM-G977N Build/LMY48Z; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/75.0.3770.143 Mobile Safari/537.36; unicom{version:android@8.0100,desmobile:${options.user}};devicetype{deviceBrand:samsung,deviceModel:SM-G977N};{yw_code:}    `;
    let { data } = await axios.request({
      headers: {
        "user-agent": useragent,
        referer:
          "https://img.client.10010.com/newyeargame/index.html?channelID=04",
        origin: "https://img.client.10010.com",
      },
      url: `https://m.client.10010.com/game_year_activity`,
      method: "POST",
      data: transParams({
        methodType: "query_box_info",
        clientVersion: "8.0102",
        deviceType: "Android",
      }),
    });
    return data.data;
  },
  box_get_reward: async (axios, options) => {
    const useragent = `Mozilla/5.0 (Linux; Android 7.1.2; SM-G977N Build/LMY48Z; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/75.0.3770.143 Mobile Safari/537.36; unicom{version:android@8.0100,desmobile:${options.user}};devicetype{deviceBrand:samsung,deviceModel:SM-G977N};{yw_code:}    `;
    let { data } = await axios.request({
      headers: {
        "user-agent": useragent,
        referer:
          "https://img.client.10010.com/newyeargame/index.html?channelID=04",
        origin: "https://img.client.10010.com",
      },
      url: `https://m.client.10010.com/game_year_activity`,
      method: "POST",
      data: transParams({
        methodType: "box_get_reward",
        clientVersion: "8.0102",
        deviceType: "Android",
        boxFlag: options.boxFlag,
      }),
    });
    if (data.code === "0000") {
      console.log(data.desc, data.data.reward_type, data.data.reward_val);
    } else {
      console.log(data.desc);
    }
  },
  doTask: async (axios, options) => {
    let boxinfo = await gameYearBox.query_box_info(axios, options);
    let boxs = [
      {
        name: "first_box",
        duration: 10,
        boxFlag: 1,
      },
      {
        name: "second_box",
        duration: 20,
        boxFlag: 2,
      },
      {
        name: "third_box",
        duration: 30,
        boxFlag: 3,
      },
      {
        name: "fourth_box",
        duration: 60,
        boxFlag: 4,
      },
    ];
    for (let box of boxs) {
      if (boxinfo[box.name] === "0") {
        console.log("领取宝箱中，尝试达成宝箱条件");
        let producGame = require("./producGame");
        let { games, jar } = await gameYearBox.games(axios, options);
        let queue = new PQueue({ concurrency: 2 });
        console.log("调度任务中", "并发数", 2);
        let n =
          Math.floor(
            (box.duration - parseInt(boxinfo.total_duration_num)) / 6
          ) + 1;
        console.log("预计再游玩", n * 6, "分钟");
        for (let game of games) {
          queue.add(async () => {
            console.log(game.name);
            await producGame.gameverify(axios, {
              ...options,
              jar,
              game,
            });
            await producGame.gamerecord(axios, {
              ...options,
              gameId: game.game_id,
            });
            await producGame.playGame(axios, {
              ...options,
              jar,
              game: {
                ...game,
                gameCode: game.game_code,
              },
            });
          });
          --n;
          if (n <= 0) {
            break;
          }
        }
        await queue.onIdle();
        await gameYearBox.query_box_info(axios, options);
        await gameYearBox.box_get_reward(axios, {
          ...options,
          boxFlag: box.boxFlag,
        });
      } else if (boxinfo[box.name] === "1") {
        console.log("领取宝箱中");
        await gameYearBox.box_get_reward(axios, {
          ...options,
          boxFlag: box.boxFlag,
        });
      } else if (boxinfo[box.name] === "2") {
        console.log("已领取，跳过");
      }
    }
  },
};

module.exports = gameYearBox;


<|start_filename|>commands/tasks/unicom/freeDownFloorAd.js<|end_filename|>
let crypto = require("crypto");
let moment = require("moment");
let { encryptPhone, sign, encrypt } = require("./handlers/PAES.js");
const { useragent, randomNumber } = require("./handlers/myPhone");
const gameEvents = require("./handlers/dailyEvent");
let { transParams } = require("./handlers/gameUtils");
const { v4: uuidv4 } = require("uuid");
const appList = [
  {
    mMainTitle: "线上桌游吧，随时随地玩桌游",
    mSubTitle: "会玩",
    mPkgName: "com.wepie.weplay",
  },
];

let Data = {
  commonInfo: {
    traceId: "10000820210212012126257215774155",
    currentTime: "20210212012126257",
    channelCode: "100008",
  },
  params: {
    serialNumber: "",
    appList: [],
  },
  methodType: "2", //1 游戏 2 app
};

let freeDownFloorAd = {
  doTask: async (axios, options) => {
    // 10000820210212140437577215167304
    //"10000820210212155412093 215210247",
    // "20210212155412093",
    let currentTime = moment().format("YYYYMMDDHHmmssSSS");
    let traceId = "100008" + currentTime + "215210247";
    Data.commonInfo.traceId = traceId;
    Data.commonInfo.currentTime = currentTime;
    Data.params.serialNumber = options.user;
    Data.params.appList.push(appList[0]);
    await freeDownFloorAd.begin(axios, options, Data);
    let jar1 = await freeDownFloorAd.onAdDisplay(axios, options, Data);
    let { citycode } = await freeDownFloorAd.onAdClick(axios, options, Data);
    await freeDownFloorAd.getCoins(axios, options, citycode);
    await freeDownFloorAd.findAll(axios, options);
    await freeDownFloorAd.onAdAppDownloadStart(axios, options, Data);
    await freeDownFloorAd.onAdAppDownloadSucceed(axios, options, Data);
    await freeDownFloorAd.onAdAppInstall(axios, options, Data);
    await freeDownFloorAd.onAdAppInstalled(axios, options, Data);
    await freeDownFloorAd.onAdAppActive(axios, options, Data);
    await freeDownFloorAd.lookVideoDouble(axios, options);
    await freeDownFloorAd.getIntegralFree(axios, options, jar1);
    await freeDownFloorAd.onAdDisplay(axios, options, Data);
  },
  begin: async (axios, options, appinfo) => {
    let currentTime = moment().format("YYYYMMDDHHmmssSSS");
    let traceId = "100008" + currentTime + "215210247";
    appinfo.commonInfo.traceId = traceId;
    appinfo.commonInfo.traceId = traceId;
    appinfo.methodType = "1";
    let res = await axios
      .request({
        baseURL: "https://m.client.10010.com/",
        headers: {
          "user-agent": "okhttp/4.4.0",
          origin: "https://m.client.10010.com/",
          "Content-Type": "application/json;charset=UTF-8",
        },
        url: `/uniAdmsInterface/getFreeDownFloorAd`,
        method: "post",
        data: appinfo,
      })
      .catch((err) => console.log(err));
    let jar1 = res.config.jar.toJSON();
    jar1.cookies.push({
      key: "req_wheel",
      value: "ssss",
      expires: "2021-02-13T09:43:35.000Z",
      domain: "10010.com",
      path: "/",
      hostOnly: false,
      creation: "2021-02-12T08:43:35.008Z",
      lastAccessed: "2021-02-12T08:43:35.008Z",
    });
    console.log(res.data);
    console.log("等待15秒再继续");
    // eslint-disable-next-line no-unused-vars
    await new Promise((resolve, reject) => setTimeout(resolve, 15 * 1000));
    return jar1;
  },
  onAdDisplay: async (axios, options, appinfo) => {
    let currentTime = moment().format("YYYYMMDDHHmmssSSS");
    let traceId = "100008" + currentTime + "215210247";
    appinfo.commonInfo.traceId = traceId;
    appinfo.commonInfo.currentTime = currentTime;
    appinfo.params.operator = "onAdDisplay";
    let res = await axios
      .request({
        baseURL: "https://m.client.10010.com/",
        headers: {
          "user-agent": "okhttp/4.4.0",
          origin: "https://m.client.10010.com/",
          "Content-Type": "application/json;charset=UTF-8",
        },
        url: `/uniAdmsInterface/getFreeDownFloorAd`,
        method: "post",
        data: appinfo,
      })
      .catch((err) => console.log(err));
    let jar1 = res.config.jar.toJSON();
    jar1.cookies.push({
      key: "req_wheel",
      value: "ssss",
      expires: "2021-02-13T09:43:35.000Z",
      domain: "10010.com",
      path: "/",
      hostOnly: false,
      creation: "2021-02-12T08:43:35.008Z",
      lastAccessed: "2021-02-12T08:43:35.008Z",
    });
    console.log(res.data);
    console.log("等待15秒再继续");
    // eslint-disable-next-line no-unused-vars
    await new Promise((resolve, reject) => setTimeout(resolve, 15 * 1000));
    return jar1;
  },
  // eslint-disable-next-line no-unused-vars
  findAll: async (axios, options) => {
    let res = await axios
      .request({
        baseURL: "https://m.client.10010.com/",
        headers: {
          "user-agent": "okhttp/4.4.0",
          "Content-Type": "application/json;charset=UTF-8",
        },
        url: `/mobileService/downloads/findAll.htm`,
        method: "post",
      })
      .catch((err) => console.log(err));
    console.log(res.data);
  },
  onAdClick: async (axios, options, appinfo) => {
    let currentTime = moment().format("YYYYMMDDHHmmssSSS");
    let traceId = "100008" + currentTime + "215210247";
    appinfo.commonInfo.traceId = traceId;
    appinfo.commonInfo.currentTime = currentTime;
    appinfo.params.operator = "onAdClick";
    let res = await axios
      .request({
        baseURL: "https://m.client.10010.com/",
        headers: {
          "user-agent": "okhttp/4.4.0",
          origin: "https://m.client.10010.com",
          "Content-Type": "application/json;charset=UTF-8",
        },
        url: `/uniAdmsInterface/getFreeDownFloorAd`,
        method: "post",
        data: appinfo,
      })
      .catch((err) => console.log(err));
    console.log(res.data);
    let jar1 = res.config.jar;

    let cookiesJson = jar1.toJSON();
    let citycode = cookiesJson.cookies.find((i) => i.key == "city");
    if (!citycode) {
      throw new Error("citycode缺失");
    }
    citycode = citycode.value;
    console.log("等待15秒再继续");
    // eslint-disable-next-line no-unused-vars
    await new Promise((resolve, reject) => setTimeout(resolve, 15 * 1000));
    return { citycode: citycode };
  },
  onAdAppDownloadStart: async (axios, options, appinfo) => {
    let currentTime = moment().format("YYYYMMDDHHmmssSSS");
    let traceId = "100008" + currentTime + "215210247";
    appinfo.commonInfo.traceId = traceId;
    appinfo.commonInfo.currentTime = currentTime;
    appinfo.params.operator = "onAdAppDownloadStart";
    let res = await axios
      .request({
        baseURL: "https://m.client.10010.com/",
        headers: {
          "user-agent": "okhttp/4.4.0",
          origin: "https://m.client.10010.com",
          "Content-Type": "application/json;charset=UTF-8",
        },
        url: `/uniAdmsInterface/getFreeDownFloorAd`,
        method: "post",
        data: appinfo,
      })
      .catch((err) => console.log(err));
    console.log(res.data);
    console.log("等待15秒再继续");
    // eslint-disable-next-line no-unused-vars
    await new Promise((resolve, reject) => setTimeout(resolve, 15 * 1000));
  },
  onAdAppDownloadSucceed: async (axios, options, appinfo) => {
    let currentTime = moment().format("YYYYMMDDHHmmssSSS");
    let traceId = "100008" + currentTime + "215210247";
    appinfo.commonInfo.traceId = traceId;
    appinfo.commonInfo.currentTime = currentTime;
    appinfo.params.operator = "onAdAppDownloadSucceed";
    let res = await axios
      .request({
        baseURL: "https://m.client.10010.com/",
        headers: {
          "user-agent": "okhttp/4.4.0",
          origin: "https://m.client.10010.com",
          "Content-Type": "application/json;charset=UTF-8",
        },
        url: `/uniAdmsInterface/getFreeDownFloorAd`,
        method: "post",
        data: appinfo,
      })
      .catch((err) => console.log(err));
    console.log(res.data);
    console.log("等待15秒再继续");
    // eslint-disable-next-line no-unused-vars
    await new Promise((resolve, reject) => setTimeout(resolve, 15 * 1000));
  },
  onAdAppInstall: async (axios, options, appinfo) => {
    let currentTime = moment().format("YYYYMMDDHHmmssSSS");
    let traceId = "100008" + currentTime + "215210247";
    appinfo.commonInfo.traceId = traceId;
    appinfo.commonInfo.currentTime = currentTime;
    appinfo.params.operator = "onAdAppInstall";
    let res = await axios
      .request({
        baseURL: "https://m.client.10010.com/",
        headers: {
          "user-agent": "okhttp/4.4.0",
          origin: "https://m.client.10010.com",
          "Content-Type": "application/json;charset=UTF-8",
        },
        url: `/uniAdmsInterface/getFreeDownFloorAd`,
        method: "post",
        data: appinfo,
      })
      .catch((err) => console.log(err));
    console.log(res.data);
    console.log("等待15秒再继续");
    // eslint-disable-next-line no-unused-vars
    await new Promise((resolve, reject) => setTimeout(resolve, 15 * 1000));
  },
  onAdAppInstalled: async (axios, options, appinfo) => {
    let currentTime = moment().format("YYYYMMDDHHmmssSSS");
    let traceId = "100008" + currentTime + "215210247";
    appinfo.commonInfo.traceId = traceId;
    appinfo.commonInfo.currentTime = currentTime;
    appinfo.params.operator = "onAdAppInstall";
    let res = await axios
      .request({
        baseURL: "https://m.client.10010.com/",
        headers: {
          "user-agent": "okhttp/4.4.0",
          origin: "https://m.client.10010.com",
          "Content-Type": "application/json;charset=UTF-8",
        },
        url: `/uniAdmsInterface/getFreeDownFloorAd`,
        method: "post",
        data: appinfo,
      })
      .catch((err) => console.log(err));
    console.log(res.data);
    console.log("等待15秒再继续");
    // eslint-disable-next-line no-unused-vars
    await new Promise((resolve, reject) => setTimeout(resolve, 15 * 1000));
  },
  onAdAppActive: async (axios, options, appinfo) => {
    let currentTime = moment().format("YYYYMMDDHHmmssSSS");
    let traceId = "100008" + currentTime + "215210247";
    appinfo.commonInfo.traceId = traceId;
    appinfo.commonInfo.currentTime = currentTime;
    appinfo.params.operator = "onAdAppActive";
    let res = await axios
      .request({
        baseURL: "https://m.client.10010.com/",
        headers: {
          "user-agent": "okhttp/4.4.0",
          origin: "https://m.client.10010.com",
          "Content-Type": "application/json;charset=UTF-8",
        },
        url: `/uniAdmsInterface/getFreeDownFloorAd`,
        method: "post",
        data: appinfo,
      })
      .catch((err) => console.log(err));
    console.log(res.data);
    let jar1 = res.config.jar;

    let cookiesJson = jar1.toJSON();
    let citycode = cookiesJson.cookies.find((i) => i.key == "city");
    if (!citycode) {
      throw new Error("citycode缺失");
    }
    citycode = citycode.value;
    console.log("等待15秒再继续");
    // eslint-disable-next-line no-unused-vars
    await new Promise((resolve, reject) => setTimeout(resolve, 15 * 1000));
    return { citycode: citycode };
  },
  // eslint-disable-next-line no-unused-vars
  getIntegralFree: async (axios, options, jar) => {
    await axios
      .request({
        headers: {
          "user-agent": useragent(options),
          origin: "https://img.client.10010.com",
          "Content-Type": "application/x-www-form-urlencoded",
          Cookie: "req_wheel=ssss;",
        },
        url: `https://act.10010.com/SigninApp/floorData/getIntegralFree`,
        method: "post",
        Referer: `https://img.client.10010.com/SigininApp/index.html?yw_code=&desmobile=${options.user}&version=android@8.0102`,
        "X-Requested-With": "com.sinovatech.unicom.ui",
      })
      .catch((err) => console.log(err));
  },
  getCoins: async (axios, options, { citycode }) => {
    let URL =
      `https://img.client.10010.com/SigininApp/index.html?` +
      `yw_code=&desmobile=${options.user}&version=android@8.0102#/&` +
      `operation=click&localUrl=https://img.client.10010.com/SigininApp/index.html?yw_code=&desmobile=${options.user
      }&version=android@8.0102&nodename=DIV&path=wrap0item0item-wrap0items-wrap0content2container6home0app&stc=&citycode=${citycode}&jfuser=${options.user
      }||&t=${new Date().getTime()}&uuid=${uuidv4()}`;
    URL =
      "https://m.jf.10010.com/jf-log/4.gif?domain=img.client.10010.com&href=" +
      encodeURIComponent(URL);
    await axios
      .request({
        headers: {
          "user-agent": useragent(options),
          origin: "https://img.client.10010.com",
        },
        url: URL,
        method: "get",
        Referer: `https://img.client.10010.com/SigininApp/index.html?yw_code=&desmobile=${options.user}&version=android@8.0102`,
        "X-Requested-With": "com.sinovatech.unicom.ui",
      })
      .catch((err) => console.log(err));
  },
  lookVideoDouble: async (axios, options) => {
    let params1 = {
      arguments1: "AC20200624091508",
      arguments2: "GGPD",
      arguments3: "f65cd1e62af1407f88b069c0ffd4e1d8",
      arguments4: new Date().getTime(),
      arguments6: "517050707",
      arguments7: "517050707",
      arguments8: "123456",
      arguments9: "4640b530b3f7481bb5821c6871854ce5",
      netWay: "Wifi",
      remark1: "签到任务下载应用得积分",
      remark: "签到任务下载应用得积分",
      version: `android@8.0102`,
      codeId: 812759,
    };
    params1["sign"] = sign([
      params1.arguments1,
      params1.arguments2,
      params1.arguments3,
      params1.arguments4,
    ]);
    let { num, jar } = await require("./taskcallback").query(axios, {
      ...options,
      params: params1,
    });

    if (!num) {
      console.log(`签到小游戏: 今日已完成`);
      return;
    }
  },
};
module.exports = freeDownFloorAd;


<|start_filename|>index.js<|end_filename|>
(async () => {
  try {
    require("./AutoSignMachine.js").run();
  } catch (e) {
    if (process.env.DEBUG_MODE) {
      console.log(e);
    }
  }
})();


<|start_filename|>commands/tasks/unicom/dailyGrabdollPage.js<|end_filename|>
var crypto = require("crypto");
var moment = require("moment");

// 开心抓大奖
var transParams = (data) => {
  let params = new URLSearchParams();
  for (let item in data) {
    params.append(item, data["" + item + ""]);
  }
  return params;
};
function w() {
  var e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {},
    t = [];
  return (
    Object.keys(e).forEach(function (a) {
      t.push("".concat(a, "=").concat(encodeURIComponent(e[a])));
    }),
    t.join("&")
  );
}
var sign = (data) => {
  let str = "integralofficial&";
  let params = [];
  data.forEach((v, i) => {
    if (v) {
      params.push("arguments" + (i + 1) + v);
    }
  });
  return crypto
    .createHash("md5")
    .update(str + params.join("&"))
    .digest("hex");
};

function encryption(data, key) {
  var iv = "";
  var cipherEncoding = "base64";
  var cipher = crypto.createCipheriv("aes-128-ecb", key, iv);
  cipher.setAutoPadding(true);
  return Buffer.concat([cipher.update(data), cipher.final()]).toString(
    cipherEncoding
  );
}

var dailyGrabdollPage = {
  getState: async (axios, options) => {
    const useragent = `Mozilla/5.0 (Linux; Android 7.1.2; SM-G977N Build/LMY48Z; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/75.0.3770.143 Mobile Safari/537.36; unicom{version:android@8.0100,desmobile:${options.user}};devicetype{deviceBrand:samsung,deviceModel:SM-G977N};{yw_code:}`;
    const { searchParams, ecs_token } = options;
    let phone = encryption(options.user, "gb6YCccUvth75Tm2");
    let timestamp = moment().format("YYYYMMDDHHmmss");
    let { data, config } = await axios.request({
      headers: {
        "user-agent": useragent,
        referer: `https://wxapp.msmds.cn/h5/react_web/unicom/grabdollPage?source=unicom&type=02&ticket=${searchParams.ticket}&version=android@8.0100&timestamp=${timestamp}&desmobile=${options.user}&num=0&postage=${searchParams.postage}&duanlianjieabc=tbKHR&userNumber=${options.user}`,
      },
      url: `https://wxapp.msmds.cn/jplus/api/channelGrabDoll/index`,
      method: "POST",
      data: transParams({
        channelId: "LT_channel",
        phone: phone,
        token: ecs_token,
        sourceCode: "lt_zhuawawa",
      }),
    });
    if (data.code !== 200) {
      console.log("获取任务状态失败");
      return {
        jar: config.jar,
        state: false,
      };
    } else {
      return {
        jar: config.jar,
        state: data.data.grabDollAgain,
      };
    }
  },
  doTask: async (axios, options) => {
    const useragent = `Mozilla/5.0 (Linux; Android 7.1.2; SM-G977N Build/LMY48Z; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/75.0.3770.143 Mobile Safari/537.36; unicom{version:android@8.0100,desmobile:${options.user}};devicetype{deviceBrand:samsung,deviceModel:SM-G977N};{yw_code:}`;
    let searchParams = {};
    let result = await axios
      .request({
        baseURL: "https://m.client.10010.com/",
        headers: {
          "user-agent": useragent,
          referer: `https://img.client.10010.com/`,
          origin: "https://img.client.10010.com",
        },
        url: `https://m.client.10010.com/mobileService/openPlatform/openPlatLine.htm?to_url=https://wxapp.msmds.cn/h5/react_web/unicom/grabdollPage?source=unicom&duanlianjieabc=tbKHR`,
        method: "GET",
        transformResponse: (data, headers) => {
          if ("location" in headers) {
            let uu = new URL(headers.location);
            let pp = {};
            for (let p of uu.searchParams) {
              pp[p[0]] = p[1];
            }
            if ("ticket" in pp) {
              searchParams = pp;
            }
          }
          return data;
        },
      })
      .catch((err) => console.log(err));
    let jar1 = result.config.jar;

    let cookiesJson = jar1.toJSON();
    let ecs_token = cookiesJson.cookies.find((i) => i.key == "ecs_token");
    ecs_token = ecs_token.value;
    if (!ecs_token) {
      console.log(
        "🚀 ~ file: dailyCheapStorePage.js ~ line 106 ~ doTask: ~ ecs_token",
        ecs_token,
        cookiesJson
      );
      throw new Error("ecs_token缺失");
    }
    let { state, jar: gjar } = await dailyGrabdollPage.getState(axios, {
      ...options,
      ecs_token,
      searchParams,
    });
    if (!state) {
      console.log("任务已完成，明日再来");
      return;
    }
    let phone = encryption(options.user, "gb6YCccUvth75Tm2");
    let times = 5;
    do {
      if (times < 5) {
        let params = {
          arguments1: "AC20200624091508",
          arguments2: "GGPD",
          arguments3: "734225b6ec9946cca3bcdc6a6e14fc1f",
          arguments4: new Date().getTime(),
          arguments6: "",
          arguments7: "",
          arguments8: "",
          arguments9: "",
          netWay: "Wifi",
          remark: "签到看视频得积分2",
          remark1: "签到看视频得积分2",
          version: `android@8.0100`,
          codeId: 945474727,
        };

        params["sign"] = sign([
          params.arguments1,
          params.arguments2,
          params.arguments3,
          params.arguments4,
        ]);
        params["orderId"] = crypto
          .createHash("md5")
          .update(new Date().getTime() + "")
          .digest("hex");
        params["arguments4"] = new Date().getTime();

        let result = await require("./taskcallback").reward(axios, {
          ...options,
          params,
          jar: jar1,
        });
        let a = {
          channelId: "LT_channel",
          phone: phone,
          token: ecs_token,
          sourceCode: "lt_zhuawawa",
        };

        let timestamp = moment().format("YYYYMMDDHHmmss");
        result = await axios.request({
          headers: {
            "user-agent": useragent,
            referer: `https://wxapp.msmds.cn/h5/react_web/unicom/grabdollPage?source=unicom&type=02&ticket=${searchParams.ticket}&version=android@8.0100&timestamp=${timestamp}&desmobile=${options.user}&num=0&postage=${searchParams.postage}&duanlianjieabc=tbKHR&userNumber=${options.user}`,
            origin: "https://wxapp.msmds.cn",
          },
          jar: gjar,
          url: `https://wxapp.msmds.cn/jplus/api/channelGrabDoll/playAgainByLookingVideos`,
          method: "POST",
          data: transParams(a),
        });

        if (result.data.code !== 200) {
          console.log("提交任务失败", result.data.msg);
        } else {
          console.log("提交任务成功", `${result.data.data}`);
        }
      }

      let timestamp = moment().format("YYYYMMDDHHmmss");
      let res = await axios.request({
        headers: {
          "user-agent": useragent,
          referer: `https://wxapp.msmds.cn/h5/react_web/unicom/grabdollPage?source=unicom&type=02&ticket=${searchParams.ticket}&version=android@8.0100&timestamp=${timestamp}&desmobile=${options.user}&num=0&postage=${searchParams.postage}&duanlianjieabc=tbKHR&userNumber=${options.user}`,
        },
        jar: gjar,
        url: `https://wxapp.msmds.cn/jplus/api/channelGrabDoll/startGame`,
        method: "POST",
        data: transParams({
          channelId: "LT_channel",
          phone: phone,
          token: ecs_token,
          sourceCode: "lt_zhuawawa",
        }),
      });

      let result = res.data;
      if (result.code === 200) {
        console.log("阅读开心抓大奖", result.data.goodsName);
      } else {
        console.log("阅读开心抓大奖", result.msg);
      }

      console.log("等待35秒再继续");
      await new Promise((resolve, reject) => setTimeout(resolve, 35 * 1000));
    } while (--times);
  },
};

module.exports = dailyGrabdollPage;


<|start_filename|>commands/tasks/unicom/dailyBookLuckdraw.js<|end_filename|>
var crypto = require("crypto");
const { RSAUtils } = require("./RSAUtils");

var transParams = (data) => {
  let params = new URLSearchParams();
  for (let item in data) {
    params.append(item, data["" + item + ""]);
  }
  return params;
};

var sign = (data) => {
  let str = "integralofficial&";
  let params = [];
  data.forEach((v, i) => {
    if (v) {
      params.push("arguments" + (i + 1) + v);
    }
  });
  return crypto
    .createHash("md5")
    .update(str + params.join("&"))
    .digest("hex");
};

var dailyBookLuckdraw = {
  oauthMethod: async (axios, options) => {
    const useragent = `Mozilla/5.0 (Linux; Android 7.1.2; SM-G977N Build/LMY48Z; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/75.0.3770.143 Mobile Safari/537.36; unicom{version:android@8.0100,desmobile:${options.user}};devicetype{deviceBrand:samsung,deviceModel:SM-G977N};{yw_code:}    `;
    let { data } = await axios.request({
      headers: {
        "user-agent": useragent,
        referer: `https://img.client.10010.com/`,
        origin: "https://img.client.10010.com",
      },
      url: `https://m.client.10010.com/finderInterface/woReadOauth/?typeCode=oauthMethod`,
      method: "GET",
    });
    return data.data.key;
  },
  login: async (axios, options) => {
    const useragent = `Mozilla/5.0 (Linux; Android 7.1.2; SM-G977N Build/LMY48Z; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/75.0.3770.143 Mobile Safari/537.36; unicom{version:android@8.0100,desmobile:${options.user}};devicetype{deviceBrand:samsung,deviceModel:SM-G977N};{yw_code:}    `;

    //密码加密
    var modulus =
      "00D9C7EE8B8C599CD75FC2629DBFC18625B677E6BA66E81102CF2D644A5C3550775163095A3AA7ED9091F0152A0B764EF8C301B63097495C7E4EA7CF2795029F61229828221B510AAE9A594CA002BA4F44CA7D1196697AEB833FD95F2FA6A5B9C2C0C44220E1761B4AB1A1520612754E94C55DC097D02C2157A8E8F159232ABC87";
    var exponent = "010001";
    var key = RSAUtils.getKeyPair(exponent, "", modulus);
    let phonenum = RSAUtils.encryptedString(key, options.user);
    let { config } = await axios.request({
      headers: {
        "user-agent": useragent,
        "X-Requested-With": "com.sinovatech.unicom.ui",
      },
      url: `https://m.iread.wo.cn/touchextenernal/common/shouTingLogin.action`,
      method: "POST",
      data: transParams({
        phonenum,
      }),
    });
    let jar = config.jar;
    let cookiesJson = jar.toJSON();
    let diwert = cookiesJson.cookies.find((i) => i.key == "diwert");
    let useraccount = cookiesJson.cookies.find((i) => i.key == "useraccount");
    if (!useraccount || !diwert) {
      throw new Error("获取用户信息失败");
    }
    try {
      await axios.request({
        headers: {
          "user-agent": useragent,
        },
        jar,
        url: `http://m.iread.wo.cn/touchextenernal/seeadvertluckdraw/index.action?channelid=18000018&yw_code=&desmobile=${options.user}&version=android@8.0100`,
        method: "GET",
      });
    } catch {
      //
    }

    return {
      jar,
    };
  },
  doTask: async (axios, options) => {
    const useragent = `Mozilla/5.0 (Linux; Android 7.1.2; SM-G977N Build/LMY48Z; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/75.0.3770.143 Mobile Safari/537.36; unicom{version:android@8.0100,desmobile:${options.user}};devicetype{deviceBrand:samsung,deviceModel:SM-G977N};{yw_code:}    `;
    let Authorization = await dailyBookLuckdraw.oauthMethod(axios, options);
    let { jar } = await dailyBookLuckdraw.login(axios, {
      ...options,
      Authorization,
    });
    let times = 5;
    do {
      if (times < 5) {
        let params = {
          arguments1: "AC20200521222721",
          arguments2: "GGPD",
          arguments3: "",
          arguments4: new Date().getTime(),
          arguments6: "",
          arguments7: "",
          arguments8: "",
          arguments9: "",
          netWay: "Wifi",
          remark: "阅读每日读书福利广告1",
          remark1: "阅读每日读书福利广告1",
          version: `android@8.0100`,
          codeId: 945535424,
        };

        params["sign"] = sign([
          params.arguments1,
          params.arguments2,
          params.arguments3,
          params.arguments4,
        ]);
        params["orderId"] = crypto
          .createHash("md5")
          .update(new Date().getTime() + "")
          .digest("hex");
        params["arguments4"] = new Date().getTime();

        await require("./taskcallback").reward(axios, {
          ...options,
          params,
          jar,
        });
      }

      let res = await axios
        .request({
          headers: {
            "user-agent": useragent,
          },
          jar,
          url: `http://m.iread.wo.cn/touchextenernal/seeadvertluckdraw/doDraw.action`,
          method: "POST",
          data: transParams({
            acticeindex: "NzJBQTQxMEE2QzQwQUE2MDYxMEI5MDNGQjFEMEEzODI=",
          }),
        })
        .catch((err) => {
          if (err.response.status !== 200) {
            console.log("访问错误", err.response.statusText);
            const { status, statusText } = err.response;
            throw new Error(`访问错误: ${status}-${statusText}`);
          }
        });
      let result = res.data;
      if (result.code === "0000") {
        console.log("阅读每日读书福利抽奖", result.prizedesc);
      } else if (result.code === "9999") {
        console.log("阅读每日读书福利抽奖", result.message);
        break;
      } else {
        console.log("阅读每日读书福利抽奖", result.message);
      }

      console.log("等待15秒再继续");
      await new Promise((resolve) => setTimeout(resolve, 15 * 1000));
    } while (--times);
  },
};

module.exports = dailyBookLuckdraw;
