UNPKG

@adguard/agtree

Version:
95 lines (94 loc) 3.21 kB
/** * @file Possible adblock syntaxes are listed here. */ /** * Adblock products (specific adblockers, excludes 'Common'). */ export declare const AdblockProduct: { /** * Adblock Plus. * * @see {@link https://adblockplus.org/} */ readonly Abp: "AdblockPlus"; /** * uBlock Origin. * * @see {@link https://github.com/gorhill/uBlock} */ readonly Ubo: "UblockOrigin"; /** * AdGuard. * * @see {@link https://adguard.com/} */ readonly Adg: "AdGuard"; }; export type AdblockProduct = typeof AdblockProduct[keyof typeof AdblockProduct]; /** * Possible adblock syntaxes (supported by this library) */ export declare const AdblockSyntax: { /** * Common syntax, which is supported by more than one adblocker (or by all adblockers). * * We typically use this syntax when we cannot determine the concrete syntax of the rule, * because the syntax is used by more than one adblocker natively. * * @example * - `||example.org^$important` is a common syntax, since it is used by all adblockers natively, and * we cannot determine at parsing level whether `important` is a valid option or not, and if it is valid, * then which adblocker supports it. */ readonly Common: "Common"; /** * Adblock Plus syntax. * * @example * - `example.org#$#abort-on-property-read alert` is an Adblock Plus syntax, since it is not used by any other * adblockers directly (probably supported by some on-the-fly conversion, but this is not the native syntax). * @see {@link https://adblockplus.org/} */ readonly Abp: "AdblockPlus"; /** * uBlock Origin syntax. * * @example * - `example.com##+js(set, atob, noopFunc)` is an uBlock Origin syntax, since it is not used by any other * adblockers directly (probably supported by some on-the-fly conversion, but this is not the native syntax). * @see {@link https://github.com/gorhill/uBlock} */ readonly Ubo: "UblockOrigin"; /** * AdGuard syntax. * * @example * - `example.org#%#//scriptlet("abort-on-property-read", "alert")` is an AdGuard syntax, since it is not used * by any other adblockers directly (probably supported by some on-the-fly conversion, but this is not the native * syntax). * @see {@link https://adguard.com/} */ readonly Adg: "AdGuard"; }; export type AdblockSyntax = typeof AdblockSyntax[keyof typeof AdblockSyntax]; /** * @deprecated Use AdblockProduct instead. */ export type StrictAdblockSyntax = AdblockProduct; /** * Returns the human-readable name for the given adblock product. * * @param product Adblock product. * * @returns Human-readable product name, e.g., 'Adblock Plus', 'uBlock Origin', 'AdGuard'. * * @throws Error if the product is unknown. * * @example * ```typescript * getHumanReadableProductName(AdblockProduct.Abp); // 'Adblock Plus' * getHumanReadableProductName(AdblockProduct.Ubo); // 'uBlock Origin' * getHumanReadableProductName(AdblockProduct.Adg); // 'AdGuard' * ``` */ export declare const getHumanReadableProductName: (product: AdblockProduct) => string;