FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
FluentRead/userscript/context.ts at main · FluentRead/FluentRead · GitHub
FluentRead
/
FluentRead
Public
Notifications
You must be signed in to change notification settings
Fork
423
Star
8.2k
Code
Issues
11
Pull requests
2
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
FluentRead
/
userscript
/
context.ts
Copy path
More file actions
More file actions
Latest commit
History
History
History
26 lines (25 loc) · 807 Bytes
Breadcrumbs
FluentRead
/
userscript
/
context.ts
Copy path
File metadata and controls
26 lines (25 loc) · 807 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
export
interface
UserscriptContentContext
{
readonly
isInvalid
:
boolean
;
onInvalidated
(
callback
:
(
)
=>
void
)
:
void
;
invalidate
(
)
:
void
;
}
/** 用显式失效回调模拟 WXT 内容脚本上下文,统一驱动共享功能在离页时清理资源。 */
export
function
createUserscriptContentContext
(
)
:
UserscriptContentContext
{
const
callbacks
=
new
Set
<
(
)
=>
void
>
(
)
;
let
invalid
=
false
;
return
{
get
isInvalid
(
)
{
return
invalid
;
}
,
onInvalidated
(
callback
)
{
if
(
invalid
)
callback
(
)
;
else
callbacks
.
add
(
callback
)
;
}
,
invalidate
(
)
{
if
(
invalid
)
return
;
invalid
=
true
;
callbacks
.
forEach
(
(
callback
)
=>
callback
(
)
)
;
callbacks
.
clear
(
)
;
}
,
}
;
}
Back
|
FazBrowse Home
|
New Git URL