@getlupa/vue 0.17.10 → 0.17.11
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/dist/lupaSearch.js +13 -0
- package/dist/lupaSearch.mjs +13 -0
- package/dist/src/types/DataExtraction.d.ts +7 -2
- package/package.json +1 -1
package/dist/lupaSearch.js
CHANGED
|
@@ -20119,6 +20119,8 @@ const extractValue = (options) => {
|
|
|
20119
20119
|
return extractFromStorage(options);
|
|
20120
20120
|
case "htmlElementText":
|
|
20121
20121
|
return extractFromHtmlElementText(options);
|
|
20122
|
+
case "htmlElementAttribute":
|
|
20123
|
+
return extractFromHtmlElementAttribute(options);
|
|
20122
20124
|
case "cookie":
|
|
20123
20125
|
return extractFromCookie(options);
|
|
20124
20126
|
default:
|
|
@@ -20162,6 +20164,17 @@ const extractFromHtmlElementText = (options) => {
|
|
|
20162
20164
|
const element = document.querySelector(options.querySelector);
|
|
20163
20165
|
return element ? ((_a = element.textContent) == null ? void 0 : _a.trim()) || options.default : options.default;
|
|
20164
20166
|
};
|
|
20167
|
+
const extractFromHtmlElementAttribute = (options) => {
|
|
20168
|
+
const element = document.querySelector(options.querySelector);
|
|
20169
|
+
if (!element) {
|
|
20170
|
+
return options.default;
|
|
20171
|
+
}
|
|
20172
|
+
const attr = options.attribute;
|
|
20173
|
+
if (attr === "value" && (element == null ? void 0 : element.value)) {
|
|
20174
|
+
return element.value;
|
|
20175
|
+
}
|
|
20176
|
+
return element.getAttribute(attr) || options.default;
|
|
20177
|
+
};
|
|
20165
20178
|
const getValueFromPath = (obj, path) => {
|
|
20166
20179
|
return path.split(".").reduce((value, key) => value && value[key] || null, obj);
|
|
20167
20180
|
};
|
package/dist/lupaSearch.mjs
CHANGED
|
@@ -20117,6 +20117,8 @@ const extractValue = (options) => {
|
|
|
20117
20117
|
return extractFromStorage(options);
|
|
20118
20118
|
case "htmlElementText":
|
|
20119
20119
|
return extractFromHtmlElementText(options);
|
|
20120
|
+
case "htmlElementAttribute":
|
|
20121
|
+
return extractFromHtmlElementAttribute(options);
|
|
20120
20122
|
case "cookie":
|
|
20121
20123
|
return extractFromCookie(options);
|
|
20122
20124
|
default:
|
|
@@ -20160,6 +20162,17 @@ const extractFromHtmlElementText = (options) => {
|
|
|
20160
20162
|
const element = document.querySelector(options.querySelector);
|
|
20161
20163
|
return element ? ((_a = element.textContent) == null ? void 0 : _a.trim()) || options.default : options.default;
|
|
20162
20164
|
};
|
|
20165
|
+
const extractFromHtmlElementAttribute = (options) => {
|
|
20166
|
+
const element = document.querySelector(options.querySelector);
|
|
20167
|
+
if (!element) {
|
|
20168
|
+
return options.default;
|
|
20169
|
+
}
|
|
20170
|
+
const attr = options.attribute;
|
|
20171
|
+
if (attr === "value" && (element == null ? void 0 : element.value)) {
|
|
20172
|
+
return element.value;
|
|
20173
|
+
}
|
|
20174
|
+
return element.getAttribute(attr) || options.default;
|
|
20175
|
+
};
|
|
20163
20176
|
const getValueFromPath = (obj, path) => {
|
|
20164
20177
|
return path.split(".").reduce((value, key) => value && value[key] || null, obj);
|
|
20165
20178
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type ExtractFrom = 'url' | 'localStorage' | 'sessionStorage' | 'htmlElementText' | 'cookie';
|
|
1
|
+
export type ExtractFrom = 'url' | 'localStorage' | 'sessionStorage' | 'htmlElementText' | 'htmlElementAttribute' | 'cookie';
|
|
2
2
|
export type BaseExtractFrom = {
|
|
3
3
|
extractFrom: ExtractFrom;
|
|
4
4
|
default: string | number | Record<string, unknown>;
|
|
@@ -16,8 +16,13 @@ export type ExtractFromHtmlElementText = BaseExtractFrom & {
|
|
|
16
16
|
extractFrom: 'htmlElementText';
|
|
17
17
|
querySelector: string;
|
|
18
18
|
};
|
|
19
|
+
export type ExtractFromHtmlElementAttribute = BaseExtractFrom & {
|
|
20
|
+
extractFrom: 'htmlElementAttribute';
|
|
21
|
+
querySelector: string;
|
|
22
|
+
attribute: string;
|
|
23
|
+
};
|
|
19
24
|
export type ExtractFromCookie = BaseExtractFrom & {
|
|
20
25
|
extractFrom: 'cookie';
|
|
21
26
|
cookieName: string;
|
|
22
27
|
};
|
|
23
|
-
export type DataExtraction = ExtractFromUrl | ExtractFromStorage | ExtractFromHtmlElementText | ExtractFromCookie;
|
|
28
|
+
export type DataExtraction = ExtractFromUrl | ExtractFromStorage | ExtractFromHtmlElementText | ExtractFromHtmlElementAttribute | ExtractFromCookie;
|