webextension-store-meta
Version:
Get browser extension(webextension) item meta from Chrome Web Store, Firefox add-ons, and Microsoft Edge Add-ons.
52 lines • 1.68 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.SourceJSONLD = void 0;
const dom_1 = require("../utils/dom");
const parse_1 = require("../utils/parse");
const utils_1 = require("./utils");
class SourceJSONLD {
dom;
/** @internal */
data;
constructor(
/** @internal */
dom) {
this.dom = dom;
const schema = (0, dom_1.findOne)((elem) => elem.name === "script" && elem.attribs.type === "application/ld+json", this.dom);
if (schema) {
this.data = (0, parse_1.tryJSONParseObject)(schema.children[0]?.data);
}
}
name() {
return (0, parse_1.toStr)(this.data?.name);
}
description() {
return (0, parse_1.toStr)(this.data?.description);
}
ratingValue() {
return (0, utils_1.parseRattingValue)((0, parse_1.toPlainObject)(this.data?.aggregateRating)?.ratingValue);
}
ratingCount() {
return (0, parse_1.parseNum)((0, parse_1.toPlainObject)(this.data?.aggregateRating)?.ratingCount);
}
price() {
return (0, parse_1.parseNum)((0, parse_1.toPlainObject)(this.data?.offers)?.price);
}
priceCurrency() {
return (0, parse_1.toStr)((0, parse_1.toPlainObject)(this.data?.offers)?.priceCurrency);
}
version() {
return (0, parse_1.parseVersion)(this.data?.version);
}
url() {
return (0, parse_1.toStr)(this.data?.url);
}
image() {
return (0, parse_1.toStr)(this.data?.image);
}
operatingSystem() {
return (0, parse_1.toStr)(this.data?.operatingSystem);
}
}
exports.SourceJSONLD = SourceJSONLD;
//# sourceMappingURL=SourceJSONLD.js.map