Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
n8n_ai_assistant
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vũ Hoàng Anh
n8n_ai_assistant
Commits
7f03fb1b
Commit
7f03fb1b
authored
Apr 10, 2024
by
Domi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: popup minimize
parent
1ee1ea77
Changes
80
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
80 changed files
with
712 additions
and
413 deletions
+712
-413
dev.html
dev.html
+2
-4
config.json
src/assets/config.json
+3
-2
index.ts
src/bg/index.ts
+39
-68
offscreen.ts
src/bg/offscreen.ts
+0
-39
Multitasking.vue
src/components/Multitasking.vue
+193
-100
Webview.vue
src/components/Webview.vue
+4
-13
ChatDocsAddon.vue
src/components/chatdocs/ChatDocsAddon.vue
+1
-1
ChatDocsPanel.vue
src/components/chatdocs/ChatDocsPanel.vue
+4
-1
IconEdit.vue
src/components/icons/IconEdit.vue
+13
-0
IconKeyboard.vue
src/components/icons/IconKeyboard.vue
+13
-0
PipWindowActions.vue
src/components/popup/PipWindowActions.vue
+38
-21
Copilot.vue
src/content/Copilot.vue
+6
-1
index.ts
src/content/index.ts
+37
-17
am.json
src/locales/am.json
+3
-1
ar.json
src/locales/ar.json
+3
-1
bg.json
src/locales/bg.json
+3
-1
bn.json
src/locales/bn.json
+3
-1
ca.json
src/locales/ca.json
+3
-1
cs.json
src/locales/cs.json
+3
-1
da.json
src/locales/da.json
+3
-1
de.json
src/locales/de.json
+3
-1
el.json
src/locales/el.json
+3
-1
en.json
src/locales/en.json
+3
-1
es-419.json
src/locales/es-419.json
+3
-1
es.json
src/locales/es.json
+3
-1
et.json
src/locales/et.json
+3
-1
fa.json
src/locales/fa.json
+3
-1
fi.json
src/locales/fi.json
+3
-1
fil.json
src/locales/fil.json
+3
-1
fr.json
src/locales/fr.json
+3
-1
gu.json
src/locales/gu.json
+3
-1
he.json
src/locales/he.json
+3
-1
hi.json
src/locales/hi.json
+3
-1
hr.json
src/locales/hr.json
+3
-1
hu.json
src/locales/hu.json
+3
-1
id.json
src/locales/id.json
+3
-1
it.json
src/locales/it.json
+3
-1
ja.json
src/locales/ja.json
+3
-1
kn.json
src/locales/kn.json
+3
-1
ko.json
src/locales/ko.json
+3
-1
lt.json
src/locales/lt.json
+3
-1
lv.json
src/locales/lv.json
+3
-1
ml.json
src/locales/ml.json
+3
-1
mr.json
src/locales/mr.json
+3
-1
ms.json
src/locales/ms.json
+3
-1
nl.json
src/locales/nl.json
+3
-1
no.json
src/locales/no.json
+3
-1
pl.json
src/locales/pl.json
+3
-1
pt-BR.json
src/locales/pt-BR.json
+3
-1
pt-PT.json
src/locales/pt-PT.json
+3
-1
ro.json
src/locales/ro.json
+3
-1
ru.json
src/locales/ru.json
+3
-1
sk.json
src/locales/sk.json
+3
-1
sl.json
src/locales/sl.json
+3
-1
sr.json
src/locales/sr.json
+3
-1
sv.json
src/locales/sv.json
+3
-1
sw.json
src/locales/sw.json
+3
-1
ta.json
src/locales/ta.json
+3
-1
te.json
src/locales/te.json
+3
-1
th.json
src/locales/th.json
+3
-1
tr.json
src/locales/tr.json
+3
-1
uk.json
src/locales/uk.json
+3
-1
vi.json
src/locales/vi.json
+3
-1
zh-CN.json
src/locales/zh-CN.json
+3
-1
zh-TW.json
src/locales/zh-TW.json
+3
-1
manifest.ts
src/manifest.ts
+1
-1
Dev.vue
src/pages/Dev.vue
+4
-2
Popup.vue
src/pages/Popup.vue
+35
-22
Sidebar.vue
src/pages/Sidebar.vue
+16
-13
dev.ts
src/pages/dev.ts
+1
-0
offscreen.ts
src/pages/offscreen.ts
+16
-23
popup.ts
src/pages/popup.ts
+10
-0
popup.ts
src/store/popup.ts
+2
-0
index.ts
src/types/index.ts
+11
-6
const.ts
src/utils/const.ts
+0
-1
ext.ts
src/utils/ext.ts
+19
-0
i18n.ts
src/utils/i18n.ts
+3
-3
ContentInvoke.ts
src/utils/invoke/ContentInvoke.ts
+42
-10
Invoke.ts
src/utils/invoke/Invoke.ts
+43
-6
WebviewInvoke.ts
src/utils/invoke/WebviewInvoke.ts
+0
-7
No files found.
dev.html
View file @
7f03fb1b
...
...
@@ -7,10 +7,8 @@
<title>
Anything Copilot DEV
</title>
</head>
<body>
<div
id=
"app"
></div>
<div>
<div
class=
"h-screen"
></div>
<div
class=
"h-screen"
></div>
<div
id=
"app"
>
<iframe
class=
"w-screen h-screen"
src=
"https://bing.com"
></iframe>
</div>
<script
type=
"module"
src=
"./src/pages/dev.ts"
></script>
</body>
...
...
src/assets/config.json
View file @
7f03fb1b
{
"data"
:
{
"configVersion"
:
20240
330
,
"configVersion"
:
20240
406
,
"chatDocSites"
:
[
{
"host"
:
"huggingface.co"
,
...
...
@@ -140,7 +140,8 @@
"defaultUA"
:
""
,
"hostUA"
:
{
"www.google.com"
:
1
,
"bing.com"
:
1
"bing.com"
:
1
,
"copilot.microsoft.com"
:
0
}
}
}
...
...
src/bg/index.ts
View file @
7f03fb1b
...
...
@@ -4,8 +4,8 @@ import {
type
ParseDocOptions
,
ContentScriptId
,
}
from
"@/types"
import
{
waitMessage
,
tabUpdated
,
getLocal
}
from
"@/utils/ext"
import
{
offscreen
}
from
"./offscreen"
import
{
waitMessage
,
tabUpdated
,
getLocal
,
getPipWindow
}
from
"@/utils/ext"
import
{
setupOffscreenDocument
,
offscreenHtmlPath
}
from
"./offscreen"
import
{
registerContentSidebar
,
unregisterContentSidebar
,
...
...
@@ -14,6 +14,7 @@ import {
import
config
from
"@/assets/config.json"
import
{
allFrameScript
,
contentMainScript
}
from
"@/manifest"
import
{
getIsEdge
}
from
"@/utils/ext"
import
{
contentInvoke
}
from
"@/utils/invoke"
type
Config
=
typeof
config
...
...
@@ -69,33 +70,6 @@ async function pipLaunch(url: string) {
})
}
type
QueryOptions
=
{
windowId
?:
number
width
?:
number
height
?:
number
}
async
function
getPipWindow
(
id
:
number
,
{
windowId
,
width
,
height
}:
QueryOptions
)
{
if
(
windowId
)
{
const
win
=
await
chrome
.
windows
.
get
(
windowId
)
chrome
.
tabs
.
sendMessage
(
id
,
{
type
:
MessageType
.
pipWinInfo
,
window
:
win
,
})
return
win
}
const
windows
=
await
chrome
.
windows
.
getAll
({})
const
win
=
windows
.
find
((
w
)
=>
w
.
width
===
width
&&
w
.
height
===
height
)
chrome
.
tabs
.
sendMessage
(
id
,
{
type
:
MessageType
.
pipWinInfo
,
window
:
win
,
})
return
win
}
type
UpdatePipWinOption
=
{
windowId
:
number
windowInfo
:
Partial
<
chrome
.
windows
.
UpdateInfo
>
...
...
@@ -105,42 +79,38 @@ async function updateWindow({ windowId, windowInfo }: UpdatePipWinOption) {
await
chrome
.
windows
.
update
(
windowId
,
windowInfo
)
}
let
currentSender
:
chrome
.
runtime
.
MessageSender
|
null
=
null
contentInvoke
.
register
(
ServiceFunc
.
setupOffscreen
,
()
=>
setupOffscreenDocument
(
offscreenHtmlPath
)
)
.
register
(
ServiceFunc
.
getAllCommands
,
()
=>
chrome
.
commands
.
getAll
())
.
register
(
ServiceFunc
.
createTab
,
(
p
:
chrome
.
tabs
.
CreateProperties
)
=>
chrome
.
tabs
.
create
(
p
)
)
.
register
(
ServiceFunc
.
getPipWindow
,
getPipWindow
)
.
register
(
ServiceFunc
.
getMyTab
,
()
=>
chrome
.
tabs
.
get
(
currentSender
!
.
tab
!
.
id
!
)
)
async
function
handleInvokeRequest
(
message
:
any
,
sender
:
chrome
.
runtime
.
MessageSender
)
{
const
{
key
,
func
,
args
}
=
message
let
result
=
null
let
error
=
null
try
{
switch
(
func
)
{
case
ServiceFunc
.
parseDoc
:
case
ServiceFunc
.
calcTokens
:
case
ServiceFunc
.
tokenSlice
:
result
=
await
offscreen
.
invoke
({
func
,
args
,
})
break
}
}
catch
(
err
)
{
console
.
error
(
"invoke error: "
,
err
)
error
=
err
}
console
.
log
(
"invoke response: "
,
result
,
error
)
currentSender
=
sender
let
result
=
await
contentInvoke
.
handleReqMsg
(
message
)
if
(
!
sender
.
tab
?.
id
)
{
console
.
error
(
"sender tab id is undefined"
,
sender
)
}
if
(
result
)
{
chrome
.
tabs
.
sendMessage
(
sender
.
tab
?.
id
!
,
{
type
:
MessageType
.
invokeResponse
,
key
,
success
:
!
error
,
payload
:
!
error
?
result
:
error
,
...
result
,
})
}
}
function
handleMessage
(
message
:
any
,
sender
:
chrome
.
runtime
.
MessageSender
)
{
...
...
@@ -152,19 +122,15 @@ function handleMessage(message: any, sender: chrome.runtime.MessageSender) {
case
MessageType
.
bgPipLaunch
:
pipLaunch
(
message
.
url
)
break
case
MessageType
.
getPipWinInfo
:
getPipWindow
(
sender
.
tab
?.
id
!
,
message
.
options
)
break
case
MessageType
.
updateWindow
:
updateWindow
(
message
.
options
)
break
case
MessageType
.
removeWindow
:
chrome
.
windows
.
remove
(
message
.
options
.
windowId
)
break
case
MessageType
.
setupOffscreenDocument
:
return
offscreen
.
setup
()
case
MessageType
.
fromOffscreen
:
return
offscreen
.
handleResMsg
(
message
)
case
MessageType
.
forwardToTab
:
chrome
.
tabs
.
sendMessage
(
message
.
tabId
,
message
.
message
)
break
case
MessageType
.
invokeRequest
:
handleInvokeRequest
(
message
,
sender
)
break
...
...
@@ -181,12 +147,17 @@ function handleMessage(message: any, sender: chrome.runtime.MessageSender) {
}
async
function
handleToggleMinimize
()
{
const
{
pipWindow
Id
}
=
await
chrome
.
storage
.
local
.
get
({
pipWindowId
:
null
})
if
(
!
pipWindow
Id
)
return
const
windowInfo
=
await
chrome
.
windows
.
get
(
pipWindowId
)
const
{
pipWindow
}
=
await
chrome
.
storage
.
local
.
get
({
pipWindow
:
null
})
if
(
!
pipWindow
)
return
const
windowInfo
=
await
chrome
.
windows
.
get
(
pipWindow
.
window
Id
)
if
(
!
windowInfo
)
return
await
chrome
.
windows
.
update
(
pipWindowId
,
{
state
:
windowInfo
.
state
==
"minimized"
?
"normal"
:
"minimized"
,
const
tabId
=
pipWindow
.
tabId
contentInvoke
.
invoke
({
tabId
,
func
:
ServiceFunc
.
toggleMinimize
,
args
:
[],
})
}
...
...
src/bg/offscreen.ts
View file @
7f03fb1b
import
{
MessageType
,
ServiceFunc
,
type
ParseDocOptions
}
from
"@/types"
import
{
Invoke
}
from
"@/utils/invoke"
let
creating
:
Promise
<
void
>
|
null
// A global promise to avoid concurrency issues
export
async
function
setupOffscreenDocument
(
path
:
string
)
{
...
...
@@ -37,39 +34,3 @@ export async function setupOffscreenDocument(path: string) {
}
export
const
offscreenHtmlPath
=
"/offscreen.html"
class
Offscreen
extends
Invoke
{
public
readonly
path
:
string
constructor
(
path
:
string
)
{
super
(
"offscreen"
)
this
.
path
=
path
}
public
async
send
(
req
:
any
):
Promise
<
{
key
:
string
;
response
:
any
}
>
{
const
key
=
this
.
key
await
this
.
setup
()
console
.
log
(
"offscreen send: "
,
key
,
req
)
const
response
=
await
chrome
.
runtime
.
sendMessage
({
type
:
MessageType
.
toOffscreen
,
key
,
...
req
,
})
return
{
key
,
response
}
}
public
handleResMsg
(
message
:
any
):
void
{
const
{
type
,
key
,
payload
,
success
}
=
message
if
(
type
===
MessageType
.
fromOffscreen
)
{
this
.
setReturnValue
(
key
,
success
,
payload
)
}
}
public
setup
()
{
return
setupOffscreenDocument
(
this
.
path
)
}
}
export
const
offscreen
=
new
Offscreen
(
offscreenHtmlPath
)
src/components/Multitasking.vue
View file @
7f03fb1b
This diff is collapsed.
Click to expand it.
src/components/Webview.vue
View file @
7f03fb1b
...
...
@@ -145,12 +145,6 @@ async function loadFrame(url: string, ua?: string) {
// iframe.srcdoc = html
}
}
iframe
.
contentWindow
?.
postMessage
(
{
type
:
FrameMessageType
.
webviewRun
,
},
"*"
)
}
function
handleFrameMessage
(
e
:
MessageEvent
)
{
...
...
@@ -162,13 +156,10 @@ function handleFrameMessage(e: MessageEvent) {
switch
(
type
)
{
case
FrameMessageType
.
pageInfo
:
if
(
!
pageInfo
.
url
)
{
pageInfo
.
url
=
e
.
data
.
url
pageInfo
.
title
=
e
.
data
.
title
pageInfo
.
icon
=
e
.
data
.
icon
emit
(
"load"
,
pageInfo
)
}
break
case
FrameMessageType
.
invokeResponse
:
webviewInvoke
.
value
?.
handleResMsg
(
e
.
data
)
...
...
src/components/chatdocs/ChatDocsAddon.vue
View file @
7f03fb1b
...
...
@@ -171,7 +171,7 @@ onUnmounted(() => {
</div>
<p
class=
"text-center text-sm mt-2"
>
{{
t
(
"chatDocs.supportFormat"
)
}}
</p>
<div
:class=
"['absolute text-xs flex items-center bottom-2 right-2']"
>
<img
:src=
"logoUrl"
class=
"
w-3 h
-3"
/>
<img
:src=
"logoUrl"
class=
"
size
-3"
/>
</div>
</div>
</div>
...
...
src/components/chatdocs/ChatDocsPanel.vue
View file @
7f03fb1b
...
...
@@ -126,6 +126,7 @@ watch(
if
(
maxInputType
!==
"token"
)
return
if
(
!
message
)
return
await
contentInvoke
.
setupOffscreen
()
const
tokenLength
=
await
contentInvoke
.
calcTokens
(
message
)
const
rate
=
(
message
.
length
/
tokenLength
)
*
0.95
const
exceedMaxInput
=
tokenLength
>
maxInput
...
...
@@ -172,6 +173,7 @@ watch(
if
(
item
.
kind
==
"file"
&&
typeof
item
.
data
!=
"string"
)
{
const
url
=
await
convertBlobToBase64
(
item
.
data
)
await
contentInvoke
.
setupOffscreen
()
const
results
=
await
contentInvoke
.
parseDoc
({
key
:
item
.
key
,
type
:
item
.
type
,
...
...
@@ -640,4 +642,5 @@ input:hover {
transform
:
translate
(
100%
,
0
);
}
}
</
style
>
@/utils/const@/utils/invoke/service@/utils/invokeb
\ No newline at end of file
</
style
>
@/utils/const@/utils/invoke/service@/utils/invokeb
src/components/icons/IconEdit.vue
0 → 100644
View file @
7f03fb1b
<
template
>
<svg
xmlns=
"http://www.w3.org/2000/svg"
height=
"24"
viewBox=
"0 -960 960 960"
width=
"24"
fill=
"currentColor"
>
<path
d=
"M120-120v-170l528-527q12-11 26.5-17t30.5-6q16 0 31 6t26 18l55 56q12 11 17.5 26t5.5 30q0 16-5.5 30.5T817-647L290-120H120Zm584-528 56-56-56-56-56 56 56 56Z"
/>
</svg>
</
template
>
src/components/icons/IconKeyboard.vue
0 → 100644
View file @
7f03fb1b
<
template
>
<svg
xmlns=
"http://www.w3.org/2000/svg"
height=
"24"
viewBox=
"0 -960 960 960"
width=
"24"
fill=
"currentColor"
>
<path
d=
"M160-200q-33 0-56.5-23.5T80-280v-400q0-33 23.5-56.5T160-760h640q33 0 56.5 23.5T880-680v400q0 33-23.5 56.5T800-200H160Zm160-120h320v-80H320v80ZM200-440h80v-80h-80v80Zm120 0h80v-80h-80v80Zm120 0h80v-80h-80v80Zm120 0h80v-80h-80v80Zm120 0h80v-80h-80v80ZM200-560h80v-80h-80v80Zm120 0h80v-80h-80v80Zm120 0h80v-80h-80v80Zm120 0h80v-80h-80v80Zm120 0h80v-80h-80v80Z"
/>
</svg>
</
template
>
src/components/popup/PipWindowActions.vue
View file @
7f03fb1b
<
script
setup
lang=
"ts"
>
import
{
ref
,
onMounted
,
onUnmounted
,
watch
}
from
"vue"
import
{
pipWindow
}
from
"@/store/
content
"
import
{
pipWindow
}
from
"@/store/
popup
"
import
IconHide
from
"@/components/icons/IconHide.vue"
import
IconArrowCircleRight
from
"@/components/icons/IconArrowCircleRight.vue"
import
IconClose
from
"@/components/icons/IconClose.vue"
import
{
MessageType
}
from
"@/types"
import
{
MessageType
,
ServiceFunc
}
from
"@/types"
import
{
computed
}
from
"vue"
import
{
contentInvoke
}
from
"@/utils/invoke"
import
{
handleImgError
}
from
"@/utils/dom"
async
function
handleUpdatePip
(
state
:
"normal"
|
"minimized"
)
{
await
chrome
.
runtime
.
sendMessage
({
type
:
MessageType
.
updateWindow
,
options
:
{
windowId
:
pipWindow
.
id
,
windowInfo
:
{
state
,
},
},
const
globeImg
=
chrome
.
runtime
.
getURL
(
"img/globe.svg"
)
const
isMinimized
=
computed
(()
=>
{
if
(
pipWindow
.
windowsWindow
)
{
const
{
width
,
height
}
=
pipWindow
.
windowsWindow
return
width
!
<
300
&&
height
!
<
100
}
return
false
})
async
function
toggleMinimize
()
{
await
contentInvoke
.
invoke
({
tabId
:
pipWindow
.
tabId
,
func
:
ServiceFunc
.
toggleMinimize
,
args
:
[],
})
if
(
pipWindow
.
id
)
{
const
win
=
await
chrome
.
windows
.
get
(
pipWindow
.
id
)
pipWindow
.
windowsWindow
=
win
}
}
async
function
closePip
()
{
pipWindow
.
windowsWindow
=
null
await
chrome
.
runtime
.
sendMessage
({
type
:
MessageType
.
updateWindow
,
options
:
{
...
...
@@ -40,24 +56,25 @@ async function closePip() {
<
template
>
<div
class=
"justify-between border-2 border-solid border-background-mute"
>
<div
<img
:src=
"pipWindow.icon"
:data-fallback=
"globeImg"
class=
"size-7 rounded mr-auto"
:style=
"
{
background: `#8881 center / contain url('${pipWindow.tab?.favIconUrl}')`,
}"
>
</div>
loading=
"lazy"
@
error=
"handleImgError"
/>
<button
v-if=
"
pipWindow.windowsWindow?.state === 'normal'
"
v-if=
"
!isMinimized
"
class=
"bg-background-soft hover:bg-background-mute rounded-full size-8 p-1 flex items-center justify-center"
@
click=
"
handleUpdatePip('minimized')
"
@
click=
"
toggleMinimize
"
>
<IconHide
class=
"size-5"
/>
</button>
<button
v-
if=
"pipWindow.windowsWindow?.state === 'minimized'"
v-
else
class=
"bg-background-soft hover:bg-background-mute rounded-full size-8 p-1 flex items-center justify-center"
@
click=
"
handleUpdatePip('normal')
"
@
click=
"
toggleMinimize
"
>
<IconArrowCircleRight
class=
"size-5"
/>
</button>
...
...
src/content/Copilot.vue
View file @
7f03fb1b
...
...
@@ -4,6 +4,11 @@ import PipSplash from "@/components/PipSplash.vue"
import
{
pipLoading
}
from
"@/store/content"
import
LoadingBar
from
"@/components/LoadingBar.vue"
import
ChatDocsAddon
from
"@/components/chatdocs/ChatDocsAddon.vue"
// const isDev =
// process.env.NODE_ENV === "development" &&
// location.host == chrome.runtime.id &&
// location.pathname == "/dev.html"
</
script
>
<
template
>
...
...
src/content/index.ts
View file @
7f03fb1b
...
...
@@ -10,6 +10,7 @@ import {
ContentEventType
,
FrameMessageType
,
MessageType
,
ServiceFunc
,
WebviewFunc
,
WindowName
,
}
from
"@/types"
...
...
@@ -45,12 +46,6 @@ function handleMessage(
})
sendResponse
({
type
:
MessageType
.
contentHere
})
break
case
MessageType
.
pipWinInfo
:
pipWindow
.
windowsWindow
=
message
.
window
chrome
.
storage
.
local
.
set
({
pipWindowId
:
message
.
window
.
id
,
})
break
case
MessageType
.
invokeResponse
:
contentInvoke
.
handleResMsg
(
message
)
break
...
...
@@ -62,6 +57,16 @@ function handleMessage(
sidebarAddon
.
hidden
=
false
sidebarAddon
.
url
=
message
.
url
break
case
MessageType
.
invokeRequest
:
contentInvoke
.
handleReqMsg
(
message
).
then
((
result
)
=>
{
if
(
result
)
{
chrome
.
runtime
.
sendMessage
({
type
:
MessageType
.
invokeResponse
,
...
result
,
})
}
})
break
}
}
...
...
@@ -90,18 +95,33 @@ async function handlePipEvent(event: any) {
addContentEventListener
(
ContentEventType
.
pipLoaded
,
handlePipLoaded
)
})
// may be 0 if not wait document is loaded
chrome
.
runtime
.
sendMessage
({
type
:
MessageType
.
getPipWinInfo
,
options
:
{
const
window
=
await
contentInvoke
.
invoke
({
func
:
ServiceFunc
.
getPipWindow
,
args
:
[
{
width
:
win
.
outerWidth
,
height
:
win
.
outerHeight
,
},
],
})
const
tab
=
await
contentInvoke
.
invoke
({
func
:
ServiceFunc
.
getMyTab
,
args
:
[],
})
pipWindow
.
windowsWindow
=
window
chrome
.
storage
.
local
.
set
({
pipWindow
:
{
windowId
:
window
.
id
,
tabId
:
tab
.
id
,
icon
:
getPageIcon
(),
},
})
win
.
addEventListener
(
"pagehide"
,
()
=>
{
chrome
.
storage
.
local
.
set
({
pipWindow
Id
:
0
,
pipWindow
:
null
,
})
})
}
...
...
@@ -146,10 +166,6 @@ function handleFrameMessage(e: MessageEvent) {
if
(
!
e
.
data
||
typeof
e
.
data
!==
"object"
)
return
const
type
=
e
.
data
.
type
switch
(
type
)
{
case
FrameMessageType
.
webviewRun
:
run
()
postPageInfo
()
return
case
FrameMessageType
.
escapeLoad
:
return
dispatchContentEvent
({
type
:
ContentEventType
.
escapeLoad
,
...
...
@@ -207,9 +223,13 @@ if (window.top !== window && window.name.startsWith(WindowName.webview)) {
},
chrome
.
runtime
.
getURL
(
""
)
)
run
()
postPageInfo
()
}
// dev
if
(
location
.
host
==
chrome
.
runtime
.
id
&&
location
.
hash
==
"#copilot"
)
{
pipWindow
.
window
=
window
mount
(
Copilot
,
window
.
document
)
}
src/locales/am.json
View file @
7f03fb1b
...
...
@@ -44,5 +44,7 @@
"notSupported"
:
"ይህ ገጽ ራስ-ሰር መላክን አይደግፍም. እባክዎ መልዕክቱን ይቅዱ እና እራስዎ ይላኩ."
},
"openSidebar"
:
"የጎን አሞሌውን ይክፈቱ"
,
"searchPlaceholder"
:
"ዩአርኤል ይፈልጉ ወይም ይተይቡ"
"searchPlaceholder"
:
"ዩአርኤል ይፈልጉ ወይም ይተይቡ"
,
"setShortcutKeys"
:
"አቋራጭ ቁልፎችን አዘጋጅ"
,
"mobileView"
:
"የሞባይል እይታ"
}
\ No newline at end of file
src/locales/ar.json
View file @
7f03fb1b
...
...
@@ -44,5 +44,7 @@
"notSupported"
:
"هذه الصفحة لا تدعم الإرسال التلقائي. يرجى نسخ الرسالة وإرسالها يدويًا."
},
"openSidebar"
:
"افتح الشريط الجانبي"
,
"searchPlaceholder"
:
"ابحث عن عنوان URL أو اكتبه"
"searchPlaceholder"
:
"ابحث عن عنوان URL أو اكتبه"
,
"setShortcutKeys"
:
"تعيين مفاتيح الاختصار"
,
"mobileView"
:
"واجهه جوال"
}
\ No newline at end of file
src/locales/bg.json
View file @
7f03fb1b
...
...
@@ -44,5 +44,7 @@
"notSupported"
:
"Тази страница не поддържа автоматично изпращане. Моля, копирайте съобщението и го изпратете ръчно."
},
"openSidebar"
:
"Отворете страничната лента"
,
"searchPlaceholder"
:
"Потърсете или въведете URL"
"searchPlaceholder"
:
"Потърсете или въведете URL"
,
"setShortcutKeys"
:
"Задаване на клавишни комбинации"
,
"mobileView"
:
"Мобилен изглед"
}
\ No newline at end of file
src/locales/bn.json
View file @
7f03fb1b
...
...
@@ -44,5 +44,7 @@
"notSupported"
:
"এই পৃষ্ঠাটি স্বয়ংক্রিয় প্রেরণকে সমর্থন করে না। দয়া করে বার্তাটি অনুলিপি করুন এবং এটি ম্যানুয়ালি প্রেরণ করুন।"
},
"openSidebar"
:
"সাইডবারটি খুলুন"
,
"searchPlaceholder"
:
"একটি URL অনুসন্ধান করুন বা টাইপ করুন"
"searchPlaceholder"
:
"একটি URL অনুসন্ধান করুন বা টাইপ করুন"
,
"setShortcutKeys"
:
"শর্টকাট কী সেট করুন"
,
"mobileView"
:
"মোবাইল দৃশ্য"
}
\ No newline at end of file
src/locales/ca.json
View file @
7f03fb1b
...
...
@@ -44,5 +44,7 @@
"notSupported"
:
"Aquesta pàgina no admet l'enviament automàtic. Copieu el missatge i envieu -lo manualment."
},
"openSidebar"
:
"Obriu la barra lateral"
,
"searchPlaceholder"
:
"Cerqueu o escriviu un URL"
"searchPlaceholder"
:
"Cerqueu o escriviu un URL"
,
"setShortcutKeys"
:
"Estableix tecles de drecera"
,
"mobileView"
:
"Vista mòbil"
}
\ No newline at end of file
src/locales/cs.json
View file @
7f03fb1b
...
...
@@ -44,5 +44,7 @@
"notSupported"
:
"Tato stránka nepodporuje automatické odesílání. Zkopírujte zprávu a odešlete ji ručně."
},
"openSidebar"
:
"Otevřete postranní panel"
,
"searchPlaceholder"
:
"Vyhledejte nebo zadejte adresu URL"
"searchPlaceholder"
:
"Vyhledejte nebo zadejte adresu URL"
,
"setShortcutKeys"
:
"Nastavit klávesové zkratky"
,
"mobileView"
:
"Mobilní pohled"
}
\ No newline at end of file
src/locales/da.json
View file @
7f03fb1b
...
...
@@ -44,5 +44,7 @@
"notSupported"
:
"Denne side understøtter ikke automatisk afsendelse. Kopier meddelelsen og send den manuelt."
},
"openSidebar"
:
"Åbn sidebjælken"
,
"searchPlaceholder"
:
"Søg eller skriv en URL"
"searchPlaceholder"
:
"Søg eller skriv en URL"
,
"setShortcutKeys"
:
"Indstil genvejstaster"
,
"mobileView"
:
"Mobil visning"
}
\ No newline at end of file
src/locales/de.json
View file @
7f03fb1b
...
...
@@ -44,5 +44,7 @@
"notSupported"
:
"Diese Seite unterstützt das automatische Senden nicht. Bitte kopieren Sie die Nachricht und senden Sie sie manuell."
},
"openSidebar"
:
"Öffnen Sie die Seitenleiste"
,
"searchPlaceholder"
:
"Suchen oder geben Sie eine URL ein"
"searchPlaceholder"
:
"Suchen oder geben Sie eine URL ein"
,
"setShortcutKeys"
:
"Legen Sie Tastenkombinationen fest"
,
"mobileView"
:
"Mobile Ansicht"
}
\ No newline at end of file
src/locales/el.json
View file @
7f03fb1b
...
...
@@ -44,5 +44,7 @@
"notSupported"
:
"Αυτή η σελίδα δεν υποστηρίζει αυτόματη αποστολή. Αντιγράψτε το μήνυμα και στείλτε το χειροκίνητα."
},
"openSidebar"
:
"Ανοίξτε την πλαϊνή μπάρα"
,
"searchPlaceholder"
:
"Αναζητήστε ή πληκτρολογήστε μια διεύθυνση URL"
"searchPlaceholder"
:
"Αναζητήστε ή πληκτρολογήστε μια διεύθυνση URL"
,
"setShortcutKeys"
:
"Ορισμός πλήκτρων συντόμευσης"
,
"mobileView"
:
"Προβολή κινητού"
}
\ No newline at end of file
src/locales/en.json
View file @
7f03fb1b
...
...
@@ -44,5 +44,7 @@
"notSupported"
:
"This page does not support automatic sending. Please copy the message and send it manually."
},
"openSidebar"
:
"Open Sidebar"
,
"searchPlaceholder"
:
"Search or type a URL"
"searchPlaceholder"
:
"Search or type a URL"
,
"setShortcutKeys"
:
"Set shortcut keys"
,
"mobileView"
:
"Mobile View"
}
\ No newline at end of file
src/locales/es-419.json
View file @
7f03fb1b
...
...
@@ -44,5 +44,7 @@
"notSupported"
:
"Esta página no admite el envío automático. Copie el mensaje y envíelo manualmente."
},
"openSidebar"
:
"Abrir la barra lateral"
,
"searchPlaceholder"
:
"Buscar o escribir una URL"
"searchPlaceholder"
:
"Buscar o escribir una URL"
,
"setShortcutKeys"
:
"Establecer teclas de acceso directo"
,
"mobileView"
:
"Vista móvil"
}
\ No newline at end of file
src/locales/es.json
View file @
7f03fb1b
...
...
@@ -44,5 +44,7 @@
"notSupported"
:
"Esta página no admite el envío automático. Copie el mensaje y envíelo manualmente."
},
"openSidebar"
:
"Abrir la barra lateral"
,
"searchPlaceholder"
:
"Buscar o escribir una URL"
"searchPlaceholder"
:
"Buscar o escribir una URL"
,
"setShortcutKeys"
:
"Establecer teclas de acceso directo"
,
"mobileView"
:
"Vista móvil"
}
\ No newline at end of file
src/locales/et.json
View file @
7f03fb1b
...
...
@@ -44,5 +44,7 @@
"notSupported"
:
"See leht ei toeta automaatset saatmist. Kopeerige sõnum ja saatke see käsitsi."
},
"openSidebar"
:
"Avage külgriba"
,
"searchPlaceholder"
:
"Otsige või sisestage URL"
"searchPlaceholder"
:
"Otsige või sisestage URL"
,
"setShortcutKeys"
:
"Määrake kiirklahvid"
,
"mobileView"
:
"Mobiilivaade"
}
\ No newline at end of file
src/locales/fa.json
View file @
7f03fb1b
...
...
@@ -44,5 +44,7 @@
"notSupported"
:
"این صفحه از ارسال خودکار پشتیبانی نمی کند. لطفا پیام را کپی کرده و به صورت دستی ارسال کنید."
},
"openSidebar"
:
"نوار کناری را باز کنید"
,
"searchPlaceholder"
:
"یک URL را جستجو یا تایپ کنید"
"searchPlaceholder"
:
"یک URL را جستجو یا تایپ کنید"
,
"setShortcutKeys"
:
"تنظیم کلیدهای میانبر"
,
"mobileView"
:
"نمای موبایل"
}
\ No newline at end of file
src/locales/fi.json
View file @
7f03fb1b
...
...
@@ -44,5 +44,7 @@
"notSupported"
:
"Tämä sivu ei tue automaattista lähettämistä. Kopioi viesti ja lähetä se manuaalisesti."
},
"openSidebar"
:
"Avaa sivupalkki"
,
"searchPlaceholder"
:
"Hae tai kirjoita URL-osoite"
"searchPlaceholder"
:
"Hae tai kirjoita URL-osoite"
,
"setShortcutKeys"
:
"Aseta pikanäppäimet"
,
"mobileView"
:
"Mobiilinäkymä"
}
\ No newline at end of file
src/locales/fil.json
View file @
7f03fb1b
...
...
@@ -44,5 +44,7 @@
"notSupported"
:
"Ang pahinang ito ay hindi sumusuporta sa awtomatikong pagpapadala. Mangyaring kopyahin ang mensahe at manu -manong ipadala ito."
},
"openSidebar"
:
"Buksan ang sidebar"
,
"searchPlaceholder"
:
"Maghanap o mag-type ng URL"
"searchPlaceholder"
:
"Maghanap o mag-type ng URL"
,
"setShortcutKeys"
:
"Itakda ang mga shortcut key"
,
"mobileView"
:
"Mobile view"
}
\ No newline at end of file
src/locales/fr.json
View file @
7f03fb1b
...
...
@@ -44,5 +44,7 @@
"notSupported"
:
"Cette page ne prend pas en charge l'envoi automatique. Veuillez copier le message et l'envoyer manuellement."
},
"openSidebar"
:
"Ouvrir la barre latérale"
,
"searchPlaceholder"
:
"Rechercher ou saisir une URL"
"searchPlaceholder"
:
"Rechercher ou saisir une URL"
,
"setShortcutKeys"
:
"Définir les touches de raccourci"
,
"mobileView"
:
"Vue mobile"
}
\ No newline at end of file
src/locales/gu.json
View file @
7f03fb1b
...
...
@@ -44,5 +44,7 @@
"notSupported"
:
"આ પૃષ્ઠ સ્વચાલિત મોકલવાનું સમર્થન કરતું નથી. કૃપા કરીને સંદેશની નકલ કરો અને તેને જાતે મોકલો."
},
"openSidebar"
:
"સાઇડબાર ખોલો"
,
"searchPlaceholder"
:
"URL શોધો અથવા લખો"
"searchPlaceholder"
:
"URL શોધો અથવા લખો"
,
"setShortcutKeys"
:
"શોર્ટકટ કી સેટ કરો"
,
"mobileView"
:
"મોબાઇલ દૃશ્ય"
}
\ No newline at end of file
src/locales/he.json
View file @
7f03fb1b
...
...
@@ -44,5 +44,7 @@
"notSupported"
:
"דף זה אינו תומך בשליחה אוטומטית. אנא העתק את ההודעה ושלח אותה ידנית."
},
"openSidebar"
:
"פתח את סרגל הצד"
,
"searchPlaceholder"
:
"חפש או הקלד כתובת אתר"
"searchPlaceholder"
:
"חפש או הקלד כתובת אתר"
,
"setShortcutKeys"
:
"הגדר מקשי קיצור"
,
"mobileView"
:
"נוף נייד"
}
\ No newline at end of file
src/locales/hi.json
View file @
7f03fb1b
...
...
@@ -44,5 +44,7 @@
"notSupported"
:
"यह पृष्ठ स्वचालित भेजने का समर्थन नहीं करता है। कृपया संदेश कॉपी करें और इसे मैन्युअल रूप से भेजें।"
},
"openSidebar"
:
"साइडबार खोलें"
,
"searchPlaceholder"
:
"URL खोजें या टाइप करें"
"searchPlaceholder"
:
"URL खोजें या टाइप करें"
,
"setShortcutKeys"
:
"शॉर्टकट कुंजियाँ सेट करें"
,
"mobileView"
:
"मोबाइल दृश्य"
}
\ No newline at end of file
src/locales/hr.json
View file @
7f03fb1b
...
...
@@ -44,5 +44,7 @@
"notSupported"
:
"Ova stranica ne podržava automatsko slanje. Kopirajte poruku i pošaljite je ručno."
},
"openSidebar"
:
"Otvorite bočnu traku"
,
"searchPlaceholder"
:
"Pretražite ili upišite URL"
"searchPlaceholder"
:
"Pretražite ili upišite URL"
,
"setShortcutKeys"
:
"Postavite tipke prečaca"
,
"mobileView"
:
"Mobilni prikaz"
}
\ No newline at end of file
src/locales/hu.json
View file @
7f03fb1b
...
...
@@ -44,5 +44,7 @@
"notSupported"
:
"Ez az oldal nem támogatja az automatikus küldéseket. Kérjük, másolja az üzenetet, és küldje el manuálisan."
},
"openSidebar"
:
"Nyissa ki az oldalsávot"
,
"searchPlaceholder"
:
"Keressen vagy írjon be egy URL-t"
"searchPlaceholder"
:
"Keressen vagy írjon be egy URL-t"
,
"setShortcutKeys"
:
"Gyorsbillentyűk beállítása"
,
"mobileView"
:
"Mobil nézet"
}
\ No newline at end of file
src/locales/id.json
View file @
7f03fb1b
...
...
@@ -44,5 +44,7 @@
"notSupported"
:
"Halaman ini tidak mendukung pengiriman otomatis. Harap salin pesan dan kirimkan secara manual."
},
"openSidebar"
:
"Buka bilah samping"
,
"searchPlaceholder"
:
"Cari atau ketik URL"
"searchPlaceholder"
:
"Cari atau ketik URL"
,
"setShortcutKeys"
:
"Setel tombol pintas"
,
"mobileView"
:
"Tampilan seluler"
}
\ No newline at end of file
src/locales/it.json
View file @
7f03fb1b
...
...
@@ -44,5 +44,7 @@
"notSupported"
:
"Questa pagina non supporta l'invio automatico. Si prega di copiare il messaggio e inviarlo manualmente."
},
"openSidebar"
:
"Apri la barra laterale"
,
"searchPlaceholder"
:
"Cerca o digita un URL"
"searchPlaceholder"
:
"Cerca o digita un URL"
,
"setShortcutKeys"
:
"Imposta i tasti di scelta rapida"
,
"mobileView"
:
"Visualizzazione mobile"
}
\ No newline at end of file
src/locales/ja.json
View file @
7f03fb1b
...
...
@@ -44,5 +44,7 @@
"notSupported"
:
"このページは、自動送信をサポートしていません。メッセージをコピーして手動で送信してください。"
},
"openSidebar"
:
"サイドバーを開きます"
,
"searchPlaceholder"
:
"URLを検索または入力します"
"searchPlaceholder"
:
"URLを検索または入力します"
,
"setShortcutKeys"
:
"ショートカットキーを設定する"
,
"mobileView"
:
"モバイルビュー"
}
\ No newline at end of file
src/locales/kn.json
View file @
7f03fb1b
...
...
@@ -44,5 +44,7 @@
"notSupported"
:
"ಈ ಪುಟವು ಸ್ವಯಂಚಾಲಿತ ಕಳುಹಿಸುವಿಕೆಯನ್ನು ಬೆಂಬಲಿಸುವುದಿಲ್ಲ. ದಯವಿಟ್ಟು ಸಂದೇಶವನ್ನು ನಕಲಿಸಿ ಮತ್ತು ಅದನ್ನು ಕೈಯಾರೆ ಕಳುಹಿಸಿ."
},
"openSidebar"
:
"ಸೈಡ್ಬಾರ್ ತೆರೆಯಿರಿ"
,
"searchPlaceholder"
:
"URL ಅನ್ನು ಹುಡುಕಿ ಅಥವಾ ಟೈಪ್ ಮಾಡಿ"
"searchPlaceholder"
:
"URL ಅನ್ನು ಹುಡುಕಿ ಅಥವಾ ಟೈಪ್ ಮಾಡಿ"
,
"setShortcutKeys"
:
"ಶಾರ್ಟ್ಕಟ್ ಕೀಗಳನ್ನು ಹೊಂದಿಸಿ"
,
"mobileView"
:
"ಮೊಬೈಲ್ ವೀಕ್ಷಣೆ"
}
\ No newline at end of file
src/locales/ko.json
View file @
7f03fb1b
...
...
@@ -44,5 +44,7 @@
"notSupported"
:
"이 페이지는 자동 전송을 지원하지 않습니다. 메시지를 복사하여 수동으로 보내주십시오."
},
"openSidebar"
:
"사이드 바를 엽니 다"
,
"searchPlaceholder"
:
"URL을 검색하거나 입력하세요."
"searchPlaceholder"
:
"URL을 검색하거나 입력하세요."
,
"setShortcutKeys"
:
"단축키 설정"
,
"mobileView"
:
"모바일 보기"
}
\ No newline at end of file
src/locales/lt.json
View file @
7f03fb1b
...
...
@@ -44,5 +44,7 @@
"notSupported"
:
"Šis puslapis nepalaiko automatinio siuntimo. Nukopijuokite pranešimą ir atsiųskite jį rankiniu būdu."
},
"openSidebar"
:
"Atidarykite šoninę juostą"
,
"searchPlaceholder"
:
"Ieškokite arba įveskite URL"
"searchPlaceholder"
:
"Ieškokite arba įveskite URL"
,
"setShortcutKeys"
:
"Nustatykite sparčiuosius klavišus"
,
"mobileView"
:
"Mobilusis vaizdas"
}
\ No newline at end of file
src/locales/lv.json
View file @
7f03fb1b
...
...
@@ -44,5 +44,7 @@
"notSupported"
:
"Šī lapa neatbalsta automātisku sūtīšanu. Lūdzu, nokopējiet ziņojumu un nosūtiet to manuāli."
},
"openSidebar"
:
"Atveriet sānjoslu"
,
"searchPlaceholder"
:
"Meklējiet vai ierakstiet URL"
"searchPlaceholder"
:
"Meklējiet vai ierakstiet URL"
,
"setShortcutKeys"
:
"Iestatiet īsinājumtaustiņus"
,
"mobileView"
:
"Mobilais skats"
}
\ No newline at end of file
src/locales/ml.json
View file @
7f03fb1b
...
...
@@ -44,5 +44,7 @@
"notSupported"
:
"ഈ പേജ് യാന്ത്രിക അയയ്ക്കുന്നതിനെ പിന്തുണയ്ക്കുന്നില്ല. സന്ദേശം പകർത്തി സ്വമേധയാ അയയ്ക്കുക."
},
"openSidebar"
:
"സൈഡ്ബാർ തുറക്കുക"
,
"searchPlaceholder"
:
"ഒരു URL തിരയുക അല്ലെങ്കിൽ ടൈപ്പ് ചെയ്യുക"
"searchPlaceholder"
:
"ഒരു URL തിരയുക അല്ലെങ്കിൽ ടൈപ്പ് ചെയ്യുക"
,
"setShortcutKeys"
:
"കുറുക്കുവഴി കീകൾ സജ്ജമാക്കുക"
,
"mobileView"
:
"മൊബൈൽ കാഴ്ച"
}
\ No newline at end of file
src/locales/mr.json
View file @
7f03fb1b
...
...
@@ -44,5 +44,7 @@
"notSupported"
:
"हे पृष्ठ स्वयंचलित पाठविण्यास समर्थन देत नाही. कृपया संदेश कॉपी करा आणि तो व्यक्तिचलितपणे पाठवा."
},
"openSidebar"
:
"साइडबार उघडा"
,
"searchPlaceholder"
:
"URL शोधा किंवा टाइप करा"
"searchPlaceholder"
:
"URL शोधा किंवा टाइप करा"
,
"setShortcutKeys"
:
"शॉर्टकट की सेट करा"
,
"mobileView"
:
"मोबाइल दृश्य"
}
\ No newline at end of file
src/locales/ms.json
View file @
7f03fb1b
...
...
@@ -44,5 +44,7 @@
"notSupported"
:
"Halaman ini tidak menyokong penghantaran automatik. Sila salin mesej dan hantarkan secara manual."
},
"openSidebar"
:
"Buka bar sisi"
,
"searchPlaceholder"
:
"Cari atau taip URL"
"searchPlaceholder"
:
"Cari atau taip URL"
,
"setShortcutKeys"
:
"Tetapkan kekunci pintasan"
,
"mobileView"
:
"Paparan mudah alih"
}
\ No newline at end of file
src/locales/nl.json
View file @
7f03fb1b
...
...
@@ -44,5 +44,7 @@
"notSupported"
:
"Deze pagina ondersteunt geen automatisch verzenden. Kopieer het bericht en stuur het handmatig."
},
"openSidebar"
:
"Open de zijbalk"
,
"searchPlaceholder"
:
"Zoek of typ een URL"
"searchPlaceholder"
:
"Zoek of typ een URL"
,
"setShortcutKeys"
:
"Sneltoetsen instellen"
,
"mobileView"
:
"Mobiele weergave"
}
\ No newline at end of file
src/locales/no.json
View file @
7f03fb1b
...
...
@@ -44,5 +44,7 @@
"notSupported"
:
"Denne siden støtter ikke automatisk sending. Kopier meldingen og send den manuelt."
},
"openSidebar"
:
"Åpne sidefeltet"
,
"searchPlaceholder"
:
"Søk eller skriv inn en URL"
"searchPlaceholder"
:
"Søk eller skriv inn en URL"
,
"setShortcutKeys"
:
"Angi snarveistaster"
,
"mobileView"
:
"Mobil visning"
}
\ No newline at end of file
src/locales/pl.json
View file @
7f03fb1b
...
...
@@ -44,5 +44,7 @@
"notSupported"
:
"Ta strona nie obsługuje automatycznego wysyłania. Skopiuj wiadomość i wysyłaj ją ręcznie."
},
"openSidebar"
:
"Otwórz pasek boczny"
,
"searchPlaceholder"
:
"Wyszukaj lub wpisz adres URL"
"searchPlaceholder"
:
"Wyszukaj lub wpisz adres URL"
,
"setShortcutKeys"
:
"Ustaw klawisze skrótu"
,
"mobileView"
:
"Widok mobilny"
}
\ No newline at end of file
src/locales/pt-BR.json
View file @
7f03fb1b
...
...
@@ -44,5 +44,7 @@
"notSupported"
:
"Esta página não suporta o envio automático. Copie a mensagem e envie -a manualmente."
},
"openSidebar"
:
"Abra a barra lateral"
,
"searchPlaceholder"
:
"Pesquise ou digite um URL"
"searchPlaceholder"
:
"Pesquise ou digite um URL"
,
"setShortcutKeys"
:
"Definir teclas de atalho"
,
"mobileView"
:
"Exibição móvel"
}
\ No newline at end of file
src/locales/pt-PT.json
View file @
7f03fb1b
...
...
@@ -44,5 +44,7 @@
"notSupported"
:
"Esta página não suporta o envio automático. Copie a mensagem e envie -a manualmente."
},
"openSidebar"
:
"Abra a barra lateral"
,
"searchPlaceholder"
:
"Pesquise ou digite um URL"
"searchPlaceholder"
:
"Pesquise ou digite um URL"
,
"setShortcutKeys"
:
"Definir teclas de atalho"
,
"mobileView"
:
"Exibição móvel"
}
\ No newline at end of file
src/locales/ro.json
View file @
7f03fb1b
...
...
@@ -44,5 +44,7 @@
"notSupported"
:
"Această pagină nu acceptă trimiterea automată. Vă rugăm să copiați mesajul și să -l trimiteți manual."
},
"openSidebar"
:
"Deschideți bara laterală"
,
"searchPlaceholder"
:
"Căutați sau introduceți o adresă URL"
"searchPlaceholder"
:
"Căutați sau introduceți o adresă URL"
,
"setShortcutKeys"
:
"Setați tastele de comandă rapidă"
,
"mobileView"
:
"Vizualizare mobilă"
}
\ No newline at end of file
src/locales/ru.json
View file @
7f03fb1b
...
...
@@ -44,5 +44,7 @@
"notSupported"
:
"Эта страница не поддерживает автоматическую отправку. Пожалуйста, скопируйте сообщение и отправьте его вручную."
},
"openSidebar"
:
"Откройте боковую панель"
,
"searchPlaceholder"
:
"Найдите или введите URL-адрес"
"searchPlaceholder"
:
"Найдите или введите URL-адрес"
,
"setShortcutKeys"
:
"Установить сочетания клавиш"
,
"mobileView"
:
"Мобильная версия"
}
\ No newline at end of file
src/locales/sk.json
View file @
7f03fb1b
...
...
@@ -44,5 +44,7 @@
"notSupported"
:
"Táto stránka nepodporuje automatické odosielanie. Skopírujte správu a pošlite ju manuálne."
},
"openSidebar"
:
"Otvorte bočný panel"
,
"searchPlaceholder"
:
"Vyhľadajte alebo zadajte adresu URL"
"searchPlaceholder"
:
"Vyhľadajte alebo zadajte adresu URL"
,
"setShortcutKeys"
:
"Nastaviť klávesové skratky"
,
"mobileView"
:
"Mobilný pohľad"
}
\ No newline at end of file
src/locales/sl.json
View file @
7f03fb1b
...
...
@@ -44,5 +44,7 @@
"notSupported"
:
"Ta stran ne podpira samodejnega pošiljanja. Kopirajte sporočilo in ga pošljite ročno."
},
"openSidebar"
:
"Odprite stransko vrstico"
,
"searchPlaceholder"
:
"Iščite ali vnesite URL"
"searchPlaceholder"
:
"Iščite ali vnesite URL"
,
"setShortcutKeys"
:
"Nastavite tipke za bližnjice"
,
"mobileView"
:
"Mobilni pogled"
}
\ No newline at end of file
src/locales/sr.json
View file @
7f03fb1b
...
...
@@ -44,5 +44,7 @@
"notSupported"
:
"Ова страница не подржава аутоматско слање. Копирајте поруку и пошаљите га ручно."
},
"openSidebar"
:
"Отвори бочну траку"
,
"searchPlaceholder"
:
"Претражите или унесите УРЛ"
"searchPlaceholder"
:
"Претражите или унесите УРЛ"
,
"setShortcutKeys"
:
"Подесите пречице"
,
"mobileView"
:
"Мобилни поглед"
}
\ No newline at end of file
src/locales/sv.json
View file @
7f03fb1b
...
...
@@ -44,5 +44,7 @@
"notSupported"
:
"Denna sida stöder inte automatisk sändning. Kopiera meddelandet och skicka det manuellt."
},
"openSidebar"
:
"Öppna sidofältet"
,
"searchPlaceholder"
:
"Sök eller skriv en URL"
"searchPlaceholder"
:
"Sök eller skriv en URL"
,
"setShortcutKeys"
:
"Ställ in kortkommandon"
,
"mobileView"
:
"Mobilvy"
}
\ No newline at end of file
src/locales/sw.json
View file @
7f03fb1b
...
...
@@ -44,5 +44,7 @@
"notSupported"
:
"Ukurasa huu hauungi mkono kutuma moja kwa moja. Tafadhali nakili ujumbe na utumie kwa mikono."
},
"openSidebar"
:
"Fungua pembeni"
,
"searchPlaceholder"
:
"Tafuta au charaza URL"
"searchPlaceholder"
:
"Tafuta au charaza URL"
,
"setShortcutKeys"
:
"Weka funguo za njia za mkato"
,
"mobileView"
:
"Mwonekano wa rununu"
}
\ No newline at end of file
src/locales/ta.json
View file @
7f03fb1b
...
...
@@ -44,5 +44,7 @@
"notSupported"
:
"இந்த பக்கம் தானியங்கி அனுப்புதலை ஆதரிக்காது. தயவுசெய்து செய்தியை நகலெடுத்து கைமுறையாக அனுப்புங்கள்."
},
"openSidebar"
:
"பக்கப்பட்டியைத் திறக்கவும்"
,
"searchPlaceholder"
:
"URL ஐத் தேடவும் அல்லது தட்டச்சு செய்யவும்"
"searchPlaceholder"
:
"URL ஐத் தேடவும் அல்லது தட்டச்சு செய்யவும்"
,
"setShortcutKeys"
:
"குறுக்குவழி விசைகளை அமைக்கவும்"
,
"mobileView"
:
"மொபைல் பார்வை"
}
\ No newline at end of file
src/locales/te.json
View file @
7f03fb1b
...
...
@@ -44,5 +44,7 @@
"notSupported"
:
"ఈ పేజీ ఆటోమేటిక్ పంపడానికి మద్దతు ఇవ్వదు. దయచేసి సందేశాన్ని కాపీ చేసి మానవీయంగా పంపండి."
},
"openSidebar"
:
"సైడ్బార్ తెరవండి"
,
"searchPlaceholder"
:
"URLని శోధించండి లేదా టైప్ చేయండి"
"searchPlaceholder"
:
"URLని శోధించండి లేదా టైప్ చేయండి"
,
"setShortcutKeys"
:
"షార్ట్కట్ కీలను సెట్ చేయండి"
,
"mobileView"
:
"మొబైల్ వీక్షణ"
}
\ No newline at end of file
src/locales/th.json
View file @
7f03fb1b
...
...
@@ -44,5 +44,7 @@
"notSupported"
:
"หน้านี้ไม่รองรับการส่งอัตโนมัติ กรุณาคัดลอกข้อความและส่งด้วยตนเอง"
},
"openSidebar"
:
"เปิดแถบด้านข้าง"
,
"searchPlaceholder"
:
"ค้นหาหรือพิมพ์ URL"
"searchPlaceholder"
:
"ค้นหาหรือพิมพ์ URL"
,
"setShortcutKeys"
:
"ตั้งค่าปุ่มลัด"
,
"mobileView"
:
"มุมมองมือถือ"
}
\ No newline at end of file
src/locales/tr.json
View file @
7f03fb1b
...
...
@@ -44,5 +44,7 @@
"notSupported"
:
"Bu sayfa otomatik göndermeyi desteklemez. Lütfen mesajı kopyalayın ve manuel olarak gönderin."
},
"openSidebar"
:
"Kenar çubuğunu aç"
,
"searchPlaceholder"
:
"Bir URL arayın veya yazın"
"searchPlaceholder"
:
"Bir URL arayın veya yazın"
,
"setShortcutKeys"
:
"Kısayol tuşlarını ayarla"
,
"mobileView"
:
"Mobil görünüm"
}
\ No newline at end of file
src/locales/uk.json
View file @
7f03fb1b
...
...
@@ -44,5 +44,7 @@
"notSupported"
:
"Ця сторінка не підтримує автоматичне надсилання. Будь ласка, скопіюйте повідомлення та надішліть його вручну."
},
"openSidebar"
:
"Відкрийте бічну панель"
,
"searchPlaceholder"
:
"Знайдіть або введіть URL-адресу"
"searchPlaceholder"
:
"Знайдіть або введіть URL-адресу"
,
"setShortcutKeys"
:
"Встановити комбінації клавіш"
,
"mobileView"
:
"Мобільний вид"
}
\ No newline at end of file
src/locales/vi.json
View file @
7f03fb1b
...
...
@@ -44,5 +44,7 @@
"notSupported"
:
"Trang này không hỗ trợ gửi tự động. Vui lòng sao chép tin nhắn và gửi thủ công."
},
"openSidebar"
:
"Mở thanh bên"
,
"searchPlaceholder"
:
"Tìm kiếm hoặc nhập URL"
"searchPlaceholder"
:
"Tìm kiếm hoặc nhập URL"
,
"setShortcutKeys"
:
"Đặt phím tắt"
,
"mobileView"
:
"Chế độ xem trên thiết bị di động"
}
\ No newline at end of file
src/locales/zh-CN.json
View file @
7f03fb1b
...
...
@@ -44,5 +44,7 @@
"notSupported"
:
"此页面不支持自动发送,请复制消息发送"
},
"openSidebar"
:
"打开侧边栏"
,
"searchPlaceholder"
:
"搜索或输入 URL"
"searchPlaceholder"
:
"搜索或输入 URL"
,
"setShortcutKeys"
:
"设置快捷键"
,
"mobileView"
:
"移动端视图"
}
\ No newline at end of file
src/locales/zh-TW.json
View file @
7f03fb1b
...
...
@@ -44,5 +44,7 @@
"notSupported"
:
"此頁面不支持自動發送。請複制消息並手動發送。"
},
"openSidebar"
:
"打開側邊欄"
,
"searchPlaceholder"
:
"搜尋或輸入 URL"
"searchPlaceholder"
:
"搜尋或輸入 URL"
,
"setShortcutKeys"
:
"設定快速鍵"
,
"mobileView"
:
"行動端視圖"
}
\ No newline at end of file
src/manifest.ts
View file @
7f03fb1b
...
...
@@ -24,7 +24,7 @@ export const defaultSidebarPath = "sidebar.html"
const
manifest
=
{
// maximum of 45 characters
name
:
"__MSG_name__"
,
version
:
"1.2.
8
"
,
version
:
"1.2.
9
"
,
// edge 12 characters
// short_name: "__MSG_short_name__",
// no more than 132 characters
...
...
src/pages/Dev.vue
View file @
7f03fb1b
<
script
setup
lang=
"ts"
>
import
ContentSidebarAddon
from
"@/components/sidebar/ContentSidebarAddon
.vue"
import
Webview
from
"@/components/Webview
.vue"
</
script
>
<
template
>
<!--
<ContentSidebarAddon
/>
-->
<!--
<div
class=
"w-screen h-screen"
>
<Webview
url=
"https://github.com"
/>
</div>
-->
</
template
>
<
style
scoped
></
style
>
src/pages/Popup.vue
View file @
7f03fb1b
...
...
@@ -49,18 +49,25 @@ const host = computed({
watch
(
()
=>
pipWindow
.
id
,
async
(
id
)
=>
{
console
.
log
(
"pip window tabs: "
,
id
)
if
(
id
)
{
const
tabs
=
await
chrome
.
tabs
.
query
({
windowId
:
id
})
if
(
tabs
&&
tabs
.
length
==
1
)
{
pipWindow
.
tab
=
tabs
[
0
]
}
const
win
=
await
chrome
.
windows
.
get
(
id
)
pipWindow
.
windowsWindow
=
win
return
}
else
{
pipWindow
.
windowsWindow
=
null
}
}
)
watch
(
()
=>
pipWindow
.
tabId
,
async
(
tabId
)
=>
{
if
(
tabId
)
{
const
tab
=
await
chrome
.
tabs
.
get
(
tabId
)
pipWindow
.
tab
=
tab
}
else
{
pipWindow
.
tab
=
null
}
}
)
onMounted
(()
=>
{
...
...
@@ -73,16 +80,19 @@ onMounted(() => {
})
})
getLocal
({
pipWindowId
:
null
,
popularSites
:
config
.
data
.
popularSites
}).
then
(
({
pipWindowId
:
id
,
popularSites
})
=>
{
if
(
id
)
{
pipWindow
.
id
=
id
getLocal
({
pipWindow
:
null
as
null
|
{
windowId
:
number
;
tabId
:
number
;
icon
:
string
},
popularSites
:
config
.
data
.
popularSites
,
}).
then
(({
pipWindow
:
pip
,
popularSites
})
=>
{
if
(
pip
)
{
pipWindow
.
id
=
pip
.
windowId
pipWindow
.
tabId
=
pip
.
tabId
pipWindow
.
icon
=
pip
.
icon
}
if
(
Array
.
isArray
(
popularSites
))
{
popularItems
.
splice
(
0
,
popularItems
.
length
,
...
popularSites
)
}
}
)
})
chrome
.
storage
.
local
.
onChanged
.
addListener
(
handleLocalChange
)
window
.
addEventListener
(
"keydown"
,
handleKeydown
)
...
...
@@ -98,7 +108,7 @@ onUnmounted(() => {
function
handleKeydown
(
e
:
KeyboardEvent
)
{
if
(
e
.
code
==
"KeyP"
&&
(
e
.
ctrlKey
||
e
.
metaKey
))
{
e
.
preventDefault
()
handle
WriteHtml
()
handle
PipPopup
()
}
if
(
e
.
code
==
"Backslash"
&&
(
e
.
ctrlKey
||
e
.
metaKey
))
{
e
.
preventDefault
()
...
...
@@ -125,12 +135,13 @@ function hanldeKeyup(e: KeyboardEvent) {
const
handleLocalChange
=
(
changes
:
{
[
key
:
string
]:
chrome
.
storage
.
StorageChange
})
=>
{
if
(
changes
.
pipWindowId
)
{
pipWindow
.
id
=
changes
.
pipWindowId
.
newValue
if
(
changes
.
pipWindow
)
{
pipWindow
.
id
=
changes
.
pipWindow
.
newValue
.
windowId
pipWindow
.
tabId
=
changes
.
pipWindow
.
newValue
.
tabId
}
}
async
function
handle
WriteHtml
()
{
async
function
handle
PipPopup
()
{
const
tabs
=
await
chrome
.
tabs
.
query
({
active
:
true
,
currentWindow
:
true
})
const
tab
=
tabs
[
0
]
if
(
tab
)
{
...
...
@@ -142,6 +153,8 @@ async function handleWriteHtml() {
},
})
}
window
.
close
()
}
async
function
openSidebar
(
url
=
""
)
{
...
...
@@ -270,11 +283,11 @@ function showChatDocs() {
]"
>
<button
v-if=
"!
pipWindow.tab
"
v-if=
"!
(pipWindow.tab && pipWindow.windowsWindow)
"
class=
"hover:bg-background-mute bg-background-soft disabled:bg-background-soft disabled:opacity-50 disabled:cursor-not-allowed"
:disabled=
"!avaiable"
:title=
"t('openInPip')"
@
click=
"handle
WriteHtml
"
@
click=
"handle
PipPopup
"
>
<IconAmpStories
class=
"size-8 shrink-0"
/>
<div
class=
"flex items-center justify-between flex-1 w-2/3 gap-2"
>
...
...
src/pages/Sidebar.vue
View file @
7f03fb1b
...
...
@@ -19,6 +19,7 @@ import IconNavigateNext from "@/components/icons/IconNavigateNext.vue"
import
IconRefresh
from
"@/components/icons/IconRefresh.vue"
import
IconHome
from
"@/components/icons/IconHome.vue"
import
IconPhone
from
"@/components/icons/IconPhone.vue"
import
IconHide
from
"@/components/icons/IconHide.vue"
import
{
handleImgError
}
from
"@/utils/dom"
import
{
FrameMessageType
}
from
"@/types"
import
{
homeUrl
}
from
"@/utils/const"
...
...
@@ -52,7 +53,7 @@ const webviewsAttr = computed(() => {
})
})
const
active
=
ref
(
-
1
)
const
pagesInfo
=
reactive
<
{
[
index
:
number
]:
PageInfo
}
>
({}
)
const
pagesInfo
=
reactive
<
(
PageInfo
|
null
)[]
>
([]
)
const
hostUA
=
reactive
<
Record
<
string
,
number
>>
(
config
.
data
.
embedView
.
hostUA
)
const
isPointerIn
=
ref
(
false
)
...
...
@@ -155,12 +156,8 @@ onUnmounted(() => {
async
function
handleMessage
(
message
:
any
)
{
switch
(
message
.
type
)
{
case
MessageType
.
openInSidebar
:
if
(
currentTab
.
tabId
==
0
)
{
const
current
=
await
chrome
.
tabs
.
getCurrent
()
currentTab
.
tabId
=
current
?.
id
||
-
1
}
if
(
message
.
tabId
==
currentTab
.
tabId
)
{
const
url
=
message
.
url
if
(
message
.
tabId
==
currentTab
.
tabId
&&
!
isProtectedUrl
(
url
))
{
go
(
url
)
}
break
...
...
@@ -231,7 +228,7 @@ function reload() {
function
closeWebview
(
index
:
number
)
{
pages
.
splice
(
index
,
1
)
delete
pagesInfo
[
index
]
pagesInfo
.
splice
(
index
,
1
)
if
(
active
.
value
>
pages
.
length
-
1
)
{
active
.
value
=
pages
.
length
-
1
}
...
...
@@ -332,8 +329,9 @@ function handlePointerLeave() {
<a
@
click=
"(e) => (e.preventDefault(), (active = -1))"
:href=
"homeUrl"
title=
"Anything Copilot"
:class=
"[
'group rounded-
lg
relative box-border border',
'group rounded-
full
relative box-border border',
active === -1
? 'bg-primary/10 border-primary-500'
: 'border-transparent hover:bg-background-mute bg-background-soft',
...
...
@@ -352,16 +350,17 @@ function handlePointerLeave() {
<a
v-for=
"(page, i) of pages"
@
click=
"(e) => (e.preventDefault(), (active = i))"
:href=
"page.url"
:href=
"pagesInfo[i]?.url"
:title=
"pagesInfo[i]?.title"
:class=
"[
'group rounded-
lg
relative box-border border',
'group rounded-
full
relative box-border border',
active === i
? 'bg-primary/10 border-primary-500'
: 'border-transparent hover:bg-background-mute bg-background-soft',
]"
>
<img
class=
"size-
5 scale-90
pointer-events-none"
class=
"size-
4
pointer-events-none"
loading=
"lazy"
:src=
"pagesInfo[i]?.icon || globeImg"
:data-fallback=
"globeImg"
...
...
@@ -401,6 +400,7 @@ function handlePointerLeave() {
</button>
-->
<button
@
click=
"reload()"
:title=
"t('refresh')"
class=
"group hover:bg-background-soft rounded-full"
>
<IconRefresh
...
...
@@ -409,6 +409,7 @@ function handlePointerLeave() {
</button>
<button
@
click=
"toggleMobileUA"
:title=
"t('mobileView')"
:class=
"[
'group hover:bg-background-soft rounded-full transition ease-in-out delay-200',
{ 'bg-background-soft text-primary-500 ': isMobileUA },
...
...
@@ -420,15 +421,17 @@ function handlePointerLeave() {
<button
v-if=
"mode == 'content'"
@
click=
"collapseSidebar()"
:title=
"t('minimize')"
class=
"group hover:bg-background-soft rounded-full"
>
<Icon
SplitscreenRight
<Icon
Hide
class=
"size-5 scale-95 group-active:scale-90 transition-transform"
/>
</button>
<button
v-if=
"mode == 'content'"
@
click=
"closeSidebar()"
:title=
"t('close')"
class=
"group hover:bg-background-soft rounded-full"
>
<IconClose
class=
"size-5 group-active:scale-90 transition-transform"
/>
...
...
src/pages/dev.ts
View file @
7f03fb1b
import
"@/assets/main.css"
import
{
createApp
}
from
"vue"
import
"@/content/index"
import
"@/content/main"
// import "@/pages/popup"
import
Dev
from
"./Dev.vue"
...
...
src/pages/offscreen.ts
View file @
7f03fb1b
...
...
@@ -6,10 +6,10 @@ import TurndownService from "turndown"
import
{
MessageType
,
ServiceFunc
,
type
ParseDocOptions
}
from
"@/types"
import
{
Tiktoken
}
from
"tiktoken/lite"
import
cl100k_base
from
"tiktoken/encoders/cl100k_base.json"
import
{
contentInvoke
}
from
"@/utils/invoke"
pdfjs
.
GlobalWorkerOptions
.
workerSrc
=
"/js/pdf.worker.js"
async
function
parsePdf
(
file
:
File
)
{
const
buffer
=
await
file
.
arrayBuffer
()
const
task
=
pdfjs
.
getDocument
(
buffer
)
...
...
@@ -102,34 +102,27 @@ async function handleMessage(
message
:
any
,
sender
:
chrome
.
runtime
.
MessageSender
)
{
if
(
message
?.
type
===
MessageType
.
toOffscreen
)
{
console
.
log
(
"offscreen message: "
,
message
,
sender
)
const
{
func
,
args
}
=
message
let
taskPromise
:
Promise
<
any
>
|
null
=
null
switch
(
func
)
{
case
ServiceFunc
.
parseDoc
:
taskPromise
=
parseDoc
(...(
args
as
[
any
]))
break
case
ServiceFunc
.
calcTokens
:
taskPromise
=
calcTokens
(...(
args
as
[
any
]))
break
case
ServiceFunc
.
tokenSlice
:
taskPromise
=
tokenSlice
(...(
args
as
[
any
,
any
]))
break
}
if
(
taskPromise
)
{
const
result
=
await
taskPromise
if
(
message
?.
type
===
MessageType
.
invokeRequest
)
{
const
result
=
await
contentInvoke
.
handleReqMsg
(
message
)
if
(
result
)
{
chrome
.
runtime
.
sendMessage
({
type
:
MessageType
.
fromOffscreen
,
key
:
message
.
key
,
task
:
message
.
task
,
payload
:
result
,
type
:
MessageType
.
forwardToTab
,
tabId
:
sender
.
tab
?.
id
,
message
:
{
type
:
MessageType
.
invokeResponse
,
...
result
,
},
})
}
}
}
contentInvoke
.
register
(
ServiceFunc
.
parseDoc
,
parseDoc
)
.
register
(
ServiceFunc
.
calcTokens
,
calcTokens
)
.
register
(
ServiceFunc
.
tokenSlice
,
tokenSlice
)
chrome
.
runtime
.
onMessage
.
addListener
(
handleMessage
)
// for testing purposes
...
...
src/pages/popup.ts
View file @
7f03fb1b
...
...
@@ -3,8 +3,18 @@ import "@/assets/main.css"
import
{
createApp
}
from
"vue"
import
Popup
from
"./Popup.vue"
import
{
i18n
}
from
"@/utils/i18n"
import
{
MessageType
}
from
"@/types"
import
{
contentInvoke
}
from
"@/utils/invoke"
const
app
=
createApp
(
Popup
)
app
.
use
(
i18n
)
app
.
mount
(
"#app"
)
chrome
.
runtime
.
onMessage
.
addListener
((
message
,
sender
,
sendResponse
)
=>
{
switch
(
message
.
type
)
{
case
MessageType
.
invokeResponse
:
contentInvoke
.
handleResMsg
(
message
)
break
}
})
src/store/popup.ts
View file @
7f03fb1b
...
...
@@ -5,4 +5,6 @@ export const pipWindow = reactive({
window
:
null
as
Window
|
null
,
windowsWindow
:
null
as
chrome
.
windows
.
Window
|
null
,
tab
:
null
as
chrome
.
tabs
.
Tab
|
null
,
tabId
:
0
,
icon
:
""
as
string
,
})
src/types/index.ts
View file @
7f03fb1b
...
...
@@ -6,13 +6,13 @@ export enum MessageType {
bgPipLaunch
=
"bg-pip-launch"
,
pipLaunch
=
"pip-launch"
,
contentMounted
=
"content-mount"
,
getPipWinInfo
=
"get-pip-win-info"
,
pipWinInfo
=
"pip-win-info"
,
//
getPipWinInfo = "get-pip-win-info",
//
pipWinInfo = "pip-win-info",
updateWindow
=
"update-window"
,
removeWindow
=
"remove-window"
,
setupOffscreenDocument
=
"setup-offscreen-document
"
,
toOffscreen
=
"to-offscreen"
,
fromOffscreen
=
"from-offscreen"
,
forwardToTab
=
"forward-to-tab
"
,
//
toOffscreen = "to-offscreen",
//
fromOffscreen = "from-offscreen",
invokeRequest
=
"invoke-request"
,
invokeResponse
=
"invoke-Response"
,
showChatDocs
=
"show-chat-docs"
,
...
...
@@ -23,9 +23,15 @@ export enum MessageType {
}
export
enum
ServiceFunc
{
setupOffscreen
=
"setup-offscreen"
,
parseDoc
=
"parse-doc"
,
calcTokens
=
"calc-tokens"
,
tokenSlice
=
"token-slice"
,
getAllCommands
=
"get-all-commands"
,
createTab
=
"create-tab"
,
toggleMinimize
=
"toggle-minimize"
,
getPipWindow
=
"get-pip-window"
,
getMyTab
=
"get-my-tab"
,
}
export
type
ParseDocOptions
=
{
...
...
@@ -51,7 +57,6 @@ export enum ContentEventType {
export
enum
FrameMessageType
{
frameReady
=
"anything-copilot_frame-ready"
,
webviewRun
=
"anything-copilot_webview-run"
,
escapeLoad
=
"anything-copilot_escape-load"
,
pageInfo
=
"anything-copilot_page-info"
,
collapseSidebar
=
"anything-copilot_collapse-sidebar"
,
...
...
src/utils/const.ts
View file @
7f03fb1b
...
...
@@ -2,4 +2,3 @@ export const chatDocPrompt = `Here is some relevant reference information. Pleas
export
const
homeUrl
=
'https://ziziyi.com/copilot'
export
const
feedbackUrl
=
'https://tawk.to/anythingcopilot'
src/utils/ext.ts
View file @
7f03fb1b
...
...
@@ -327,3 +327,22 @@ export function isProtectedUrl(url: string) {
return
true
}
export
async
function
getPipWindow
({
windowId
,
width
,
height
,
}:
{
windowId
?:
number
width
?:
number
height
?:
number
})
{
if
(
windowId
)
{
const
win
=
await
chrome
.
windows
.
get
(
windowId
)
return
win
}
const
windows
=
await
chrome
.
windows
.
getAll
({})
const
win
=
windows
.
find
((
w
)
=>
w
.
width
===
width
&&
w
.
height
===
height
)
return
win
}
src/utils/i18n.ts
View file @
7f03fb1b
...
...
@@ -6,9 +6,9 @@ import type ZhMessage from "@/locales/zh-CN.json"
type
MessageSchema
=
typeof
EnMessage
&
typeof
ZhMessage
export
function
getLocale
()
{
if
(
__DEV__
)
{
return
"zh-CN"
}
//
if (__DEV__) {
//
return "zh-CN"
//
}
const
language
=
chrome
.
i18n
.
getUILanguage
()
let
code
=
language
...
...
src/utils/invoke/ContentInvoke.ts
View file @
7f03fb1b
import
{
MessageType
,
ServiceFunc
,
type
ParseDocOptions
}
from
"@/types"
import
Invoke
from
"./Invoke"
import
Invoke
,
{
type
InvokeReq
}
from
"./Invoke"
class
ContentInvoke
extends
Invoke
{
public
async
send
(
req
:
any
)
{
public
async
send
(
req
:
InvokeReq
&
{
tabId
?:
number
}
)
{
const
key
=
this
.
key
const
response
=
await
chrome
.
runtime
.
sendMessage
({
if
(
req
.
tabId
)
{
chrome
.
tabs
.
sendMessage
(
req
.
tabId
,
{
type
:
MessageType
.
invokeRequest
,
key
,
...
req
,
})
}
else
{
chrome
.
runtime
.
sendMessage
({
type
:
MessageType
.
invokeRequest
,
key
,
...
req
,
})
}
return
{
key
,
response
}
return
{
key
}
}
public
handleResMsg
(
message
:
any
)
{
if
(
message
?.
type
===
MessageType
.
invokeResponse
)
{
const
{
key
,
success
,
payload
}
=
message
this
.
setReturnValue
(
key
,
success
,
payload
)
const
{
key
,
success
,
value
}
=
message
this
.
setReturnValue
(
key
,
success
,
value
)
}
}
public
setupOffscreen
()
{
return
this
.
invoke
({
func
:
ServiceFunc
.
setupOffscreen
,
args
:
[],
})
}
public
parseDoc
(
options
:
ParseDocOptions
):
Promise
<
string
[]
>
{
...
...
@@ -40,6 +56,22 @@ class ContentInvoke extends Invoke {
args
:
[
text
,
length
],
})
}
public
getAllCommands
():
Promise
<
chrome
.
commands
.
Command
[]
>
{
return
this
.
invoke
({
func
:
ServiceFunc
.
getAllCommands
,
args
:
[],
})
}
public
createTab
(
properties
:
chrome
.
tabs
.
CreateProperties
):
Promise
<
chrome
.
tabs
.
Tab
>
{
return
this
.
invoke
({
func
:
ServiceFunc
.
createTab
,
args
:
[
properties
],
})
}
}
const
contentInvoke
=
new
ContentInvoke
(
"content"
)
...
...
src/utils/invoke/Invoke.ts
View file @
7f03fb1b
...
...
@@ -3,29 +3,33 @@ type CallbackItem = {
reject
:
(
e
:
any
)
=>
void
}
interface
InvokeReq
{
export
interface
InvokeReq
{
func
:
string
args
:
any
[]
timeout
?:
number
key
?:
string
[
key
:
string
]:
any
}
interface
InvokeRes
{
export
interface
InvokeRes
{
key
:
string
success
:
boolean
value
:
any
}
abstract
class
Invoke
{
export
abstract
class
Invoke
{
private
pendingCallback
:
Record
<
string
,
CallbackItem
>
private
count
:
number
private
name
:
string
private
uniqueId
:
string
private
services
:
Map
<
string
,
Function
>
constructor
(
name
:
string
)
{
this
.
name
=
name
this
.
uniqueId
=
`
${
Math
.
round
(
Math
.
random
()
*
1
e6
)}
`
this
.
pendingCallback
=
{}
this
.
count
=
0
this
.
services
=
new
Map
()
}
protected
get
key
()
{
...
...
@@ -64,15 +68,48 @@ abstract class Invoke {
}
}
abstract
send
(
req
:
InvokeReq
):
Promise
<
{
key
:
string
;
response
:
any
}
>
abstract
handleResMsg
(
message
:
InvokeRes
):
void
abstract
send
(
req
:
InvokeReq
):
Promise
<
{
key
:
string
}
>
public
handleResMsg
(
message
:
InvokeRes
)
{
const
{
key
,
success
,
value
}
=
message
this
.
setReturnValue
(
key
,
success
,
value
)
}
public
async
handleReqMsg
(
message
:
InvokeReq
)
{
const
{
key
,
func
,
args
,
timeout
}
=
message
let
result
=
null
let
error
=
null
try
{
const
service
=
this
.
services
.
get
(
func
)
if
(
service
)
{
result
=
await
service
(...
args
)
}
else
{
error
=
`unknown service:
${
func
}
`
console
.
warn
(
`unknown service:
${
func
}
`
)
return
null
}
}
catch
(
err
)
{
console
.
error
(
"invoke error: "
,
err
)
error
=
err
}
return
{
key
,
success
:
!
error
,
value
:
!
error
?
result
:
error
}
}
public
async
invoke
<
T
=
any
>
(
req
:
InvokeReq
):
Promise
<
T
>
{
const
{
key
}
=
await
this
.
send
(
req
)
req
.
timeout
=
req
.
timeout
||
20000
return
this
.
getReturnValue
(
key
,
req
)
}
public
register
(
func
:
string
,
service
:
Function
)
{
this
.
services
.
set
(
func
,
service
)
return
this
}
public
unregister
(
func
:
string
)
{
this
.
services
.
delete
(
func
)
return
this
}
}
export
default
Invoke
export
{
Invoke
}
src/utils/invoke/WebviewInvoke.ts
View file @
7f03fb1b
...
...
@@ -18,13 +18,6 @@ class WebviewInvoke extends Invoke {
win
?.
postMessage
({
type
:
FrameMessageType
.
invokeRequest
,
key
,
...
req
},
"*"
)
return
{
key
,
response
:
null
}
}
public
handleResMsg
(
message
:
any
)
{
if
(
message
?.
type
===
FrameMessageType
.
invokeResponse
)
{
const
{
key
,
success
,
payload
}
=
message
this
.
setReturnValue
(
key
,
success
,
payload
)
}
}
}
export
{
WebviewInvoke
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment