一些兼容问题

1、iphone不支持 xxxx-xx-xx 的时间格式 需要替换成 /

2、videojs 在 iphone 14及以下版本中,更换播放地址后,loadmetadata以后使用currentTime 跳转时间戳前一两次会跳不过去,需要设置一个轮训判断是否跳转成功,否则继续调用

3、微信支付,对接服务商,支付完成后会退出页面,可以开通点金计划,引导用户展示商家小票页面,跳回到原页面

行为验证防抓包

之前做了一个网页表格导出excel 的数据抓取功能,原因是当前网站没有入口把数据导出。

然后用上了

1、egg.js做服务端(现成的日志系统和异常重启)
2、natapp做内网穿透(域名是动态,隔几天会变)
3、excel4node 做表格导出(批量下载表格里的图片到本地,再插入本地图片到sheet表里)

第一步就是用node去拉去列表数据,发现一开始可以拉取,后面就报错异常操作,然后冷静了一天,第二天工作之余去看了他们的页面,看到每次获取数据前有一个类似上报的接口请求,查看详情发现里面有记录类似行为的东西

1
'[{"events":[{"event":"onload","params":"{\"app_id\":29 ...

然后直接右键请求把接口复制cURL的请求格式,存放到bash里用curl命令去模拟用户行为的接口,把cookie数据也能一起拿出来很方便

1
2
3
4
5
6
7
result="$(curl 'https://mcs.zijieapi.com/list' \
-H 'authority: mcs.zijieapi.com' \
-H 'accept: */*' \
...
--compressed)"

echo ${result}

然后继续模拟修改分页行数的行为,拉取服务器允许的最大条数100条数据,这样就完成了第一步。

后面的难度就不大了。

总结:

· 一开始就用了node做了一个本地功能然后用上 pkg 的插件做一个跨端的打包功能
后来版本bug 更新多,加上excel4node 在win10打包后闪退,日志不能随时查看到(使用端是别人)
所以考虑做个服务端,随时更新重启,随时查看日志

· 单纯的服务端接口,如果没有权限验证,很容易被人盗用爬取数据,所以用一个前置行为约束接口权限是一种相对更安全的做法,在行为里加入时间戳,点击位置等参数,更严格控制是否是真人行为(和滑动验证码异曲同工)

js_map_foreach

map forEach 内部循环时候貌似会用content hash来确定当前遍历项的唯一性;或者说rest 合并运算符concat 方法有这个特性

开发大转盘相邻不同色功能过程中复制了几条相同的假数据做测试

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
let awards = res.data.kuaishouLotteryVOS.concat(res.data.kuaishouLotteryVOS.slice(0, 2));
let newAwards = [];
if (awards.length && awards.length % 2 == 1) {
const colorList = ['#f7f7f7', '#f8d384', '#f9e3bb']
newAwards = awards.map((item, index, arr) => {
const length = arr.length
const key = index % 3;
item.color = colorList[key];
if (length > 3 && (length % 3 == 1) && (index == (length - 1))) {
item.color = colorList[1]
console.log(99999)
}
console.log(index, key, length, index == (length - 1), length > 3, length % 3 == 1, item.color, item)
return item;
});
console.log(JSON.stringify(newAwards))

前两个和倒数两个key value相同的对象颜色相同了

1
2
3
4
5
6
7
8
9
10
index.vue?6ced:106 0 0 9 false true false "#f7f7f7" {lotteryId: 5, name: "5", fee: 5, feeStr: "5.00", color: "#f7f7f7"}
16:50:20.954 index.vue?6ced:106 1 1 9 false true false "#f8d384" {lotteryId: 1, name: "1", fee: 1, feeStr: "1.00", color: "#f8d384"}
16:50:20.954 index.vue?6ced:106 2 2 9 false true false "#f9e3bb" {lotteryId: 4, name: "4", fee: 4, feeStr: "4.00", color: "#f9e3bb"}
16:50:20.954 index.vue?6ced:106 3 0 9 false true false "#f7f7f7" {lotteryId: 3, name: "3", fee: 3, feeStr: "3.00", color: "#f7f7f7"}
16:50:20.955 index.vue?6ced:106 4 1 9 false true false "#f8d384" {lotteryId: 2, name: "1", fee: 2, feeStr: "2.00", color: "#f8d384"}
16:50:20.955 index.vue?6ced:106 5 2 9 false true false "#f9e3bb" {lotteryId: 6, name: "6", fee: 6, feeStr: "6.00", color: "#f9e3bb"}
16:50:20.955 index.vue?6ced:106 6 0 9 false true false "#f7f7f7" {lotteryId: 7, name: "7", fee: 7, feeStr: "7.00", color: "#f7f7f7"}
16:50:20.955 index.vue?6ced:106 7 1 9 false true false "#f8d384" {lotteryId: 5, name: "5", fee: 5, feeStr: "5.00", color: "#f8d384"}
16:50:20.956 index.vue?6ced:106 8 2 9 true true false "#f9e3bb" {lotteryId: 1, name: "1", fee: 1, feeStr: "1.00", color: "#f9e3bb"}
16:50:20.956 index.vue?6ced:109 [{"lotteryId":5,"name":"5","fee":5,"feeStr":"5.00","color":"#f8d384"},{"lotteryId":1,"name":"1","fee":1,"feeStr":"1.00","color":"#f9e3bb"},{"lotteryId":4,"name":"4","fee":4,"feeStr":"4.00","color":"#f9e3bb"},{"lotteryId":3,"name":"3","fee":3,"feeStr":"3.00","color":"#f7f7f7"},{"lotteryId":2,"name":"1","fee":2,"feeStr":"2.00","color":"#f8d384"},{"lotteryId":6,"name":"6","fee":6,"feeStr":"6.00","color":"#f9e3bb"},{"lotteryId":7,"name":"7","fee":7,"feeStr":"7.00","color":"#f7f7f7"},{"lotteryId":5,"name":"5","fee":5,"feeStr":"5.00","color":"#f8d384"},{"lotteryId":1,"name":"1","fee":1,"feeStr":"1.00","color":"#f9e3bb"}]

js属性链

1、babel 插件 @babel/plugin-proposal-optional-chaining 简化代码。(从 coffescript、kotlin、swift、c# 用法相似)

https://babeljs.io/docs/en/next/babel-plugin-proposal-optional-chaining

使用场景: 获取深层嵌套属性值

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
const obj = {
foo: {
bar: {
baz: 42,
},
},
};

const baz = obj?.foo?.bar?.baz; // 42

const safe = obj?.qux?.baz; // undefined

// Optional chaining and normal chaining can be intermixed
obj?.foo.bar?.baz; // Only access `foo` if `obj` exists, and `baz` if
// `bar` exists

// Example usage with bracket notation:
obj?.['foo']?.bar?.baz // 42

vue_for

1
2
3
4
<el-dropdown-item v-for="(item, index) in statusList.splice(1)" :key

// 不能直接放.splice(1)

linux_mail2

https://www.cnblogs.com/github-cn/archive/2019/08/01/11281961.html

https://segmentfault.com/q/1010000004497746/a-1020000004501310

1、下载ssmtp(适用于内置 mail 命令的机器)

1
sudo apt-get install ssmtp

重启邮件服务

1
2
3
4
service  stop sendmail / systemctl stop sendmail
service start sendmail / systemctl start sendmail
systemctl start sendmail / systemctl stop postfix
systemctl start sendmail / systemctl stop postfix

2、配置 /etc/ssmtp/ssmtp.conf

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#
# Config file for sSMTP sendmail
#
# The person who gets all mail for userids < 1000
# Make this empty to disable rewriting.
root=xxxxxxx@qq.com

# The place where the mail goes. The actual machine name is required no
# MX records are consulted. Commonly mailhosts are named mail.domain.com
mailhub=smtp.exmail.qq.com:587
AuthUser=xxxxxxx@qq.com
AuthPass=xxxxxxxx
UseTLS=YES
UseSTARTTLS=YES
# Where will the mail seem to come from?
#rewriteDomain=

rewriteDomain=ghubserver
# The full hostname
hostname=xxxxxxx

# Are users allowed to set their own From: address?
# YES - Allow the user to specify their own From: address
# NO - Use the system generated From: address
FromLineOverride=YES

hostname=xxxxxxx@qq.com

or vim /etc/mail.rc

1
2
3
4
5
6
set append dot save ask crt
ignore Received Message-Id Resent-Message-Id Status Mail-From Return-Path Via

set from=xxxxxxx@qq.com smtp="smtp.exmail.qq.com:587"
set smtp-auth-user="xxxxxxx@qq.com" smtp-auth-password="xxxxxx"
set smtp-auth=login

vim /etc/ssmtp/revaliases

1
2
3
4
5
6
7
8
# sSMTP aliases
#
# Format: local_account:outgoing_address:mailhub
#
# Example: root:your_login@your.domain:mailhub.your.domain[:port]
# where [:port] is an optional port number that defaults to 25.
www:xxxxxxx@qq.com:smtp.exmail.qq.com:587
mainuser:xxxxxxx@qq.com:smtp.exmail.qq.com:587

最后记得配置安全组 25 or 587 or …