chrome.sessions
Description
使用 chrome.sessions
API 从浏览会话中查询和恢复选项卡和窗口。
Permissions
sessions
Summary
Types
Properties
Methods
Events
Types
Device
PROPERTIES
deviceName
string
外部设备的名称。
sessions
Session[]
外部设备的打开窗口会话列表,从最近到最近最少修改的会话排序。
Filter
PROPERTIES
maxResults
number optional
要在请求的列表中获取的最大条目数。省略此参数以获取最大条目数 (
sessions.MAX_SESSION_RESULTS
)。
Session
PROPERTIES
lastModified
number
窗口或选项卡关闭或修改的时间,以纪元以来的毫秒数表示。
tab
Tab optional
tabs.Tab
,如果这个条目描述了一个选项卡。将设置 this 或sessions.Session.window
。window
Window optional
windows.Window
,如果这个条目描述了一个窗口。将设置 this 或sessions.Session.tab
。
Properties
MAX_SESSION_RESULTS
将包含在请求列表中的最大会话数sessions.Session
。
VALUE
25
Methods
getDevices
chrome.sessions.getDevices( filter?: Filter, callback?: function, )
Promise
检索所有具有同步会话的设备。
PARAMETERS
filter
Filter optional
callback
function optional
The
callback
parameter looks like:(devices: Device[]) => void
devices
Device[]
每个同步会话的
sessions.Device
对象列表,按从最近修改会话的设备到最近修改会话最少的设备的顺序排序。tabs.Tab
对象在sessions.Session
对象的windows.Window
中按新近度排序。
RETURNS
Promise<Device[]>
Pending
这仅在未指定
callback
参数时返回Promise
,并且使用 MV3+。Promise
中的类型与callback
的第一个参数相同。
getRecentlyClosed
chrome.sessions.getRecentlyClosed( filter?: Filter, callback?: function, )
Promise
获取最近关闭的选项卡和/或窗口的列表。
PARAMETERS
filter
Filter optional
callback
function optional
The
callback
parameter looks like:(sessions: Session[]) => void
sessions
Session[]
关闭条目的列表与它们关闭的顺序相反(最近关闭的选项卡或窗口将位于索引 0)。这些条目可能包含选项卡或窗口。
RETURNS
Promise<Session[]>
Pending
这仅在未指定
callback
参数时返回Promise
,并且使用 MV3+。Promise
中的类型与callback
的第一个参数相同.
restore
chrome.sessions.restore(
sessionId?: string,
callback?: function,
)
Promise
重新打开 windows.Window
或 tabs.Tab
,并在条目恢复时运行可选的回调。
PARAMETERS
sessionId
string optional
要恢复的
windows.Window.sessionId
或tabs.Tab.sessionId
。如果未指定此参数,则恢复最近关闭的会话。callback
function optional
The
callback
parameter looks like:(restoredSession: Session) => void
restoredSession
sessions.Session
包含恢复的windows.Window
或tabs.Tab
对象。
RETURNS
Promise<Session>
Pending
这仅在未指定
callback
参数时返回Promise
,并且使用 MV3+。Promise
中的类型与callback
的第一个参数相同.
Events
onChanged
chrome.sessions.onChanged.addListener(
callback: function,
)
当最近关闭的选项卡和/或窗口发生更改时触发。此事件不监视同步会话更改。
PARAMETERS
callback
function
The
callback
parameter looks like:() => void
By.一粒技术服务.