1
0
mirror of https://shylinux.com/x/volcanos synced 2025-04-25 08:48:06 +08:00

opt chrome

This commit is contained in:
IT 老营长 @云轩领航-创始人 2022-01-02 22:03:01 +08:00
parent 39d51e92ee
commit 072a309443
7 changed files with 87 additions and 47 deletions

View File

@ -198,7 +198,7 @@ Volcanos("onappend", {help: "渲染引擎", list: [], _init: function(can, meta,
},
_action: function(can, list, action, meta) { action = action||can._action, meta = meta||can.onaction
can.core.List(list||can.onaction.list, function(item) { can.onappend.input(can, item == ""? /*空白*/ {type: html.SPACE}:
can.base.isString(item)? /*按键*/ {type: html.BUTTON, value: item, onclick: function(event) {
can.base.isString(item)? /*按键*/ {type: html.BUTTON, value: can.user.trans(can, item), onclick: function(event) {
var cb = meta[item]||meta["_engine"]
cb? can.core.CallFunc(cb, {event: event, can: can, button: item}): can.run(event, [ctx.ACTION, item].concat(can.sup.Input()))

View File

@ -38,7 +38,7 @@ Volcanos("misc", {help: "通信协议", Message: function(event, can) { var msg
return can.base.isFunc(cb) && (res = cb(one, index, array)) && res != undefined && res || one
})
},
Clear: function(key) { switch (key) {
Clear: function(key) { switch (key||ice.MSG_APPEND) {
case ice.MSG_APPEND:
case ice.MSG_OPTION:
can.core.List(msg[key], function(item) { delete(msg[item]) })

View File

@ -33,6 +33,12 @@ Volcanos("page", {help: "用户界面", ClassList: {
if (key.indexOf(ice.PT) > -1) { return [""]}
return can.page.Select(can, option, key? "textarea[name="+key+"],"+"input[name="+key+"],"+"select[name="+key+"]": ".args", cb)
},
SelectAll: shy("选择节点", function(can, target, key, cb, interval, cbs) {
can.page.Select(can, target, html.IFRAME, function(item) {
can.page.SelectAll(can, item.contentWindow.document.body, key, cb, interval, cbs)
})
return can.core.List(target && target.querySelectorAll(key), cb, interval, cbs)
}),
Select: shy("选择节点", function(can, target, key, cb, interval, cbs) { if (key == ice.PT) { cb(target); return [] }
return can.core.List(target && target.querySelectorAll(key), cb, interval, cbs)
}),
@ -51,6 +57,7 @@ Volcanos("page", {help: "用户界面", ClassList: {
"height": true, "max-height": true, "min-height": true,
"left": true, "right": true, "top": true, "bottom": true,
"margin-top": true, "margin-left": true,
"font-size": true,
}
if (size[k] && v && (can.base.isNumber(v) || v.indexOf && v.indexOf("px") == -1)) {

View File

@ -1,17 +1,19 @@
var kit = {
MDB_ID: "id",
MDB_KEY: "key",
MDB_ZONE: "zone",
MDB_TIME: "time",
MDB_ZONE: "zone",
MDB_TYPE: "type",
MDB_NAME: "name",
MDB_TEXT: "text",
MDB_HELP: "help",
MDB_LINK: "link",
MDB_INDEX: "index",
MDB_VALUE: "value",
MDB_COUNT: "count",
MDB_INDEX: "index",
MDB_LINK: "link",
MDB_HELP: "help",
MDB_ARGS: "args",
MDB_HASH: "hash",
@ -63,6 +65,7 @@ var ice = {
var ctx = {
CONTEXT: "context", COMMAND: "command", ACTION: "action", CONFIG: "config",
INDEX: "index", ARGS: "args",
}
var cli = {
START: "start", STOP: "stop",
@ -88,6 +91,27 @@ var mdb = {
MODIFY: "modify", SELECT: "select",
META: "meta", HASH: "hash", LIST: "list",
ID: "id",
KEY: "key",
TIME: "time",
ZONE: "zone",
TYPE: "type",
NAME: "name",
TEXT: "text",
LINK: "link",
SCAN: "scan",
SHOW: "show",
HELP: "help",
SHORT: "short",
FIELD: "field",
COUNT: "count",
LIMIT: "limit",
INDEX: "index",
VALUE: "value",
EXPIRE: "expire",
}
var ssh = {
SCRIPT: "script",

View File

@ -35,13 +35,14 @@ Volcanos({
can.core.CallFunc([can, cmd], {can: can, msg: msg, arg: arg, cb: function() { msg.Reply() }})
})
chrome.runtime.onMessage.addListener(function(req, sender, cb) {
var msg = can.request({}, {tid: sender.tab.id, url: sender.url}); msg.__daemon = can.core.Keys(html.CHROME, sender.tab.id)
var msg = can.request({}, {tid: sender.tab.id, url: sender.url})
can.core.List(req.option, function(key) { msg.Option(key, req[key][0]) })
msg.__daemon = can.core.Keys(html.CHROME, sender.tab.id)
can.run(msg._event, req.detail||[], cb)
return true
})
chrome.history.onVisited.addListener(function(item) {
can.run({}, ["sync", kit.MDB_TYPE, "link", kit.MDB_NAME, item.title, kit.MDB_TEXT, item.url, "tid", item.id])
can.run({}, ["sync", mdb.TYPE, "link", mdb.NAME, item.title, mdb.LINK, item.url, "tid", item.id])
})
},
_motion: function(can) {

View File

@ -62,6 +62,12 @@ fieldset.contexts input[type=text] {
fieldset.contexts input[type=text]:hover {
background-color:white;
}
fieldset.contexts table.content a {
color:white;
}
fieldset.contexts table.content {
color:white;
}
fieldset.contexts div.code {
background-color:#343a3445; color:white;
font-size:14px; font-family:monospace;

View File

@ -1,48 +1,54 @@
setTimeout(function() { Volcanos({
spide: function(can, msg, arg) { var has = {}
can.page.Select(can, document.body, html.VIDEO, function(item) {
if (!item.src || has[item.src]) { return } has[item.src] = true
var p = can.page.Select(can, document.body, "p.title")[0]
var ls = item.src.split("?")
var ls = ls[0].split(ice.PT)
setTimeout(function() { Volcanos({Option: function() { return [] },
spide: function(can, msg, _target) {
if (!_target) {
msg.Push(mdb.TYPE, mdb.LINK)
msg.Push(mdb.NAME, document.title)
msg.Push(mdb.LINK, location.href)
}
msg.Push(kit.MDB_TIME, can.base.Time())
msg.Push(kit.MDB_TYPE, html.VIDEO)
msg.Push(kit.MDB_NAME, (p && p.innerText || html.VIDEO)+ice.PT+ls[ls.length-1])
msg.Push(kit.MDB_TEXT, item.src)
msg.Push(kit.MDB_LINK, item.src)
var has = {}; _target = _target||document.body
can.page.Select(can, _target, html.IFRAME, function(item) {
if (!item.src || has[item.src]) { return } has[item.src] = true
msg.Push(mdb.TYPE, html.IFRAME)
msg.Push(mdb.NAME, "")
msg.Push(mdb.LINK, item.src)
can.spide(can, msg, item.contentWindow.document.body)
})
can.page.Select(can, _target, html.VIDEO, function(item) {
if (!item.src || has[item.src]) { return } has[item.src] = true
var name = item.src.split("?")[0].split(ice.PT).pop()
var p = can.page.Select(can, _target, "p.title")[0]
msg.Push(mdb.TYPE, html.VIDEO)
msg.Push(mdb.NAME, (p && p.innerText || html.VIDEO)+ice.PT+name)
msg.Push(mdb.LINK, item.src)
})
can.page.Select(can, document.body, html.IMG, function(item) {
can.page.Select(can, _target, html.IMG, function(item) {
if (!item.src || has[item.src]) { return } has[item.src] = true
var ls = item.src.split("?")
var ls = ls[0].split(ice.PS)
var name = item.src.split("?")[0].split(ice.PS).pop()
msg.Push(kit.MDB_TIME, can.base.Time())
msg.Push(kit.MDB_TYPE, html.IMG)
msg.Push(mdb.TYPE, html.IMG)
if (item.src.indexOf("data:image") == 0) {
msg.Push(kit.MDB_NAME, item.src.slice(item.src.length-20))
msg.Push(mdb.NAME, item.src.slice(item.src.length-20))
} else {
msg.Push(kit.MDB_NAME, ls[ls.length-1]||"image.jpg")
msg.Push(mdb.NAME, name||"image.jpg")
}
msg.Push(kit.MDB_TEXT, item.src)
msg.Push(kit.MDB_LINK, item.src)
msg.Push(mdb.LINK, item.src)
})
},
change: function(can, msg, arg) {
if (arg.length > 1) {
can.page.Modify(can, arg[0], can.base.Obj(arg[1]))
}
if (arg.length > 0) {
can.page.Select(can, document.body, arg[0], function(item) {
msg.Push(kit.MDB_TEXT, item.outerHTML)
})
}
arg.length > 1 && can.page.Modify(can, arg[0], can.base.Obj(arg[1]))
arg.length > 0 && can.page.Select(can, document.body, arg[0], function(item) {
msg.Push(mdb.TEXT, item.outerHTML)
})
},
order: function(can, msg, arg) {
var ui = can.user.input(event, can, ["index", "args", "selection", "left", "top"], function(event, button, data, list, args) {
can.run(event, [chat.FIELD, mdb.INSERT, kit.MDB_ZONE, location.host].concat(args), function(res) {
var ui = can.user.input(event, can, [ctx.INDEX, ctx.ARGS, "selection", html.LEFT, html.TOP], function(event, button, data, list, args) {
can.run(event, [chat.FIELD, mdb.INSERT, mdb.ZONE, location.host].concat(args), function(res) {
can.user.toastSuccess(can)
})
}); can.page.Modify(can, ui._target, {style: {left: 200, top: 200}})
@ -65,9 +71,8 @@ setTimeout(function() { Volcanos({
can.onmotion.toggle(can, sub._output)
can.onmotion.toggle(can, sub._status)
}, msg.Option("selection")||sub._legend.onclick()
can.onmotion.float.auto(can, sub._target, chat.CARTE)
sub.run = function(event, cmds, cb) {
sub.run = function(event, cmds, cb) { if (msg.RunAction(event, can, cmds)) { return }
can.run(event, can.misc.concat([ctx.ACTION, ice.RUN, meta.index], cmds), cb)
}
@ -76,7 +81,7 @@ setTimeout(function() { Volcanos({
}))
sub.onaction["保存参数"] = function(event) {
can.request(event, {zone: location.host, id: msg.Option(kit.MDB_ID)})
can.request(event, {zone: location.host, id: msg.Option(mdb.ID)})
can.run(event, [chat.FIELD, mdb.MODIFY, chat.TOP, sub._target.offsetTop])
can.run(event, [chat.FIELD, mdb.MODIFY, chat.LEFT, sub._target.offsetLeft])
can.run(event, [chat.FIELD, mdb.MODIFY, "args", JSON.stringify(sub.Input([], true))])
@ -92,17 +97,14 @@ setTimeout(function() { Volcanos({
})
},
Option: function() { return [] },
_daemon: function(can) {
chrome.extension.onMessage.addListener(function(req, sender, cb) { var msg = can.request(); msg.Copy(req); can.misc.Log(req.detail, msg)
can.core.CallFunc([can, req.detail[3]||"spide"], {can: can, msg: msg, arg: req.detail.slice(4), cb: function() {
can.core.CallFunc([can, req.detail[3]||"spide"], {can: can, msg: msg, cmds: req.detail.slice(4), arg: req.detail.slice(4), cb: function() {
delete(msg._event), delete(msg._can), cb(msg)
}})
})
},
_motion: function(can) {
can.onmotion.float.auto(can, document.body)
_motion: function(can) { can.onmotion.float.auto(can, document.body)
document.body.ondblclick = function(event) { can.onengine.signal(can, "onselection") }
can.run({}, [ctx.ACTION, ctx.COMMAND], function(msg) {