diff --git a/index.js b/index.js index 5f8f16e1..329a1943 100644 --- a/index.js +++ b/index.js @@ -7,7 +7,7 @@ import Notifier from './src/notifier/index.js' import { parseToken } from './src/user.js' import updateNotifier from './src/update-notifier.js' import { grabCoupons } from './src/coupons/index.js' -import { readPkgJson } from './src/util/index.js' +import { maskNickName, readPkgJson } from './src/util/index.js' const { version: currentVersion } = readPkgJson() @@ -167,7 +167,7 @@ async function doJob(account, progress) { const { coupons, userInfo } = res.data console.log(...coupons) - console.log(`\n红包已放入账号:${userInfo.nickName}`) + console.log(`\n红包已放入账号:${maskNickName(userInfo.nickName)}`) console.log(`\n🎉 领取成功!`) const message = stringifyCoupons(coupons) diff --git a/src/coupons/gundam.js b/src/coupons/gundam.js index 8f896943..8f9da593 100644 --- a/src/coupons/gundam.js +++ b/src/coupons/gundam.js @@ -1,5 +1,5 @@ import fetch from '../fetch.js' -import { dateFormat } from '../util/index.js' +import { dateFormat, removePhoneRestriction } from '../util/index.js' import { getTemplateData, matchMoudleData } from '../template.js' import { ECODE } from './const.js' @@ -72,7 +72,7 @@ function formatCoupons(coupons, actName) { etime, amount: item.couponAmount, amountLimit, - useCondition: item.useCondition, + useCondition: removePhoneRestriction(item.useCondition), actName: actName } }) diff --git a/src/util/index.js b/src/util/index.js index 64ff985f..7a4cbc33 100644 --- a/src/util/index.js +++ b/src/util/index.js @@ -31,4 +31,19 @@ function dateFormat(date) { }) } -export { dateFormat, groupBy, readPkgJson, replacePhoneNumber } +function maskNickName(nickName) { + return nickName.replace(/^(.).*(.)$/, '$1***$2') +} + +function removePhoneRestriction(text) { + return text.replace(/限登录手机号为\d{3}\*\*\*\*\d{4}使用。/, '') +} + +export { + dateFormat, + groupBy, + readPkgJson, + replacePhoneNumber, + maskNickName, + removePhoneRestriction +}