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).

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;
} = ...
modules: {
    CopiedTemplateEditor: typeof CopiedTemplateEditor;
    InfringementAssistant: typeof InfringementAssistant;
} = ...
session: DeputySession
storage: DeputyStorage
util: {
    Requester: typeof Requester;
    applyOverrides: ((data: Record<string, any>, overrides: Record<string, any>, logger?: ((key: string, oldVal: any, newVal: any) => void)) => void);
    blockExit: "/home/runner/work/deputy/deputy/project/src/util/blockExit";
    classMix: ((...classes: ArrayOrNot<string | false>[]) => string);
    cleanParams: (<T>(obj: T, _options?: Partial<CleanParamsOptions<T>>) => Partial<T>);
    cloneRegex: ((regex: RegExp, options?: Partial<{
        post: string;
        pre: string;
        transformer?: ((source: string) => string);
    }>) => RegExp);
    copyToClipboard: ((text: string) => void);
    dangerModeConfirm: ((config: UserConfiguration, message: string | JQuery<HTMLElement>, options?: SetupDataMap) => JQuery.Promise<boolean>);
    equalTitle: ((title1: TitleLike, title2: TitleLike) => boolean);
    error: ((...data: any[]) => void);
    findNextSiblingElement: ((element: Node) => Element | null);
    fromObjectEntries: (<T, U>(obj: [T, U][]) => Record<T, U>);
    generateId: (() => string);
    getObjectValues: ((obj: any) => any[]);
    last: {
        <T>(array: NodeListOf<T>): T;
        <T>(array: T[]): T;
        (string: string): string;
    };
    log: ((...data: any[]) => void);
    matchAll: ((_regex: RegExp, string: string) => RegExpExecArray[]);
    moveToStart: (<T>(array: T[], index: number) => T[]);
    organize: (<T>(objects: T[], keyer: ((pivot: T) => string)) => Record<string, T[]>);
    pickSequence: (<T>(arr: T[], condition: ((val: T) => boolean)) => Iterable<T[]>);
    removeElement: (<T>(element: T) => T);
    sleep: ((ms: number) => Promise<void>);
    swapElements: (<T>(element1: T, element2: T) => T);
    unwrapElement: ((el: HTMLElement) => (HTMLElement | string)[]);
    unwrapJQ: ((element?: Element, $j: JQuery<HTMLElement>) => JSX.Element);
    unwrapWidget: ((el: Element) => HTMLElement);
    warn: ((...data: any[]) => void);
    yesNo: ((value: string | number | boolean, pull?: boolean) => boolean);
} = util

Type declaration

  • Requester: typeof Requester
  • applyOverrides: ((data: Record<string, any>, overrides: Record<string, any>, logger?: ((key: string, oldVal: any, newVal: any) => void)) => 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>
        • Optionallogger: ((key: string, oldVal: any, newVal: any) => 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: ArrayOrNot<string | false>[]) => string)
      • (...classes): string
      • Mixes values together into a string for the class attribute.

        Parameters

        Returns string

        string

  • cleanParams: (<T>(obj: T, _options?: Partial<CleanParamsOptions<T>>) => 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: RegExp, options?: Partial<{
        post: string;
        pre: string;
        transformer?: ((source: string) => string);
    }>) => 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) => string);
          }> = {}

        Returns RegExp

        A new regular expression object.

  • copyToClipboard: ((text: string) => 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: UserConfiguration, message: string | JQuery<HTMLElement>, options?: SetupDataMap) => 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.

        • Optionaloptions: SetupDataMap

          See OO.ui.MessageDialog's parameters.

        Returns JQuery.Promise<boolean>

        Promise resolving to a true/false boolean.

  • equalTitle: ((title1: TitleLike, title2: TitleLike) => 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: any[]) => void)
      • (...data): void
      • Log errors to the console.

        Parameters

        • Rest...data: any[]

        Returns void

  • findNextSiblingElement: ((element: Node) => Element | null)
  • fromObjectEntries: (<T, U>(obj: [T, U][]) => 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) => 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: NodeListOf<T>): T;
        <T>(array: T[]): T;
        (string: 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: any[]) => void)
      • (...data): void
      • Log to the console.

        Parameters

        • Rest...data: any[]

        Returns void

  • matchAll: ((_regex: RegExp, string: 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: T[], index: number) => 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: T[], keyer: ((pivot: T) => string)) => Record<string, T[]>)
      • <T>(objects, keyer): Record<string, T[]>
      • Type Parameters

        • T

        Parameters

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

              • pivot: T

              Returns string

        Returns Record<string, T[]>

  • pickSequence: (<T>(arr: T[], condition: ((val: T) => boolean)) => 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: T) => boolean)
            • (val): boolean
            • Parameters

              • val: T

              Returns boolean

        Returns Iterable<T[]>

        The found sequence

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

        Type Parameters

        Parameters

        • element: T

        Returns T

        The removed element

  • sleep: ((ms: number) => 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: T, element2: T) => 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) => (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?: Element, $j: JQuery<HTMLElement>) => 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: Element) => 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: any[]) => void)
      • (...data): void
      • Log warnings to the console.

        Parameters

        • Rest...data: any[]

        Returns void

  • yesNo: ((value: string | number | boolean, pull?: boolean) => 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: string, config?: UserConfiguration) => string);
    delink: ((string: string) => string);
    errorToOO: ((error: Error, config: {
        recoverable: boolean;
        warning: boolean;
    }) => Error);
    findSectionHeading: ((sectionHeadingName: string, n?: number) => HTMLElement | null);
    getApiErrorText: ((errorData: any, n?: number) => string | JQuery);
    getNativeRange: ((rangeLike: {
        endContainer: Element;
        endOffset: number;
        startContainer: Element;
        startOffset: number;
    }) => Range);
    getPageContent: ((page: string | number | Title, extraOptions?: Record<string, any>, api?: Api) => PromiseLike<string & {
        contentFormat: string;
        page: any;
        revid: number;
    }>);
    getPageExists: ((pages: ArrayOrNot<string | Title>) => Promise<string[]>);
    getPageTitle: ((pageID: number) => Promise<mw.Title>);
    getRevisionContent: ((revision: number, extraOptions?: Record<string, any>, api?: Api) => PromiseLike<string & {
        contentFormat: string;
    }>);
    getRevisionDiffURL: ((from:
        | number
        | "oldid"
        | "cur"
        | "prev", to?:
        | number
        | "oldid"
        | "cur"
        | "prev", includeCurrentParams?: boolean) => string);
    getRevisionURL: ((revid: number, page: TitleLike, includeCurrentParams?: boolean) => string);
    getSectionElements: ((sectionHeading: HTMLElement, sectionHeadingPredicate?: ((el: HTMLElement) => boolean)) => HTMLElement[]);
    getSectionHTML: ((page: string | Title, section: string | number, extraOptions?: Record<string, any>) => Promise<{
        element: HTMLDivElement;
        revid: number;
        wikitext: string;
    }>);
    getSectionId: ((page: string | Title, sectionName: string, n?: number) => Promise<number>);
    guessAuthor: ((comment: string) => string);
    isWikiHeading: ((el: Element) => boolean);
    msgEval: {
        (string: string, namedParameters: Record<string, string>, ...parameters: string[]): mw.Message;
        (string: string, ...parameters: string[]): mw.Message;
    };
    normalizeTitle: Object;
    normalizeWikiHeading: ((node: Node, ceiling?: Element) => WikiHeading | null);
    nsId: ((namespace: string) => number);
    openWindow: ((window: Window) => Promise<void>);
    pagelinkToTitle: ((el: HTMLAnchorElement) => mw.Title | false);
    parseDiffUrl: ((url: string | URL) => DiffInfo);
    performHacks: (() => void);
    purge: ((title: TitleLike) => Promise<void>);
    renderWikitext: ((wikitext: string, title: string, options?: Record<string, any>) => Promise<string & {
        summary?: string;
    }>);
    sectionHeadingN: ((heading: WikiHeading) => number);
    toRedirectsObject: ((redirects: {
        from: string;
        to: string;
    }[], normalized?: {
        from: string;
        to: string;
    }[]) => Record<string, string>);
} = wikiUtil

Type declaration

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

        Parameters

        • editSummary: string

          The edit summary

        • Optionalconfig: 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): 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: Error, config: {
        recoverable: boolean;
        warning: boolean;
    }) => 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: string, n?: number) => 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: any, n?: number) => 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: {
        endContainer: Element;
        endOffset: number;
        startContainer: Element;
        startOffset: number;
    }) => 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: string | number | Title, extraOptions?: Record<string, any>, api?: 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: ArrayOrNot<string | Title>) => 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: number) => 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: number, extraOptions?: Record<string, any>, api?: 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:
        | number
        | "oldid"
        | "cur"
        | "prev", to?:
        | number
        | "oldid"
        | "cur"
        | "prev", includeCurrentParams?: boolean) => string)
      • (from, to?, includeCurrentParams?): string
      • Gets the URL of a diff page.

        Parameters

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

          The revision to compare with

        • Optionalto:
              | 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: number, page: TitleLike, includeCurrentParams?: boolean) => 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: HTMLElement, sectionHeadingPredicate?: ((el: HTMLElement) => boolean)) => HTMLElement[])
      • (sectionHeading, sectionHeadingPredicate?): HTMLElement[]
      • Finds section elements from a given section heading (and optionally a predicate)

        Parameters

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

          A function which returns true if the section should stop here

        Returns HTMLElement[]

        Section headings.

  • getSectionHTML: ((page: string | Title, section: string | number, extraOptions?: Record<string, any>) => 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: string | Title, sectionName: string, n?: number) => 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) => 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: Element) => 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: string, namedParameters: Record<string, string>, ...parameters: string[]): mw.Message;
        (string: string, ...parameters: string[]): 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: Object
  • normalizeWikiHeading: ((node: Node, ceiling?: Element) => 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

        • Optionalceiling: 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: string) => 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: 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: HTMLAnchorElement) => 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: string | 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.

        If diff parameters were not found (no diff or oldid), they will be null.

        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: TitleLike) => Promise<void>)
      • (title): Promise<void>
      • Purges a page.

        Parameters

        • title: TitleLike

          The title of the page to purge

        Returns Promise<void>

  • renderWikitext: ((wikitext: string, title: string, options?: Record<string, any>) => 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: WikiHeading) => 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: {
        from: string;
        to: string;
    }[], normalized?: {
        from: string;
        to: string;
    }[]) => 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;
          }[]
        • Optionalnormalized: {
              from: string;
              to: string;
          }[]

        Returns Record<string, string>

        Redirects as an object

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>