]> 127.0.0.1 Git - bili_danmu/.git/commitdiff
小心心
authorqydysky <qydysky@foxmail.com>
Sun, 31 Jan 2021 13:58:02 +0000 (21:58 +0800)
committerqydysky <qydysky@foxmail.com>
Sun, 31 Jan 2021 13:58:02 +0000 (21:58 +0800)
13 files changed:
CV/Var.go
F/api.go
F/xinxin.go [new file with mode: 0644]
Reply/0Init.go
Reply/F.go
Reply/Reply.go
Reply/gtk.go
bili_danmu.go
demo/config/config_K_v.json
demo/html/27.02768ee66953cfc6d097.js [new file with mode: 0644]
demo/html/bili.js [new file with mode: 0644]
demo/html/e791556706f88d88b4846a61a583b31db007f83d.wasm [new file with mode: 0644]
demo/html/index.html [new file with mode: 0644]

index 739097c7c8df069b180ee6fe0ec0a1f3fedcc717..71b7e44b6ef2844665c4433bdf7bbbe7cd9667f2 100644 (file)
--- a/CV/Var.go
+++ b/CV/Var.go
@@ -3,6 +3,7 @@ package cv
 import (
        "time"
        mq "github.com/qydysky/part/msgq"
+       s "github.com/qydysky/part/buf"
        log "github.com/qydysky/part/log"
 )
 
@@ -45,6 +46,17 @@ var Log = log.New(log.Config{
        },
 })
 
+//k-v
+var K_v =make(map[string]interface{})
+
+func init() {
+       buf := s.New()
+       buf.Load("config/config_K_v.json")
+       for k,v := range buf.B {
+               K_v[k] = v
+       }
+}
+
 //from player-loader-2.0.11.min.js
 /*
        customAuthParam
index 973aa95758e528e100fd79314ea2ce5ea7c9b761..69ca35ab8d270bc9e2b0bc677cf4d2375c3d7163 100644 (file)
--- a/F/api.go
+++ b/F/api.go
@@ -16,6 +16,7 @@ import (
        c "github.com/qydysky/bili_danmu/CV"
        g "github.com/qydysky/part/get"
        p "github.com/qydysky/part"
+       uuid "github.com/gofrs/uuid"
 )
 
 type api struct {
@@ -27,6 +28,7 @@ type api struct {
        Locked bool
        Token string
        Parent_area_id int
+       Area_id int
 }
 
 var apilog = c.Log.Base(`api`)
@@ -36,8 +38,9 @@ func New_api(Roomid int) (o *api) {
        apilog.Base_add(`新建`).L(`T: `,"ok")
        o = new(api)
        o.Roomid = Roomid
-       o.Get_info()
        o.Parent_area_id = -1
+       o.Area_id = -1
+       o.Get_info()
        return
 }
 
@@ -52,7 +55,7 @@ func (i *api) Get_info() (o *api) {
        if api_limit.TO() {return}//超额请求阻塞,超时将取消
 
        o.Get_LIVE_BUVID()
-
+       
        Roomid := strconv.Itoa(o.Roomid)
 
        r := g.Get(p.Rval{
@@ -80,6 +83,11 @@ func (i *api) Get_info() (o *api) {
                        apilog.L(`E: `,"parent_area_id", e)
                } else {o.Parent_area_id = tmp}
        }
+       if e := r.S(`"area_id":`, `,`, 0, 0).Err;e == nil {
+               if tmp,e := strconv.Atoi(r.RS[0]);e != nil{
+                       apilog.L(`E: `,"area_id", e)
+               } else {o.Area_id = tmp}
+       }
        //roomid
        if tmp := r.S(`"room_id":`, `,`, 0, 0);tmp.Err != nil {
                // apilog.L(`E: `,"room_id", tmp.Err)
@@ -89,7 +97,11 @@ func (i *api) Get_info() (o *api) {
                o.Roomid = i
        }
 
-       if o.Parent_area_id != -1&&o.Roomid != 0 && o.Uid != 0 && c.Title != ``{return}
+       if      o.Area_id != -1 && 
+               o.Parent_area_id != -1 &&
+               o.Roomid != 0 &&
+               o.Uid != 0 &&
+               c.Title != ``{return}
 
        {//使用其他api
                req := p.Req()
@@ -114,6 +126,7 @@ func (i *api) Get_info() (o *api) {
                                        Room_id int `json:"room_id"`
                                        Title string `json:"title"`
                                        Lock_status int `json:"lock_status"`
+                                       Area_id int `json:"area_id"`
                                        Parent_area_id int `json:"parent_area_id"`
                                } `json:"room_info"`
                                Anchor_info struct{
@@ -154,6 +167,12 @@ func (i *api) Get_info() (o *api) {
                        apilog.L(`E: `,"data.room_info.parent_area_id = 0")
                        return
                }
+               if tmp.Data.Room_info.Area_id != 0{
+                       o.Area_id = tmp.Data.Room_info.Area_id
+               } else {
+                       apilog.L(`E: `,"data.room_info.Area_id = 0")
+                       return
+               }
 
                //房间id
                if tmp.Data.Room_info.Room_id != 0{
@@ -1073,22 +1092,51 @@ type E_json struct{
        } `json:"data"`
 }
 
-func F_x25Kn() {
-       apilog := apilog.Base_add(`LIVE_BUVID`).L(`T: `,`获取LIVE_BUVID`)
+func (i *api) F_x25Kn() (o *api) {
+       o = i
+       apilog := apilog.Base_add(`小心心`).L(`T: `,`获取小心心`)
        if len(c.Cookie) == 0 {apilog.L(`E: `,`失败!无cookie`);return}
        if c.Cookie[`LIVE_BUVID`] == `` {apilog.L(`E: `,`失败!无LIVE_BUVID`);return}
+       if o.Parent_area_id == -1 {apilog.L(`E: `,`失败!未获取Parent_area_id`);return}
+       if o.Area_id == -1 {apilog.L(`E: `,`失败!未获取Area_id`);return}
        if api_limit.TO() {apilog.L(`E: `,`超时!`);return}//超额请求阻塞,超时将取消
 
-       var res E_json
+       //查看今天小心心数量
+       for _,v := range Gift_list() {
+               if v.Gift_id == 30607 && v.Expire_at - int(p.Sys().GetSTime()) > 6 * 86400 {
+                       if v.Gift_num == 24 {
+                               apilog.L(`I: `,`今天小心心已满!`);return
+                       } else {
+                               apilog.L(`I: `,`今天已有`,v.Gift_num,`个小心心`)
+                       }
+               }
+       }
+
+       var (
+               res E_json
+               loop_num = 0
+       )
 
-       {//初始化
+       csrf := c.Cookie[`bili_jct`]
+       if csrf == `` {apilog.L(`E: `,"Cookie错误,无bili_jct");return}
 
-               csrf := c.Cookie[`bili_jct`]
-               if csrf == `` {apilog.L(`E: `,"Cookie错误,无bili_jct=");return}
+       LIVE_BUVID := c.Cookie[`LIVE_BUVID`]
+       if LIVE_BUVID == `` {apilog.L(`E: `,"Cookie错误,无LIVE_BUVID");return}
 
-               PostStr := `id=`
-               PostStr += `&device=`
-               PostStr += `&ts=`
+       var new_uuid string
+       {
+               if tmp_uuid,e := uuid.NewV4();e == nil {
+                       new_uuid = tmp_uuid.String()
+               } else {
+                       apilog.L(`E: `,e)
+                       return
+               }
+       }
+
+       {//初始化
+               PostStr := `id=[`+strconv.Itoa(o.Parent_area_id)+`,`+strconv.Itoa(o.Area_id)+`,`+strconv.Itoa(loop_num)+`,`+strconv.Itoa(o.Roomid)+`]&`
+               PostStr += `device=["`+LIVE_BUVID+`","`+new_uuid+`"]&`
+               PostStr += `ts=`+strconv.Itoa(int(p.Sys().GetMTime()))
                PostStr += `&is_patch=0&`
                PostStr += `heart_beat=[]&`
                PostStr += `ua=Mozilla/5.0 (X11; Linux x86_64; rv:84.0) Gecko/20100101 Firefox/84.0&`
@@ -1109,10 +1157,10 @@ func F_x25Kn() {
                                `Connection`: `keep-alive`,
                                `Pragma`: `no-cache`,
                                `Cache-Control`: `no-cache`,
-                               `Referer`:"https://live.bilibili.com/"+strconv.Itoa(c.Roomid),
+                               `Referer`:"https://live.bilibili.com/"+strconv.Itoa(o.Roomid),
                                `Cookie`:p.Map_2_Cookies_String(c.Cookie),
                        },
-                       PostStr:url.QueryEscape(PostStr),
+                       PostStr:url.PathEscape(PostStr),
                        Timeout:3,
                        Retry:2,
                });err != nil {
@@ -1130,5 +1178,169 @@ func F_x25Kn() {
                        return
                }
        }
+
+       {//loop
+               var cancle = make(chan struct{},1)
+               //使用带tag的消息队列在功能间传递消息
+               c.Danmu_Main_mq.Pull_tag(map[string]func(interface{})(bool){
+                       `change_room`:func(data interface{})(bool){//换房时退出当前房间
+                               close(cancle)
+                               return true
+                       },
+               })
+               
+               defer apilog.L(`I: `,`退出`)
+
+               for loop_num < 24*5 {
+                       select{
+                       case <- time.After(time.Second*time.Duration(res.Data.Heartbeat_interval)):
+                       case <- cancle:
+                               return
+                       }
+
+                       loop_num += 1
+                       
+                       var rt_obj = RT{
+                               R:R{
+                                       Id:`[`+strconv.Itoa(o.Parent_area_id)+`,`+strconv.Itoa(o.Area_id)+`,`+strconv.Itoa(loop_num)+`,`+strconv.Itoa(o.Roomid)+`]`,
+                                       Device:`["`+LIVE_BUVID+`","`+new_uuid+`"]`,
+                                       Ets:res.Data.Timestamp,
+                                       Benchmark:res.Data.Secret_key,
+                                       Time:res.Data.Heartbeat_interval,
+                                       Ts:int(p.Sys().GetMTime()),
+                               },
+                               T:res.Data.Secret_rule,
+                       }
+
+                       PostStr := `id=`+rt_obj.R.Id+`&`
+                       PostStr += `device=["`+LIVE_BUVID+`","`+new_uuid+`"]&`
+                       PostStr += `ets=`+strconv.Itoa(res.Data.Timestamp)
+                       PostStr += `&benchmark=`+res.Data.Secret_key
+                       PostStr += `&time=`+strconv.Itoa(res.Data.Heartbeat_interval)
+                       PostStr += `&ts=`+strconv.Itoa(rt_obj.R.Ts)
+                       PostStr += `&is_patch=0&`
+                       PostStr += `heart_beat=[]&`
+                       PostStr += `ua=Mozilla/5.0 (X11; Linux x86_64; rv:84.0) Gecko/20100101 Firefox/84.0&`
+                       PostStr += `csrf_token=`+csrf+`&csrf=`+csrf+`&`
+                       PostStr += `visit_id=`
+                       
+                       if wasm := Wasm(rt_obj);wasm == `` {
+                               apilog.L(`E: `,`发生错误`)
+                               return
+                       } else {
+                               PostStr = `s=`+wasm+`&`+PostStr
+                       }
+                       
+                       req := p.Req()
+                       if err := req.Reqf(p.Rval{
+                               Url:`https://live-trace.bilibili.com/xlive/data-interface/v1/x25Kn/X`,
+                               Header:map[string]string{
+                                       `Host`: `api.live.bilibili.com`,
+                                       `User-Agent`: `Mozilla/5.0 (X11; Linux x86_64; rv:83.0) Gecko/20100101 Firefox/83.0`,
+                                       `Accept`: `application/json, text/plain, */*`,
+                                       `Content-Type`: `application/x-www-form-urlencoded`,
+                                       `Accept-Language`: `zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2`,
+                                       `Accept-Encoding`: `gzip, deflate, br`,
+                                       `Origin`: `https://live.bilibili.com`,
+                                       `Connection`: `keep-alive`,
+                                       `Pragma`: `no-cache`,
+                                       `Cache-Control`: `no-cache`,
+                                       `Referer`:"https://live.bilibili.com/"+strconv.Itoa(o.Roomid),
+                                       `Cookie`:p.Map_2_Cookies_String(c.Cookie),
+                               },
+                               PostStr:url.PathEscape(PostStr),
+                               Timeout:3,
+                               Retry:2,
+                       });err != nil {
+                               apilog.L(`E: `,err)
+                               return
+                       }
+
+                       if e := json.Unmarshal(req.Respon,&res);e != nil {
+                               apilog.L(`E: `,e)
+                               return
+                       }
        
-}
\ No newline at end of file
+                       if res.Code != 0{
+                               apilog.L(`E: `,res.Message)
+                               return
+                       }
+
+                       //查看今天小心心数量
+                       if loop_num%5 == 0 {//每5min
+                               for _,v := range Gift_list() {
+                                       if v.Gift_id == 30607 && v.Expire_at - int(p.Sys().GetSTime()) > 6 * 86400 {
+                                               if v.Gift_num == 24 {
+                                                       apilog.L(`I: `,`今天小心心已满!`);return
+                                               } else {
+                                                       apilog.L(`I: `,`获取到第`,v.Gift_num,`个小心心`)
+                                               }
+                                       }
+                               }
+                       }
+               }
+       }
+       return
+}
+
+//礼物列表
+type Gift_list_type struct {
+       Code int `json:"code"`
+       Message string `json:"message"`
+       Data Gift_list_type_Data `json:"data"`
+}
+
+type Gift_list_type_Data struct {
+       List []Gift_list_type_Data_List `json:"list"`
+}
+
+type Gift_list_type_Data_List struct{
+       Gift_id int `json:"gift_id"`
+       Gift_num int `json:"gift_num"`
+       Expire_at int `json:"expire_at"`
+}
+
+func Gift_list() (list []Gift_list_type_Data_List) {
+       apilog := apilog.Base_add(`小心心`).L(`T: `,`获取礼物列表`)
+       if len(c.Cookie) == 0 {apilog.L(`E: `,`失败!无cookie`);return}
+       if c.Roomid == 0 {apilog.L(`E: `,`失败!无Roomid`);return}
+       if api_limit.TO() {apilog.L(`E: `,`超时!`);return}//超额请求阻塞,超时将取消
+
+       req := p.Req()
+       if err := req.Reqf(p.Rval{
+               Url:`https://api.live.bilibili.com/xlive/web-room/v1/gift/bag_list?t=`+strconv.Itoa(int(p.Sys().GetMTime()))+`&room_id=`+strconv.Itoa(c.Roomid),
+               Header:map[string]string{
+                       `Host`: `api.live.bilibili.com`,
+                       `User-Agent`: `Mozilla/5.0 (X11; Linux x86_64; rv:83.0) Gecko/20100101 Firefox/83.0`,
+                       `Accept`: `application/json, text/plain, */*`,
+                       `Content-Type`: `application/x-www-form-urlencoded`,
+                       `Accept-Language`: `zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2`,
+                       `Accept-Encoding`: `gzip, deflate, br`,
+                       `Origin`: `https://live.bilibili.com`,
+                       `Connection`: `keep-alive`,
+                       `Pragma`: `no-cache`,
+                       `Cache-Control`: `no-cache`,
+                       `Referer`:"https://live.bilibili.com/"+strconv.Itoa(c.Roomid),
+                       `Cookie`:p.Map_2_Cookies_String(c.Cookie),
+               },
+               Timeout:3,
+               Retry:2,
+       });err != nil {
+               apilog.L(`E: `,err)
+               return
+       }
+
+       var res Gift_list_type
+
+       if e := json.Unmarshal(req.Respon,&res);e != nil {
+               apilog.L(`E: `,e)
+               return
+       }
+
+       if res.Code != 0{
+               apilog.L(`E: `,res.Message)
+               return
+       }
+
+       return res.Data.List
+}
diff --git a/F/xinxin.go b/F/xinxin.go
new file mode 100644 (file)
index 0000000..62d7069
--- /dev/null
@@ -0,0 +1,193 @@
+package F
+
+import (
+       "net/http"
+       "encoding/json"
+    "time"
+       "context"
+       "strconv"
+       "github.com/gorilla/websocket"
+       "github.com/skratchdot/open-golang/open"
+       p "github.com/qydysky/part"
+       c "github.com/qydysky/bili_danmu/CV"
+)
+
+/*
+       小心心加密golang-ws-js-webassembly工具
+*/
+
+//需要加密的数据
+type R struct {
+       Id string `json:"id"` 
+       Device string `json:"device"`
+       Ets int `json:"ets"`
+       Benchmark string `json:"benchmark"`
+       Time int `json:"time"`
+       Ts int `json:"ts"`
+}
+
+//发送的原始对象
+type RT struct {
+       R R `json:"r"`
+       T []int `json:"t"` //加密方法
+}
+
+//返回的加密对象
+type S struct {
+       S string `json:"s"` //加密字符串
+}
+
+//全局对象
+var (
+       xinxinboot = make(chan struct{},1) //调用标记,仅调用一次
+       wslog = c.Log.Base(`api`).Base_add(`小心心加密`) //日志
+       send_chan = make(chan RT,1)//发通道
+       rec_chan = make(chan S,1)//收通道
+       port = p.Sys().GetFreePort()//随机端口
+)
+
+func init() {
+       go func() {
+               for {
+                       v,ok := c.K_v["get_xiao_xinxin"]
+                       if !ok {
+                               time.Sleep(time.Second)
+                               continue
+                       }
+                       if t,ok := v.(bool);!ok || !t {return}
+                       break
+               }
+       
+               wslog.L(`T: `,`被调用`)
+       
+               select{
+               case xinxinboot <- struct{}{}: //没有启动实例
+                       wslog.L(`I: `,`启动`)
+                       web()
+                       <- xinxinboot
+               default: //有启动实例
+                       wslog.L(`I: `,`已启动`)
+               }
+       }()
+}
+
+func web() {
+       web :=  http.NewServeMux()
+
+       var (
+               server *http.Server
+               upgrader = websocket.Upgrader{}
+       )
+
+       web.HandleFunc("/exit", func(w http.ResponseWriter, r *http.Request) {
+               server.Shutdown(context.Background())
+       })
+
+       web.HandleFunc("/ws", func(w http.ResponseWriter, r *http.Request) {
+               ws, err := upgrader.Upgrade(w, r, nil)
+               if err != nil {
+                       wslog.L(`E: `,"upgrade:", err)
+                       return
+               }
+               defer ws.Close()
+
+               //测试 提示
+               go func(){
+                       time.Sleep(time.Second*time.Duration(3))
+                       if s := Wasm(RT{
+                               R:R{
+                               Id: "[9,371,1,22613059]",
+                               Device: "[\"AUTO8216117272375373\",\"77bee604-b591-4664-845b-b69603f8c71c\"]",
+                               Ets: 1611836581,
+                               Benchmark: "seacasdgyijfhofiuxoannn",
+                               Time: 60,
+                               Ts: 1611836642190,
+                               },
+                               T: []int{2, 5, 1, 4},
+                       });s == `e4249b7657c2d4a44955548eb814797d41ddd99bfdfa5974462b8c387d701b8c83898f6d7dde1772c67fad6a113d20c20e454be1d1627e7ea99617a8a1f99bd0` {
+                               wslog.L(`I: `,`测试通过`)
+                       } else {
+                               wslog.L(`E: `,`测试未通过`,s)
+                       }
+               }()
+
+               var close_chan = make(chan struct{})
+               //发送
+               go func(){
+                       for {
+                               select {
+                               case <-close_chan:
+                                       return
+                               case tmp := <- send_chan:
+                                       b, e := json.Marshal(tmp)
+                                       if e != nil {
+                                               wslog.L(`E: `,e)
+                                       }
+
+                                       if e := ws.WriteMessage(websocket.TextMessage,b);e != nil {
+                                               wslog.L(`E: `,e)
+                                               return
+                                       }
+                               }
+                       }
+               }()
+
+               //接收
+               for {
+                       ws.SetReadDeadline(time.Now().Add(time.Second*time.Duration(300)))
+                       if _, message, e := ws.ReadMessage();e != nil {
+                               if websocket.IsCloseError(e,websocket.CloseGoingAway) {
+                                       wslog.L(`I: `,e)
+                               } else {
+                                       wslog.L(`E: `,e)
+                               }
+                               close(close_chan)
+                               break
+                       } else {
+                               var s S
+                               e := json.Unmarshal(message, &s)
+                               if e != nil {
+                                       wslog.L(`E: `, e, string(message))
+                               }
+                               rec_chan <- s
+                       }
+               }
+       })
+
+       //html js
+       web.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
+               var path string = r.URL.Path[1:]
+               if path == `` {path = `index.html`}
+        http.ServeFile(w, r, "html/"+path)
+       })
+       
+       server = &http.Server{
+               Addr: "127.0.0.1:"+strconv.Itoa(port),
+               WriteTimeout: time.Second * time.Duration(10),
+               Handler: web,
+       }
+
+       //测试 提示
+       go func(){
+               time.Sleep(time.Second*time.Duration(3))
+               open.Run("http://127.0.0.1:"+strconv.Itoa(port))
+               wslog.L(`I: `,`保持浏览器打开`,"http://127.0.0.1:"+strconv.Itoa(port),`以正常运行`)
+       }()
+
+       server.ListenAndServe()
+}
+
+func Wasm(s RT) (o string) {
+       select{
+       case send_chan <- s:
+               select {
+               case r :=<- rec_chan:
+                       return r.S
+               case <- time.After(time.Second):
+                       wslog.L(`E: `,`超时!响应>1s,确认保持`,"http://127.0.0.1:"+strconv.Itoa(port),`开启`)
+                       return
+               }
+       default:
+               return
+       }
+}
\ No newline at end of file
index f3af66927ba14921173cda7b529f1f1ea759d52f..039ec6db49f268d8b378644199d9870e8c65371c 100644 (file)
@@ -12,14 +12,3 @@ func init(){
                AllF[k] = v.(bool)
        }
 } 
-
-//k-v
-var K_v =make(map[string]interface{})
-
-func init() {
-       buf := s.New()
-       buf.Load("config/config_K_v.json")
-       for k,v := range buf.B {
-               K_v[k] = v
-       }
-}
index 38e50b5d148f1a926245709295de5191242bbe35..bb3068b9572797d3943bfb384b1981d0582c90f2 100644 (file)
@@ -734,7 +734,7 @@ func init(){
 }
 
 func Save_to_json(Loc int,Context []interface{}) {
-       if path,ok := K_v[`save_to_json`].(string);ok && path != ``{
+       if path,ok := c.K_v[`save_to_json`].(string);ok && path != ``{
                p.File().FileWR(p.Filel{
                        File:path,
                        Write:true,
index cf8a9c697534abda77342c84fd26c8dcec95a1d9..0a60e14d7fd5225881ed38ab8f4e593f54d1f9da 100644 (file)
@@ -185,13 +185,13 @@ func (replyF) user_toast_msg(s string){
                if uid != 0 {
                        c.Danmu_Main_mq.Push_tag(`pm`,send.Pm_item{
                                Uid:int(uid.(float64)),
-                               Msg:K_v[`上舰私信`].(string),
+                               Msg:c.K_v[`上舰私信`].(string),
                        })//上舰私信
                }
-               if K_v[`额外私信对象`].(float64) != 0 {
+               if c.K_v[`额外私信对象`].(float64) != 0 {
                        c.Danmu_Main_mq.Push_tag(`pm`,send.Pm_item{
-                               Uid:int(K_v[`额外私信对象`].(float64)),
-                               Msg:K_v[`上舰私信(额外)`].(string),
+                               Uid:int(c.K_v[`额外私信对象`].(float64)),
+                               Msg:c.K_v[`上舰私信(额外)`].(string),
                        })//上舰私信-对额外
                }
        }
@@ -369,7 +369,7 @@ func (replyF) send_gift(s string){
        //小于设定
        {
                var tmp = 20.0
-               if v,ok := K_v[`弹幕_礼物金额显示阈值`];ok {
+               if v,ok := c.K_v[`弹幕_礼物金额显示阈值`];ok {
                        tmp = v.(float64)
                }
                if allprice < tmp {msglog.L(`T: `, sh_log...);return}
@@ -719,13 +719,13 @@ func Msg_showdanmu(auth interface{}, m ...string) {
                        if i,e := strconv.Atoi(m[1]);e == nil {
                                c.Danmu_Main_mq.Push_tag(`pm`,send.Pm_item{
                                        Uid:i,
-                                       Msg:K_v[`弹幕私信`].(string),
+                                       Msg:c.K_v[`弹幕私信`].(string),
                                })//上舰私信
                        }
-                       if K_v[`额外私信对象`].(float64) != 0 {
+                       if c.K_v[`额外私信对象`].(float64) != 0 {
                                c.Danmu_Main_mq.Push_tag(`pm`,send.Pm_item{
-                                       Uid:int(K_v[`额外私信对象`].(float64)),
-                                       Msg:K_v[`弹幕私信(额外)`].(string),
+                                       Uid:int(c.K_v[`额外私信对象`].(float64)),
+                                       Msg:c.K_v[`弹幕私信(额外)`].(string),
                                })//上舰私信-对额外
                        }
                }
index 5e90058d6d0e5d53afabb454b4a999056abcf6fb..30caf38c2b98fc77a720d26c2297623fd9fec708 100644 (file)
@@ -366,7 +366,7 @@ func Gtk_danmu() {
                                } else {
                                        in_smooth_roll = false
                                        tmp.SetValue(max)
-                                       if v,ok := K_v[`gtk_保留弹幕数量`].(float64);ok {
+                                       if v,ok := c.K_v[`gtk_保留弹幕数量`].(float64);ok {
                                                loc -= int(v)
                                        } else {
                                                loc -= 25
@@ -511,7 +511,7 @@ func load_face(uid string) (loc string) {
                loc = Gtk_img_path + `/` + uid
                return
        }
-       if v,ok := K_v[`gtk_头像获取等待最大数量`].(float64);ok && len(gtkGetList) > int(v) {return}
+       if v,ok := c.K_v[`gtk_头像获取等待最大数量`].(float64);ok && len(gtkGetList) > int(v) {return}
        select{
                case gtkGetList <- uid:
                default:
@@ -564,7 +564,7 @@ func show(s,img_src string,to_grid ...int){
                        pixbuf,e = gdk.PixbufNewFromFileAtSize(img_src, 40, 40);
                        if e == nil {
                                imgbuf.Lock()
-                               if v,ok := K_v[`gtk_内存头像数量`].(float64);ok && len(imgbuf.b) > int(v) + 10 {
+                               if v,ok := c.K_v[`gtk_内存头像数量`].(float64);ok && len(imgbuf.b) > int(v) + 10 {
                                        for k,_ := range imgbuf.b {
                                                delete(imgbuf.b,k)
                                                if len(imgbuf.b) <= int(v) {break}
index da12bad4dbd2ed96f8b5758fa0946f1e4d1b2b13..5b56074dc69ec555e203e88d1aafb58a9ede8b3c 100644 (file)
@@ -148,6 +148,8 @@ func Demo(roomid ...int) {
                        api.Get_Version()
                        //获取热门榜
                        api.Get_HotRank()
+                       //小心心
+                       go api.F_x25Kn()
                        //切换粉丝牌,只在cookie存在时启用
                        api.Switch_FansMedal()
                        if len(api.Url) == 0 || api.Roomid == 0 || api.Token == "" || api.Uid == 0 || api.Locked {
index bb29f8c21bc985659e6f03d972dcf67e4e2f63cb..c2c81c886d140b47458b335155961d5277c771c7 100644 (file)
@@ -20,5 +20,8 @@
     "gtk_头像获取等待最大数量":30,
 
     "save_to_json-help":"保存消息设置,将所有消息保存为json文件,输入文件名(带后缀)",
-    "save_to_json":""
+    "save_to_json":"",
+
+    "get_xiao_xinxin-help":"获取小心心",
+    "get_xiao_xinxin":true
 }
\ No newline at end of file
diff --git a/demo/html/27.02768ee66953cfc6d097.js b/demo/html/27.02768ee66953cfc6d097.js
new file mode 100644 (file)
index 0000000..26f64ab
--- /dev/null
@@ -0,0 +1,755 @@
+(window.webpackJsonp = window.webpackJsonp || []).push([
+  [27],
+  {
+    1439: function (e, r, t) {
+      t(431)("WeakMap");
+    },
+    1440: function (e, r, t) {
+      t(432)("WeakMap");
+    },
+    1441: function (e, r, t) {
+      "use strict";
+      var n = t(361),
+        _ = t(228).getWeak,
+        a = t(94),
+        o = t(73),
+        c = t(362),
+        E = t(197),
+        i = t(545),
+        u = t(134),
+        f = t(356),
+        T = i(5),
+        s = i(6),
+        A = 0,
+        P = function (e) {
+          return e._l || (e._l = new l());
+        },
+        l = function () {
+          this.a = [];
+        },
+        d = function (e, r) {
+          return T(e.a, function (e) {
+            return e[0] === r;
+          });
+        };
+      (l.prototype = {
+        get: function (e) {
+          var r = d(this, e);
+          if (r) return r[1];
+        },
+        has: function (e) {
+          return !!d(this, e);
+        },
+        set: function (e, r) {
+          var t = d(this, e);
+          t ? (t[1] = r) : this.a.push([e, r]);
+        },
+        delete: function (e) {
+          var r = s(this.a, function (r) {
+            return r[0] === e;
+          });
+          return ~r && this.a.splice(r, 1), !!~r;
+        },
+      }),
+        (e.exports = {
+          getConstructor: function (e, r, t, a) {
+            var i = e(function (e, n) {
+              c(e, i, r, "_i"),
+                (e._t = r),
+                (e._i = A++),
+                (e._l = void 0),
+                void 0 != n && E(n, t, e[a], e);
+            });
+            return (
+              n(i.prototype, {
+                delete: function (e) {
+                  if (!o(e)) return !1;
+                  var t = _(e);
+                  return !0 === t
+                    ? P(f(this, r)).delete(e)
+                    : t && u(t, this._i) && delete t[this._i];
+                },
+                has: function (e) {
+                  if (!o(e)) return !1;
+                  var t = _(e);
+                  return !0 === t ? P(f(this, r)).has(e) : t && u(t, this._i);
+                },
+              }),
+              i
+            );
+          },
+          def: function (e, r, t) {
+            var n = _(a(r), !0);
+            return !0 === n ? P(e).set(r, t) : (n[e._i] = t), e;
+          },
+          ufstore: P,
+        });
+    },
+    1442: function (e, r, t) {
+      "use strict";
+      var n,
+        _ = t(59),
+        a = t(545)(0),
+        o = t(440),
+        c = t(228),
+        E = t(547),
+        i = t(1441),
+        u = t(73),
+        f = t(356),
+        T = t(356),
+        s = !_.ActiveXObject && "ActiveXObject" in _,
+        A = c.getWeak,
+        P = Object.isExtensible,
+        l = i.ufstore,
+        d = function (e) {
+          return function () {
+            return e(this, arguments.length > 0 ? arguments[0] : void 0);
+          };
+        },
+        p = {
+          get: function (e) {
+            if (u(e)) {
+              var r = A(e);
+              return !0 === r
+                ? l(f(this, "WeakMap")).get(e)
+                : r
+                ? r[this._i]
+                : void 0;
+            }
+          },
+          set: function (e, r) {
+            return i.def(f(this, "WeakMap"), e, r);
+          },
+        },
+        W = (e.exports = t(433)("WeakMap", d, p, i, !0, !0));
+      T &&
+        s &&
+        (E((n = i.getConstructor(d, "WeakMap")).prototype, p),
+        (c.NEED = !0),
+        a(["delete", "has", "get", "set"], function (e) {
+          var r = W.prototype,
+            t = r[e];
+          o(r, e, function (r, _) {
+            if (u(r) && !P(r)) {
+              this._f || (this._f = new n());
+              var a = this._f[e](r, _);
+              return "set" == e ? this : a;
+            }
+            return t.call(this, r, _);
+          });
+        }));
+    },
+    1443: function (e, r, t) {
+      t(233), t(198), t(1442), t(1440), t(1439), (e.exports = t(43).WeakMap);
+    },
+    1444: function (e, r, t) {
+      e.exports = { default: t(1443), __esModule: !0 };
+    },
+    2222: function (e, r, t) {
+      "use strict";
+      t.r(r);
+      var n = t(200),
+        _ = t.n(n), //new _.a() = new Map()
+        a = t(1444),
+        o = t.n(a), //new o.a() = new WeakMap()
+        c = t(12),
+        E = t.n(c), //E()(util) = typeof util
+        i = t(15),
+        u = t.n(i); //u()(t) = Object.keys(t)
+      r.default = function () {
+        var e = { STDWEB_PRIVATE: {} };
+        (e.STDWEB_PRIVATE.to_utf8 = function (r, t) {
+          for (var n = e.HEAPU8, _ = 0; _ < r.length; ++_) {
+            var a = r.charCodeAt(_);
+            a >= 55296 &&
+              a <= 57343 &&
+              (a = (65536 + ((1023 & a) << 10)) | (1023 & r.charCodeAt(++_))),
+              a <= 127
+                ? (n[t++] = a)
+                : a <= 2047
+                ? ((n[t++] = 192 | (a >> 6)), (n[t++] = 128 | (63 & a)))
+                : a <= 65535
+                ? ((n[t++] = 224 | (a >> 12)),
+                  (n[t++] = 128 | ((a >> 6) & 63)),
+                  (n[t++] = 128 | (63 & a)))
+                : a <= 2097151
+                ? ((n[t++] = 240 | (a >> 18)),
+                  (n[t++] = 128 | ((a >> 12) & 63)),
+                  (n[t++] = 128 | ((a >> 6) & 63)),
+                  (n[t++] = 128 | (63 & a)))
+                : a <= 67108863
+                ? ((n[t++] = 248 | (a >> 24)),
+                  (n[t++] = 128 | ((a >> 18) & 63)),
+                  (n[t++] = 128 | ((a >> 12) & 63)),
+                  (n[t++] = 128 | ((a >> 6) & 63)),
+                  (n[t++] = 128 | (63 & a)))
+                : ((n[t++] = 252 | (a >> 30)),
+                  (n[t++] = 128 | ((a >> 24) & 63)),
+                  (n[t++] = 128 | ((a >> 18) & 63)),
+                  (n[t++] = 128 | ((a >> 12) & 63)),
+                  (n[t++] = 128 | ((a >> 6) & 63)),
+                  (n[t++] = 128 | (63 & a)));
+          }
+        }),
+          (e.STDWEB_PRIVATE.noop = function () {}),
+          (e.STDWEB_PRIVATE.to_js = function (r) {
+            var t = e.HEAPU8[r + 12];
+            if (0 !== t) {
+              if (1 === t) return null;
+              if (2 === t) return e.HEAP32[r / 4];
+              if (3 === t) return e.HEAPF64[r / 8];
+              if (4 === t) {
+                var n = e.HEAPU32[r / 4],
+                  _ = e.HEAPU32[(r + 4) / 4];
+                return e.STDWEB_PRIVATE.to_js_string(n, _);
+              }
+              if (5 === t) return !1;
+              if (6 === t) return !0;
+              if (7 === t) {
+                (n = e.STDWEB_PRIVATE.arena + e.HEAPU32[r / 4]),
+                  (_ = e.HEAPU32[(r + 4) / 4]);
+                for (var a = [], o = 0; o < _; ++o)
+                  a.push(e.STDWEB_PRIVATE.to_js(n + 16 * o));
+                return a;
+              }
+              if (8 === t) {
+                var c = e.STDWEB_PRIVATE.arena,
+                  E = c + e.HEAPU32[r / 4],
+                  i = ((_ = e.HEAPU32[(r + 4) / 4]), c + e.HEAPU32[(r + 8) / 4]);
+                for (a = {}, o = 0; o < _; ++o) {
+                  var u = e.HEAPU32[(i + 8 * o) / 4],
+                    f = e.HEAPU32[(i + 4 + 8 * o) / 4],
+                    T = e.STDWEB_PRIVATE.to_js_string(u, f),
+                    s = e.STDWEB_PRIVATE.to_js(E + 16 * o);
+                  a[T] = s;
+                }
+                return a;
+              }
+              if (9 === t)
+                return e.STDWEB_PRIVATE.acquire_js_reference(e.HEAP32[r / 4]);
+              if (10 === t || 12 === t || 13 === t) {
+                var A = e.HEAPU32[r / 4],
+                  P = ((n = e.HEAPU32[(r + 4) / 4]), e.HEAPU32[(r + 8) / 4]),
+                  l = 0,
+                  d = !1;
+                return (
+                  ((a = function r() {
+                    if (0 === n || !0 === d)
+                      throw 10 === t
+                        ? new ReferenceError("Already dropped Rust function called!")
+                        : 12 === t
+                        ? new ReferenceError("Already dropped FnMut function called!")
+                        : new ReferenceError(
+                            "Already called or dropped FnOnce function called!"
+                          );
+                    var _ = n;
+                    if (
+                      (13 === t && ((r.drop = e.STDWEB_PRIVATE.noop), (n = 0)),
+                      0 !== l && (12 === t || 13 === t))
+                    )
+                      throw new ReferenceError(
+                        "FnMut function called multiple times concurrently!"
+                      );
+                    var a = e.STDWEB_PRIVATE.alloc(16);
+                    e.STDWEB_PRIVATE.serialize_array(a, arguments);
+                    try {
+                      (l += 1), e.STDWEB_PRIVATE.dyncall("vii", A, [_, a]);
+                      var o = e.STDWEB_PRIVATE.tmp;
+                      e.STDWEB_PRIVATE.tmp = null;
+                    } finally {
+                      l -= 1;
+                    }
+                    return !0 === d && 0 === l && r.drop(), o;
+                  }).drop = function () {
+                    if (0 === l) {
+                      a.drop = e.STDWEB_PRIVATE.noop;
+                      var r = n;
+                      (n = 0), 0 != r && e.STDWEB_PRIVATE.dyncall("vi", P, [r]);
+                    } else d = !0;
+                  }),
+                  a
+                );
+              }
+              if (14 === t) {
+                (n = e.HEAPU32[r / 4]), (_ = e.HEAPU32[(r + 4) / 4]);
+                var p = e.HEAPU32[(r + 8) / 4],
+                  W = n + _;
+                switch (p) {
+                  case 0:
+                    return e.HEAPU8.subarray(n, W);
+                  case 1:
+                    return e.HEAP8.subarray(n, W);
+                  case 2:
+                    return e.HEAPU16.subarray(n, W);
+                  case 3:
+                    return e.HEAP16.subarray(n, W);
+                  case 4:
+                    return e.HEAPU32.subarray(n, W);
+                  case 5:
+                    return e.HEAP32.subarray(n, W);
+                  case 6:
+                    return e.HEAPF32.subarray(n, W);
+                  case 7:
+                    return e.HEAPF64.subarray(n, W);
+                }
+              } else if (15 === t)
+                return e.STDWEB_PRIVATE.get_raw_value(e.HEAPU32[r / 4]);
+            }
+          }),
+          (e.STDWEB_PRIVATE.serialize_object = function (r, t) {
+            var n = u()(t),
+              _ = n.length,
+              a = e.STDWEB_PRIVATE.alloc(8 * _),
+              o = e.STDWEB_PRIVATE.alloc(16 * _);
+            (e.HEAPU8[r + 12] = 8),
+              (e.HEAPU32[r / 4] = o),
+              (e.HEAPU32[(r + 4) / 4] = _),
+              (e.HEAPU32[(r + 8) / 4] = a);
+            for (var c = 0; c < _; ++c) {
+              var E = n[c],
+                i = a + 8 * c;
+              e.STDWEB_PRIVATE.to_utf8_string(i, E),
+                e.STDWEB_PRIVATE.from_js(o + 16 * c, t[E]);
+            }
+          }),
+          (e.STDWEB_PRIVATE.serialize_array = function (r, t) {
+            var n = t.length,
+              _ = e.STDWEB_PRIVATE.alloc(16 * n);
+            (e.HEAPU8[r + 12] = 7),
+              (e.HEAPU32[r / 4] = _),
+              (e.HEAPU32[(r + 4) / 4] = n);
+            for (var a = 0; a < n; ++a) e.STDWEB_PRIVATE.from_js(_ + 16 * a, t[a]);
+          });
+        var r =
+          "function" == typeof TextEncoder
+            ? new TextEncoder("utf-8")
+            : "object" === ("undefined" == typeof util ? "undefined" : E()(util)) &&
+              util &&
+              "function" == typeof util.TextEncoder
+            ? new util.TextEncoder("utf-8")
+            : null;
+        (e.STDWEB_PRIVATE.to_utf8_string =
+          null != r
+            ? function (t, n) {
+                var _ = r.encode(n),
+                  a = _.length,
+                  o = 0;
+                a > 0 && ((o = e.STDWEB_PRIVATE.alloc(a)), e.HEAPU8.set(_, o)),
+                  (e.HEAPU32[t / 4] = o),
+                  (e.HEAPU32[(t + 4) / 4] = a);
+              }
+            : function (r, t) {
+                var n = e.STDWEB_PRIVATE.utf8_len(t),
+                  _ = 0;
+                n > 0 &&
+                  ((_ = e.STDWEB_PRIVATE.alloc(n)), e.STDWEB_PRIVATE.to_utf8(t, _)),
+                  (e.HEAPU32[r / 4] = _),
+                  (e.HEAPU32[(r + 4) / 4] = n);
+              }),
+          (e.STDWEB_PRIVATE.from_js = function (r, t) {
+            var n = Object.prototype.toString.call(t);
+            if ("[object String]" === n)
+              (e.HEAPU8[r + 12] = 4), e.STDWEB_PRIVATE.to_utf8_string(r, t);
+            else if ("[object Number]" === n)
+              t === (0 | t)
+                ? ((e.HEAPU8[r + 12] = 2), (e.HEAP32[r / 4] = t))
+                : ((e.HEAPU8[r + 12] = 3), (e.HEAPF64[r / 8] = t));
+            else if (null === t) e.HEAPU8[r + 12] = 1;
+            else if (void 0 === t) e.HEAPU8[r + 12] = 0;
+            else if (!1 === t) e.HEAPU8[r + 12] = 5;
+            else if (!0 === t) e.HEAPU8[r + 12] = 6;
+            else if ("[object Symbol]" === n) {
+              var _ = e.STDWEB_PRIVATE.register_raw_value(t);
+              (e.HEAPU8[r + 12] = 15), (e.HEAP32[r / 4] = _);
+            } else {
+              var a = e.STDWEB_PRIVATE.acquire_rust_reference(t);
+              (e.HEAPU8[r + 12] = 9), (e.HEAP32[r / 4] = a);
+            }
+          });
+        var t =
+          "function" == typeof TextDecoder
+            ? new TextDecoder("utf-8")
+            : "object" === ("undefined" == typeof util ? "undefined" : E()(util)) &&
+              util &&
+              "function" == typeof util.TextDecoder
+            ? new util.TextDecoder("utf-8")
+            : null;
+        (e.STDWEB_PRIVATE.to_js_string =
+          null != t
+            ? function (r, n) {
+                return t.decode(e.HEAPU8.subarray(r, r + n));
+              }
+            : function (r, t) {
+                for (
+                  var n = e.HEAPU8, _ = (0 | (r |= 0)) + (0 | (t |= 0)), a = "";
+                  r < _;
+        
+                ) {
+                  var o = n[r++];
+                  if (o < 128) a += String.fromCharCode(o);
+                  else {
+                    var c = 31 & o,
+                      E = 0;
+                    r < _ && (E = n[r++]);
+                    var i = (c << 6) | (63 & E);
+                    if (o >= 224) {
+                      var u = 0;
+                      r < _ && (u = n[r++]);
+                      var f = ((63 & E) << 6) | (63 & u);
+                      if (((i = (c << 12) | f), o >= 240)) {
+                        var T = 0;
+                        r < _ && (T = n[r++]),
+                          (i = ((7 & c) << 18) | (f << 6) | (63 & T)),
+                          (a += String.fromCharCode(55232 + (i >> 10))),
+                          (i = 56320 + (1023 & i));
+                      }
+                    }
+                    a += String.fromCharCode(i);
+                  }
+                }
+                return a;
+              }),
+          (e.STDWEB_PRIVATE.id_to_ref_map = {}),
+          (e.STDWEB_PRIVATE.id_to_refcount_map = {}),
+          (e.STDWEB_PRIVATE.ref_to_id_map = new o.a()),
+          (e.STDWEB_PRIVATE.ref_to_id_map_fallback = new _.a()),
+          (e.STDWEB_PRIVATE.last_refid = 1),
+          (e.STDWEB_PRIVATE.id_to_raw_value_map = {}),
+          (e.STDWEB_PRIVATE.last_raw_value_id = 1),
+          (e.STDWEB_PRIVATE.acquire_rust_reference = function (r) {
+            if (void 0 === r || null === r) return 0;
+            var t = e.STDWEB_PRIVATE.id_to_refcount_map,
+              n = e.STDWEB_PRIVATE.id_to_ref_map,
+              _ = e.STDWEB_PRIVATE.ref_to_id_map,
+              a = e.STDWEB_PRIVATE.ref_to_id_map_fallback,
+              o = _.get(r);
+            if ((void 0 === o && (o = a.get(r)), void 0 === o)) {
+              o = e.STDWEB_PRIVATE.last_refid++;
+              try {
+                _.set(r, o);
+              } catch (e) {
+                a.set(r, o);
+              }
+            }
+            return o in n ? t[o]++ : ((n[o] = r), (t[o] = 1)), o;
+          }),
+          (e.STDWEB_PRIVATE.acquire_js_reference = function (r) {
+            return e.STDWEB_PRIVATE.id_to_ref_map[r];
+          }),
+          (e.STDWEB_PRIVATE.increment_refcount = function (r) {
+            e.STDWEB_PRIVATE.id_to_refcount_map[r]++;
+          }),
+          (e.STDWEB_PRIVATE.decrement_refcount = function (r) {
+            var t = e.STDWEB_PRIVATE.id_to_refcount_map;
+            if (0 == --t[r]) {
+              var n = e.STDWEB_PRIVATE.id_to_ref_map,
+                _ = e.STDWEB_PRIVATE.ref_to_id_map_fallback,
+                a = n[r];
+              delete n[r], delete t[r], _.delete(a);
+            }
+          }),
+          (e.STDWEB_PRIVATE.register_raw_value = function (r) {
+            var t = e.STDWEB_PRIVATE.last_raw_value_id++;
+            return (e.STDWEB_PRIVATE.id_to_raw_value_map[t] = r), t;
+          }),
+          (e.STDWEB_PRIVATE.unregister_raw_value = function (r) {
+            delete e.STDWEB_PRIVATE.id_to_raw_value_map[r];
+          }),
+          (e.STDWEB_PRIVATE.get_raw_value = function (r) {
+            return e.STDWEB_PRIVATE.id_to_raw_value_map[r];
+          }),
+          (e.STDWEB_PRIVATE.alloc = function (r) {
+            return e.web_malloc(r);
+          }),
+          (e.STDWEB_PRIVATE.dyncall = function (r, t, n) {
+            return e.web_table.get(t).apply(null, n);
+          }),
+          (e.STDWEB_PRIVATE.utf8_len = function (e) {
+            for (var r = 0, t = 0; t < e.length; ++t) {
+              var n = e.charCodeAt(t);
+              n >= 55296 &&
+                n <= 57343 &&
+                (n = (65536 + ((1023 & n) << 10)) | (1023 & e.charCodeAt(++t))),
+                n <= 127
+                  ? ++r
+                  : (r +=
+                      n <= 2047
+                        ? 2
+                        : n <= 65535
+                        ? 3
+                        : n <= 2097151
+                        ? 4
+                        : n <= 67108863
+                        ? 5
+                        : 6);
+            }
+            return r;
+          }),
+          (e.STDWEB_PRIVATE.prepare_any_arg = function (r) {
+            var t = e.STDWEB_PRIVATE.alloc(16);
+            return e.STDWEB_PRIVATE.from_js(t, r), t;
+          }),
+          (e.STDWEB_PRIVATE.acquire_tmp = function (r) {
+            var t = e.STDWEB_PRIVATE.tmp;
+            return (e.STDWEB_PRIVATE.tmp = null), t;
+          });
+        var n = null,
+          a = null,
+          c = null,
+          i = null,
+          f = null,
+          T = null,
+          s = null,
+          A = null;
+        function P() {
+          var r = e.instance.exports.memory.buffer;
+          (n = new Int8Array(r)),
+            (a = new Int16Array(r)),
+            (c = new Int32Array(r)),
+            (i = new Uint8Array(r)),
+            (f = new Uint16Array(r)),
+            (T = new Uint32Array(r)),
+            (s = new Float32Array(r)),
+            (A = new Float64Array(r)),
+            (e.HEAP8 = n),
+            (e.HEAP16 = a),
+            (e.HEAP32 = c),
+            (e.HEAPU8 = i),
+            (e.HEAPU16 = f),
+            (e.HEAPU32 = T),
+            (e.HEAPF32 = s),
+            (e.HEAPF64 = A);
+        }
+        return (
+          Object.defineProperty(e, "exports", { value: {} }),
+          {
+        imports: {
+            env: {
+            __cargo_web_snippet_0d39c013e2144171d64e2fac849140a7e54c939a: function (
+                r,
+                t
+            ) {
+                (t = e.STDWEB_PRIVATE.to_js(t)),
+                e.STDWEB_PRIVATE.from_js(r, t.location);
+            },
+                __cargo_web_snippet_0f503de1d61309643e0e13a7871406891e3691c9: function (
+                  r
+                ) {
+                  e.STDWEB_PRIVATE.from_js(r, window);
+                },
+                __cargo_web_snippet_10f5aa3985855124ab83b21d4e9f7297eb496508: function (
+                  r
+                ) {
+                  return (
+                    (e.STDWEB_PRIVATE.acquire_js_reference(r) instanceof Array) | 0
+                  );
+                },
+                __cargo_web_snippet_2b0b92aee0d0de6a955f8e5540d7923636d951ae: function (
+                  r,
+                  t
+                ) {
+                  (t = e.STDWEB_PRIVATE.to_js(t)),
+                    e.STDWEB_PRIVATE.from_js(
+                      r,
+                      (function () {
+                        try {
+                          return { value: t.origin, success: !0 };
+                        } catch (e) {
+                          return { error: e, success: !1 };
+                        }
+                      })()
+                    );
+                },
+                __cargo_web_snippet_461d4581925d5b0bf583a3b445ed676af8701ca6: function (
+                  r,
+                  t
+                ) {
+                  (t = e.STDWEB_PRIVATE.to_js(t)),
+                    e.STDWEB_PRIVATE.from_js(
+                      r,
+                      (function () {
+                        try {
+                          return { value: t.host, success: !0 };
+                        } catch (e) {
+                          return { error: e, success: !1 };
+                        }
+                      })()
+                    );
+                },
+                __cargo_web_snippet_4c895ac2b754e5559c1415b6546d672c58e29da6: function (
+                  r,
+                  t
+                ) {
+                  (t = e.STDWEB_PRIVATE.to_js(t)),
+                    e.STDWEB_PRIVATE.from_js(
+                      r,
+                      (function () {
+                        try {
+                          return { value: t.protocol, success: !0 };
+                        } catch (e) {
+                          return { error: e, success: !1 };
+                        }
+                      })()
+                    );
+                },
+                __cargo_web_snippet_614a3dd2adb7e9eac4a0ec6e59d37f87e0521c3b: function (
+                  r,
+                  t
+                ) {
+                  (t = e.STDWEB_PRIVATE.to_js(t)),
+                    e.STDWEB_PRIVATE.from_js(r, t.error);
+                },
+                __cargo_web_snippet_62ef43cf95b12a9b5cdec1639439c972d6373280: function (
+                  r,
+                  t
+                ) {
+                  (t = e.STDWEB_PRIVATE.to_js(t)),
+                    e.STDWEB_PRIVATE.from_js(r, t.childNodes);
+                },
+                __cargo_web_snippet_6fcce0aae651e2d748e085ff1f800f87625ff8c8: function (
+                  r
+                ) {
+                  e.STDWEB_PRIVATE.from_js(r, document);
+                },
+                __cargo_web_snippet_7ba9f102925446c90affc984f921f414615e07dd: function (
+                  r,
+                  t
+                ) {
+                  (t = e.STDWEB_PRIVATE.to_js(t)),
+                    e.STDWEB_PRIVATE.from_js(r, t.body);
+                },
+                __cargo_web_snippet_80d6d56760c65e49b7be8b6b01c1ea861b046bf0: function (
+                  r
+                ) {
+                  e.STDWEB_PRIVATE.decrement_refcount(r);
+                },
+                __cargo_web_snippet_897ff2d0160606ea98961935acb125d1ddbf4688: function (
+                  r
+                ) {
+                  var t = e.STDWEB_PRIVATE.acquire_js_reference(r);
+                  return t instanceof DOMException && "SecurityError" === t.name;
+                },
+                __cargo_web_snippet_8c32019649bb581b1b742eeedfc410e2bedd56a6: function (
+                  r,
+                  t
+                ) {
+                  var n = e.STDWEB_PRIVATE.acquire_js_reference(r);
+                  e.STDWEB_PRIVATE.serialize_array(t, n);
+                },
+                __cargo_web_snippet_a466a2ab96cd77e1a77dcdb39f4f031701c195fc: function (
+                  r,
+                  t
+                ) {
+                  (t = e.STDWEB_PRIVATE.to_js(t)),
+                    e.STDWEB_PRIVATE.from_js(
+                      r,
+                      (function () {
+                        try {
+                          return { value: t.pathname, success: !0 };
+                        } catch (e) {
+                          return { error: e, success: !1 };
+                        }
+                      })()
+                    );
+                },
+                __cargo_web_snippet_ab05f53189dacccf2d365ad26daa407d4f7abea9: function (
+                  r,
+                  t
+                ) {
+                  (t = e.STDWEB_PRIVATE.to_js(t)),
+                    e.STDWEB_PRIVATE.from_js(r, t.value);
+                },
+                __cargo_web_snippet_b06dde4acf09433b5190a4b001259fe5d4abcbc2: function (
+                  r,
+                  t
+                ) {
+                  (t = e.STDWEB_PRIVATE.to_js(t)),
+                    e.STDWEB_PRIVATE.from_js(r, t.success);
+                },
+                __cargo_web_snippet_b33a39de4ca954888e26fe9caa277138e808eeba: function (
+                  r,
+                  t
+                ) {
+                  (t = e.STDWEB_PRIVATE.to_js(t)),
+                    e.STDWEB_PRIVATE.from_js(r, t.length);
+                },
+                __cargo_web_snippet_cdf2859151791ce4cad80688b200564fb08a8613: function (
+                  r,
+                  t
+                ) {
+                  (t = e.STDWEB_PRIVATE.to_js(t)),
+                    e.STDWEB_PRIVATE.from_js(
+                      r,
+                      (function () {
+                        try {
+                          return { value: t.href, success: !0 };
+                        } catch (e) {
+                          return { error: e, success: !1 };
+                        }
+                      })()
+                    );
+                },
+                __cargo_web_snippet_e8ef87c41ded1c10f8de3c70dea31a053e19747c: function (
+                  r,
+                  t
+                ) {
+                  (t = e.STDWEB_PRIVATE.to_js(t)),
+                    e.STDWEB_PRIVATE.from_js(
+                      r,
+                      (function () {
+                        try {
+                          return { value: t.hostname, success: !0 };
+                        } catch (e) {
+                          return { error: e, success: !1 };
+                        }
+                      })()
+                    );
+                },
+                __cargo_web_snippet_e9638d6405ab65f78daf4a5af9c9de14ecf1e2ec: function (
+                  r
+                ) {
+                  (r = e.STDWEB_PRIVATE.to_js(r)),
+                    console.log(t),
+                    e.STDWEB_PRIVATE.unregister_raw_value(r);
+                },
+                __cargo_web_snippet_ff5103e6cc179d13b4c7a785bdce2708fd559fc0: function (
+                  r
+                ) {
+                  e.STDWEB_PRIVATE.tmp = e.STDWEB_PRIVATE.to_js(r);
+                },
+                __web_on_grow: P,
+              },
+            },
+            initialize: function (r) {
+              return (
+                Object.defineProperty(e, "instance", { value: r }),
+                Object.defineProperty(e, "web_malloc", {
+                  value: e.instance.exports.__web_malloc,
+                }),
+                Object.defineProperty(e, "web_free", {
+                  value: e.instance.exports.__web_free,
+                }),
+                Object.defineProperty(e, "web_table", {
+                  value: e.instance.exports.__indirect_function_table,
+                }),
+                (e.exports.spyder = function (r, t) {
+                  return e.STDWEB_PRIVATE.acquire_tmp(
+                    e.instance.exports.spyder(
+                      e.STDWEB_PRIVATE.prepare_any_arg(r),
+                      e.STDWEB_PRIVATE.prepare_any_arg(t)
+                    )
+                  );
+                }),
+                (e.exports.from_js = (r, t) => {//export fromjs
+                    return e.STDWEB_PRIVATE.from_js(r, t)
+                }),
+                P(),
+                e.exports
+              );
+            },
+          }
+        );
+      };
+    },
+  },
+]);
diff --git a/demo/html/bili.js b/demo/html/bili.js
new file mode 100644 (file)
index 0000000..ed5a177
--- /dev/null
@@ -0,0 +1,189 @@
+/**
+ * 获取wasm并返回instance
+ * @param {string} url wasm文件位置
+ * @param {{}} importObject new t_func()得到的对象
+ */
+function fetchAndInstantiate(url, importObject) {
+  return fetch(url)
+    .then((response) => response.arrayBuffer())
+    .then((bytes) => WebAssembly.instantiate(bytes, importObject))
+    .then((results) => results.instance);
+}
+
+/**
+ * 根据
+ * https://github.com/lkeme/bilibili-pcheartbeat 及
+ * 27.02768ee66953cfc6d097.js(改自bilibili)
+ * 编写
+ */
+function t_func() {
+  var tmp = {};
+  tmp = (arg) => {
+    if (arg == 200) {
+      return { a: Map };
+    }
+    if (arg == 1444) {
+      return { a: WeakMap };
+    }
+    if (arg == 12) {
+      return () => {
+        return (argc) => {
+          return typeof argc;
+        };
+      };
+    }
+    if (arg == 15) {
+      return () => {
+        return (argc) => {
+          return Object.keys(argc);
+        };
+      };
+    }
+  };
+  tmp.n = (arg) => {
+    return arg;
+  };
+  tmp.r = (arg) => {
+    arg.default = {};
+  };
+  return tmp;
+}
+
+/**
+ * 全局操作对象
+ */
+var wasm =
+  /**
+   * 初始化
+   */
+  (() => {
+    let r = {};
+    webpackJsonp[0][1][2222](null, r, new t_func());
+    return r.default();
+  })();
+
+/**
+ * 替换27.02768ee66953cfc6d097.js(改自bilibili)中的导入函数
+ */
+(() => {
+  /**
+   * 返回host
+   */
+  wasm.imports.env.__cargo_web_snippet_461d4581925d5b0bf583a3b445ed676af8701ca6 = (
+    r,
+    t
+  ) => {
+    wasm.all.from_js(r, { value: "live.bilibili.com", success: !0 }); //hs
+  };
+  /**
+   * 返回protocol
+   */
+  wasm.imports.env.__cargo_web_snippet_4c895ac2b754e5559c1415b6546d672c58e29da6 = (
+    r,
+    t
+  ) => {
+    wasm.all.from_js(r, { value: "https:", success: !0 }); //pe
+  };
+  /**
+   * 返回hostname
+   */
+  wasm.imports.env.__cargo_web_snippet_e8ef87c41ded1c10f8de3c70dea31a053e19747c = (
+    r,
+    t
+  ) => {
+    wasm.all.from_js(r, { value: "live.bilibili.com", success: !0 }); //hn
+  };
+  /**
+   * 返回href
+   */
+  wasm.imports.env.__cargo_web_snippet_cdf2859151791ce4cad80688b200564fb08a8613 = (
+    r,
+    t
+  ) => {
+    wasm.all.from_js(r, {
+      value: "https://live.bilibili.com/0",
+      success: !0,
+    }); //hq
+  };
+})();
+
+/**
+ * 加密
+ */
+wasm.spyder = (r, t) => {
+  try {
+    return wasm.all.spyder(JSON.stringify(r), t);
+  } catch (err) {
+    return err;
+  }
+};
+
+/**
+ * 测试加密是否正常
+ */
+wasm.test = () => {
+  let test = {
+    r: {
+      id: "[9,371,1,22613059]",
+      device: '["AUTO8216117272375373","77bee604-b591-4664-845b-b69603f8c71c"]',
+      ets: 1611836581,
+      benchmark: "seacasdgyijfhofiuxoannn",
+      time: 60,
+      ts: 1611836642190,
+    },
+    t: [2, 5, 1, 4],
+  };
+  `e4249b7657c2d4a44955548eb814797d41ddd99bfdfa5974462b8c387d701b8c83898f6d7dde1772c67fad6a113d20c20e454be1d1627e7ea99617a8a1f99bd0` ==
+  wasm.spyder(test.r, test.t)
+    ? (() => {
+        console.log(`Test Pass`);
+        console.log(`现在可以使用 wasm.spyder(r,t)进行加密`);
+      })()
+    : console.error(`Test No Pass`);
+};
+
+/**
+ * 获取wasm并测试加密
+ */
+(() => {
+  fetchAndInstantiate("e791556706f88d88b4846a61a583b31db007f83d.wasm", {
+    env: wasm.imports.env,
+  })
+    .then((instance) => {
+      wasm.all = wasm.initialize(instance);
+      wasm.test();
+    })
+    .catch((reason) => console.error(reason));
+})();
+
+/**
+ * ws 收发
+ */
+(() => {
+  if (window["WebSocket"]) {
+    conn = new WebSocket("ws://" + document.location.host + "/ws");
+    conn.onclose = function () {
+      location.reload();
+    };
+    conn.onmessage = function (evt) {
+      deal(evt.data)
+    };
+
+    function deal(data) {
+      //或许还没初始化
+      if (wasm.all == null) {
+        setTimeout(()=>{
+          deal(data)
+        },100)
+        return
+      }
+
+      let rt = JSON.parse(data),
+          s = wasm.spyder(rt.r, rt.t);
+
+      conn.send(JSON.stringify({
+        s:s
+      }));
+    }
+  }
+})();
diff --git a/demo/html/e791556706f88d88b4846a61a583b31db007f83d.wasm b/demo/html/e791556706f88d88b4846a61a583b31db007f83d.wasm
new file mode 100644 (file)
index 0000000..563ace6
Binary files /dev/null and b/demo/html/e791556706f88d88b4846a61a583b31db007f83d.wasm differ
diff --git a/demo/html/index.html b/demo/html/index.html
new file mode 100644 (file)
index 0000000..d4f9813
--- /dev/null
@@ -0,0 +1,71 @@
+<!DOCTYPE html>
+<html lang="zh-cmn-Hans">
+  <head>
+    <meta charset="utf-8" />
+    <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
+    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
+    <style>
+      a,p {
+        font-size: 0.9em;
+        padding: 0 0 0 1em;
+        margin: 0;
+      }
+      h4 {
+        margin: 1em 0 0.7em 0;
+      }
+      footer {
+        font-size: 0.9em;
+        margin: 3em 0 1em 0;
+      }
+    </style>
+  </head>
+  <body>
+    <h3>小心心加密页面</h3>
+    <h4>介绍</h4>
+    <p>
+      本页面用于在获取小心心过程中的加密问题。大致原理:加载wasm文件并处理golang-websocket发来的数据再返回加密字符串<br />
+      打开开发者工具查看运行情况<br />
+      !!如需获取小心心请勿关闭此标签页!!
+    </p>
+    <a target="_blank" href="https://github.com/qydysky/bili_danmu">项目地址</a
+    ><br />
+    <h4>外部资源来源:</h4>
+    <p>
+      <a
+        target="_blank"
+        href="https://s1.hdslb.com/bfs/static/blive/blfe-live-room/static/js/27.02768ee66953cfc6d097.js"
+        >27.02768ee66953cfc6d097.js</a
+      ><br />
+      <a
+        target="_blank"
+        href="https://i0.hdslb.com/bfs/live/e791556706f88d88b4846a61a583b31db007f83d.wasm"
+        >e791556706f88d88b4846a61a583b31db007f83d.wasm</a
+      >
+    </p>
+    <h4>改动:</h4>
+    <p>
+      <code> 27.02768ee66953cfc6d097.js </code>
+      <br />
+      <code>
+        + (e.exports.from_js = (r, t) => {//export fromjs return
+        e.STDWEB_PRIVATE.from_js(r, t) }),
+      </code>
+    </p>
+    <h4>资料参考:</h4>
+    <p>
+      <a
+        target="_blank"
+        href="https://gist.github.com/qydysky/d856d811670841ab33ce2d910abddb8f#webassembly"
+        >WebAssembly</a
+      ><br />
+      <a
+        target="_blank"
+        href="https://mudew.com/20200722/bilibili-webside-live-broadcast-encryption-heartbeat-request-analysis/"
+        >Bilibili Web端直播加密心跳请求解析</a
+      ><br />
+    </p>
+    <footer>qydysky 2020</footer>
+    <script src="27.02768ee66953cfc6d097.js"></script>
+    <script src="bili.js"></script>
+  </body>
+</html>