Class Deputy

The main class for Deputy. Entry point for execution.

This class is not exported to avoid circular references and extraneous export code in the Rollup bundle (unnecessary for a userscript).

Hierarchy

  • Deputy

Constructors

Properties

DeputyCase: typeof DeputyCase = DeputyCase
DeputyCasePage: typeof DeputyCasePage = DeputyCasePage
DeputyCommunications: typeof DeputyCommunications = DeputyCommunications
DeputyDispatch: typeof Dispatch = Dispatch
DeputySession: typeof DeputySession = DeputySession
DeputyStorage: typeof DeputyStorage = DeputyStorage
_windowManager: WindowManager

An OOUI WindowManager. Automatically instantiated when needed. See the windowManager getter for instantiation.

CopiedTemplateEditor instance.

currentPage: Title = ...

The current page as an mw.Title.

currentPageId: number = ...

The current page ID.

dispatch: Dispatch
models: {
    ContributionSurveyRow: typeof ContributionSurveyRow;
} = ...

Type declaration

modules: {
    CopiedTemplateEditor: typeof CopiedTemplateEditor;
    InfringementAssistant: typeof InfringementAssistant;
} = ...

Type declaration

session: DeputySession
storage: DeputyStorage
util: {
    Requester: typeof Requester;
    applyOverrides: ((data, overrides, logger?) => void);
    blockExit: "/home/runner/work/deputy/deputy/project/src/util/blockExit";
    classMix: ((...classes) => string);
    cleanParams: (<T>(obj, _options?) => Partial<T>);
    cloneRegex: ((regex, options?) => RegExp);
    copyToClipboard: ((text) => void);
    dangerModeConfirm: ((config, message, options?) => JQuery.Promise<boolean>);
    equalTitle: ((title1, title2) => boolean);
    error: ((...data) => void);
    findNextSiblingElement: ((element) => Element | null);
    fromObjectEntries: (<T, U>(obj) => Record<T, U>);
    generateId: (() => string);
    getObjectValues: ((obj) => any[]);
    last: {
        <T>(array): T;
        <T>(array): T;
        (string): string;
    };
    log: ((...data) => void);
    matchAll: ((_regex, string) => RegExpExecArray[]);
    moveToStart: (<T>(array, index) => T[]);
    organize: (<T>(objects, keyer) => Record<string, T[]>);
    pickSequence: (<T>(arr, condition) => Iterable<T[]>);
    removeElement: (<T>(element) => T);
    sleep: ((ms) => Promise<void>);
    swapElements: (<T>(element1, element2) => T);
    unwrapElement: ((el) => (HTMLElement | string)[]);
    unwrapJQ: ((element?, $j) => JSX.Element);
    unwrapWidget: ((el) => HTMLElement);
    warn: ((...data) => void);
    yesNo: ((value, pull?) => boolean);
} = util

Type declaration

  • Requester: typeof Requester
  • applyOverrides: ((data, overrides, logger?) => void)
      • (data, overrides, logger?): void
      • Applies configuration overrides. This takes two objects, A and B. A's keys will be respected and will remain unchanged. Object values of A that also exist in B will be overwritten with its values in B.

        Parameters

        • data: Record<string, any>
        • overrides: Record<string, any>
        • Optional logger: ((key, oldVal, newVal) => void)
            • (key, oldVal, newVal): void
            • Parameters

              • key: string
              • oldVal: any
              • newVal: any

              Returns void

        Returns void

  • blockExit: "/home/runner/work/deputy/deputy/project/src/util/blockExit"
  • classMix: ((...classes) => string)
      • (...classes): string
      • Mixes values together into a string for the class attribute.

        Parameters

        Returns string

        string

  • cleanParams: (<T>(obj, _options?) => Partial<T>)
      • <T>(obj, _options?): Partial<T>
      • Cleans a parameter list. By default, this performs the following:

        • Removes all undefined, null, or empty values
        • Trims all strings
        • Removes newly undefined, null, or empty values

        This mutates the original object and also returns it for chaining.

        Type Parameters

        • T extends Record<string, string>

        Parameters

        Returns Partial<T>

        The cleaned parameter list.

  • cloneRegex: ((regex, options?) => RegExp)
      • (regex, options?): RegExp
      • Clones a regular expression.

        Parameters

        • regex: RegExp

          The regular expression to clone.

        • options: Partial<{
              post: string;
              pre: string;
              transformer?: ((source) => string);
          }> = {}

        Returns RegExp

        A new regular expression object.

  • copyToClipboard: ((text) => void)
      • (text): void
      • Copies text to the clipboard. Relies on the old style of clipboard copying (using document.execCommand due to a lack of support for navigator-based clipboard handling).

        Parameters

        • text: string

          The text to copy to the clipboard.

        Returns void

  • dangerModeConfirm: ((config, message, options?) => JQuery.Promise<boolean>)
      • (config, message, options?): JQuery.Promise<boolean>
      • Shows a confirmation dialog, if the user does not have danger mode enabled. If the user has danger mode enabled, this immediately resolves to true, letting the action run immediately.

        Do not use this with any action that can potentially break templates, user data, or cause irreversible data loss.

        Parameters

        • config: UserConfiguration

          The user's configuration

        • message: string | JQuery<HTMLElement>

          See OO.ui.MessageDialog's parameters.

        • Optional options: SetupDataMap

          See OO.ui.MessageDialog's parameters.

        Returns JQuery.Promise<boolean>

        Promise resolving to a true/false boolean.

  • equalTitle: ((title1, title2) => boolean)
      • (title1, title2): boolean
      • Checks if two MediaWiki page titles are equal.

        Parameters

        Returns boolean

        true if title1 and title2 refer to the same page

  • error: ((...data) => void)
      • (...data): void
      • Log errors to the console.

        Parameters

        • Rest ...data: any[]

        Returns void

  • findNextSiblingElement: ((element) => Element | null)
  • fromObjectEntries: (<T, U>(obj) => Record<T, U>)
      • <T, U>(obj): Record<T, U>
      • Works like Object.fromEntries

        Type Parameters

        • T extends string

        • U

        Parameters

        • obj: [T, U][]

          The object to get the values of.

        Returns Record<T, U>

        The values of the given object as an array

  • generateId: (() => string)
      • (): string
      • Generates an ID using the current time and a random number. Quick and dirty way to generate random IDs.

        Returns string

        A string in the format TIMESTAMP++RANDOM_NUMBER

  • getObjectValues: ((obj) => any[])
      • (obj): any[]
      • Works like Object.values.

        Parameters

        • obj: any

          The object to get the values of.

        Returns any[]

        The values of the given object as an array

  • last: {
        <T>(array): T;
        <T>(array): T;
        (string): string;
    }
      • <T>(array): T
      • Returns the last item of a NodeList array.

        Type Parameters

        Parameters

        • array: NodeListOf<T>

          The array to get the last element from

        Returns T

        The last element of the array

      • <T>(array): T
      • Returns the last item of an array.

        Type Parameters

        • T

        Parameters

        • array: T[]

          The array to get the last element from

        Returns T

        The last element of the array

      • (string): string
      • Returns the last character of a string.

        Parameters

        • string: string

          The string to get the last character from

        Returns string

        The last character of the string

  • log: ((...data) => void)
      • (...data): void
      • Log to the console.

        Parameters

        • Rest ...data: any[]

        Returns void

  • matchAll: ((_regex, string) => RegExpExecArray[])
      • (_regex, string): RegExpExecArray[]
      • Replacement for String.prototype.matchALl (ES2020 only)

        Parameters

        • _regex: RegExp

          The regular expression to exec with

        • string: string

          The string to exec against

        Returns RegExpExecArray[]

        The matches found

  • moveToStart: (<T>(array, index) => T[])
      • <T>(array, index): T[]
      • Moves a value as determined by an index of the array to the start of the array. Mutates the original array.

        Type Parameters

        • T

        Parameters

        • array: T[]

          The array to use

        • index: number

          The index of the value to move to the start of the array

        Returns T[]

        The reordered array.

  • organize: (<T>(objects, keyer) => Record<string, T[]>)
      • <T>(objects, keyer): Record<string, T[]>
      • Type Parameters

        • T

        Parameters

        • objects: T[]
        • keyer: ((pivot) => string)
            • (pivot): string
            • Parameters

              • pivot: T

              Returns string

        Returns Record<string, T[]>

  • pickSequence: (<T>(arr, condition) => Iterable<T[]>)
      • <T>(arr, condition): Iterable<T[]>
      • Iterates over an array and returns an Iterator which checks each element of the array sequentially for a given condition (predicated by condition) and returns another array, containing an element where true was returned, and every subsequent element where the check returns false.

        Type Parameters

        • T

        Parameters

        • arr: T[]
        • condition: ((val) => boolean)
            • (val): boolean
            • Parameters

              • val: T

              Returns boolean

        Returns Iterable<T[]>

        Yield

        The found sequence

  • removeElement: (<T>(element) => T)
      • <T>(element): T
      • Removes an element from its document.

        Type Parameters

        Parameters

        • element: T

        Returns T

        The removed element

  • sleep: ((ms) => Promise<void>)
      • (ms): Promise<void>
      • Sleep for an specified amount of time.

        Parameters

        • ms: number

          Milliseconds to sleep for.

        Returns Promise<void>

  • swapElements: (<T>(element1, element2) => T)
      • <T>(element1, element2): T
      • Swaps two elements in the DOM. Element 1 will be removed from the DOM, Element 2 will be added in its place.

        Type Parameters

        Parameters

        • element1: T

          The element to remove

        • element2: T

          The element to insert

        Returns T

        element2, for chaining

  • unwrapElement: ((el) => (HTMLElement | string)[])
      • (el): (HTMLElement | string)[]
      • Unwraps an element into its child elements. This entirely discards the parent element.

        Parameters

        Returns (HTMLElement | string)[]

        The unwrapped element.

  • unwrapJQ: ((element?, $j) => JSX.Element)
      • (element?, $j): JSX.Element
      • Get the nodes from a JQuery object and wraps it in an element.

        Parameters

        • element: Element = ...

          The element to add the children into

        • $j: JQuery<HTMLElement>

          The JQuery object

        Returns JSX.Element

        The original element, now with children

  • unwrapWidget: ((el) => HTMLElement)
      • (el): HTMLElement
      • Unwraps an OOUI widget from its JQuery $element variable and returns it as an HTML element.

        Parameters

        • el: Element

          The widget to unwrap.

        Returns HTMLElement

        The unwrapped widget.

  • warn: ((...data) => void)
      • (...data): void
      • Log warnings to the console.

        Parameters

        • Rest ...data: any[]

        Returns void

  • yesNo: ((value, pull?) => boolean)
      • (value, pull?): boolean
      • Performs {{yesno}}-based string interpretation.

        Parameters

        • value: string | number | boolean

          The value to check

        • pull: boolean = true

          Depends which direction to pull unspecified values.

        Returns boolean

        If pull is true, any value that isn't explicitly a negative value will return true. Otherwise, any value that isn't explicitly a positive value will return false.

version: string = deputyVersion

This version of Deputy.

wikiConfig: WikiConfiguration
wikiUtil: {
    decorateEditSummary: ((editSummary, config?) => string);
    delink: ((string) => string);
    errorToOO: ((error, config) => Error);
    findSectionHeading: ((sectionHeadingName, n?) => HTMLElement | null);
    getApiErrorText: ((errorData, n?) => string | JQuery);
    getNativeRange: ((rangeLike) => Range);
    getPageContent: ((page, extraOptions?, api?) => PromiseLike<string & {
        contentFormat: string;
        page: any;
        revid: number;
    }>);
    getPageExists: ((pages) => Promise<string[]>);
    getPageTitle: ((pageID) => Promise<mw.Title>);
    getRevisionContent: ((revision, extraOptions?, api?) => PromiseLike<string & {
        contentFormat: string;
    }>);
    getRevisionDiffURL: ((from, to?, includeCurrentParams?) => string);
    getRevisionURL: ((revid, page, includeCurrentParams?) => string);
    getSectionElements: ((sectionHeading, sectionHeadingPredicate?) => HTMLElement[]);
    getSectionHTML: ((page, section, extraOptions?) => Promise<{
        element: HTMLDivElement;
        revid: number;
        wikitext: string;
    }>);
    getSectionId: ((page, sectionName, n?) => Promise<number>);
    guessAuthor: ((comment) => string);
    isWikiHeading: ((el) => boolean);
    msgEval: {
        (string, namedParameters, ...parameters): mw.Message;
        (string, ...parameters): mw.Message;
    };
    normalizeTitle: ((title?) => mw.Title);
    normalizeWikiHeading: ((node, ceiling?) => WikiHeading | null);
    nsId: ((namespace) => number);
    openWindow: ((window) => Promise<void>);
    pagelinkToTitle: ((el) => mw.Title | false);
    parseDiffUrl: ((url) => DiffInfo);
    performHacks: (() => void);
    purge: ((title) => Promise<void>);
    renderWikitext: ((wikitext, title, options?) => Promise<string & {
        summary?: string;
    }>);
    sectionHeadingN: ((heading) => number);
    toRedirectsObject: ((redirects, normalized?) => Record<string, string>);
} = wikiUtil

Type declaration

  • decorateEditSummary: ((editSummary, config?) => string)
      • (editSummary, config?): string
      • Appends extra information to an edit summary (also known as the "advert").

        Parameters

        • editSummary: string

          The edit summary

        • Optional config: UserConfiguration

          The user's configuration. Used to get the "danger mode" setting.

        Returns string

        The decorated edit summary (in wikitext)

  • delink: ((string) => string)
      • (string): string
      • Delinks wikitext. Does not handle templates. Only does dumb delinking (RegExp replacement; does not parse and handle link nesting, etc.).

        Parameters

        • string: string

        Returns string

        delinked wikitext

  • errorToOO: ((error, config) => Error)
      • (error, config): Error
      • Converts a normal error into an OO.ui.Error for ProcessDialogs.

        Parameters

        • error: Error

          A plain error object.

        • config: {
              recoverable: boolean;
              warning: boolean;
          }

          Error configuration.

          • recoverable: boolean

            Whether or not the error is recoverable.

          • warning: boolean

            Whether or not the error is a warning.

        Returns Error

        An OOUI Error.

  • findSectionHeading: ((sectionHeadingName, n?) => HTMLElement | null)
      • (sectionHeadingName, n?): HTMLElement | null
      • Finds a MediaWiki section heading from the current DOM using its title.

        Parameters

        • sectionHeadingName: string

          The name of the section to find.

        • n: number = 1

          The n of the section. Starts at 1.

        Returns HTMLElement | null

        The found section heading. null if not found.

  • getApiErrorText: ((errorData, n?) => string | JQuery)
      • (errorData, n?): string | JQuery
      • Get the API error text from an API response.

        Parameters

        • errorData: any
        • n: number = 0

          Get the nth error. Defaults to 0 (first error).

        Returns string | JQuery

  • getNativeRange: ((rangeLike) => Range)
      • (rangeLike): Range
      • Converts a range-like Object into a native Range object.

        Parameters

        • rangeLike: {
              endContainer: Element;
              endOffset: number;
              startContainer: Element;
              startOffset: number;
          }

          The range to convert

          • endContainer: Element
          • endOffset: number
          • startContainer: Element
          • startOffset: number

        Returns Range

        A Range object.

  • getPageContent: ((page, extraOptions?, api?) => PromiseLike<string & {
        contentFormat: string;
        page: any;
        revid: number;
    }>)
      • (page, extraOptions?, api?): PromiseLike<string & {
            contentFormat: string;
            page: any;
            revid: number;
        }>
      • Get the content of a page on-wiki.

        Parameters

        • page: string | number | Title

          The page to get

        • extraOptions: Record<string, any> = {}

          Extra options to pass to the request

        • api: Api = MwApi.action

          The API object to use

        Returns PromiseLike<string & {
            contentFormat: string;
            page: any;
            revid: number;
        }>

        A promise resolving to the page content. Resolves to null if missing page.

  • getPageExists: ((pages) => Promise<string[]>)
      • (pages): Promise<string[]>
      • From a list of page titles, get which pages exist.

        Parameters

        • pages: ArrayOrNot<string | Title>

          The pages to search for

        Returns Promise<string[]>

        An array of pages which exist, ordered by input order.

  • getPageTitle: ((pageID) => Promise<mw.Title>)
      • (pageID): Promise<mw.Title>
      • Gets the page title of a given page ID.

        Parameters

        • pageID: number

        Returns Promise<mw.Title>

  • getRevisionContent: ((revision, extraOptions?, api?) => PromiseLike<string & {
        contentFormat: string;
    }>)
      • (revision, extraOptions?, api?): PromiseLike<string & {
            contentFormat: string;
        }>
      • Get the content of a revision on-wiki.

        Parameters

        • revision: number

          The revision ID of the revision to get the content of

        • extraOptions: Record<string, any> = {}

          Extra options to pass to the request

        • api: Api = MwApi.action

          The API object to use

        Returns PromiseLike<string & {
            contentFormat: string;
        }>

        A promise resolving to the page content

  • getRevisionDiffURL: ((from, to?, includeCurrentParams?) => string)
      • (from, to?, includeCurrentParams?): string
      • Gets the URL of a diff page.

        Parameters

        • from: number | "oldid" | "cur" | "prev"

          The revision to compare with

        • Optional to: number | "oldid" | "cur" | "prev"

          The revision to compare from

        • includeCurrentParams: boolean = false

          true if the current query parameters should be included

        Returns string

        The URL of the diff page

  • getRevisionURL: ((revid, page, includeCurrentParams?) => string)
      • (revid, page, includeCurrentParams?): string
      • Gets the URL of a permanent link page.

        Parameters

        • revid: number

          The revision ID to link to

        • page: TitleLike

          The title of the page to compare to

        • includeCurrentParams: boolean = false

          true if the current query parameters should be included

        Returns string

        The URL of the diff page

  • getSectionElements: ((sectionHeading, sectionHeadingPredicate?) => HTMLElement[])
      • (sectionHeading, sectionHeadingPredicate?): HTMLElement[]
      • Finds section elements from a given section heading (and optionally a predicate)

        Parameters

        • sectionHeading: HTMLElement
        • sectionHeadingPredicate: ((el) => boolean) = isWikiHeading

          A function which returns true if the section should stop here

            • (el): boolean
            • Parameters

              Returns boolean

        Returns HTMLElement[]

        Section headings.

  • getSectionHTML: ((page, section, extraOptions?) => Promise<{
        element: HTMLDivElement;
        revid: number;
        wikitext: string;
    }>)
      • (page, section, extraOptions?): Promise<{
            element: HTMLDivElement;
            revid: number;
            wikitext: string;
        }>
      • Get the parser output HTML of a specific page section.

        Parameters

        • page: string | Title
        • section: string | number
        • extraOptions: Record<string, any> = {}

        Returns Promise<{
            element: HTMLDivElement;
            revid: number;
            wikitext: string;
        }>

        A promise resolving to the <div class="mw-parser-output"> element.

  • getSectionId: ((page, sectionName, n?) => Promise<number>)
      • (page, sectionName, n?): Promise<number>
      • Get the ID of a section from its heading.

        Parameters

        • page: string | Title

          The page to check for

        • sectionName: string

          The section name to get the ID of

        • n: number = 1

          The nth occurrence of a section with the same name

        Returns Promise<number>

  • guessAuthor: ((comment) => string)
      • (comment): string
      • Attempt to guess the author of a comment from the comment signature.

        Parameters

        • comment: string

          The comment to read.

        Returns string

        The author of the comment

  • isWikiHeading: ((el) => boolean)
      • (el): boolean
      • Check if a given parameter is a wikitext heading parsed into HTML.

        Alias for normalizeWikiHeading( el ) != null.

        Parameters

        Returns boolean

        true if the element is a heading, false otherwise

  • msgEval: {
        (string, namedParameters, ...parameters): mw.Message;
        (string, ...parameters): mw.Message;
    }
      • (string, namedParameters, ...parameters): mw.Message
      • Evaluates any string using mw.msg. This handles internationalization of strings that are loaded outside the script or asynchronously.

        Parameters

        • string: string

          The string to evaluate

        • namedParameters: Record<string, string>

          Named parameters to evaluate. Uses $ notation.

        • Rest ...parameters: string[]

          Parameters to pass, if any

        Returns mw.Message

        A mw.Message

      • (string, ...parameters): mw.Message
      • Evaluates any string using mw.msg. This handles internationalization of strings that are loaded outside the script or asynchronously.

        Parameters

        • string: string

          The string to evaluate

        • Rest ...parameters: string[]

          Parameters to pass, if any

        Returns mw.Message

        A mw.Message

  • normalizeTitle: ((title?) => mw.Title)
      • (title?): mw.Title
      • Private

        Normalizes the title into an mw.Title object based on either a given title or the current page.

        Parameters

        • Optional title: TitleLike

          The title to normalize. Default is current page.

        Returns mw.Title

        A mw.Title object. null if not a valid title.

  • normalizeWikiHeading: ((node, ceiling?) => WikiHeading | null)
      • (node, ceiling?): WikiHeading | null
      • Annoyingly, there are many different ways that a heading can be parsed into depending on the version and the parser used for given wikitext.

        In order to properly perform such wiki heading checks, we need to identify if a given element is part of a wiki heading, and perform a normalization if so.

        Since this function needs to check many things before deciding if a given HTML element is part of a section heading or not, this also acts as an isWikiHeading check.

        The layout for a heading differs depending on the MediaWiki version:

        On 1.43+ (Parser)

        <div class="mw-heading mw-heading2">
        <h2 id="Parsed_wikitext...">Parsed <i>wikitext</i>...</h2>
        <span class="mw-editsection>...</span>
        </div>

        On Parsoid

        <h2 id="Parsed_wikitext...">Parsed <i>wikitext</i>...</h2>
        

        On pre-1.43

        <h2>
        <span class="mw-headline" id="Parsed_wikitext...">Parsed <i>wikitext</i>...</span>
        <span class="mw-editsection">...</span>
        </h2>

        Worst case execution time would be if this was run with an element which was outside a heading and deeply nested within the page.

        Backwards-compatibility support may be removed in the future. This function does not support Parsoid specification versions lower than 2.0.

        Parameters

        • node: Node

          The node to check for

        • Optional ceiling: Element

          An element which node must be in to be a valid heading. This is set to the .mw-parser-output element by default.

        Returns WikiHeading | null

        The root heading element (can be an <h2> or <div>), or null if it is not a valid heading.

  • nsId: ((namespace) => number)
      • (namespace): number
      • Gets the namespace ID from a canonical (not localized) namespace name.

        Parameters

        • namespace: string

          The namespace to get

        Returns number

        The namespace ID

  • openWindow: ((window) => Promise<void>)
      • (window): Promise<void>
      • Opens a temporary window. Use this for dialogs that are immediately destroyed after running. Do NOT use this for re-openable dialogs, such as the main ANTE dialog.

        Parameters

        • window: Window

        Returns Promise<void>

        A promise. Resolves when the window is closed.

  • pagelinkToTitle: ((el) => mw.Title | false)
      • (el): mw.Title | false
      • Extracts a page title from a MediaWiki <a>. If the link does not validly point to a MediaWiki page, false is returned.

        The part of the link used to determine the page title depends on how trustworthy the data is in telling the correct title. If the link does not have an href, only two routes are available: the selflink check and the title attribute check.

        The following methods are used, in order.

        • title parameter from anchor href
        • /wiki/$1 path from anchor href
        • ./$1 path from Parsoid document anchor href
        • selflinks (not run on Parsoid)
        • title attribute from anchor

        Parameters

        Returns mw.Title | false

        the page linked to

  • parseDiffUrl: ((url) => DiffInfo)
      • (url): DiffInfo
      • What it says on the tin. Attempt to parse out a title, diff, or oldid from a URL. This is useful for converting diff URLs into actual diff information, and especially useful for {{copied}} templates.

        Parameters

        • url: string | URL

          The URL to parse

        Returns DiffInfo

        Parsed info: diff or oldid revision IDs, and/or the page title.

  • performHacks: (() => void)
      • (): void
      • MediaWiki core contains a lot of quirks in the code. Other extensions also have their own quirks. To prevent these quirks from affecting Deputy's functionality, we need to perform a few hacks.

        Returns void

  • purge: ((title) => Promise<void>)
      • (title): Promise<void>
      • Purges a page.

        Parameters

        • title: TitleLike

          The title of the page to purge

        Returns Promise<void>

  • renderWikitext: ((wikitext, title, options?) => Promise<string & {
        summary?: string;
    }>)
      • (wikitext, title, options?): Promise<string & {
            summary?: string;
        }>
      • Renders wikitext as HTML.

        Parameters

        • wikitext: string
        • title: string
        • options: Record<string, any> = {}

        Returns Promise<string & {
            summary?: string;
        }>

  • sectionHeadingN: ((heading) => number)
      • (heading): number
      • Checks the n of a given element, that is to say the nth occurrence of a section with this exact heading name in the entire page.

        This is purely string- and element-based, with no additional metadata or parsing information required.

        This function detects the n using the following conditions:

        • If the heading ID does not have an n suffix, the n is always 1.
        • If the heading ID does have an n suffix, and the detected heading name does not end with a number, the n is always the last number on the ID.
        • If the heading ID and heading name both end with a number,
          • The n is 1 if the ID has an equal number of ending number patterns (sequences of "_n", e.g. "_20_30_40" has three) with the heading name.
          • Otherwise, the n is the last number on the ID if the ID than the heading name.

        Parameters

        Returns number

        The n, a number

  • toRedirectsObject: ((redirects, normalized?) => Record<string, string>)
      • (redirects, normalized?): Record<string, string>
      • Transforms the redirects object returned by MediaWiki's query action into an object instead of an array.

        Parameters

        • redirects: {
              from: string;
              to: string;
          }[]
        • Optional normalized: {
              from: string;
              to: string;
          }[]

        Returns Record<string, string>

        Redirects as an object

instance: Deputy

Singleton for this class.

Accessors

  • get windowManager(): WindowManager
  • Returns WindowManager

    An OOUI window manager

Methods

  • Initializes Deputy. By this point, the loader should have succeeded in loading all dependencies required for Deputy to work. It's only a matter of initializing sub-components as well.

    Returns Promise<void>

  • Initialize Deputy. This static function attaches Deputy to the window.deputy object and initializes that instance.

    Returns Promise<void>

Generated using TypeDoc