1
0
forked from x/icebergs

opt chrome

This commit is contained in:
IT 老营长 @云轩领航-创始人 2022-01-02 22:02:44 +08:00
parent c43212865a
commit 069808d74b
2 changed files with 88 additions and 0 deletions

68
misc/chrome/operate.go Normal file
View File

@ -0,0 +1,68 @@
package chrome
import (
"shylinux.com/x/ice"
"shylinux.com/x/icebergs/base/mdb"
"shylinux.com/x/icebergs/base/web"
"shylinux.com/x/icebergs/core/wiki"
kit "shylinux.com/x/toolkits"
)
type operate struct {
reload string `name:"reload" help:"刷新"`
list string `name:"list wid tid url auto" help:"操作"`
}
func (o operate) send(m *ice.Message, arg ...interface{}) *ice.Message {
return m.Cmdy(web.SPACE, "chrome", "chrome", arg)
}
func (o operate) Inputs(m *ice.Message, arg ...string) {
switch arg[0] {
case mdb.ZONE:
o.send(m.Spawn()).Table(func(index int, value map[string]string, head []string) {
o.send(m.Spawn(), value[WID]).Table(func(index int, value map[string]string, head []string) {
m.Push(mdb.ZONE, kit.ParseURL(value[URL]).Host)
})
}).Sort(mdb.ZONE)
}
}
func (o operate) Spide(m *ice.Message, arg ...string) {
if len(arg) < 2 {
o.send(m, arg)
return
}
o.send(m, arg[:2], "spide").Table(func(index int, value map[string]string, head []string) {
switch value[mdb.TYPE] {
case wiki.VIDEO:
m.PushVideos(mdb.SHOW, value[mdb.LINK])
case wiki.IMG:
m.PushImages(mdb.SHOW, value[mdb.LINK])
default:
m.Push(mdb.SHOW, "")
}
}).Cut("show,type,name,link")
}
func (o operate) Reload(m *ice.Message, arg ...string) {
o.send(m, arg[:2], "user.reload", ice.TRUE).ProcessHold()
}
func (o operate) List(m *ice.Message, arg ...string) {
switch len(arg) {
case 3:
o.send(m, arg[:2], "user.jumps", arg[2])
case 2:
m.Action(o.Reload)
o.Spide(m, arg...)
m.StatusTimeCount()
default:
o.send(m, arg)
}
}
const (
WID = "wid"
TID = "tid"
URL = "url"
)
func init() { ice.CodeCtxCmd(operate{}) }

20
misc/chrome/video.go Normal file
View File

@ -0,0 +1,20 @@
package chrome
import (
"shylinux.com/x/ice"
)
type video struct {
operate
play string `name:"play" help:"播放"`
next string `name:"next" help:"下一集"`
list string `name:"list tags='ul.stui-content__playlist.column10.clearfix li a' rate=1.5 skip=140 next=2520 auto play next" help:"操作"`
}
func (v video) List(m *ice.Message, arg ...string) {
m.DisplayStory("video.js")
m.Echo("hello world")
}
func init() { ice.CodeCtxCmd(video{}) }