browser-extension-utils 0.0.2 → 0.0.4
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/lib/index.d.ts +47 -0
- package/lib/index.js +6 -6
- package/package.json +2 -1
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export function uniq(array: any[]): any[]
|
|
2
|
+
|
|
3
|
+
export function toCamelCase(text: string): string
|
|
4
|
+
|
|
5
|
+
export function $(
|
|
6
|
+
element: HTMLElement | string,
|
|
7
|
+
selectors?: string
|
|
8
|
+
): HTMLElement
|
|
9
|
+
|
|
10
|
+
export function querySelector(
|
|
11
|
+
element: HTMLElement | string,
|
|
12
|
+
selectors?: string
|
|
13
|
+
): HTMLElement
|
|
14
|
+
|
|
15
|
+
export function $$(
|
|
16
|
+
element: HTMLElement | string,
|
|
17
|
+
selectors?: string
|
|
18
|
+
): HTMLElement[]
|
|
19
|
+
|
|
20
|
+
export function querySelectorAll(
|
|
21
|
+
element: HTMLElement | string,
|
|
22
|
+
selectors?: string
|
|
23
|
+
): HTMLElement[]
|
|
24
|
+
|
|
25
|
+
export function createElement(tagName: string): HTMLElement
|
|
26
|
+
|
|
27
|
+
export function addEventListener(
|
|
28
|
+
element: HTMLElement,
|
|
29
|
+
type: string | Record<string, unknown>,
|
|
30
|
+
listener?
|
|
31
|
+
): void
|
|
32
|
+
|
|
33
|
+
export function setAttribute(
|
|
34
|
+
element: HTMLElement,
|
|
35
|
+
name: string,
|
|
36
|
+
value: string
|
|
37
|
+
): void
|
|
38
|
+
|
|
39
|
+
export function setStyle(element, style: string | Record<string, unknown>): void
|
|
40
|
+
|
|
41
|
+
export function toStyleMap(styleText: string): Record<string, unknown>
|
|
42
|
+
|
|
43
|
+
export function noStyleSpace(text: string): string
|
|
44
|
+
|
|
45
|
+
export function createSetStyle(styleText: string): setStyle
|
|
46
|
+
|
|
47
|
+
export function isUrl(text: string): boolean
|
package/lib/index.js
CHANGED
|
@@ -9,16 +9,16 @@ export const toCamelCase = function (text) {
|
|
|
9
9
|
})
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
export const
|
|
12
|
+
export const $ = (element, selectors) =>
|
|
13
13
|
typeof element === "object"
|
|
14
14
|
? element.querySelector(selectors)
|
|
15
15
|
: doc.querySelector(element)
|
|
16
|
-
export const
|
|
16
|
+
export const $$ = (element, selectors) =>
|
|
17
17
|
typeof element === "object"
|
|
18
18
|
? [...element.querySelectorAll(selectors)]
|
|
19
19
|
: [...doc.querySelectorAll(element)]
|
|
20
|
-
export const
|
|
21
|
-
export const
|
|
20
|
+
export const querySelector = $
|
|
21
|
+
export const querySelectorAll = $$
|
|
22
22
|
|
|
23
23
|
export const createElement = doc.createElement.bind(doc)
|
|
24
24
|
|
|
@@ -35,8 +35,8 @@ export const addEventListener = (element, type, listener) => {
|
|
|
35
35
|
// TODO: return remover function
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
export const setAttribute = (element,
|
|
39
|
-
element.setAttribute(
|
|
38
|
+
export const setAttribute = (element, name, value) =>
|
|
39
|
+
element.setAttribute(name, value)
|
|
40
40
|
|
|
41
41
|
export const setStyle = (element, values) => {
|
|
42
42
|
// setAttribute(element, "style", value)
|
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "browser-extension-utils",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"description": "Utilities for developing browser extensions and userscripts",
|
|
5
5
|
"type": "module",
|
|
6
|
+
"main": "./lib/index.js",
|
|
6
7
|
"exports": "./lib/index.js",
|
|
7
8
|
"scripts": {
|
|
8
9
|
"p": "prettier --write .",
|