browser-extension-utils 0.2.1 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -3
- package/lib/add-element.ts +38 -0
- package/lib/create-element.ts +11 -0
- package/lib/dom-utils.ts +232 -0
- package/lib/global.d.ts +154 -0
- package/lib/index.ts +358 -0
- package/lib/set-attributes.ts +42 -0
- package/lib/userscript.ts +94 -0
- package/package.json +20 -31
- package/lib/index.d.ts +0 -207
- package/lib/index.js +0 -548
- package/lib/userscript.js +0 -86
package/lib/index.d.ts
DELETED
|
@@ -1,207 +0,0 @@
|
|
|
1
|
-
export const doc: Document
|
|
2
|
-
|
|
3
|
-
export const win: Window
|
|
4
|
-
|
|
5
|
-
export function uniq(array: any[]): any[]
|
|
6
|
-
|
|
7
|
-
export function toCamelCase(text: string): string
|
|
8
|
-
|
|
9
|
-
export function $(
|
|
10
|
-
selectors: string,
|
|
11
|
-
element?: HTMLElement | Document
|
|
12
|
-
): HTMLElement | undefined
|
|
13
|
-
|
|
14
|
-
export function querySelector(
|
|
15
|
-
selectors: string,
|
|
16
|
-
element?: HTMLElement | Document
|
|
17
|
-
): HTMLElement | undefined
|
|
18
|
-
|
|
19
|
-
export function $$(
|
|
20
|
-
selectors: string,
|
|
21
|
-
element?: HTMLElement | Document
|
|
22
|
-
): HTMLElement[]
|
|
23
|
-
|
|
24
|
-
export function querySelectorAll(
|
|
25
|
-
selectors: string,
|
|
26
|
-
element?: HTMLElement | Document
|
|
27
|
-
): HTMLElement[]
|
|
28
|
-
|
|
29
|
-
export function createElement(
|
|
30
|
-
tagName: string,
|
|
31
|
-
attributes?: Record<string, unknown>
|
|
32
|
-
): HTMLElement
|
|
33
|
-
|
|
34
|
-
export function addElement(
|
|
35
|
-
tagName: string,
|
|
36
|
-
attributes?: Record<string, unknown>
|
|
37
|
-
): HTMLElement
|
|
38
|
-
|
|
39
|
-
export function addElement(
|
|
40
|
-
parentNode: HTMLElement,
|
|
41
|
-
tagName: string | HTMLElement,
|
|
42
|
-
attributes?: Record<string, unknown>
|
|
43
|
-
): HTMLElement
|
|
44
|
-
|
|
45
|
-
export function addStyle(styleText: string): HTMLElement
|
|
46
|
-
|
|
47
|
-
export function addEventListener(
|
|
48
|
-
element: HTMLElement | Document | EventTarget,
|
|
49
|
-
type: string,
|
|
50
|
-
listener: EventListenerOrEventListenerObject,
|
|
51
|
-
options?: boolean | AddEventListenerOptions
|
|
52
|
-
): void
|
|
53
|
-
|
|
54
|
-
export function addEventListener(
|
|
55
|
-
element: HTMLElement | Document | EventTarget,
|
|
56
|
-
type: string | Record<string, unknown>
|
|
57
|
-
): void
|
|
58
|
-
|
|
59
|
-
export function removeEventListener(
|
|
60
|
-
element: HTMLElement | Document | EventTarget,
|
|
61
|
-
type: string,
|
|
62
|
-
listener: EventListenerOrEventListenerObject,
|
|
63
|
-
options?: boolean | AddEventListenerOptions
|
|
64
|
-
): void
|
|
65
|
-
|
|
66
|
-
export function removeEventListener(
|
|
67
|
-
element: HTMLElement | Document | EventTarget,
|
|
68
|
-
type: string | Record<string, unknown>
|
|
69
|
-
): void
|
|
70
|
-
|
|
71
|
-
export function getAttribute(
|
|
72
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
73
|
-
element: HTMLElement | null | undefined,
|
|
74
|
-
name: string
|
|
75
|
-
): string | undefined
|
|
76
|
-
|
|
77
|
-
export function setAttribute(
|
|
78
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
79
|
-
element: HTMLElement | null | undefined,
|
|
80
|
-
name: string,
|
|
81
|
-
value: string
|
|
82
|
-
): void
|
|
83
|
-
|
|
84
|
-
export function removeAttribute(
|
|
85
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
86
|
-
element: HTMLElement | null | undefined,
|
|
87
|
-
name: string
|
|
88
|
-
): void
|
|
89
|
-
|
|
90
|
-
export function setAttributes(
|
|
91
|
-
element: HTMLElement,
|
|
92
|
-
attributes: Record<string, unknown>
|
|
93
|
-
): void
|
|
94
|
-
|
|
95
|
-
export function addAttribute(
|
|
96
|
-
element: HTMLElement,
|
|
97
|
-
name: string,
|
|
98
|
-
value: string
|
|
99
|
-
): void
|
|
100
|
-
|
|
101
|
-
export function addClass(
|
|
102
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
103
|
-
element: HTMLElement | null | undefined,
|
|
104
|
-
className: string
|
|
105
|
-
): void
|
|
106
|
-
|
|
107
|
-
export function removeClass(
|
|
108
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
109
|
-
element: HTMLElement | null | undefined,
|
|
110
|
-
className: string
|
|
111
|
-
): void
|
|
112
|
-
|
|
113
|
-
export function hasClass(
|
|
114
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
115
|
-
element: HTMLElement | null | undefined,
|
|
116
|
-
className: string
|
|
117
|
-
): boolean
|
|
118
|
-
|
|
119
|
-
export type SetStyle = (
|
|
120
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
121
|
-
element: HTMLElement | null | undefined,
|
|
122
|
-
style: string | Record<string, unknown>,
|
|
123
|
-
overwrite?: boolean
|
|
124
|
-
) => void
|
|
125
|
-
|
|
126
|
-
export function setStyle(
|
|
127
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
128
|
-
element: HTMLElement | null | undefined,
|
|
129
|
-
style: string | Record<string, unknown>,
|
|
130
|
-
overwrite?: boolean
|
|
131
|
-
): void
|
|
132
|
-
|
|
133
|
-
export function toStyleMap(styleText: string): Record<string, string>
|
|
134
|
-
|
|
135
|
-
export function noStyleSpace(text: string): string
|
|
136
|
-
|
|
137
|
-
export function createSetStyle(styleText: string): SetStyle
|
|
138
|
-
|
|
139
|
-
export function isUrl(text: string | undefined): boolean
|
|
140
|
-
|
|
141
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
142
|
-
export function throttle(func: Function, interval: number): Function
|
|
143
|
-
|
|
144
|
-
export type MenuCallback = (event?: MouseEvent | KeyboardEvent) => void
|
|
145
|
-
export type RegisterMenuCommandOptions = {
|
|
146
|
-
id?: string
|
|
147
|
-
title?: string
|
|
148
|
-
autoClose?: boolean
|
|
149
|
-
// O - Tampermonkey
|
|
150
|
-
// X - Violentmonkey
|
|
151
|
-
accessKey?: string
|
|
152
|
-
}
|
|
153
|
-
export function registerMenuCommand(
|
|
154
|
-
name: string,
|
|
155
|
-
callback: MenuCallback,
|
|
156
|
-
options?: RegisterMenuCommandOptions
|
|
157
|
-
): string | undefined
|
|
158
|
-
|
|
159
|
-
export function extendHistoryApi(): void
|
|
160
|
-
|
|
161
|
-
export const actionHref: string
|
|
162
|
-
|
|
163
|
-
export function getOffsetPosition(
|
|
164
|
-
element: HTMLElement | undefined,
|
|
165
|
-
referElement?: HTMLElement | undefined
|
|
166
|
-
): {
|
|
167
|
-
top: number
|
|
168
|
-
left: number
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
172
|
-
export async function runOnce(key: string, func: Function): Promise<any>
|
|
173
|
-
|
|
174
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
175
|
-
export function runWhenRootExists(func: Function): void
|
|
176
|
-
|
|
177
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
178
|
-
export function runWhenHeadExists(func: Function): void
|
|
179
|
-
|
|
180
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
181
|
-
export function runWhenBodyExists(func: Function): void
|
|
182
|
-
|
|
183
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
184
|
-
export function runWhenDomReady(func: Function): void
|
|
185
|
-
|
|
186
|
-
export async function sleep(time: number): Promise<void>
|
|
187
|
-
|
|
188
|
-
export type Cache = {
|
|
189
|
-
get: (key: string | any[]) => any
|
|
190
|
-
add: (key: string | any[], value: any) => void
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
export const cache: Cache
|
|
194
|
-
|
|
195
|
-
export function isVisible(element: HTMLElement): boolean
|
|
196
|
-
|
|
197
|
-
export function isTouchScreen(): boolean
|
|
198
|
-
|
|
199
|
-
export function parseInt10(
|
|
200
|
-
number: string | undefined,
|
|
201
|
-
defaultValue?: number
|
|
202
|
-
): number
|
|
203
|
-
|
|
204
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
205
|
-
export function createHTML(html: string): string
|
|
206
|
-
|
|
207
|
-
export function compareVersions(v1: string, v2: string): number
|