webextension-store-meta
Version:
Get browser extension(webextension) item meta from Chrome Web Store, Firefox add-ons, and Microsoft Edge Add-ons.
33 lines (27 loc) • 692 B
text/typescript
import type { Node } from "domhandler";
import { findOne } from "../utils/dom";
export class SourceOG {
public constructor(
/** @internal */
private readonly dom: Node[],
) {}
public description(): string | null {
return this.find("og:description");
}
public url(): string | null {
return this.find("og:url");
}
public image(): string | null {
return this.find("og:image");
}
/** @internal */
private find(property: string): string | null {
const ogElem = findOne(
(elem) => elem.attribs.property === property,
this.dom,
);
return ogElem && ogElem.attribs.content != null
? ogElem.attribs.content
: null;
}
}