···11-/* ======================================================
22- Glide version: 0.1.51a
33- ====================================================== */
44-55-declare const GLIDE_EXCOMMANDS: [
66- {
77- readonly name: "back";
88- readonly description: "Go back one page in history";
99- readonly content: false;
1010- readonly repeatable: true;
1111- },
1212- {
1313- readonly name: "forward";
1414- readonly description: "Go forward one page in history";
1515- readonly content: false;
1616- readonly repeatable: true;
1717- },
1818- {
1919- readonly name: "reload";
2020- readonly description: "Reload the current page";
2121- readonly content: false;
2222- readonly repeatable: true;
2323- },
2424- {
2525- readonly name: "reload_hard";
2626- readonly description: "Reload the current page, bypassing the cache";
2727- readonly content: false;
2828- readonly repeatable: true;
2929- },
3030- {
3131- readonly name: "quit";
3232- readonly description: "Close all windows";
3333- readonly content: false;
3434- readonly repeatable: false;
3535- },
3636- {
3737- readonly name: "clear";
3838- readonly description: "Clear all notifications";
3939- readonly content: false;
4040- readonly repeatable: false;
4141- },
4242- {
4343- readonly name: "set";
4444- readonly description: "Set an option";
4545- readonly args_schema: {
4646- readonly name: {
4747- readonly type: "string";
4848- readonly position: 0;
4949- readonly required: true;
5050- };
5151- readonly value: {
5252- readonly type: "string";
5353- readonly position: 1;
5454- readonly required: true;
5555- };
5656- };
5757- readonly content: false;
5858- readonly repeatable: false;
5959- },
6060- {
6161- readonly name: "profile_dir";
6262- readonly description: "Show the current profile directory";
6363- readonly content: false;
6464- readonly repeatable: false;
6565- },
6666- {
6767- readonly name: "config_edit";
6868- readonly description: "Open the config file in the default editor";
6969- readonly content: false;
7070- readonly repeatable: false;
7171- },
7272- {
7373- readonly name: "config_path";
7474- readonly description: "Show the config file path";
7575- readonly content: false;
7676- readonly repeatable: false;
7777- },
7878- {
7979- readonly name: "config_reload";
8080- readonly description: "Reload the config file";
8181- readonly content: false;
8282- readonly repeatable: false;
8383- },
8484- {
8585- readonly name: "config_init";
8686- readonly description: "Initialise a config dir with all the necessary setup";
8787- readonly args_schema: {
8888- readonly location: {
8989- readonly type: {
9090- readonly enum: readonly [
9191- "home",
9292- "profile",
9393- "cwd"
9494- ];
9595- };
9696- readonly required: false;
9797- readonly position: 0;
9898- };
9999- };
100100- readonly content: false;
101101- readonly repeatable: false;
102102- },
103103- {
104104- readonly name: "css_edit";
105105- readonly description: "Open the userChrome.css file in the default editor";
106106- readonly content: false;
107107- readonly repeatable: false;
108108- },
109109- {
110110- readonly name: "repeat";
111111- readonly description: "Repeat the last invoked command. In general only applies to \"mutative\" commands";
112112- readonly content: false;
113113- readonly repeatable: false;
114114- },
115115- {
116116- readonly name: "map";
117117- readonly description: "Show all mappings";
118118- readonly content: false;
119119- readonly repeatable: false;
120120- },
121121- {
122122- readonly name: "unmap";
123123- readonly description: "Remove a mapping from normal mode";
124124- readonly args_schema: {
125125- readonly lhs: {
126126- readonly type: "string";
127127- readonly required: true;
128128- readonly position: 0;
129129- };
130130- };
131131- readonly content: false;
132132- readonly repeatable: false;
133133- },
134134- {
135135- readonly name: "nunmap";
136136- readonly description: "Remove a mapping from normal mode";
137137- readonly args_schema: {
138138- readonly lhs: {
139139- readonly type: "string";
140140- readonly required: true;
141141- readonly position: 0;
142142- };
143143- };
144144- readonly content: false;
145145- readonly repeatable: false;
146146- },
147147- {
148148- readonly name: "iunmap";
149149- readonly description: "Remove a mapping from insert mode";
150150- readonly args_schema: {
151151- readonly lhs: {
152152- readonly type: "string";
153153- readonly required: true;
154154- readonly position: 0;
155155- };
156156- };
157157- readonly content: false;
158158- readonly repeatable: false;
159159- },
160160- {
161161- readonly name: "tab";
162162- readonly description: "Switch to the given tab index";
163163- readonly args_schema: {
164164- readonly tab_index: {
165165- readonly type: "integer";
166166- readonly required: true;
167167- readonly position: 0;
168168- };
169169- };
170170- readonly content: false;
171171- readonly repeatable: false;
172172- },
173173- {
174174- readonly name: "tab_new";
175175- readonly description: "Create a new tab with the given URL or the default new tab page if not provided";
176176- readonly args_schema: {
177177- readonly url: {
178178- readonly type: "string";
179179- readonly required: false;
180180- readonly position: 0;
181181- };
182182- };
183183- readonly content: false;
184184- readonly repeatable: false;
185185- },
186186- {
187187- readonly name: "tab_close";
188188- readonly description: "Close the current tab";
189189- readonly content: false;
190190- readonly repeatable: true;
191191- },
192192- {
193193- readonly name: "tab_next";
194194- readonly description: "Switch to the next tab, wrapping around if applicable";
195195- readonly content: false;
196196- readonly repeatable: true;
197197- },
198198- {
199199- readonly name: "tab_prev";
200200- readonly description: "Switch to the previous tab, wrapping around if applicable";
201201- readonly content: false;
202202- readonly repeatable: true;
203203- },
204204- {
205205- readonly name: "commandline_show";
206206- readonly description: "Show the commandline UI";
207207- readonly content: false;
208208- readonly args_schema: {};
209209- readonly repeatable: false;
210210- },
211211- {
212212- readonly name: "commandline_toggle";
213213- readonly description: "Toggle the commandline UI";
214214- readonly content: false;
215215- readonly args_schema: {};
216216- readonly repeatable: false;
217217- },
218218- {
219219- readonly name: "commandline_focus_next";
220220- readonly description: "Focus the next completion in the commandline";
221221- readonly content: false;
222222- readonly args_schema: {};
223223- readonly repeatable: false;
224224- },
225225- {
226226- readonly name: "commandline_focus_back";
227227- readonly description: "Focus the previous completion in the commandline";
228228- readonly content: false;
229229- readonly args_schema: {};
230230- readonly repeatable: false;
231231- },
232232- {
233233- readonly name: "commandline_delete";
234234- readonly description: "Delete the focused commandline completion";
235235- readonly content: false;
236236- readonly args_schema: {};
237237- readonly repeatable: false;
238238- },
239239- {
240240- readonly name: "commandline_accept";
241241- readonly description: "Accept the focused commandline completion";
242242- readonly content: false;
243243- readonly args_schema: {};
244244- readonly repeatable: false;
245245- },
246246- {
247247- readonly name: "url_yank";
248248- readonly description: "Yank the URL of the current tab to the clipboard";
249249- readonly content: false;
250250- readonly repeatable: false;
251251- },
252252- {
253253- readonly name: "echo";
254254- readonly description: "Log the given arguments to the console";
255255- readonly content: false;
256256- readonly args_schema: {};
257257- readonly repeatable: false;
258258- },
259259- {
260260- readonly name: "mode_change";
261261- readonly description: "Change the current mode";
262262- readonly content: false;
263263- readonly repeatable: false;
264264- readonly args_schema: {
265265- readonly mode: {
266266- readonly type: {
267267- readonly enum: GlideMode[];
268268- };
269269- readonly required: true;
270270- readonly position: 0;
271271- };
272272- readonly "--automove": {
273273- readonly type: {
274274- readonly enum: readonly [
275275- "left",
276276- "endline"
277277- ];
278278- };
279279- readonly required: false;
280280- };
281281- readonly "--operator": {
282282- readonly type: {
283283- readonly enum: readonly [
284284- "d",
285285- "c",
286286- "r"
287287- ];
288288- };
289289- readonly required: false;
290290- readonly description: "Only applicable for operator-pending mode";
291291- };
292292- };
293293- },
294294- {
295295- readonly name: "caret_move";
296296- readonly description: "Move the text caret";
297297- readonly content: false;
298298- readonly repeatable: false;
299299- readonly args_schema: {
300300- readonly direction: {
301301- readonly type: {
302302- readonly enum: readonly [
303303- "left",
304304- "right",
305305- "up",
306306- "down"
307307- ];
308308- };
309309- readonly required: true;
310310- readonly position: 0;
311311- };
312312- };
313313- },
314314- {
315315- readonly name: "visual_selection_copy";
316316- readonly description: "Copy the currently selected text to the clipboard & change to normal mode";
317317- readonly content: false;
318318- readonly repeatable: false;
319319- },
320320- {
321321- readonly name: "help";
322322- readonly description: "Open the docs";
323323- readonly content: false;
324324- readonly repeatable: false;
325325- },
326326- {
327327- readonly name: "tutor";
328328- readonly description: "Open the Glide tutorial";
329329- readonly content: false;
330330- readonly repeatable: false;
331331- },
332332- {
333333- readonly name: "repl";
334334- readonly description: "Start the config REPL";
335335- readonly content: false;
336336- readonly repeatable: false;
337337- },
338338- {
339339- readonly name: "keys";
340340- readonly description: "Synthesize the given key sequence as if they were actually pressed";
341341- readonly args_schema: {
342342- readonly keyseq: {
343343- readonly type: "string";
344344- readonly required: true;
345345- readonly position: 0;
346346- };
347347- };
348348- readonly content: false;
349349- readonly repeatable: false;
350350- },
351351- {
352352- readonly name: "r";
353353- readonly description: "Replace the current character";
354354- readonly content: false;
355355- readonly repeatable: false;
356356- readonly args_schema: {
357357- readonly character: {
358358- readonly type: "string";
359359- readonly required: false;
360360- readonly position: 0;
361361- };
362362- };
363363- },
364364- {
365365- readonly name: "scroll_top";
366366- readonly description: "Scroll to the top of the window";
367367- readonly content: true;
368368- readonly repeatable: false;
369369- },
370370- {
371371- readonly name: "scroll_page_down";
372372- readonly description: "Scroll down by 1 page (the size of the viewport)";
373373- readonly content: true;
374374- readonly repeatable: false;
375375- },
376376- {
377377- readonly name: "scroll_page_up";
378378- readonly description: "Scroll up by 1 page (the size of the viewport)";
379379- readonly content: true;
380380- readonly repeatable: false;
381381- },
382382- {
383383- readonly name: "scroll_bottom";
384384- readonly description: "Scroll to the bottom of the window";
385385- readonly content: true;
386386- readonly repeatable: false;
387387- },
388388- {
389389- readonly name: "blur";
390390- readonly description: "Blur the active element";
391391- readonly content: true;
392392- readonly repeatable: false;
393393- },
394394- {
395395- readonly name: "focusinput";
396396- readonly description: "Focus an input element based on the given filter";
397397- readonly content: true;
398398- readonly repeatable: false;
399399- readonly args_schema: {
400400- readonly filter: {
401401- readonly type: {
402402- readonly enum: readonly [
403403- "last"
404404- ];
405405- };
406406- readonly required: true;
407407- readonly position: 0;
408408- };
409409- };
410410- },
411411- {
412412- readonly name: "hint";
413413- readonly description: "Show hint labels for jumping to clickable elements";
414414- readonly content: false;
415415- readonly repeatable: false;
416416- readonly args_schema: {
417417- readonly "-s": {
418418- readonly type: "string";
419419- readonly required: false;
420420- readonly description: "*Only* show hints for all elements matching this CSS selector";
421421- };
422422- readonly "--include": {
423423- readonly type: "string";
424424- readonly required: false;
425425- readonly description: "*Also* show hints for all elements matching this CSS selector";
426426- };
427427- readonly "-e": {
428428- readonly type: "boolean";
429429- readonly required: false;
430430- readonly description: "*Only* show hints for all elements that are editable";
431431- };
432432- readonly "--auto": {
433433- readonly type: "boolean";
434434- readonly required: false;
435435- readonly description: "If only one hint is generated, automatically activate it.";
436436- };
437437- readonly "--action": {
438438- readonly type: {
439439- readonly enum: readonly [
440440- "click",
441441- "newtab-click"
442442- ];
443443- };
444444- readonly required: false;
445445- };
446446- readonly "--location": {
447447- readonly type: {
448448- readonly enum: readonly [
449449- "content",
450450- "browser-ui"
451451- ];
452452- };
453453- readonly required: false;
454454- };
455455- };
456456- },
457457- {
458458- readonly name: "hints_remove";
459459- readonly description: "Remove all hint labels and exit hint mode";
460460- readonly content: false;
461461- readonly repeatable: false;
462462- },
463463- {
464464- readonly name: "execute_motion";
465465- readonly description: "Used from op-pending mode to execute a motion.";
466466- readonly content: true;
467467- readonly repeatable: false;
468468- },
469469- {
470470- readonly name: "motion";
471471- readonly description: "Execute a given motion (internal)";
472472- readonly content: true;
473473- readonly repeatable: false;
474474- readonly args_schema: {
475475- readonly keyseq: {
476476- readonly type: {
477477- readonly enum: readonly [
478478- "w",
479479- "W",
480480- "e",
481481- "b",
482482- "B",
483483- "0",
484484- "$",
485485- "{",
486486- "}",
487487- "s",
488488- "v",
489489- "vh",
490490- "vl",
491491- "vd",
492492- "vc",
493493- "x",
494494- "X",
495495- "o"
496496- ];
497497- };
498498- readonly required: true;
499499- readonly position: 0;
500500- };
501501- };
502502- },
503503- {
504504- readonly name: "undo";
505505- readonly description: "Undo the most recent edit";
506506- readonly content: false;
507507- readonly repeatable: false;
508508- },
509509- {
510510- readonly name: "redo";
511511- readonly description: "Redo the most recent undo";
512512- readonly content: false;
513513- readonly repeatable: false;
514514- }
515515-];
516516-export type GlideExcmdName = (typeof GLIDE_EXCOMMANDS)[number]["name"];
517517-export type GlideCommandString = GlideExcmdName | `${GlideExcmdName} ${string}`;
518518-// This Source Code Form is subject to the terms of the Mozilla Public
519519-// License, v. 2.0. If a copy of the MPL was not distributed with this
520520-// file, You can obtain one at http://mozilla.org/MPL/2.0/.
521521-declare global {
522522- var glide: {
523523- ctx: {
524524- /**
525525- * The currently active mode.
526526- */
527527- mode: GlideMode;
528528- /**
529529- * The URL of the currently focused tab.
530530- */
531531- url: URL;
532532- /**
533533- * The operating system Glide is running on.
534534- */
535535- os: "linux" | "win" | "macosx" | "ios" | "android" | "other";
536536- /**
537537- * Whether or not the currently focused element is editable.
538538- *
539539- * This includes but is not limited to `html:<textarea>`, `html:<input>`, `contenteditable=true`.
540540- */
541541- is_editing(): Promise<boolean>;
542542- };
543543- /**
544544- * Set browser-wide options.
545545- */
546546- /// @docs-expand-type-reference
547547- o: glide.Options;
548548- /**
549549- * Set buffer specific options.
550550- *
551551- * This has the exact same API as {@link glide.o}.
552552- */
553553- bo: Partial<glide.Options>;
554554- options: {
555555- /**
556556- * Returns either a buffer-specific option, or the global version. In that order
557557- */
558558- get<Name extends keyof glide.Options>(name: Name): glide.Options[Name];
559559- };
560560- env: {
561561- /**
562562- * Get the value of an environment variable.
563563- *
564564- * If it does not exist `null` is returned.
565565- */
566566- get(name: string): string | null;
567567- /**
568568- * Set the value of an environment variable.
569569- */
570570- set(name: string, value: string): void;
571571- /**
572572- * Remove an environment variable.
573573- *
574574- * Does *not* error if the environment variable did not already exist.
575575- *
576576- * Returns the value of the deleted environment variable, if it did not exist `null` is returned.
577577- */
578578- delete(name: string): string | null;
579579- };
580580- process: {
581581- /**
582582- * Spawn a new process. The given `command` can either be the name of a binary in the `PATH`
583583- * or an absolute path to a binary file.
584584- *
585585- * If the process exits with a non-zero code, an error will be thrown, you can disable this check with `{ check_exit_code: false }`.
586586- *
587587- * ```ts
588588- * const proc = await glide.process.spawn('kitty', ['nvim', 'glide.ts'], { cwd: '~/.dotfiles/glide' });
589589- * console.log('opened kitty with pid', proc.pid);
590590- * ```
591591- */
592592- spawn(command: string, args?: string[] | null | undefined, opts?: glide.SpawnOptions): Promise<glide.Process>;
593593- /**
594594- * Spawn a new process and wait for it to exit.
595595- *
596596- * See {@link glide.process.spawn} for more information.
597597- */
598598- execute(command: string, args?: string[] | null | undefined, opts?: glide.SpawnOptions): Promise<glide.CompletedProcess>;
599599- };
600600- autocmds: {
601601- /**
602602- * Create an autocmd that will be invoked whenever the focused URL changes.
603603- *
604604- * This includes:
605605- * 1. URL changes within the same tab
606606- * 2. Switching tabs
607607- * 3. Navigating back and forth in history within the same tab
608608- */
609609- create<const Event extends "UrlEnter">(event: Event, pattern: glide.AutocmdPatterns[Event], callback: (args: glide.AutocmdArgs[Event]) => void): void;
610610- /**
611611- * Create an autocmd that will be invoked whenever the mode changes.
612612- *
613613- * The pattern is matched against `old_mode:new_mode`. You can also use `*` as a placeholder
614614- * to match *any* mode.
615615- *
616616- * for example, to define an autocmd that will be fired every time visual mode is entered:
617617- *
618618- * `*:visual`
619619- *
620620- * or when visual mode is left:
621621- *
622622- * `visual:*`
623623- *
624624- * or transitioning from visual to insert:
625625- *
626626- * `visual:insert`
627627- *
628628- * or for just any mode:
629629- *
630630- * `*`
631631- */
632632- create<const Event extends "ModeChanged">(event: Event, pattern: glide.AutocmdPatterns[Event], callback: (args: glide.AutocmdArgs[Event]) => void): void;
633633- /**
634634- * Create an autocmd that will be invoked whenever the key sequence changes.
635635- *
636636- * This will be fired under four circumstances:
637637- *
638638- * 1. A key is pressed that matches a key mapping.
639639- * 2. A key is pressed that is part of a key mapping.
640640- * 3. A key is pressed that cancels a previous partial key mapping sequence.
641641- * 4. A partial key mapping is cancelled (see {@link glide.o.mapping_timeout})
642642- *
643643- * For example, with
644644- * ```typescript
645645- * glide.keymaps.set('normal', 'gt', '...');
646646- * ```
647647- *
648648- * Pressing `g` will fire with `{ sequence: ["g"], partial: true }`, then either:
649649- * - Pressing `t` would fire `{ sequence: ["g", "t"], partial: false }`
650650- * - Pressing any other key would fire `{ sequence: [], partial: false }`
651651- *
652652- * Note that this is not fired for consecutive key presses for keys that don't correspond to mappings,
653653- * as the key state has not changed.
654654- */
655655- create<const Event extends "KeyStateChanged">(event: Event, callback: (args: glide.AutocmdArgs[Event]) => void): void;
656656- /**
657657- * Create an autocmd that will be invoked whenever the config is loaded.
658658- *
659659- * Called once on initial load and again every time the config is reloaded.
660660- */
661661- create<const Event extends "ConfigLoaded">(event: Event, callback: (args: glide.AutocmdArgs[Event]) => void): void;
662662- /**
663663- * Create an autocmd that will be invoked when the window is initially loaded.
664664- *
665665- * **note**: this is not invoked when the config is reloaded.
666666- */
667667- create<const Event extends "WindowLoaded">(event: Event, callback: (args: glide.AutocmdArgs[Event]) => void): void;
668668- create<const Event extends glide.AutocmdEvent>(event: Event, pattern: glide.AutocmdPatterns[Event] extends never ? (args: glide.AutocmdArgs[Event]) => void : glide.AutocmdPatterns[Event], callback?: (args: glide.AutocmdArgs[Event]) => void): void;
669669- };
670670- prefs: {
671671- /**
672672- * Set a preference. This is an alternative to `prefs.js` / [`about:config`](https://support.mozilla.org/en-US/kb/about-config-editor-firefox) so
673673- * that all customisation can be represented in a single `glide.ts` file.
674674- *
675675- * **warning**: this function is expected to be called at the top-level of your config, there is no guarantee that calling {@link glide.prefs.set} in callbacks
676676- * will result in the pref being properly applied everywhere.
677677- *
678678- * **warning**: there is also no guarantee that these settings will be applied when first loaded, sometimes a restart is required.
679679- */
680680- set(name: string, value: string | number | boolean): void;
681681- /**
682682- * Get the value of a pref.
683683- *
684684- * If the pref is not defined, then `undefined` is returned.
685685- */
686686- get(name: string): string | number | boolean | undefined;
687687- /**
688688- * Reset the pref value back to its default.
689689- */
690690- clear(name: string): void;
691691- };
692692- /**
693693- * Equivalent to `vim.g`.
694694- *
695695- * You can also store arbitrary data here in a typesafe fashion with:
696696- * ```ts
697697- * declare global {
698698- * interface GlideGlobals {
699699- * my_prop?: boolean;
700700- * }
701701- * }
702702- * glide.g.my_prop = true;
703703- * ```
704704- */
705705- /// @docs-expand-type-reference
706706- g: GlideGlobals;
707707- tabs: {
708708- /**
709709- * Returns the active tab for the currently focused window.
710710- *
711711- * This is equivalent to:
712712- * ```ts
713713- * const tab = await browser.tabs.query({ active: true, currentWindow: true })[0];
714714- * ```
715715- * But with additional error handling for invalid states.
716716- */
717717- active(): Promise<glide.TabWithID>;
718718- /**
719719- * Find the first tab matching the given query filter.
720720- *
721721- * This is the same API as [browser.tabs.get](https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/tabs/get),
722722- * but returns the first tab instead of an Array.
723723- */
724724- get_first(query: Browser.Tabs.QueryQueryInfoType): Promise<Browser.Tabs.Tab | undefined>;
725725- };
726726- excmds: {
727727- /**
728728- * Execute an excmd, this is the same as typing `:cmd --args`.
729729- */
730730- execute(cmd: glide.ExcmdString): Promise<void>;
731731- /**
732732- * Create a new excmd.
733733- *
734734- * e.g.
735735- * ```typescript
736736- * const cmd = glide.excmds.create(
737737- * { name: "my_excmd", description: "..." },
738738- * () => {
739739- * // ...
740740- * }
741741- * );
742742- * declare global {
743743- * interface ExcmdRegistry {
744744- * my_excmd: typeof cmd;
745745- * }
746746- * }
747747- * ```
748748- */
749749- create<const Excmd extends glide.ExcmdCreateProps>(info: Excmd, fn: (props: glide.ExcmdCallbackProps) => void | Promise<void>): Excmd;
750750- };
751751- content: {
752752- /**
753753- * Execute a function in the content process for the given tab.
754754- *
755755- * The given function will be stringified before being sent across processes, which
756756- * means it **cannot** capture any outside variables.
757757- *
758758- * If you need to pass some context into the function, use `args`, e.g.
759759- *
760760- * ```ts
761761- * function set_body_border_style(css: string) {
762762- * document.body.style.setProperty('border', css)
763763- * }
764764- * await glide.content.execute(set_body_border_style, { tab_id, args: ["20px dotted pink"] })
765765- * ```
766766- *
767767- * Note: all `args` must be JSON serialisable.
768768- */
769769- execute<F extends (...args: any[]) => any>(func: F, opts: {
770770- /**
771771- * The ID of the tab into which to inject.
772772- *
773773- * Or the tab object as returned by {@link glide.tabs.active}.
774774- */
775775- tab_id: number | glide.TabWithID;
776776- } & (Parameters<F> extends [
777777- ] ? {
778778- /**
779779- * Note: the given function doesn't take any arguments but if
780780- * it did, you could pass them here.
781781- */
782782- args?: undefined;
783783- } : {
784784- /**
785785- * Arguments to pass to the given function.
786786- *
787787- * **Must** be JSON serialisable
788788- */
789789- args: Parameters<F>;
790790- })): Promise<ReturnType<F>>;
791791- };
792792- keymaps: {
793793- set<const LHS>(modes: GlideMode | GlideMode[], lhs: $keymapcompletions.T<LHS>, rhs: glide.ExcmdString | glide.KeymapCallback, opts?: glide.KeymapOpts | undefined): void;
794794- /**
795795- * Remove the mapping of {lhs} for the {modes} where the map command applies.
796796- *
797797- * The mapping may remain defined for other modes where it applies.
798798- */
799799- del<const LHS>(modes: GlideMode | GlideMode[], lhs: $keymapcompletions.T<LHS>, opts?: glide.KeymapDeleteOpts): void;
800800- /**
801801- * List all global key mappings.
802802- *
803803- * If a key mapping is defined for multiple modes, multiple entries
804804- * will be returned for each mode.
805805- */
806806- list(modes?: GlideMode | GlideMode[]): glide.Keymap[];
807807- };
808808- hints: {
809809- /**
810810- * Find and show hints for "clickable" elements in the content frame.
811811- *
812812- * An optional `action()` function can be passed that will be invoked when
813813- * a hint is selected.
814814- */
815815- show(opts?: {
816816- /**
817817- * *Only* show hints for all elements matching this [CSS selector](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_selectors).
818818- *
819819- * @example "li, textarea"
820820- * @example "[id="my-element"]"
821821- */
822822- selector?: string;
823823- /**
824824- * *Also* show hints for all elements matching this [CSS selector](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_selectors)
825825- * as well as the default set of [hintable elements](https://glide-browser.app/hints#hintable-elements).
826826- *
827827- * @example "li, textarea"
828828- * @example "[id="my-element"]"
829829- */
830830- include?: string;
831831- /**
832832- * *Only* show hints for elements that are editable.
833833- */
834834- editable?: boolean;
835835- /**
836836- * If only one hint is generated, automatically activate it.
837837- *
838838- * @default false
839839- */
840840- auto_activate?: boolean;
841841- /**
842842- * Callback invoked when the selected hint is chosen.
843843- *
844844- * This is executed in the content process.
845845- */
846846- action?: "click" | "newtab-click" | ((target: HTMLElement) => Promise<void>);
847847- /**
848848- * Which area to generate hints for.
849849- *
850850- * - `content` - Show hints for clickable elements within the web page (links, buttons, etc.)
851851- * - `chrome` - Show hints for browser interface elements (toolbar buttons, tabs, menus, etc.)
852852- *
853853- * @default "content"
854854- */
855855- location?: glide.HintLocation;
856856- /**
857857- * Define a callback to filter the resolved hints. It is called once with the resolved hints,
858858- * and must return an array of the hints you want to include.
859859- *
860860- * An empty array may be returned but will result in an error notification indicating that no
861861- * hints were found.
862862- *
863863- * @content this function is evaluated in the content process.
864864- */
865865- pick?: (hints: glide.ContentHint[]) => glide.ContentHint[];
866866- }): void;
867867- };
868868- buf: {
869869- prefs: {
870870- /**
871871- * Set a preference for the current buffer. When navigating to a new buffer, the pref will be reset
872872- * to the previous value.
873873- *
874874- * See {@link glide.prefs.set} for more information.
875875- */
876876- set(name: string, value: string | number | boolean): void;
877877- };
878878- keymaps: {
879879- set<const LHS>(modes: GlideMode | GlideMode[], lhs: $keymapcompletions.T<LHS>, rhs: glide.ExcmdString | glide.KeymapCallback, opts?: Omit<glide.KeymapOpts, "buffer"> | undefined): void;
880880- /**
881881- * Remove the mapping of {lhs} for the {modes} where the map command applies.
882882- *
883883- * The mapping may remain defined for other modes where it applies.
884884- */
885885- del(modes: GlideMode | GlideMode[], lhs: string, opts?: Omit<glide.KeymapDeleteOpts, "buffer"> | undefined): void;
886886- };
887887- };
888888- keys: {
889889- /**
890890- * Send a key sequence to the browser, simulating physical key presses.
891891- *
892892- * The key sequence can include multiple regular keys, special keys, and modifiers.
893893- *
894894- * For example:
895895- *
896896- * ```ts
897897- * // Send a simple key sequence, each char is sent separately
898898- * await glide.keys.send("hello");
899899- *
900900- * // Send with modifiers, results in two events
901901- * // - { ctrlKey: true, key: 'a' }
902902- * // - { ctrlKey: true, key: 'c' }
903903- * await glide.keys.send("<C-a><C-c>");
904904- * ```
905905- */
906906- send<const Keys>(keyseq: $keymapcompletions.T<Keys> | {
907907- glide_key: string;
908908- }, opts?: glide.KeySendOptions): Promise<void>;
909909- /**
910910- * Returns a `Promise` that resolves to a {@link glide.KeyEvent} when the next key is pressed.
911911- *
912912- * This also prevents the key input from being processed further and does *not* invoke any associated mappings.
913913- *
914914- * If you *want* to inspect keys without preventing any default behaviour, you can use {@link glide.keys.next_passthrough}.
915915- *
916916- * Note: there can only be one `Promise` registered at any given time.
917917- *
918918- * Note: this does not include modifier keys by themselves, e.g. just pressing ctrl will not resolve
919919- * until another key is pressed, e.g. `<C-a>`.
920920- */
921921- next(): Promise<glide.KeyEvent>;
922922- /**
923923- * Returns a `Promise` that resolves to a {@link glide.KeyEvent} when the next key is pressed.
924924- *
925925- * Unlike {@link glide.keys.next}, this does not prevent key events from passing through into their original behaviour.
926926- *
927927- * Note: this does not include modifier keys by themselves, e.g. just pressing ctrl will not resolve
928928- * until another key is pressed, e.g. `<C-a>`.
929929- */
930930- next_passthrough(): Promise<glide.KeyEvent>;
931931- /**
932932- * Returns a `Promise` that resolves to a string representation of the key, when the next key is pressed.
933933- *
934934- * This also prevents the key input from being processed further and does *not* invoke any associated mappings.
935935- *
936936- * If you *want* to inspect keys without preventing any default behaviour, you can use {@link glide.keys.next_passthrough}.
937937- *
938938- * Note: there can only be one `Promise` registered at any given time.
939939- *
940940- * Note: this does not include modifier keys by themselves, e.g. just pressing ctrl will not resolve
941941- * until another key is pressed, e.g. `<C-a>`.
942942- *
943943- * @example 'd'
944944- * @example '<C-l>'
945945- */
946946- next_str(): Promise<string>;
947947- /**
948948- * Parse a single key notation into a structured object.
949949- *
950950- * This normalises special keys to be consistent but otherwise the
951951- * parsed object only containers modifiers that were in the input string.
952952- *
953953- * Shifted keys are *not* special cased, the returned key is whatever was given
954954- * in in the input.
955955- *
956956- * @example "<Space>" -> { key: "<Space>" }
957957- * @example "H" -> { key: "H" }
958958- * @example "<S-h>" -> { key: "h", shift: true }
959959- * @example "<S-H>" -> { key: "H", shift: true }
960960- * @example "<C-S-a>" -> { key: "A", shift: true, ctrl: true }
961961- * @example "<M-a>" -> { key: "a", meta: true }
962962- */
963963- parse(key_notation: string): glide.KeyNotation;
964964- };
965965- unstable: {
966966- /**
967967- * Include another file as part of your config. The given file is evluated as if it
968968- * was just another Glide config file.
969969- *
970970- * **note**: this only supports files that are directly relative to your config file,
971971- * for example, `ts:"shared.glide.ts"` or `ts:"shared/glide.ts"` would work but
972972- * `ts:"../shared/glide.ts"` will not.
973973- *
974974- * **note**: this function cannot be called from inside a file that has been included
975975- * itself, i.e. nested {@link glide.unstable.include} calls are not supported.
976976- *
977977- * @example glide.unstable.include("shared.glide.ts")
978978- */
979979- include(path: string): Promise<void>;
980980- };
981981- path: {
982982- readonly cwd: string;
983983- readonly home_dir: string;
984984- readonly temp_dir: string;
985985- readonly profile_dir: string;
986986- /**
987987- * Join all arguments together and normalize the resulting path.
988988- *
989989- * Throws an error on non-relative paths.
990990- */
991991- join(...parts: string[]): string;
992992- };
993993- fs: {
994994- /**
995995- * Read the file at the given path.
996996- *
997997- * Relative paths are resolved relative to the config directory, if no config directory is defined then relative
998998- * paths are not allowed.
999999- *
10001000- * The `encoding` must currently be set to `"utf8"` as that is the only supported encoding.
10011001- *
10021002- * @example await glide.fs.read("github.css", "utf8");
10031003- */
10041004- read(path: string, encoding: "utf8"): Promise<string>;
10051005- /**
10061006- * Write to the file at the given path.
10071007- *
10081008- * Relative paths are resolved relative to the config directory, if no config directory is defined then relative
10091009- * paths are not allowed.
10101010- *
10111011- * If the path has parent directories that do not exist, they will be created.
10121012- *
10131013- * The `contents` are written in utf8.
10141014- *
10151015- * @example await glide.fs.write("github.css", ".copilot { display: none !important }");
10161016- */
10171017- write(path: string, contents: string): Promise<void>;
10181018- /**
10191019- * Determine if the given path exists.
10201020- *
10211021- * Relative paths are resolved relative to the config directory, if no config directory is defined then relative
10221022- * paths are not allowed.
10231023- *
10241024- * @example await glide.fs.exists(`${glide.path.home_dir}/.config/foo`);
10251025- */
10261026- exists(path: string): Promise<boolean>;
10271027- /**
10281028- * Obtain information about a file, such as size, modification dates, etc.
10291029- *
10301030- * Relative paths are resolved relative to the config directory, if no config directory is defined then relative
10311031- * paths are not allowed.
10321032- *
10331033- * ```ts
10341034- * const stat = await glide.fs.stat('userChrome.css');
10351035- * stat.last_modified // 1758835015092
10361036- * stat.type // "file"
10371037- * ```
10381038- */
10391039- stat(path: string): Promise<glide.FileInfo>;
10401040- };
10411041- messengers: {
10421042- /**
10431043- * Create a {@link glide.ParentMessenger} that can be used to communicate with the content process.
10441044- *
10451045- * Communication is currently uni-directional, the content process can communicate with the main
10461046- * process, but not the other way around.
10471047- *
10481048- * Sending and receiving messages is type safe & determined from the type variable passed to this function.
10491049- * e.g. in the example below, the only message that can be sent is `my_message`.
10501050- *
10511051- * ```typescript
10521052- * // create a messenger and pass in the callback that will be invoked
10531053- * // when `messenger.send()` is called below
10541054- * const messenger = glide.messengers.create<{ my_message: null }>((message) => {
10551055- * switch (message.name) {
10561056- * case "my_message": {
10571057- * // ...
10581058- * break;
10591059- * }
10601060- * }
10611061- * });
10621062- *
10631063- * glide.keymaps.set("normal", "gt", ({ tab_id }) => {
10641064- * // note the `messenger.content.execute()` function intead of
10651065- * // the typical `glide.content.execute()` function.
10661066- * messenger.content.execute((messenger) => {
10671067- * document.addEventListener('focusin', (event) => {
10681068- * if (event.target.id === 'my-element') {
10691069- * messenger.send('my_message');
10701070- * }
10711071- * })
10721072- * }, { tab_id });
10731073- * });
10741074- * ```
10751075- */
10761076- create<Messages extends Record<string, any>>(receiver: (message: glide.Message<Messages>) => void): glide.ParentMessenger<Messages>;
10771077- };
10781078- modes: {
10791079- /**
10801080- * Register a custom `mode`.
10811081- *
10821082- * **note**: you must *also* register it as a type like so:
10831083- *
10841084- * ```typescript
10851085- * declare global {
10861086- * interface GlideModes {
10871087- * leap: "leap";
10881088- * }
10891089- * }
10901090- * glide.modes.register('leap', { caret: 'block' })
10911091- * ```
10921092- */
10931093- register<Mode extends keyof GlideModes>(mode: Mode, opts: {
10941094- caret: "block" | "line" | "underline";
10951095- }): void;
10961096- };
10971097- };
10981098- /**
10991099- * Defines all the supported modes.
11001100- *
11011101- * **note**: the key is what defines the list of supported modes, currently the value is
11021102- * not used for anything.
11031103- *
11041104- * **note**: you must *also* register it at runtime like so:
11051105- *
11061106- * ```typescript
11071107- * declare global {
11081108- * interface GlideModes {
11091109- * leap: "leap";
11101110- * }
11111111- * }
11121112- * glide.modes.register('leap', { caret: 'block' })
11131113- * ```
11141114- */
11151115- interface GlideModes {
11161116- normal: "normal";
11171117- insert: "insert";
11181118- visual: "visual";
11191119- ignore: "ignore";
11201120- command: "command";
11211121- "op-pending": "op-pending";
11221122- }
11231123- /**
11241124- * All of the supported modes.
11251125- *
11261126- * See {@link GlideModes} for more information.
11271127- */
11281128- type GlideMode = keyof GlideModes;
11291129- interface GlideGlobals {
11301130- /**
11311131- * The key notation that any `<leader>` mapping matches against.
11321132- *
11331133- * For example, a mapping defined with `<leader>r` would be matched when Space + r is pressed.
11341134- *
11351135- * @default "<Space>"
11361136- */
11371137- mapleader: string;
11381138- }
11391139- /**
11401140- * Throws an error if the given value is not truthy.
11411141- *
11421142- * Returns the value if it is truthy.
11431143- */
11441144- function ensure<T>(value: T, message?: string): T extends false | "" | 0 | 0n | null | undefined ? never : T;
11451145- /**
11461146- * Assert an invariant. An \`AssertionError\` will be thrown if `value` is falsy.
11471147- */
11481148- function assert(value: unknown, message?: string): asserts value;
11491149- /**
11501150- * The inverse of `{@link assert}`, useful for blowing up when the condition becomes `truthy`.
11511151- */
11521152- function todo_assert(value: unknown, message?: string): void;
11531153- /**
11541154- * Helper function for asserting exhaustiveness checks.
11551155- *
11561156- * You can optionally pass a second argument which will be used as the error message,
11571157- * if not given then the first argument will be stringified in the error message.
11581158- *
11591159- * ```typescript
11601160- * switch (union.type) {
11611161- * case 'type1': ...
11621162- * case 'type2': ...
11631163- * default:
11641164- * throw assert_never(union.type);
11651165- * }
11661166- */
11671167- function assert_never(x: never, detail?: string | Error): never;
11681168- class FileNotFoundError extends Error {
11691169- path: string;
11701170- constructor(message: string, props: {
11711171- path: string;
11721172- });
11731173- }
11741174- class GlideProcessError extends Error {
11751175- process: glide.CompletedProcess;
11761176- exit_code: number;
11771177- constructor(message: string, process: glide.CompletedProcess);
11781178- }
11791179- /**
11801180- * Interface used to define types for excmds, intended for declaration merging.
11811181- *
11821182- * e.g.
11831183- * ```typescript
11841184- * const cmd = glide.excmds.create(
11851185- * { name: "my_excmd", description: "..." },
11861186- * () => {
11871187- * // ...
11881188- * }
11891189- * );
11901190- * declare global {
11911191- * interface ExcmdRegistry {
11921192- * my_excmd: typeof cmd;
11931193- * }
11941194- * }
11951195- * ```
11961196- */
11971197- export interface ExcmdRegistry {
11981198- }
11991199- namespace glide {
12001200- /**
12011201- * Corresponds to {@link glide.o} or {@link glide.bo}.
12021202- */
12031203- // note: this is skipped in docs generation because we expand `glide.o`, so rendering
12041204- // the `Options` type as well would be redundant.
12051205- /// @docs-skip
12061206- export type Options = {
12071207- /**
12081208- * How long to wait until cancelling a partial keymapping execution.
12091209- *
12101210- * For example, `glide.keymaps.set('insert', 'jj', 'mode_change normal')`, after
12111211- * pressing `j` once, this option determines how long the delay should be until
12121212- * the `j` key is considered fully pressed and the mapping sequence is reset.
12131213- *
12141214- * note: this only applies in insert mode.
12151215- *
12161216- * @default 200
12171217- */
12181218- mapping_timeout: number;
12191219- /**
12201220- * Color used to briefly highlight text when it's yanked.
12211221- *
12221222- * @example "#ff6b35" // Orange highlight
12231223- * @default "#edc73b"
12241224- */
12251225- yank_highlight: glide.RGBString;
12261226- /**
12271227- * How long, in milliseconds, to highlight the selection for when it's yanked.
12281228- *
12291229- * @default 150
12301230- */
12311231- yank_highlight_time: number;
12321232- /**
12331233- * The delay, in milliseconds, before showing the which key UI.
12341234- *
12351235- * @default 300
12361236- */
12371237- which_key_delay: number;
12381238- /**
12391239- * The maximum number of entries to include in the jumplist, i.e.
12401240- * how far back in history will the jumplist store.
12411241- *
12421242- * @default 100
12431243- */
12441244- jumplist_max_entries: number;
12451245- /**
12461246- * The font size of the hint label, directly corresponds to the
12471247- * [font-size](https://developer.mozilla.org/en-US/docs/Web/CSS/font-size) property.
12481248- *
12491249- * @default "11px"
12501250- */
12511251- hint_size: string;
12521252- };
12531253- export type SpawnOptions = {
12541254- cwd?: string;
12551255- env?: Record<string, string | null>;
12561256- extend_env?: boolean;
12571257- success_codes?: number[];
12581258- /**
12591259- * If `false`, do not throw an error for non-zero exit codes.
12601260- *
12611261- * @default true
12621262- */
12631263- check_exit_code?: boolean;
12641264- /**
12651265- * Control where the stderr output is sent.
12661266- *
12671267- * If `"pipe"` then sterr is accessible through `process.stderr`.
12681268- * If `"stdout"` then sterr is mixed with stdout and accessible through `process.stdout`.
12691269- *
12701270- * @default "pipe"
12711271- */
12721272- stderr?: "pipe" | "stdout";
12731273- };
12741274- export type Process = {
12751275- pid: number;
12761276- /**
12771277- * The process exit code.
12781278- *
12791279- * `null` if it has not exited yet.
12801280- */
12811281- exit_code: number | null;
12821282- /**
12831283- * A `ReadableStream` of `string`s from the stdout pipe.
12841284- */
12851285- stdout: ReadableStream<string>;
12861286- /**
12871287- * A `ReadableStream` of `string`s from the stderr pipe.
12881288- *
12891289- * This is `null` if the `stderr: 'stdout'` option was set as the pipe will be forwarded
12901290- * to `stdout` instead.
12911291- */
12921292- stderr: ReadableStream<string> | null;
12931293- /**
12941294- * Wait for the process to exit.
12951295- */
12961296- wait(): Promise<glide.CompletedProcess>;
12971297- /**
12981298- * Kill the process.
12991299- *
13001300- * On platforms which support it, the process will be sent a `SIGTERM` signal immediately,
13011301- * so that it has a chance to terminate gracefully, and a `SIGKILL` signal if it hasn't exited
13021302- * within `timeout` milliseconds.
13031303- *
13041304- * @param {integer} [timeout=300]
13051305- * A timeout, in milliseconds, after which the process will be forcibly killed.
13061306- */
13071307- kill(timeout?: number): Promise<glide.CompletedProcess>;
13081308- };
13091309- /**
13101310- * Represents a process that has exited.
13111311- */
13121312- export type CompletedProcess = glide.Process & {
13131313- exit_code: number;
13141314- };
13151315- export type RGBString = `#${string}`;
13161316- /** A web extension tab that is guaranteed to have the `ts:id` property present. */
13171317- export type TabWithID = Omit<Browser.Tabs.Tab, "id"> & {
13181318- id: number;
13191319- };
13201320- export type KeyEvent = KeyboardEvent & {
13211321- /**
13221322- * The vim notation of the KeyEvent, e.g.
13231323- *
13241324- * `{ ctrlKey: true, key: 's' }` -> `'<C-s>'`
13251325- */
13261326- glide_key: string;
13271327- };
13281328- export type KeySendOptions = {
13291329- /**
13301330- * Send the key event(s) directly through to the builtin Firefox
13311331- * input handler and skip all of the mappings defined in Glide.
13321332- */
13331333- skip_mappings?: boolean;
13341334- };
13351335- export type KeymapCallback = (props: glide.KeymapCallbackProps) => void;
13361336- export type KeymapCallbackProps = {
13371337- /**
13381338- * The tab that the callback is being executed in.
13391339- */
13401340- tab_id: number;
13411341- };
13421342- /// @docs-skip
13431343- export type ExcmdCreateProps = {
13441344- name: string;
13451345- description?: string | undefined;
13461346- };
13471347- /// @docs-skip
13481348- export type ExcmdValue = glide.ExcmdString | glide.ExcmdCallback | glide.KeymapCallback;
13491349- /// @docs-skip
13501350- export type ExcmdCallback = (props: glide.ExcmdCallbackProps) => void;
13511351- /// @docs-skip
13521352- export type ExcmdCallbackProps = {
13531353- /**
13541354- * The tab that the callback is being executed in.
13551355- */
13561356- tab_id: number;
13571357- /**
13581358- * The args passed to the excmd.
13591359- *
13601360- * @example "foo -r" -> ["-r"]
13611361- * @example "foo -r 'string with spaces'" -> ["-r", "string with spaces"]
13621362- */
13631363- args_arr: string[];
13641364- };
13651365- /// @docs-skip
13661366- export type ExcmdString =
13671367- // builtin
13681368- GlideCommandString
13691369- // custom
13701370- | keyof ExcmdRegistry | `${keyof ExcmdRegistry} ${string}`;
13711371- /// @docs-skip
13721372- export type ContentHint = {
13731373- id: number;
13741374- x: number;
13751375- y: number;
13761376- width: number;
13771377- height: number;
13781378- element: HTMLElement;
13791379- };
13801380- export type HintLocation = "content" | "browser-ui";
13811381- export type KeyNotation = {
13821382- /**
13831383- * @example <leader>
13841384- * @example h
13851385- * @example j
13861386- * @example K
13871387- * @example L
13881388- * @example <Tab>
13891389- */
13901390- key: string;
13911391- // modifiers
13921392- alt: boolean;
13931393- ctrl: boolean;
13941394- meta: boolean;
13951395- shift: boolean;
13961396- };
13971397- export type Keymap = {
13981398- sequence: string[];
13991399- lhs: string;
14001400- rhs: glide.ExcmdValue;
14011401- description: string | undefined;
14021402- mode: GlideMode;
14031403- };
14041404- export type KeymapOpts = {
14051405- description?: string | undefined;
14061406- /**
14071407- * If `true`, applies the mapping for the current buffer instead of globally.
14081408- *
14091409- * @default {false}
14101410- */
14111411- buffer?: boolean;
14121412- /**
14131413- * If true, the key sequence will be displayed even after the mapping is executed.
14141414- *
14151415- * This is useful for mappings that are conceptually chained but are not *actually*, e.g. `diw`.
14161416- *
14171417- * @default false
14181418- */
14191419- retain_key_display?: boolean;
14201420- };
14211421- export type KeymapDeleteOpts = Pick<glide.KeymapOpts, "buffer">;
14221422- type AutocmdEvent = "UrlEnter" | "ModeChanged" | "ConfigLoaded" | "WindowLoaded" | "KeyStateChanged";
14231423- type AutocmdPatterns = {
14241424- UrlEnter: RegExp | {
14251425- hostname?: string;
14261426- };
14271427- ModeChanged: "*" | `${GlideMode | "*"}:${GlideMode | "*"}`;
14281428- ConfigLoaded: null;
14291429- WindowLoaded: null;
14301430- KeyStateChanged: null;
14311431- };
14321432- type AutocmdArgs = {
14331433- UrlEnter: {
14341434- readonly url: string;
14351435- readonly tab_id: number;
14361436- };
14371437- ModeChanged: {
14381438- /**
14391439- * This may be `null` when first loading Glide or when reloading the config.
14401440- */
14411441- readonly old_mode: GlideMode | null;
14421442- readonly new_mode: GlideMode;
14431443- };
14441444- ConfigLoaded: {};
14451445- WindowLoaded: {};
14461446- KeyStateChanged: {
14471447- readonly mode: GlideMode;
14481448- readonly sequence: string[];
14491449- readonly partial: boolean;
14501450- };
14511451- };
14521452- /// doesn't render properly right now
14531453- /// @docs-skip
14541454- type Message<Messages extends Record<string, any>> = {
14551455- [K in keyof Messages]: {
14561456- name: K;
14571457- data: Messages[K];
14581458- };
14591459- }[keyof Messages];
14601460- interface ParentMessenger<Messages extends Record<string, any>> {
14611461- content: {
14621462- /**
14631463- * The given callback is executed in the content process and is given a
14641464- * {@link glide.ContentMessenger} as the first argument.
14651465- *
14661466- * **note**: unlike {@link glide.content.execute} the callback cannot be passed custom arguments
14671467- */
14681468- execute: (callback: (messenger: glide.ContentMessenger<Messages>) => void, opts: {
14691469- /**
14701470- * The ID of the tab into which to inject.
14711471- *
14721472- * Or the tab object as returned by {@link glide.tabs.active}.
14731473- */
14741474- tab_id: number | glide.TabWithID;
14751475- }) => void;
14761476- };
14771477- }
14781478- interface ContentMessenger<Messages extends Record<string, any>> {
14791479- /**
14801480- * Send a message to the receiver in the parent process.
14811481- */
14821482- send<MessageName extends keyof Messages>(name: MessageName): void;
14831483- }
14841484- export type FileInfo = {
14851485- type: "file" | "directory" | null;
14861486- permissions: number | undefined;
14871487- last_accessed: number | undefined;
14881488- last_modified: number | undefined;
14891489- creation_time: number | undefined;
14901490- path: string | undefined;
14911491- size: number | undefined;
14921492- };
14931493- }
14941494- /**
14951495- * Dedent template function.
14961496- *
14971497- * Inspired by the https://www.npmjs.com/package/dedent package.
14981498- */
14991499- function dedent(arg: string): string;
15001500- function dedent(strings: TemplateStringsArray, ...values: unknown[]): string;
15011501- /**
15021502- * Dedent template function for syntax highlighting.
15031503- *
15041504- * Inspired by the https://www.npmjs.com/package/dedent package.
15051505- *
15061506- * note: we don't support passing in arguments to these functions as we would have to
15071507- * support escaping them, to not make it easy to accidentally cause XSS
15081508- */
15091509- function html(arg: TemplateStringsArray): string;
15101510- /**
15111511- * Dedent template function for syntax highlighting.
15121512- *
15131513- * Inspired by the https://www.npmjs.com/package/dedent package.
15141514- *
15151515- * note: we don't support passing in arguments to these functions as we would have to
15161516- * support escaping them, to not make it easy to accidentally cause XSS
15171517- */
15181518- function css(arg: TemplateStringsArray): string;
15191519- /**
15201520- * Helper functions for interacting with the DOM.
15211521- *
15221522- * **note**: this is currently only available in the main process, for
15231523- * updating the browser UI itself. it is not available in
15241524- * content processes.
15251525- */
15261526- var DOM: {
15271527- /**
15281528- * Wrapper over `document.createElement()` providing a more ergonomic API.
15291529- *
15301530- * Element properties that can be assigned directly can be provided as props:
15311531- *
15321532- * ```ts
15331533- * DOM.create_element('img', { src: '...' });
15341534- * ```
15351535- *
15361536- * You can also pass a `children` property, which will use `.replaceChildren()`:
15371537- *
15381538- * ```ts
15391539- * DOM.create_element("div", {
15401540- * children: ["text content", DOM.create_element("img", { alt: "hint" })],
15411541- * });
15421542- * ```
15431543- */
15441544- create_element<TagName extends keyof HTMLElementTagNameMap | (string & {})>(tag_name: TagName, props?: DOM.CreateElementProps<TagName extends keyof HTMLElementTagNameMap ? TagName : "div">): TagName extends keyof HTMLElementTagNameMap ? HTMLElementTagNameMap[TagName] : HTMLElement;
15451545- };
15461546- namespace DOM {
15471547- type Utils = typeof DOM;
15481548- type CreateElementProps<K extends keyof HTMLElementTagNameMap> = Omit<Partial<NonReadonly<HTMLElementTagNameMap[K]>>, "children"> & {
15491549- /**
15501550- * Can be an individual child or an array of children.
15511551- */
15521552- children?: (Node | string) | Array<Node | string>;
15531553- /**
15541554- * Set arbitrary attributes on the element.
15551555- */
15561556- attributes?: Record<string, string>;
15571557- /**
15581558- * Set specific CSS style properties.
15591559- *
15601560- * This uses the JS style naming convention for properties, e.g. `zIndex`.
15611561- */
15621562- style?: Partial<CSSStyleDeclaration>;
15631563- };
15641564- }
15651565- namespace $keymapcompletions {
15661566- /**
15671567- * This type takes in a string literal type, e.g. `<C-`, `a`, `<leader>`
15681568- * and resolves a new string literal type union type that represents as many
15691569- * valid additional entries as possible.
15701570- *
15711571- * `<C-` -> `<C-a>` | `<C-D-` ...
15721572- * `<leader>` -> `<leader>f` | `<leader><CR>` ...
15731573- * `g` -> `gg` | `gj` ...
15741574- */
15751575- type T<LHS> = LHS extends "" ? SingleKey : LHS extends "<" ? SpecialKey | `<${ModifierKey}-` : LHS extends `${infer S}<${infer M}-` ? `${S}<${M}-${Exclude<StripAngles<SingleKey>, ModifierKey>}>` | `${S}<${M}-${ModifierKey}-` | (S & {}) : LHS extends `${infer S}<` ? `${S}${SpecialKey}` | S : LHS extends `${infer S}` ? `${S}${SingleKey}` | S : LHS;
15761576- /**
15771577- * e.g. a, b, <leader>
15781578- */
15791579- type SingleKey = StringToUnion<"abcdefghijklmnoprstuvwxyz"> | StringToUnion<"ABCDEFGHIJKLMNOPRSTUVWXYZ"> | StringToUnion<"0123456789"> | SpecialKey;
15801580- type SpecialKey = "<space>" | "<tab>" | "<esc>" | "<escape>" | "<space>" | "<enter>" | "<backspace>" | "<BS>" | "<CR>" | "<leader>" | "<up>" | "<down>" | "<left>" | "<right>" | "<del>" | "<home>" | "<end>" | "<pageup>" | "<pagedown>" | "<F1>" | "<F2>" | "<F3>" | "<F4>" | "<F5>" | "<F6>" | "<F7>" | "<F8>" | "<F9>" | "<F10>" | "<F11>" | "<F12>" | "<lt>" | "<bar>" | "<bslash>";
15811581- type ModifierKey = "C" | "D" | "A" | "S";
15821582- type StringToUnion<S extends string> = S extends `${infer First}${infer Rest}` ? First | StringToUnion<Rest> : never;
15831583- /**
15841584- * `<foo>` -> `foo`
15851585- */
15861586- type StripAngles<K extends SingleKey> = K extends `<${infer Inner}>` ? Inner : K;
15871587- }
15881588-}
15891589-/// ----------------- util types -----------------
15901590-/**
15911591- * Filter out `readonly` properties from the given object type.
15921592- */
15931593-export type NonReadonly<T> = Pick<T, {
15941594- [K in keyof T]: T[K] extends Readonly<any> ? never : K;
15951595-}[keyof T]>;
15961596-// This Source Code Form is subject to the terms of the Mozilla Public
15971597-// License, v. 2.0. If a copy of the MPL was not distributed with this
15981598-// file, You can obtain one at http://mozilla.org/MPL/2.0/.
15991599-//////////////////////////////////////////////////////
16001600-// BEWARE: DO NOT EDIT MANUALLY! Changes will be lost!
16011601-//////////////////////////////////////////////////////
16021602-declare global {
16031603- const browser: Browser.Browser;
16041604- namespace Browser {
16051605- /**
16061606- * Namespace: browser.activityLog
16071607- */
16081608- namespace ActivityLog {
16091609- interface OnExtensionActivityDetailsType {
16101610- /**
16111611- * The date string when this call is triggered.
16121612- */
16131613- timeStamp: ExtensionTypes.DateType;
16141614- /**
16151615- * The type of log entry. api_call is a function call made by the extension and api_event is an event callback to the
16161616- * extension. content_script is logged when a content script is injected.
16171617- */
16181618- type: OnExtensionActivityDetailsTypeTypeEnum;
16191619- /**
16201620- * The type of view where the activity occurred. Content scripts will not have a viewType.
16211621- * Optional.
16221622- */
16231623- viewType?: OnExtensionActivityDetailsTypeViewTypeEnum;
16241624- /**
16251625- * The name of the api call or event, or the script url if this is a content or user script event.
16261626- */
16271627- name: string;
16281628- data: OnExtensionActivityDetailsTypeDataType;
16291629- }
16301630- /**
16311631- * The type of log entry. api_call is a function call made by the extension and api_event is an event callback to the
16321632- * extension. content_script is logged when a content script is injected.
16331633- */
16341634- type OnExtensionActivityDetailsTypeTypeEnum = "api_call" | "api_event" | "content_script" | "user_script";
16351635- /**
16361636- * The type of view where the activity occurred. Content scripts will not have a viewType.
16371637- */
16381638- type OnExtensionActivityDetailsTypeViewTypeEnum = "background" | "popup" | "sidebar" | "tab" | "devtools_page" | "devtools_panel";
16391639- /**
16401640- * The result of the call.
16411641- */
16421642- interface OnExtensionActivityDetailsTypeDataResultType {
16431643- [s: string]: unknown;
16441644- }
16451645- interface OnExtensionActivityDetailsTypeDataType {
16461646- /**
16471647- * A list of arguments passed to the call.
16481648- * Optional.
16491649- */
16501650- args?: unknown[];
16511651- /**
16521652- * The result of the call.
16531653- * Optional.
16541654- */
16551655- result?: OnExtensionActivityDetailsTypeDataResultType;
16561656- /**
16571657- * The tab associated with this event if it is a tab or content script.
16581658- * Optional.
16591659- */
16601660- tabId?: number;
16611661- /**
16621662- * If the type is content_script, this is the url of the script that was injected.
16631663- * Optional.
16641664- */
16651665- url?: string;
16661666- }
16671667- /**
16681668- * Receives an activityItem for each logging event.
16691669- */
16701670- interface OnExtensionActivityEvent extends Events.Event<(details: OnExtensionActivityDetailsType) => void> {
16711671- /**
16721672- * Registers an event listener <em>callback</em> to an event.
16731673- *
16741674- * @param callback Called when an event occurs. The parameters of this function depend on the type of event.
16751675- */
16761676- addListener(callback: (details: OnExtensionActivityDetailsType) => void, id: string): void;
16771677- }
16781678- interface Static {
16791679- /**
16801680- * Receives an activityItem for each logging event.
16811681- */
16821682- onExtensionActivity: OnExtensionActivityEvent;
16831683- }
16841684- }
16851685- /**
16861686- * Namespace: browser.alarms
16871687- */
16881688- namespace Alarms {
16891689- interface Alarm {
16901690- /**
16911691- * Name of this alarm.
16921692- */
16931693- name: string;
16941694- /**
16951695- * Time when the alarm is scheduled to fire, in milliseconds past the epoch.
16961696- */
16971697- scheduledTime: number;
16981698- /**
16991699- * When present, signals that the alarm triggers periodically after so many minutes.
17001700- * Optional.
17011701- */
17021702- periodInMinutes?: number;
17031703- }
17041704- /**
17051705- * Details about the alarm. The alarm first fires either at 'when' milliseconds past the epoch (if 'when' is provided),
17061706- * after 'delayInMinutes' minutes from the current time (if 'delayInMinutes' is provided instead),
17071707- * or after 'periodInMinutes' minutes from the current time (if only 'periodInMinutes' is provided).
17081708- * Users should never provide both 'when' and 'delayInMinutes'. If 'periodInMinutes' is provided,
17091709- * then the alarm recurs repeatedly after that many minutes.
17101710- */
17111711- interface CreateAlarmInfoType {
17121712- /**
17131713- * Time when the alarm is scheduled to first fire, in milliseconds past the epoch.
17141714- * Optional.
17151715- */
17161716- when?: number;
17171717- /**
17181718- * Number of minutes from the current time after which the alarm should first fire.
17191719- * Optional.
17201720- */
17211721- delayInMinutes?: number;
17221722- /**
17231723- * Number of minutes after which the alarm should recur repeatedly.
17241724- * Optional.
17251725- */
17261726- periodInMinutes?: number;
17271727- }
17281728- interface Static {
17291729- /**
17301730- * Creates an alarm. After the delay is expired, the onAlarm event is fired. If there is another alarm with the same name
17311731- * (or no name if none is specified), it will be cancelled and replaced by this alarm.
17321732- *
17331733- * @param name Optional. Optional name to identify this alarm. Defaults to the empty string.
17341734- * @param alarmInfo Details about the alarm. The alarm first fires either at 'when' milliseconds past the epoch (if 'when'
17351735- * is provided), after 'delayInMinutes' minutes from the current time (if 'delayInMinutes' is provided instead),
17361736- * or after 'periodInMinutes' minutes from the current time (if only 'periodInMinutes' is provided).
17371737- * Users should never provide both 'when' and 'delayInMinutes'. If 'periodInMinutes' is provided,
17381738- * then the alarm recurs repeatedly after that many minutes.
17391739- */
17401740- create(name: string | undefined, alarmInfo: CreateAlarmInfoType): Promise<void>;
17411741- /**
17421742- * Creates an alarm. After the delay is expired, the onAlarm event is fired. If there is another alarm with the same name
17431743- * (or no name if none is specified), it will be cancelled and replaced by this alarm.
17441744- *
17451745- * @param alarmInfo Details about the alarm. The alarm first fires either at 'when' milliseconds past the epoch (if 'when'
17461746- * is provided), after 'delayInMinutes' minutes from the current time (if 'delayInMinutes' is provided instead),
17471747- * or after 'periodInMinutes' minutes from the current time (if only 'periodInMinutes' is provided).
17481748- * Users should never provide both 'when' and 'delayInMinutes'. If 'periodInMinutes' is provided,
17491749- * then the alarm recurs repeatedly after that many minutes.
17501750- */
17511751- create(alarmInfo: CreateAlarmInfoType): Promise<void>;
17521752- /**
17531753- * Retrieves details about the specified alarm.
17541754- *
17551755- * @param name Optional. The name of the alarm to get. Defaults to the empty string.
17561756- */
17571757- get(name?: string): Promise<Alarm | undefined>;
17581758- /**
17591759- * Gets an array of all the alarms.
17601760- */
17611761- getAll(): Promise<Alarm[]>;
17621762- /**
17631763- * Clears the alarm with the given name.
17641764- *
17651765- * @param name Optional. The name of the alarm to clear. Defaults to the empty string.
17661766- */
17671767- clear(name?: string): Promise<boolean>;
17681768- /**
17691769- * Clears all alarms.
17701770- */
17711771- clearAll(): Promise<boolean>;
17721772- /**
17731773- * Fired when an alarm has expired. Useful for transient background pages.
17741774- *
17751775- * @param name The alarm that has expired.
17761776- */
17771777- onAlarm: Events.Event<(name: Alarm) => void>;
17781778- }
17791779- }
17801780- /**
17811781- * Namespace: browser.bookmarks
17821782- */
17831783- namespace Bookmarks {
17841784- /**
17851785- * Indicates the reason why this node is unmodifiable. The <var>managed</var> value indicates that this node was configured
17861786- * by the system administrator or by the custodian of a supervised user. Omitted if the node can be modified by the user
17871787- * and the extension (default).
17881788- */
17891789- type BookmarkTreeNodeUnmodifiable = "managed";
17901790- /**
17911791- * Indicates the type of a BookmarkTreeNode, which can be one of bookmark, folder or separator.
17921792- */
17931793- type BookmarkTreeNodeType = "bookmark" | "folder" | "separator";
17941794- /**
17951795- * A node (either a bookmark or a folder) in the bookmark tree. Child nodes are ordered within their parent folder.
17961796- */
17971797- interface BookmarkTreeNode {
17981798- /**
17991799- * The unique identifier for the node. IDs are unique within the current profile, and they remain valid even after the
18001800- * browser is restarted.
18011801- */
18021802- id: string;
18031803- /**
18041804- * The <code>id</code> of the parent folder. Omitted for the root node.
18051805- * Optional.
18061806- */
18071807- parentId?: string;
18081808- /**
18091809- * The 0-based position of this node within its parent folder.
18101810- * Optional.
18111811- */
18121812- index?: number;
18131813- /**
18141814- * The URL navigated to when a user clicks the bookmark. Omitted for folders.
18151815- * Optional.
18161816- */
18171817- url?: string;
18181818- /**
18191819- * The text displayed for the node.
18201820- */
18211821- title: string;
18221822- /**
18231823- * When this node was created, in milliseconds since the epoch (<code>new Date(dateAdded)</code>).
18241824- * Optional.
18251825- */
18261826- dateAdded?: number;
18271827- /**
18281828- * When the contents of this folder last changed, in milliseconds since the epoch.
18291829- * Optional.
18301830- */
18311831- dateGroupModified?: number;
18321832- /**
18331833- * Indicates the reason why this node is unmodifiable. The <var>managed</var> value indicates that this node was configured
18341834- * by the system administrator or by the custodian of a supervised user. Omitted if the node can be modified by the user
18351835- * and the extension (default).
18361836- * Optional.
18371837- */
18381838- unmodifiable?: BookmarkTreeNodeUnmodifiable;
18391839- /**
18401840- * Indicates the type of the BookmarkTreeNode, which can be one of bookmark, folder or separator.
18411841- * Optional.
18421842- */
18431843- type?: BookmarkTreeNodeType;
18441844- /**
18451845- * An ordered list of children of this node.
18461846- * Optional.
18471847- */
18481848- children?: BookmarkTreeNode[];
18491849- }
18501850- /**
18511851- * Object passed to the create() function.
18521852- */
18531853- interface CreateDetails {
18541854- /**
18551855- * Defaults to the Other Bookmarks folder.
18561856- * Optional.
18571857- */
18581858- parentId?: string;
18591859- /**
18601860- * Optional.
18611861- */
18621862- index?: number;
18631863- /**
18641864- * Optional.
18651865- */
18661866- title?: string;
18671867- /**
18681868- * Optional.
18691869- */
18701870- url?: string;
18711871- /**
18721872- * Indicates the type of BookmarkTreeNode to create, which can be one of bookmark, folder or separator.
18731873- * Optional.
18741874- */
18751875- type?: BookmarkTreeNodeType;
18761876- }
18771877- /**
18781878- * An object specifying properties and values to match when searching. Produces bookmarks matching all properties.
18791879- */
18801880- interface SearchQueryC2Type {
18811881- /**
18821882- * A string of words that are matched against bookmark URLs and titles.
18831883- * Optional.
18841884- */
18851885- query?: string;
18861886- /**
18871887- * The URL of the bookmark; matches verbatim. Note that folders have no URL.
18881888- * Optional.
18891889- */
18901890- url?: string;
18911891- /**
18921892- * The title of the bookmark; matches verbatim.
18931893- * Optional.
18941894- */
18951895- title?: string;
18961896- }
18971897- interface MoveDestinationType {
18981898- /**
18991899- * Optional.
19001900- */
19011901- parentId?: string;
19021902- /**
19031903- * Optional.
19041904- */
19051905- index?: number;
19061906- }
19071907- interface UpdateChangesType {
19081908- /**
19091909- * Optional.
19101910- */
19111911- title?: string;
19121912- /**
19131913- * Optional.
19141914- */
19151915- url?: string;
19161916- }
19171917- interface OnRemovedRemoveInfoType {
19181918- parentId: string;
19191919- index: number;
19201920- node: BookmarkTreeNode;
19211921- }
19221922- interface OnChangedChangeInfoType {
19231923- title: string;
19241924- /**
19251925- * Optional.
19261926- */
19271927- url?: string;
19281928- }
19291929- interface OnMovedMoveInfoType {
19301930- parentId: string;
19311931- index: number;
19321932- oldParentId: string;
19331933- oldIndex: number;
19341934- }
19351935- interface Static {
19361936- /**
19371937- * Retrieves the specified BookmarkTreeNode(s).
19381938- *
19391939- * @param idOrIdList A single string-valued id, or an array of string-valued ids
19401940- */
19411941- get(idOrIdList: string | string[]): Promise<BookmarkTreeNode[]>;
19421942- /**
19431943- * Retrieves the children of the specified BookmarkTreeNode id.
19441944- */
19451945- getChildren(id: string): Promise<BookmarkTreeNode[]>;
19461946- /**
19471947- * Retrieves the recently added bookmarks.
19481948- *
19491949- * @param numberOfItems The maximum number of items to return.
19501950- */
19511951- getRecent(numberOfItems: number): Promise<BookmarkTreeNode[]>;
19521952- /**
19531953- * Retrieves the entire Bookmarks hierarchy.
19541954- */
19551955- getTree(): Promise<BookmarkTreeNode[]>;
19561956- /**
19571957- * Retrieves part of the Bookmarks hierarchy, starting at the specified node.
19581958- *
19591959- * @param id The ID of the root of the subtree to retrieve.
19601960- */
19611961- getSubTree(id: string): Promise<BookmarkTreeNode[]>;
19621962- /**
19631963- * Searches for BookmarkTreeNodes matching the given query. Queries specified with an object produce BookmarkTreeNodes
19641964- * matching all specified properties.
19651965- *
19661966- * @param query Either a string of words that are matched against bookmark URLs and titles, or an object. If an object,
19671967- * the properties <code>query</code>, <code>url</code>, and <code>title</code> may be specified and bookmarks matching all
19681968- * specified properties will be produced.
19691969- */
19701970- search(query: string | SearchQueryC2Type): Promise<BookmarkTreeNode[]>;
19711971- /**
19721972- * Creates a bookmark or folder under the specified parentId. If url is NULL or missing, it will be a folder.
19731973- */
19741974- create(bookmark: CreateDetails): Promise<BookmarkTreeNode>;
19751975- /**
19761976- * Moves the specified BookmarkTreeNode to the provided location.
19771977- */
19781978- move(id: string, destination: MoveDestinationType): Promise<BookmarkTreeNode>;
19791979- /**
19801980- * Updates the properties of a bookmark or folder. Specify only the properties that you want to change; unspecified
19811981- * properties will be left unchanged. <b>Note:</b> Currently, only 'title' and 'url' are supported.
19821982- */
19831983- update(id: string, changes: UpdateChangesType): Promise<BookmarkTreeNode>;
19841984- /**
19851985- * Removes a bookmark or an empty bookmark folder.
19861986- */
19871987- remove(id: string): Promise<void>;
19881988- /**
19891989- * Recursively removes a bookmark folder.
19901990- */
19911991- removeTree(id: string): Promise<void>;
19921992- /**
19931993- * Fired when a bookmark or folder is created.
19941994- */
19951995- onCreated: Events.Event<(id: string, bookmark: BookmarkTreeNode) => void>;
19961996- /**
19971997- * Fired when a bookmark or folder is removed. When a folder is removed recursively,
19981998- * a single notification is fired for the folder, and none for its contents.
19991999- */
20002000- onRemoved: Events.Event<(id: string, removeInfo: OnRemovedRemoveInfoType) => void>;
20012001- /**
20022002- * Fired when a bookmark or folder changes. <b>Note:</b> Currently, only title and url changes trigger this.
20032003- */
20042004- onChanged: Events.Event<(id: string, changeInfo: OnChangedChangeInfoType) => void>;
20052005- /**
20062006- * Fired when a bookmark or folder is moved to a different parent folder.
20072007- */
20082008- onMoved: Events.Event<(id: string, moveInfo: OnMovedMoveInfoType) => void>;
20092009- }
20102010- }
20112011- /**
20122012- * Namespace: browser.action
20132013- */
20142014- namespace Action {
20152015- /**
20162016- * Specifies to which tab or window the value should be set, or from which one it should be retrieved.
20172017- * If no tab nor window is specified, the global value is set or retrieved.
20182018- */
20192019- interface Details {
20202020- /**
20212021- * When setting a value, it will be specific to the specified tab, and will automatically reset when the tab navigates.
20222022- * When getting, specifies the tab to get the value from; if there is no tab-specific value,
20232023- * the window one will be inherited.
20242024- * Optional.
20252025- */
20262026- tabId?: number;
20272027- /**
20282028- * When setting a value, it will be specific to the specified window. When getting, specifies the window to get the value
20292029- * from; if there is no window-specific value, the global one will be inherited.
20302030- * Optional.
20312031- */
20322032- windowId?: number;
20332033- }
20342034- type ColorArray = [
20352035- number,
20362036- number,
20372037- number,
20382038- number
20392039- ];
20402040- /**
20412041- * Pixel data for an image. Must be an ImageData object (for example, from a <code>canvas</code> element).
20422042- */
20432043- interface ImageDataType extends ImageData {
20442044- [s: string]: unknown;
20452045- }
20462046- /**
20472047- * An array of four integers in the range [0,255] that make up the RGBA color of the badge. For example,
20482048- * opaque red is <code>[255, 0, 0, 255]</code>. Can also be a string with a CSS value, with opaque red being <code>
20492049- * #FF0000</code> or <code>#F00</code>.
20502050- */
20512051- type ColorValue = string | ColorArray | null;
20522052- /**
20532053- * Information sent when a browser action is clicked.
20542054- */
20552055- interface OnClickData {
20562056- /**
20572057- * An array of keyboard modifiers that were held while the menu item was clicked.
20582058- */
20592059- modifiers: OnClickDataModifiersItemEnum[];
20602060- /**
20612061- * An integer value of button by which menu item was clicked.
20622062- * Optional.
20632063- */
20642064- button?: number;
20652065- }
20662066- interface SetTitleDetailsType extends Details {
20672067- /**
20682068- * The string the browser action should display when moused over.
20692069- */
20702070- title: string | null;
20712071- }
20722072- /**
20732073- * The collection of user-specified settings relating to an extension's action.
20742074- */
20752075- interface GetUserSettingsCallbackUserSettingsType {
20762076- /**
20772077- * Whether the extension's action icon is visible on browser windows' top-level toolbar (i.e.,
20782078- * whether the extension has been 'pinned' by the user).
20792079- * Optional.
20802080- */
20812081- isOnToolbar?: boolean;
20822082- }
20832083- interface SetIconDetailsType extends Details {
20842084- /**
20852085- * Either an ImageData object or a dictionary {size -> ImageData} representing icon to be set.
20862086- * If the icon is specified as a dictionary, the actual image to be used is chosen depending on screen's pixel density.
20872087- * If the number of image pixels that fit into one screen space unit equals <code>scale</code>, then image with size <code>
20882088- * scale</code> * 19 will be selected. Initially only scales 1 and 2 will be supported.
20892089- * At least one image must be specified. Note that 'details.imageData = foo' is equivalent to 'details.
20902090- * imageData = {'19': foo}'
20912091- * Optional.
20922092- */
20932093- imageData?: ImageDataType | Record<string, ImageDataType>;
20942094- /**
20952095- * Either a relative image path or a dictionary {size -> relative image path} pointing to icon to be set.
20962096- * If the icon is specified as a dictionary, the actual image to be used is chosen depending on screen's pixel density.
20972097- * If the number of image pixels that fit into one screen space unit equals <code>scale</code>, then image with size <code>
20982098- * scale</code> * 19 will be selected. Initially only scales 1 and 2 will be supported.
20992099- * At least one image must be specified. Note that 'details.path = foo' is equivalent to 'details.imageData = {'19': foo}'
21002100- * Optional.
21012101- */
21022102- path?: string | Record<string, string>;
21032103- }
21042104- interface SetPopupDetailsType extends Details {
21052105- /**
21062106- * The html file to show in a popup. If set to the empty string (''), no popup is shown.
21072107- */
21082108- popup: string | null;
21092109- }
21102110- interface SetBadgeTextDetailsType extends Details {
21112111- /**
21122112- * Any number of characters can be passed, but only about four can fit in the space.
21132113- */
21142114- text: string | null;
21152115- }
21162116- interface SetBadgeBackgroundColorDetailsType extends Details {
21172117- color: ColorValue;
21182118- }
21192119- interface SetBadgeTextColorDetailsType extends Details {
21202120- color: ColorValue;
21212121- }
21222122- /**
21232123- * An object with information about the popup to open.
21242124- */
21252125- interface OpenPopupOptionsType {
21262126- /**
21272127- * Defaults to the $(topic:current-window)[current window].
21282128- * Optional.
21292129- */
21302130- windowId?: number;
21312131- }
21322132- type OnClickDataModifiersItemEnum = "Shift" | "Alt" | "Command" | "Ctrl" | "MacCtrl";
21332133- interface Static {
21342134- /**
21352135- * Sets the title of the browser action. This shows up in the tooltip.
21362136- */
21372137- setTitle(details: SetTitleDetailsType): Promise<void>;
21382138- /**
21392139- * Gets the title of the browser action.
21402140- */
21412141- getTitle(details: Details): Promise<string>;
21422142- /**
21432143- * Returns the user-specified settings relating to an extension's action.
21442144- */
21452145- getUserSettings(): Promise<GetUserSettingsCallbackUserSettingsType>;
21462146- /**
21472147- * Sets the icon for the browser action. The icon can be specified either as the path to an image file or as the pixel data
21482148- * from a canvas element, or as dictionary of either one of those. Either the <b>path</b> or the <b>imageData</b>
21492149- * property must be specified.
21502150- */
21512151- setIcon(details: SetIconDetailsType): Promise<void>;
21522152- /**
21532153- * Sets the html document to be opened as a popup when the user clicks on the browser action's icon.
21542154- */
21552155- setPopup(details: SetPopupDetailsType): Promise<void>;
21562156- /**
21572157- * Gets the html document set as the popup for this browser action.
21582158- */
21592159- getPopup(details: Details): Promise<string>;
21602160- /**
21612161- * Sets the badge text for the browser action. The badge is displayed on top of the icon.
21622162- */
21632163- setBadgeText(details: SetBadgeTextDetailsType): Promise<void>;
21642164- /**
21652165- * Gets the badge text of the browser action. If no tab nor window is specified is specified,
21662166- * the global badge text is returned.
21672167- */
21682168- getBadgeText(details: Details): Promise<string>;
21692169- /**
21702170- * Sets the background color for the badge.
21712171- */
21722172- setBadgeBackgroundColor(details: SetBadgeBackgroundColorDetailsType): Promise<void>;
21732173- /**
21742174- * Gets the background color of the browser action badge.
21752175- */
21762176- getBadgeBackgroundColor(details: Details): Promise<ColorArray>;
21772177- /**
21782178- * Sets the text color for the badge.
21792179- */
21802180- setBadgeTextColor(details: SetBadgeTextColorDetailsType): Promise<void>;
21812181- /**
21822182- * Gets the text color of the browser action badge.
21832183- */
21842184- getBadgeTextColor(details: Details): Promise<ColorArray>;
21852185- /**
21862186- * Enables the browser action for a tab. By default, browser actions are enabled.
21872187- *
21882188- * @param tabId Optional. The id of the tab for which you want to modify the browser action.
21892189- */
21902190- enable(tabId?: number): Promise<void>;
21912191- /**
21922192- * Disables the browser action for a tab.
21932193- *
21942194- * @param tabId Optional. The id of the tab for which you want to modify the browser action.
21952195- */
21962196- disable(tabId?: number): Promise<void>;
21972197- /**
21982198- * Checks whether the browser action is enabled.
21992199- */
22002200- isEnabled(details: Details): Promise<boolean>;
22012201- /**
22022202- * Opens the extension popup window in the specified window.
22032203- *
22042204- * @param options Optional. An object with information about the popup to open.
22052205- */
22062206- openPopup(options?: OpenPopupOptionsType): Promise<void>;
22072207- /**
22082208- * Fired when a browser action icon is clicked. This event will not fire if the browser action has a popup.
22092209- *
22102210- * @param info Optional.
22112211- */
22122212- onClicked: Events.Event<(tab: Browser.Tabs.Tab, info: OnClickData | undefined) => void>;
22132213- }
22142214- }
22152215- /**
22162216- * Namespace: browser.browserAction
22172217- */
22182218- namespace BrowserAction {
22192219- interface Static extends Action.Static {
22202220- [s: string]: unknown;
22212221- }
22222222- }
22232223- /**
22242224- * Namespace: browser.browserSettings
22252225- */
22262226- namespace BrowserSettings {
22272227- /**
22282228- * How images should be animated in the browser.
22292229- */
22302230- type ImageAnimationBehavior = "normal" | "none" | "once";
22312231- /**
22322232- * After which mouse event context menus should popup.
22332233- */
22342234- type ContextMenuMouseEvent = "mouseup" | "mousedown";
22352235- /**
22362236- * Color management mode.
22372237- */
22382238- type ColorManagementMode = "off" | "full" | "tagged_only";
22392239- interface Static {
22402240- /**
22412241- * Allows or disallows pop-up windows from opening in response to user events.
22422242- */
22432243- allowPopupsForUserEvents: Browser.Types.Setting;
22442244- /**
22452245- * Enables or disables the browser cache.
22462246- */
22472247- cacheEnabled: Browser.Types.Setting;
22482248- /**
22492249- * This boolean setting controls whether the selected tab can be closed with a double click.
22502250- */
22512251- closeTabsByDoubleClick: Browser.Types.Setting;
22522252- /**
22532253- * Controls after which mouse event context menus popup. This setting's value is of type ContextMenuMouseEvent,
22542254- * which has possible values of <code>mouseup</code> and <code>mousedown</code>.
22552255- */
22562256- contextMenuShowEvent: Browser.Types.Setting;
22572257- /**
22582258- * Returns the value of the overridden home page. Read-only.
22592259- */
22602260- homepageOverride: Browser.Types.Setting;
22612261- /**
22622262- * Controls the behaviour of image animation in the browser. This setting's value is of type ImageAnimationBehavior,
22632263- * defaulting to <code>normal</code>.
22642264- */
22652265- imageAnimationBehavior: Browser.Types.Setting;
22662266- /**
22672267- * Returns the value of the overridden new tab page. Read-only.
22682268- */
22692269- newTabPageOverride: Browser.Types.Setting;
22702270- /**
22712271- * Controls where new tabs are opened. `afterCurrent` will open all new tabs next to the current tab,
22722272- * `relatedAfterCurrent` will open only related tabs next to the current tab, and `atEnd` will open all tabs at the end of
22732273- * the tab strip. The default is `relatedAfterCurrent`.
22742274- */
22752275- newTabPosition: Browser.Types.Setting;
22762276- /**
22772277- * This boolean setting controls whether bookmarks are opened in the current tab or in a new tab.
22782278- */
22792279- openBookmarksInNewTabs: Browser.Types.Setting;
22802280- /**
22812281- * This boolean setting controls whether search results are opened in the current tab or in a new tab.
22822282- */
22832283- openSearchResultsInNewTabs: Browser.Types.Setting;
22842284- /**
22852285- * This boolean setting controls whether urlbar results are opened in the current tab or in a new tab.
22862286- */
22872287- openUrlbarResultsInNewTabs: Browser.Types.Setting;
22882288- /**
22892289- * Disables webAPI notifications.
22902290- */
22912291- webNotificationsDisabled: Browser.Types.Setting;
22922292- /**
22932293- * This setting controls whether the user-chosen colors override the page's colors.
22942294- */
22952295- overrideDocumentColors: Browser.Types.Setting;
22962296- /**
22972297- * This setting controls whether a light or dark color scheme overrides the page's preferred color scheme.
22982298- */
22992299- overrideContentColorScheme: Browser.Types.Setting;
23002300- /**
23012301- * This setting controls whether the document's fonts are used.
23022302- */
23032303- useDocumentFonts: Browser.Types.Setting;
23042304- /**
23052305- * This boolean setting controls whether zoom is applied to the full page or to text only.
23062306- */
23072307- zoomFullPage: Browser.Types.Setting;
23082308- /**
23092309- * This boolean setting controls whether zoom is applied on a per-site basis or to the current tab only. If privacy.
23102310- * resistFingerprinting is true, this setting has no effect and zoom is applied to the current tab only.
23112311- */
23122312- zoomSiteSpecific: Browser.Types.Setting;
23132313- colorManagement: ColorManagement.Static;
23142314- }
23152315- }
23162316- /**
23172317- * Namespace: browser.browsingData
23182318- */
23192319- namespace BrowsingData {
23202320- /**
23212321- * Options that determine exactly what data will be removed.
23222322- */
23232323- interface RemovalOptions {
23242324- /**
23252325- * Remove data accumulated on or after this date, represented in milliseconds since the epoch (accessible via the <code>
23262326- * getTime</code> method of the JavaScript <code>Date</code> object). If absent, defaults to 0 (which would remove all
23272327- * browsing data).
23282328- * Optional.
23292329- */
23302330- since?: ExtensionTypes.DateType;
23312331- /**
23322332- * Only remove data associated with these hostnames (only applies to cookies and localStorage).
23332333- * Optional.
23342334- */
23352335- hostnames?: string[];
23362336- /**
23372337- * Only remove data associated with this specific cookieStoreId.
23382338- * Optional.
23392339- */
23402340- cookieStoreId?: string;
23412341- /**
23422342- * An object whose properties specify which origin types ought to be cleared. If this object isn't specified,
23432343- * it defaults to clearing only "unprotected" origins. Please ensure that you <em>really</em>
23442344- * want to remove application data before adding 'protectedWeb' or 'extensions'.
23452345- * Optional.
23462346- */
23472347- originTypes?: RemovalOptionsOriginTypesType;
23482348- }
23492349- /**
23502350- * A set of data types. Missing data types are interpreted as <code>false</code>.
23512351- */
23522352- interface DataTypeSet {
23532353- /**
23542354- * The browser's cache. Note: when removing data, this clears the <em>entire</em> cache: it is not limited to the range you
23552355- * specify.
23562356- * Optional.
23572357- */
23582358- cache?: boolean;
23592359- /**
23602360- * The browser's cookies.
23612361- * Optional.
23622362- */
23632363- cookies?: boolean;
23642364- /**
23652365- * The browser's download list.
23662366- * Optional.
23672367- */
23682368- downloads?: boolean;
23692369- /**
23702370- * The browser's stored form data.
23712371- * Optional.
23722372- */
23732373- formData?: boolean;
23742374- /**
23752375- * The browser's history.
23762376- * Optional.
23772377- */
23782378- history?: boolean;
23792379- /**
23802380- * Websites' IndexedDB data.
23812381- * Optional.
23822382- */
23832383- indexedDB?: boolean;
23842384- /**
23852385- * Websites' local storage data.
23862386- * Optional.
23872387- */
23882388- localStorage?: boolean;
23892389- /**
23902390- * Server-bound certificates.
23912391- * Optional.
23922392- */
23932393- serverBoundCertificates?: boolean;
23942394- /**
23952395- * Stored passwords.
23962396- * Optional.
23972397- */
23982398- passwords?: boolean;
23992399- /**
24002400- * Plugins' data.
24012401- * Optional.
24022402- */
24032403- pluginData?: boolean;
24042404- /**
24052405- * Service Workers.
24062406- * Optional.
24072407- */
24082408- serviceWorkers?: boolean;
24092409- }
24102410- interface SettingsCallbackResultType {
24112411- options: RemovalOptions;
24122412- /**
24132413- * All of the types will be present in the result, with values of <code>true</code> if they are both selected to be removed
24142414- * and permitted to be removed, otherwise <code>false</code>.
24152415- */
24162416- dataToRemove: DataTypeSet;
24172417- /**
24182418- * All of the types will be present in the result, with values of <code>true</code> if they are permitted to be removed (e.
24192419- * g., by enterprise policy) and <code>false</code> if not.
24202420- */
24212421- dataRemovalPermitted: DataTypeSet;
24222422- }
24232423- /**
24242424- * An object whose properties specify which origin types ought to be cleared. If this object isn't specified,
24252425- * it defaults to clearing only "unprotected" origins. Please ensure that you <em>really</em>
24262426- * want to remove application data before adding 'protectedWeb' or 'extensions'.
24272427- */
24282428- interface RemovalOptionsOriginTypesType {
24292429- /**
24302430- * Normal websites.
24312431- * Optional.
24322432- */
24332433- unprotectedWeb?: boolean;
24342434- /**
24352435- * Websites that have been installed as hosted applications (be careful!).
24362436- * Optional.
24372437- */
24382438- protectedWeb?: boolean;
24392439- /**
24402440- * Extensions and packaged applications a user has installed (be _really_ careful!).
24412441- * Optional.
24422442- */
24432443- extension?: boolean;
24442444- }
24452445- interface Static {
24462446- /**
24472447- * Reports which types of data are currently selected in the 'Clear browsing data' settings UI.
24482448- * Note: some of the data types included in this API are not available in the settings UI,
24492449- * and some UI settings control more than one data type listed here.
24502450- */
24512451- settings(): Promise<SettingsCallbackResultType>;
24522452- /**
24532453- * Clears various types of browsing data stored in a user's profile.
24542454- *
24552455- * @param dataToRemove The set of data types to remove.
24562456- * @returns Called when deletion has completed.
24572457- */
24582458- remove(options: RemovalOptions, dataToRemove: DataTypeSet): Promise<void>;
24592459- /**
24602460- * Clears the browser's cache.
24612461- *
24622462- * @returns Called when the browser's cache has been cleared.
24632463- */
24642464- removeCache(options: RemovalOptions): Promise<void>;
24652465- /**
24662466- * Clears the browser's cookies and server-bound certificates modified within a particular timeframe.
24672467- *
24682468- * @returns Called when the browser's cookies and server-bound certificates have been cleared.
24692469- */
24702470- removeCookies(options: RemovalOptions): Promise<void>;
24712471- /**
24722472- * Clears the browser's list of downloaded files (<em>not</em> the downloaded files themselves).
24732473- *
24742474- * @returns Called when the browser's list of downloaded files has been cleared.
24752475- */
24762476- removeDownloads(options: RemovalOptions): Promise<void>;
24772477- /**
24782478- * Clears the browser's stored form data (autofill).
24792479- *
24802480- * @returns Called when the browser's form data has been cleared.
24812481- */
24822482- removeFormData(options: RemovalOptions): Promise<void>;
24832483- /**
24842484- * Clears the browser's history.
24852485- *
24862486- * @returns Called when the browser's history has cleared.
24872487- */
24882488- removeHistory(options: RemovalOptions): Promise<void>;
24892489- /**
24902490- * Clears websites' local storage data.
24912491- *
24922492- * @returns Called when websites' local storage has been cleared.
24932493- */
24942494- removeLocalStorage(options: RemovalOptions): Promise<void>;
24952495- /**
24962496- * Clears plugins' data.
24972497- *
24982498- * @returns Called when plugins' data has been cleared.
24992499- */
25002500- removePluginData(options: RemovalOptions): Promise<void>;
25012501- /**
25022502- * Clears the browser's stored passwords.
25032503- *
25042504- * @returns Called when the browser's passwords have been cleared.
25052505- */
25062506- removePasswords(options: RemovalOptions): Promise<void>;
25072507- }
25082508- }
25092509- /**
25102510- * Namespace: browser.captivePortal
25112511- */
25122512- namespace CaptivePortal {
25132513- interface OnStateChangedDetailsType {
25142514- /**
25152515- * The current captive portal state.
25162516- */
25172517- state: OnStateChangedDetailsTypeStateEnum;
25182518- }
25192519- type OnConnectivityAvailableStatusEnum = "captive" | "clear";
25202520- /**
25212521- * The current captive portal state.
25222522- */
25232523- type OnStateChangedDetailsTypeStateEnum = "unknown" | "not_captive" | "unlocked_portal" | "locked_portal";
25242524- interface Static {
25252525- /**
25262526- * Returns the current portal state, one of `unknown`, `not_captive`, `unlocked_portal`, `locked_portal`.
25272527- */
25282528- getState(): Promise<"unknown" | "not_captive" | "unlocked_portal" | "locked_portal">;
25292529- /**
25302530- * Returns the time difference between NOW and the last time a request was completed in milliseconds.
25312531- */
25322532- getLastChecked(): Promise<number>;
25332533- /**
25342534- * Fired when the captive portal state changes.
25352535- */
25362536- onStateChanged: Events.Event<(details: OnStateChangedDetailsType) => void>;
25372537- /**
25382538- * This notification will be emitted when the captive portal service has determined that we can connect to the internet.
25392539- * The service will pass either `captive` if there is an unlocked captive portal present,
25402540- * or `clear` if no captive portal was detected.
25412541- */
25422542- onConnectivityAvailable: Events.Event<(status: OnConnectivityAvailableStatusEnum) => void>;
25432543- /**
25442544- * Return the canonical captive-portal detection URL. Read-only.
25452545- */
25462546- canonicalURL: Browser.Types.Setting;
25472547- }
25482548- }
25492549- /**
25502550- * Namespace: browser.clipboard
25512551- */
25522552- namespace Clipboard {
25532553- /**
25542554- * The type of imageData.
25552555- */
25562556- type SetImageDataImageTypeEnum = "jpeg" | "png";
25572557- interface Static {
25582558- /**
25592559- * Copy an image to the clipboard. The image is re-encoded before it is written to the clipboard. If the image is invalid,
25602560- * the clipboard is not modified.
25612561- *
25622562- * @param imageData The image data to be copied.
25632563- * @param imageType The type of imageData.
25642564- */
25652565- setImageData(imageData: ArrayBuffer, imageType: SetImageDataImageTypeEnum): Promise<void>;
25662566- }
25672567- }
25682568- /**
25692569- * Namespace: browser.commands
25702570- */
25712571- namespace Commands {
25722572- interface Command {
25732573- /**
25742574- * The name of the Extension Command
25752575- * Optional.
25762576- */
25772577- name?: string;
25782578- /**
25792579- * The Extension Command description
25802580- * Optional.
25812581- */
25822582- description?: string;
25832583- /**
25842584- * The shortcut active for this command, or blank if not active.
25852585- * Optional.
25862586- */
25872587- shortcut?: string;
25882588- }
25892589- /**
25902590- * The new description for the command.
25912591- */
25922592- interface UpdateDetailType {
25932593- /**
25942594- * The name of the command.
25952595- */
25962596- name: string;
25972597- /**
25982598- * The new description for the command.
25992599- * Optional.
26002600- */
26012601- description?: string;
26022602- /**
26032603- * Optional.
26042604- */
26052605- shortcut?: string;
26062606- }
26072607- interface OnChangedChangeInfoType {
26082608- /**
26092609- * The name of the shortcut.
26102610- */
26112611- name: string;
26122612- /**
26132613- * The new shortcut active for this command, or blank if not active.
26142614- */
26152615- newShortcut: string;
26162616- /**
26172617- * The old shortcut which is no longer active for this command, or blank if the shortcut was previously inactive.
26182618- */
26192619- oldShortcut: string;
26202620- }
26212621- interface Static {
26222622- /**
26232623- * Update the details of an already defined command.
26242624- *
26252625- * @param detail The new description for the command.
26262626- */
26272627- update(detail: UpdateDetailType): Promise<void>;
26282628- /**
26292629- * Reset a command's details to what is specified in the manifest.
26302630- *
26312631- * @param name The name of the command.
26322632- */
26332633- reset(name: string): Promise<void>;
26342634- /**
26352635- * Returns all the registered extension commands for this extension and their shortcut (if active).
26362636- *
26372637- * @returns Called to return the registered commands.
26382638- */
26392639- getAll(): Promise<Command[]>;
26402640- /**
26412641- * Open extension shortcuts configuration page.
26422642- */
26432643- openShortcutSettings(): void;
26442644- /**
26452645- * Fired when a registered command is activated using a keyboard shortcut.
26462646- *
26472647- * @param tab Optional. Details of the $(ref:tabs.Tab) where the command was activated.
26482648- */
26492649- onCommand: Events.Event<(command: string, tab: Browser.Tabs.Tab | undefined) => void>;
26502650- /**
26512651- * Fired when a registered command's shortcut is changed.
26522652- */
26532653- onChanged: Events.Event<(changeInfo: OnChangedChangeInfoType) => void>;
26542654- }
26552655- }
26562656- /**
26572657- * Namespace: browser.contentScripts
26582658- */
26592659- namespace ContentScripts {
26602660- /**
26612661- * Details of a content script registered programmatically
26622662- */
26632663- interface RegisteredContentScriptOptions {
26642664- matches: Browser.Manifest.MatchPattern[];
26652665- /**
26662666- * Optional.
26672667- */
26682668- excludeMatches?: Browser.Manifest.MatchPattern[];
26692669- /**
26702670- * Optional.
26712671- */
26722672- includeGlobs?: string[];
26732673- /**
26742674- * Optional.
26752675- */
26762676- excludeGlobs?: string[];
26772677- /**
26782678- * The list of CSS files to inject
26792679- * Optional.
26802680- */
26812681- css?: Browser.ExtensionTypes.ExtensionFileOrCode[];
26822682- /**
26832683- * The list of JS files to inject
26842684- * Optional.
26852685- */
26862686- js?: Browser.ExtensionTypes.ExtensionFileOrCode[];
26872687- /**
26882688- * If allFrames is <code>true</code>, implies that the JavaScript or CSS should be injected into all frames of current page.
26892689- * By default, it's <code>false</code> and is only injected into the top frame.
26902690- * Optional.
26912691- */
26922692- allFrames?: boolean;
26932693- /**
26942694- * If matchAboutBlank is true, then the code is also injected in about:blank and about:srcdoc frames if your extension has
26952695- * access to its parent document. Ignored if matchOriginAsFallback is specified. By default it is <code>false</code>.
26962696- * Optional.
26972697- */
26982698- matchAboutBlank?: boolean;
26992699- /**
27002700- * If matchOriginAsFallback is true, then the code is also injected in about:, data:,
27012701- * blob: when their origin matches the pattern in 'matches', even if the actual document origin is opaque (due to the use
27022702- * of CSP sandbox or iframe sandbox). Match patterns in 'matches' must specify a wildcard path glob. By default it is <code>
27032703- * false</code>.
27042704- * Optional.
27052705- */
27062706- matchOriginAsFallback?: boolean;
27072707- /**
27082708- * The soonest that the JavaScript or CSS will be injected into the tab. Defaults to "document_idle".
27092709- * Optional.
27102710- */
27112711- runAt?: Browser.ExtensionTypes.RunAt;
27122712- /**
27132713- * The JavaScript world for a script to execute within. Defaults to "ISOLATED".
27142714- * Optional.
27152715- */
27162716- world?: Browser.ExtensionTypes.ExecutionWorld;
27172717- /**
27182718- * limit the set of matched tabs to those that belong to the given cookie store id
27192719- * Optional.
27202720- */
27212721- cookieStoreId?: string[] | string;
27222722- }
27232723- /**
27242724- * An object that represents a content script registered programmatically
27252725- */
27262726- interface RegisteredContentScript {
27272727- /**
27282728- * Unregister a content script registered programmatically
27292729- */
27302730- unregister(): Promise<void>;
27312731- }
27322732- interface Static {
27332733- /**
27342734- * Register a content script programmatically
27352735- */
27362736- register(contentScriptOptions: RegisteredContentScriptOptions): Promise<RegisteredContentScript>;
27372737- }
27382738- }
27392739- /**
27402740- * Namespace: browser.contextualIdentities
27412741- */
27422742- namespace ContextualIdentities {
27432743- /**
27442744- * Represents information about a contextual identity.
27452745- */
27462746- interface ContextualIdentity {
27472747- /**
27482748- * The name of the contextual identity.
27492749- */
27502750- name: string;
27512751- /**
27522752- * The icon name of the contextual identity.
27532753- */
27542754- icon: string;
27552755- /**
27562756- * The icon url of the contextual identity.
27572757- */
27582758- iconUrl: string;
27592759- /**
27602760- * The color name of the contextual identity.
27612761- */
27622762- color: string;
27632763- /**
27642764- * The color hash of the contextual identity.
27652765- */
27662766- colorCode: string;
27672767- /**
27682768- * The cookie store ID of the contextual identity.
27692769- */
27702770- cookieStoreId: string;
27712771- }
27722772- /**
27732773- * Information to filter the contextual identities being retrieved.
27742774- */
27752775- interface QueryDetailsType {
27762776- /**
27772777- * Filters the contextual identity by name.
27782778- * Optional.
27792779- */
27802780- name?: string;
27812781- }
27822782- /**
27832783- * Details about the contextual identity being created.
27842784- */
27852785- interface CreateDetailsType {
27862786- /**
27872787- * The name of the contextual identity.
27882788- */
27892789- name: string;
27902790- /**
27912791- * The color of the contextual identity.
27922792- */
27932793- color: string;
27942794- /**
27952795- * The icon of the contextual identity.
27962796- */
27972797- icon: string;
27982798- }
27992799- /**
28002800- * Details about the contextual identity being created.
28012801- */
28022802- interface UpdateDetailsType {
28032803- /**
28042804- * The name of the contextual identity.
28052805- * Optional.
28062806- */
28072807- name?: string;
28082808- /**
28092809- * The color of the contextual identity.
28102810- * Optional.
28112811- */
28122812- color?: string;
28132813- /**
28142814- * The icon of the contextual identity.
28152815- * Optional.
28162816- */
28172817- icon?: string;
28182818- }
28192819- interface OnUpdatedChangeInfoType {
28202820- /**
28212821- * Contextual identity that has been updated
28222822- */
28232823- contextualIdentity: ContextualIdentity;
28242824- }
28252825- interface OnCreatedChangeInfoType {
28262826- /**
28272827- * Contextual identity that has been created
28282828- */
28292829- contextualIdentity: ContextualIdentity;
28302830- }
28312831- interface OnRemovedChangeInfoType {
28322832- /**
28332833- * Contextual identity that has been removed
28342834- */
28352835- contextualIdentity: ContextualIdentity;
28362836- }
28372837- interface Static {
28382838- /**
28392839- * Retrieves information about a single contextual identity.
28402840- *
28412841- * @param cookieStoreId The ID of the contextual identity cookie store.
28422842- */
28432843- get(cookieStoreId: string): Promise<ContextualIdentity>;
28442844- /**
28452845- * Retrieves all contextual identities
28462846- *
28472847- * @param details Information to filter the contextual identities being retrieved.
28482848- */
28492849- query(details: QueryDetailsType): Promise<ContextualIdentity[]>;
28502850- /**
28512851- * Creates a contextual identity with the given data.
28522852- *
28532853- * @param details Details about the contextual identity being created.
28542854- */
28552855- create(details: CreateDetailsType): Promise<ContextualIdentity>;
28562856- /**
28572857- * Updates a contextual identity with the given data.
28582858- *
28592859- * @param cookieStoreId The ID of the contextual identity cookie store.
28602860- * @param details Details about the contextual identity being created.
28612861- */
28622862- update(cookieStoreId: string, details: UpdateDetailsType): Promise<ContextualIdentity>;
28632863- /**
28642864- * Reorder one or more contextual identities by their cookieStoreIDs to a given position.
28652865- *
28662866- * @param cookieStoreIds The ID or list of IDs of the contextual identity cookie stores.
28672867- * @param position The position the contextual identity should move to.
28682868- */
28692869- move(cookieStoreIds: string | string[], position: number): Promise<void>;
28702870- /**
28712871- * Deletes a contextual identity by its cookie Store ID.
28722872- *
28732873- * @param cookieStoreId The ID of the contextual identity cookie store.
28742874- */
28752875- remove(cookieStoreId: string): Promise<ContextualIdentity>;
28762876- /**
28772877- * Fired when a container is updated.
28782878- */
28792879- onUpdated: Events.Event<(changeInfo: OnUpdatedChangeInfoType) => void>;
28802880- /**
28812881- * Fired when a new container is created.
28822882- */
28832883- onCreated: Events.Event<(changeInfo: OnCreatedChangeInfoType) => void>;
28842884- /**
28852885- * Fired when a container is removed.
28862886- */
28872887- onRemoved: Events.Event<(changeInfo: OnRemovedChangeInfoType) => void>;
28882888- }
28892889- }
28902890- /**
28912891- * Namespace: browser.cookies
28922892- */
28932893- namespace Cookies {
28942894- /**
28952895- * A cookie's 'SameSite' state (https://tools.ietf.org/html/draft-west-first-party-cookies).
28962896- * 'no_restriction' corresponds to a cookie set without a 'SameSite' attribute, 'lax' to 'SameSite=Lax',
28972897- * and 'strict' to 'SameSite=Strict'.
28982898- */
28992899- type SameSiteStatus = "unspecified" | "no_restriction" | "lax" | "strict";
29002900- /**
29012901- * The description of the storage partition of a cookie. This object may be omitted (null) if a cookie is not partitioned.
29022902- */
29032903- interface PartitionKey {
29042904- /**
29052905- * The first-party URL of the cookie, if the cookie is in storage partitioned by the top-level site.
29062906- * Optional.
29072907- */
29082908- topLevelSite?: string;
29092909- /**
29102910- * Whether or not the cookie is in a third-party context, respecting ancestor chains.
29112911- * Optional.
29122912- */
29132913- hasCrossSiteAncestor?: boolean;
29142914- }
29152915- /**
29162916- * Represents information about an HTTP cookie.
29172917- */
29182918- interface Cookie {
29192919- /**
29202920- * The name of the cookie.
29212921- */
29222922- name: string;
29232923- /**
29242924- * The value of the cookie.
29252925- */
29262926- value: string;
29272927- /**
29282928- * The domain of the cookie (e.g. "www.google.com", "example.com").
29292929- */
29302930- domain: string;
29312931- /**
29322932- * True if the cookie is a host-only cookie (i.e. a request's host must exactly match the domain of the cookie).
29332933- */
29342934- hostOnly: boolean;
29352935- /**
29362936- * The path of the cookie.
29372937- */
29382938- path: string;
29392939- /**
29402940- * True if the cookie is marked as Secure (i.e. its scope is limited to secure channels, typically HTTPS).
29412941- */
29422942- secure: boolean;
29432943- /**
29442944- * True if the cookie is marked as HttpOnly (i.e. the cookie is inaccessible to client-side scripts).
29452945- */
29462946- httpOnly: boolean;
29472947- /**
29482948- * The cookie's same-site status (i.e. whether the cookie is sent with cross-site requests).
29492949- */
29502950- sameSite: SameSiteStatus;
29512951- /**
29522952- * True if the cookie is a session cookie, as opposed to a persistent cookie with an expiration date.
29532953- */
29542954- session: boolean;
29552955- /**
29562956- * The expiration date of the cookie as the number of seconds since the UNIX epoch. Not provided for session cookies.
29572957- * Optional.
29582958- */
29592959- expirationDate?: number;
29602960- /**
29612961- * The ID of the cookie store containing this cookie, as provided in getAllCookieStores().
29622962- */
29632963- storeId: string;
29642964- /**
29652965- * The first-party domain of the cookie.
29662966- */
29672967- firstPartyDomain: string;
29682968- /**
29692969- * The cookie's storage partition, if any. null if not partitioned.
29702970- * Optional.
29712971- */
29722972- partitionKey?: PartitionKey;
29732973- }
29742974- /**
29752975- * Represents a cookie store in the browser. An incognito mode window, for instance, uses a separate cookie store from a
29762976- * non-incognito window.
29772977- */
29782978- interface CookieStore {
29792979- /**
29802980- * The unique identifier for the cookie store.
29812981- */
29822982- id: string;
29832983- /**
29842984- * Identifiers of all the browser tabs that share this cookie store.
29852985- */
29862986- tabIds: number[];
29872987- /**
29882988- * Indicates if this is an incognito cookie store
29892989- */
29902990- incognito: boolean;
29912991- }
29922992- /**
29932993- * The underlying reason behind the cookie's change. If a cookie was inserted, or removed via an explicit call to
29942994- * $(ref:cookies.remove), "cause" will be "explicit". If a cookie was automatically removed due to expiry,
29952995- * "cause" will be "expired". If a cookie was removed due to being overwritten with an already-expired expiration date,
29962996- * "cause" will be set to "expired_overwrite". If a cookie was automatically removed due to garbage collection,
29972997- * "cause" will be "evicted". If a cookie was automatically removed due to a "set" call that overwrote it,
29982998- * "cause" will be "overwrite". Plan your response accordingly.
29992999- */
30003000- type OnChangedCause = "evicted" | "expired" | "explicit" | "expired_overwrite" | "overwrite";
30013001- /**
30023002- * Details to identify the cookie being retrieved.
30033003- */
30043004- interface GetDetailsType {
30053005- /**
30063006- * The URL with which the cookie to retrieve is associated. This argument may be a full URL,
30073007- * in which case any data following the URL path (e.g. the query string) is simply ignored.
30083008- * If host permissions for this URL are not specified in the manifest file, the API call will fail.
30093009- */
30103010- url: string;
30113011- /**
30123012- * The name of the cookie to retrieve.
30133013- */
30143014- name: string;
30153015- /**
30163016- * The ID of the cookie store in which to look for the cookie. By default, the current execution context's cookie store
30173017- * will be used.
30183018- * Optional.
30193019- */
30203020- storeId?: string;
30213021- /**
30223022- * The first-party domain which the cookie to retrieve is associated. This attribute is required if First-Party Isolation
30233023- * is enabled.
30243024- * Optional.
30253025- */
30263026- firstPartyDomain?: string;
30273027- /**
30283028- * The storage partition, if the cookie is part of partitioned storage. By default, only non-partitioned cookies are
30293029- * returned.
30303030- * Optional.
30313031- */
30323032- partitionKey?: PartitionKey;
30333033- }
30343034- /**
30353035- * Information to filter the cookies being retrieved.
30363036- */
30373037- interface GetAllDetailsType {
30383038- /**
30393039- * Restricts the retrieved cookies to those that would match the given URL.
30403040- * Optional.
30413041- */
30423042- url?: string;
30433043- /**
30443044- * Filters the cookies by name.
30453045- * Optional.
30463046- */
30473047- name?: string;
30483048- /**
30493049- * Restricts the retrieved cookies to those whose domains match or are subdomains of this one.
30503050- * Optional.
30513051- */
30523052- domain?: string;
30533053- /**
30543054- * Restricts the retrieved cookies to those whose path exactly matches this string.
30553055- * Optional.
30563056- */
30573057- path?: string;
30583058- /**
30593059- * Filters the cookies by their Secure property.
30603060- * Optional.
30613061- */
30623062- secure?: boolean;
30633063- /**
30643064- * Filters out session vs. persistent cookies.
30653065- * Optional.
30663066- */
30673067- session?: boolean;
30683068- /**
30693069- * The cookie store to retrieve cookies from. If omitted, the current execution context's cookie store will be used.
30703070- * Optional.
30713071- */
30723072- storeId?: string;
30733073- /**
30743074- * Restricts the retrieved cookies to those whose first-party domains match this one.
30753075- * This attribute is required if First-Party Isolation is enabled. To not filter by a specific first-party domain,
30763076- * use `null` or `undefined`.
30773077- * Optional.
30783078- */
30793079- firstPartyDomain?: string | null;
30803080- /**
30813081- * Selects a specific storage partition to look up cookies. Defaults to null, in which case only non-partitioned cookies
30823082- * are retrieved. If an object iis passed, partitioned cookies are also included, and filtered based on the keys present in
30833083- * the given PartitionKey description. An empty object ({}) returns all cookies (partitioned + unpartitioned),
30843084- * a non-empty object (e.g. {topLevelSite: '...'}) only returns cookies whose partition match all given attributes.
30853085- * Optional.
30863086- */
30873087- partitionKey?: PartitionKey;
30883088- }
30893089- /**
30903090- * Details about the cookie being set.
30913091- */
30923092- interface SetDetailsType {
30933093- /**
30943094- * The request-URI to associate with the setting of the cookie. This value can affect the default domain and path values of
30953095- * the created cookie. If host permissions for this URL are not specified in the manifest file, the API call will fail.
30963096- */
30973097- url: string;
30983098- /**
30993099- * The name of the cookie. Empty by default if omitted.
31003100- * Optional.
31013101- */
31023102- name?: string;
31033103- /**
31043104- * The value of the cookie. Empty by default if omitted.
31053105- * Optional.
31063106- */
31073107- value?: string;
31083108- /**
31093109- * The domain of the cookie. If omitted, the cookie becomes a host-only cookie.
31103110- * Optional.
31113111- */
31123112- domain?: string;
31133113- /**
31143114- * The path of the cookie. Defaults to the path portion of the url parameter.
31153115- * Optional.
31163116- */
31173117- path?: string;
31183118- /**
31193119- * Whether the cookie should be marked as Secure. Defaults to false.
31203120- * Optional.
31213121- */
31223122- secure?: boolean;
31233123- /**
31243124- * Whether the cookie should be marked as HttpOnly. Defaults to false.
31253125- * Optional.
31263126- */
31273127- httpOnly?: boolean;
31283128- /**
31293129- * The cookie's same-site status.
31303130- * Optional.
31313131- */
31323132- sameSite?: SameSiteStatus;
31333133- /**
31343134- * The expiration date of the cookie as the number of seconds since the UNIX epoch. If omitted,
31353135- * the cookie becomes a session cookie.
31363136- * Optional.
31373137- */
31383138- expirationDate?: number;
31393139- /**
31403140- * The ID of the cookie store in which to set the cookie. By default, the cookie is set in the current execution context's
31413141- * cookie store.
31423142- * Optional.
31433143- */
31443144- storeId?: string;
31453145- /**
31463146- * The first-party domain of the cookie. This attribute is required if First-Party Isolation is enabled.
31473147- * Optional.
31483148- */
31493149- firstPartyDomain?: string;
31503150- /**
31513151- * The storage partition, if the cookie is part of partitioned storage. By default, non-partitioned storage is used.
31523152- * Optional.
31533153- */
31543154- partitionKey?: PartitionKey;
31553155- }
31563156- /**
31573157- * Information to identify the cookie to remove.
31583158- */
31593159- interface RemoveDetailsType {
31603160- /**
31613161- * The URL associated with the cookie. If host permissions for this URL are not specified in the manifest file,
31623162- * the API call will fail.
31633163- */
31643164- url: string;
31653165- /**
31663166- * The name of the cookie to remove.
31673167- */
31683168- name: string;
31693169- /**
31703170- * The ID of the cookie store to look in for the cookie. If unspecified, the cookie is looked for by default in the current
31713171- * execution context's cookie store.
31723172- * Optional.
31733173- */
31743174- storeId?: string;
31753175- /**
31763176- * The first-party domain associated with the cookie. This attribute is required if First-Party Isolation is enabled.
31773177- * Optional.
31783178- */
31793179- firstPartyDomain?: string;
31803180- /**
31813181- * The storage partition, if the cookie is part of partitioned storage. By default, non-partitioned storage is used.
31823182- * Optional.
31833183- */
31843184- partitionKey?: PartitionKey;
31853185- }
31863186- /**
31873187- * Contains details about the cookie that's been removed. If removal failed for any reason, this will be "null",
31883188- * and $(ref:runtime.lastError) will be set.
31893189- */
31903190- interface RemoveCallbackDetailsType {
31913191- /**
31923192- * The URL associated with the cookie that's been removed.
31933193- */
31943194- url: string;
31953195- /**
31963196- * The name of the cookie that's been removed.
31973197- */
31983198- name: string;
31993199- /**
32003200- * The ID of the cookie store from which the cookie was removed.
32013201- */
32023202- storeId: string;
32033203- /**
32043204- * The first-party domain associated with the cookie that's been removed.
32053205- */
32063206- firstPartyDomain: string;
32073207- /**
32083208- * The storage partition, if the cookie is part of partitioned storage. null if not partitioned.
32093209- * Optional.
32103210- */
32113211- partitionKey?: PartitionKey;
32123212- }
32133213- interface OnChangedChangeInfoType {
32143214- /**
32153215- * True if a cookie was removed.
32163216- */
32173217- removed: boolean;
32183218- /**
32193219- * Information about the cookie that was set or removed.
32203220- */
32213221- cookie: Cookie;
32223222- /**
32233223- * The underlying reason behind the cookie's change.
32243224- */
32253225- cause: OnChangedCause;
32263226- }
32273227- interface Static {
32283228- /**
32293229- * Retrieves information about a single cookie. If more than one cookie of the same name exists for the given URL,
32303230- * the one with the longest path will be returned. For cookies with the same path length,
32313231- * the cookie with the earliest creation time will be returned.
32323232- *
32333233- * @param details Details to identify the cookie being retrieved.
32343234- */
32353235- get(details: GetDetailsType): Promise<Cookie | null>;
32363236- /**
32373237- * Retrieves all cookies from a single cookie store that match the given information. The cookies returned will be sorted,
32383238- * with those with the longest path first. If multiple cookies have the same path length,
32393239- * those with the earliest creation time will be first.
32403240- *
32413241- * @param details Information to filter the cookies being retrieved.
32423242- */
32433243- getAll(details: GetAllDetailsType): Promise<Cookie[]>;
32443244- /**
32453245- * Sets a cookie with the given cookie data; may overwrite equivalent cookies if they exist.
32463246- *
32473247- * @param details Details about the cookie being set.
32483248- */
32493249- set(details: SetDetailsType): Promise<Cookie>;
32503250- /**
32513251- * Deletes a cookie by name.
32523252- *
32533253- * @param details Information to identify the cookie to remove.
32543254- */
32553255- remove(details: RemoveDetailsType): Promise<RemoveCallbackDetailsType | null>;
32563256- /**
32573257- * Lists all existing cookie stores.
32583258- */
32593259- getAllCookieStores(): Promise<CookieStore[]>;
32603260- /**
32613261- * Fired when a cookie is set or removed. As a special case, note that updating a cookie's properties is implemented as a
32623262- * two step process: the cookie to be updated is first removed entirely, generating a notification with "cause" of
32633263- * "overwrite" . Afterwards, a new cookie is written with the updated values, generating a second notification with
32643264- * "cause" "explicit".
32653265- */
32663266- onChanged: Events.Event<(changeInfo: OnChangedChangeInfoType) => void>;
32673267- }
32683268- }
32693269- /**
32703270- * Namespace: browser.declarativeContent
32713271- */
32723272- namespace DeclarativeContent {
32733273- /**
32743274- * See <a href="https://developer.mozilla.org/en-US/docs/Web/API/ImageData">https://developer.mozilla.
32753275- * org/en-US/docs/Web/API/ImageData</a>.
32763276- */
32773277- interface ImageDataType extends ImageData {
32783278- [s: string]: unknown;
32793279- }
32803280- /**
32813281- * Matches the state of a web page based on various criteria.
32823282- */
32833283- interface PageStateMatcher {
32843284- /**
32853285- * Matches if the conditions of the <code>UrlFilter</code> are fulfilled for the top-level URL of the page.
32863286- * Optional.
32873287- */
32883288- pageUrl?: Browser.Events.UrlFilter;
32893289- /**
32903290- * Matches if all of the CSS selectors in the array match displayed elements in a frame with the same origin as the page's
32913291- * main frame. All selectors in this array must be <a href="http://www.w3.org/TR/selectors4/#compound">
32923292- * compound selectors</a> to speed up matching. Note: Listing hundreds of CSS selectors or listing CSS selectors that match
32933293- * hundreds of times per page can slow down web sites.
32943294- * Optional.
32953295- */
32963296- css?: string[];
32973297- /**
32983298- * Matches if the bookmarked state of the page is equal to the specified value. Requres the <a
32993299- * href='/docs/extensions/develop/concepts/declare-permissions'>bookmarks permission</a>.
33003300- * Optional.
33013301- */
33023302- isBookmarked?: boolean;
33033303- }
33043304- /**
33053305- * Please use ShowAction.
33063306- */
33073307- type ShowPageAction = never;
33083308- /**
33093309- * A declarative event action that sets the extension's toolbar $(ref:action action) to an enabled state while the
33103310- * corresponding conditions are met. This action can be used without <a
33113311- * href="/docs/extensions/develop/concepts/declare-permissions#host-permissions">host permissions</a>.
33123312- * If the extension has the <a href="/docs/extensions/develop/concepts/activeTab">activeTab</a> permission,
33133313- * clicking the page action grants access to the active tab.<p>On pages where the conditions are not met the extension's
33143314- * toolbar action will be grey-scale, and clicking it will open the context menu, instead of triggering the action.</p>
33153315- */
33163316- interface ShowAction {
33173317- [s: string]: unknown;
33183318- }
33193319- /**
33203320- * Declarative event action that sets the n-<abbr title="device-independent pixel">dip</abbr>
33213321- * square icon for the extension's $(ref:pageAction page action) or $(ref:browserAction browser action)
33223322- * while the corresponding conditions are met. This action can be used without <a
33233323- * href="/docs/extensions/develop/concepts/declare-permissions#host-permissions">host permissions</a>,
33243324- * but the extension must have a page or browser action.<p>Exactly one of <code>imageData</code> or <code>path</code>
33253325- * must be specified. Both are dictionaries mapping a number of pixels to an image representation.
33263326- * The image representation in <code>imageData</code> is an <a href="https://developer.mozilla.
33273327- * org/en-US/docs/Web/API/ImageData">ImageData</a> object; for example, from a <code>canvas</code> element,
33283328- * while the image representation in <code>path</code> is the path to an image file relative to the extension's manifest.
33293329- * If <code>scale</code> screen pixels fit into a device-independent pixel, the <code>scale * n</code> icon is used.
33303330- * If that scale is missing, another image is resized to the required size.</p>
33313331- */
33323332- interface SetIcon {
33333333- /**
33343334- * Either an <code>ImageData</code> object or a dictionary {size -> ImageData} representing an icon to be set.
33353335- * If the icon is specified as a dictionary, the image used is chosen depending on the screen's pixel density.
33363336- * If the number of image pixels that fit into one screen space unit equals <code>scale</code>,
33373337- * then an image with size <code>scale * n</code> is selected, where <i>n</i> is the size of the icon in the UI.
33383338- * At least one image must be specified. Note that <code>details.imageData = foo</code> is equivalent to <code>details.
33393339- * imageData = {'16': foo}</code>.
33403340- * Optional.
33413341- */
33423342- imageData?: ImageDataType | SetIconImageDataC2Type;
33433343- }
33443344- /**
33453345- * Declarative event action that injects a content script. <p><b>WARNING:</b> This action is still experimental and is not
33463346- * supported on stable builds of Chrome.</p>
33473347- */
33483348- interface RequestContentScript {
33493349- /**
33503350- * Names of CSS files to be injected as a part of the content script.
33513351- * Optional.
33523352- */
33533353- css?: string[];
33543354- /**
33553355- * Names of JavaScript files to be injected as a part of the content script.
33563356- * Optional.
33573357- */
33583358- js?: string[];
33593359- /**
33603360- * Whether the content script runs in all frames of the matching page, or in only the top frame. Default is <code>
33613361- * false</code>.
33623362- * Optional.
33633363- */
33643364- allFrames?: boolean;
33653365- /**
33663366- * Whether to insert the content script on <code>about:blank</code> and <code>about:srcdoc</code>. Default is <code>
33673367- * false</code>.
33683368- * Optional.
33693369- */
33703370- matchAboutBlank?: boolean;
33713371- }
33723372- interface Rule<TCondition, TAction> {
33733373- /**
33743374- * List of conditions that can trigger the actions.
33753375- */
33763376- conditions: TCondition[];
33773377- /**
33783378- * List of actions that are triggered if one of the conditions is fulfilled.
33793379- */
33803380- actions: TAction[];
33813381- }
33823382- /**
33833383- * An object which allows the addition and removal of rules for declarative content.
33843384- */
33853385- interface RuleEvent<TCondition, TAction> {
33863386- /**
33873387- * Registers rules to handle events.
33883388- *
33893389- * @param rules Rules to be registered. These do not replace previously registered rules.
33903390- */
33913391- addRules(rules: Array<Rule<TCondition, TAction>>): void;
33923392- /**
33933393- * Fetches currently registered rules.
33943394- *
33953395- * @param rules Optional. Rule ids to fetch.
33963396- * @param callback Optional. Called when rules have been fetched.
33973397- */
33983398- getRules(rules?: string[], callback?: (rules: Array<Rule<TCondition, TAction>>) => void): void;
33993399- /**
34003400- * Unregisters currently registered rules.
34013401- *
34023402- * @param rules Optional. Rule ids to be unregistered.
34033403- * @param callback Optional. Called when rules were unregistered.
34043404- */
34053405- removeRules(rules?: string[], callback?: () => void): void;
34063406- }
34073407- interface SetIconImageDataC2Type {
34083408- [s: string]: unknown;
34093409- }
34103410- interface Static {
34113411- PageStateMatcher: {
34123412- new (options?: PageStateMatcher): PageStateMatcher;
34133413- };
34143414- ShowAction: {
34153415- new (options?: ShowAction): ShowAction;
34163416- };
34173417- SetIcon: {
34183418- new (options?: SetIcon): SetIcon;
34193419- };
34203420- RequestContentScript: {
34213421- new (options?: RequestContentScript): RequestContentScript;
34223422- };
34233423- onPageChanged: RuleEvent<PageStateMatcher, RequestContentScript | SetIcon | ShowPageAction | ShowAction>;
34243424- }
34253425- }
34263426- /**
34273427- * Namespace: browser.declarativeNetRequest
34283428- */
34293429- namespace DeclarativeNetRequest {
34303430- /**
34313431- * How the requested resource will be used. Comparable to the webRequest.ResourceType type.
34323432- * object_subrequest is unsupported.
34333433- */
34343434- type ResourceType = "main_frame" | "sub_frame" | "stylesheet" | "script" | "image" | "object" | "object_subrequest" | "xmlhttprequest" | "xslt" | "ping" | "beacon" | "xml_dtd" | "font" | "media" | "websocket" | "csp_report" | "imageset" | "web_manifest" | "speculative" | "json" | "other";
34353435- /**
34363436- * Describes the reason why a given regular expression isn't supported.
34373437- */
34383438- type UnsupportedRegexReason = "syntaxError" | "memoryLimitExceeded";
34393439- interface MatchedRule {
34403440- /**
34413441- * A matching rule's ID.
34423442- */
34433443- ruleId: number;
34443444- /**
34453445- * ID of the Ruleset this rule belongs to.
34463446- */
34473447- rulesetId: string;
34483448- /**
34493449- * ID of the extension, if this rule belongs to a different extension.
34503450- * Optional.
34513451- */
34523452- extensionId?: string;
34533453- }
34543454- /**
34553455- * Describes the type of the Rule.action.redirect.transform property.
34563456- */
34573457- interface URLTransform {
34583458- /**
34593459- * The new scheme for the request.
34603460- * Optional.
34613461- */
34623462- scheme?: URLTransformSchemeEnum;
34633463- /**
34643464- * The new username for the request.
34653465- * Optional.
34663466- */
34673467- username?: string;
34683468- /**
34693469- * The new password for the request.
34703470- * Optional.
34713471- */
34723472- password?: string;
34733473- /**
34743474- * The new host name for the request.
34753475- * Optional.
34763476- */
34773477- host?: string;
34783478- /**
34793479- * The new port for the request. If empty, the existing port is cleared.
34803480- * Optional.
34813481- */
34823482- port?: string;
34833483- /**
34843484- * The new path for the request. If empty, the existing path is cleared.
34853485- * Optional.
34863486- */
34873487- path?: string;
34883488- /**
34893489- * The new query for the request. Should be either empty, in which case the existing query is cleared; or should begin with
34903490- * '?'. Cannot be specified if 'queryTransform' is specified.
34913491- * Optional.
34923492- */
34933493- query?: string;
34943494- /**
34953495- * Add, remove or replace query key-value pairs. Cannot be specified if 'query' is specified.
34963496- * Optional.
34973497- */
34983498- queryTransform?: URLTransformQueryTransformType;
34993499- /**
35003500- * The new fragment for the request. Should be either empty, in which case the existing fragment is cleared; or should
35013501- * begin with '#'.
35023502- * Optional.
35033503- */
35043504- fragment?: string;
35053505- }
35063506- interface Rule {
35073507- /**
35083508- * An id which uniquely identifies a rule. Mandatory and should be >= 1.
35093509- */
35103510- id: number;
35113511- /**
35123512- * Rule priority. Defaults to 1. When specified, should be >= 1
35133513- * Optional.
35143514- */
35153515- priority?: number;
35163516- /**
35173517- * The condition under which this rule is triggered.
35183518- */
35193519- condition: RuleConditionType;
35203520- /**
35213521- * The action to take if this rule is matched.
35223522- */
35233523- action: RuleActionType;
35243524- }
35253525- interface GetRulesFilter {
35263526- /**
35273527- * If specified, only rules with matching IDs are included.
35283528- * Optional.
35293529- */
35303530- ruleIds?: number[];
35313531- }
35323532- interface UpdateDynamicRulesOptionsType {
35333533- /**
35343534- * IDs of the rules to remove. Any invalid IDs will be ignored.
35353535- * Optional.
35363536- */
35373537- removeRuleIds?: number[];
35383538- /**
35393539- * Rules to add.
35403540- * Optional.
35413541- */
35423542- addRules?: Rule[];
35433543- }
35443544- interface UpdateSessionRulesOptionsType {
35453545- /**
35463546- * IDs of the rules to remove. Any invalid IDs will be ignored.
35473547- * Optional.
35483548- */
35493549- removeRuleIds?: number[];
35503550- /**
35513551- * Rules to add.
35523552- * Optional.
35533553- */
35543554- addRules?: Rule[];
35553555- }
35563556- interface UpdateEnabledRulesetsUpdateRulesetOptionsType {
35573557- /**
35583558- * Optional.
35593559- */
35603560- disableRulesetIds?: string[];
35613561- /**
35623562- * Optional.
35633563- */
35643564- enableRulesetIds?: string[];
35653565- }
35663566- interface UpdateStaticRulesOptionsType {
35673567- rulesetId: string;
35683568- /**
35693569- * Optional.
35703570- */
35713571- disableRuleIds?: number[];
35723572- /**
35733573- * Optional.
35743574- */
35753575- enableRuleIds?: number[];
35763576- }
35773577- interface GetDisabledRuleIdsOptionsType {
35783578- rulesetId: string;
35793579- }
35803580- interface IsRegexSupportedRegexOptionsType {
35813581- /**
35823582- * The regular expresson to check.
35833583- */
35843584- regex: string;
35853585- /**
35863586- * Whether the 'regex' specified is case sensitive.
35873587- * Optional.
35883588- */
35893589- isCaseSensitive?: boolean;
35903590- /**
35913591- * Whether the 'regex' specified requires capturing. Capturing is only required for redirect rules which specify a
35923592- * 'regexSubstition' action.
35933593- * Optional.
35943594- */
35953595- requireCapturing?: boolean;
35963596- }
35973597- interface IsRegexSupportedCallbackResultType {
35983598- /**
35993599- * Whether the given regex is supported
36003600- */
36013601- isSupported: boolean;
36023602- /**
36033603- * Specifies the reason why the regular expression is not supported. Only provided if 'isSupported' is false.
36043604- * Optional.
36053605- */
36063606- reason?: UnsupportedRegexReason;
36073607- }
36083608- /**
36093609- * The details of the request to test.
36103610- */
36113611- interface TestMatchOutcomeRequestType {
36123612- /**
36133613- * The URL of the hypothetical request.
36143614- */
36153615- url: string;
36163616- /**
36173617- * The initiator URL (if any) for the hypothetical request.
36183618- * Optional.
36193619- */
36203620- initiator?: string;
36213621- /**
36223622- * Standard HTTP method of the hypothetical request.
36233623- * Optional.
36243624- */
36253625- method?: string;
36263626- /**
36273627- * The resource type of the hypothetical request.
36283628- */
36293629- type: ResourceType;
36303630- /**
36313631- * The ID of the tab in which the hypothetical request takes place. Does not need to correspond to a real tab ID.
36323632- * Default is -1, meaning that the request isn't related to a tab.
36333633- * Optional.
36343634- */
36353635- tabId?: number;
36363636- }
36373637- interface TestMatchOutcomeOptionsType {
36383638- /**
36393639- * Whether to account for rules from other installed extensions during rule evaluation.
36403640- * Optional.
36413641- */
36423642- includeOtherExtensions?: boolean;
36433643- }
36443644- interface TestMatchOutcomeCallbackResultType {
36453645- /**
36463646- * The rules (if any) that match the hypothetical request.
36473647- */
36483648- matchedRules: MatchedRule[];
36493649- }
36503650- /**
36513651- * The new scheme for the request.
36523652- */
36533653- type URLTransformSchemeEnum = "http" | "https" | "moz-extension";
36543654- interface URLTransformQueryTransformAddOrReplaceParamsItemType {
36553655- key: string;
36563656- value: string;
36573657- /**
36583658- * If true, the query key is replaced only if it's already present. Otherwise, the key is also added if it's missing.
36593659- * Optional.
36603660- */
36613661- replaceOnly?: boolean;
36623662- }
36633663- /**
36643664- * Add, remove or replace query key-value pairs. Cannot be specified if 'query' is specified.
36653665- */
36663666- interface URLTransformQueryTransformType {
36673667- /**
36683668- * The list of query keys to be removed.
36693669- * Optional.
36703670- */
36713671- removeParams?: string[];
36723672- /**
36733673- * The list of query key-value pairs to be added or replaced.
36743674- * Optional.
36753675- */
36763676- addOrReplaceParams?: URLTransformQueryTransformAddOrReplaceParamsItemType[];
36773677- }
36783678- /**
36793679- * Specifies whether the network request is first-party or third-party to the domain from which it originated. If omitted,
36803680- * all requests are matched.
36813681- */
36823682- type RuleConditionDomainTypeEnum = "firstParty" | "thirdParty";
36833683- /**
36843684- * The condition under which this rule is triggered.
36853685- */
36863686- interface RuleConditionType {
36873687- /**
36883688- * TODO: link to doc explaining supported pattern. The pattern which is matched against the network request url.
36893689- * Only one of 'urlFilter' or 'regexFilter' can be specified.
36903690- * Optional.
36913691- */
36923692- urlFilter?: string;
36933693- /**
36943694- * Regular expression to match against the network request url. Only one of 'urlFilter' or 'regexFilter' can be specified.
36953695- * Optional.
36963696- */
36973697- regexFilter?: string;
36983698- /**
36993699- * Whether 'urlFilter' or 'regexFilter' is case-sensitive.
37003700- * Optional.
37013701- */
37023702- isUrlFilterCaseSensitive?: boolean;
37033703- /**
37043704- * The rule will only match network requests originating from the list of 'initiatorDomains'. If the list is omitted,
37053705- * the rule is applied to requests from all domains.
37063706- * Optional.
37073707- */
37083708- initiatorDomains?: string[];
37093709- /**
37103710- * The rule will not match network requests originating from the list of 'initiatorDomains'.
37113711- * If the list is empty or omitted, no domains are excluded. This takes precedence over 'initiatorDomains'.
37123712- * Optional.
37133713- */
37143714- excludedInitiatorDomains?: string[];
37153715- /**
37163716- * The rule will only match network requests when the domain matches one from the list of 'requestDomains'.
37173717- * If the list is omitted, the rule is applied to requests from all domains.
37183718- * Optional.
37193719- */
37203720- requestDomains?: string[];
37213721- /**
37223722- * The rule will not match network requests when the domains matches one from the list of 'excludedRequestDomains'.
37233723- * If the list is empty or omitted, no domains are excluded. This takes precedence over 'requestDomains'.
37243724- * Optional.
37253725- */
37263726- excludedRequestDomains?: string[];
37273727- /**
37283728- * List of resource types which the rule can match. When the rule action is 'allowAllRequests',
37293729- * this must be specified and may only contain 'main_frame' or 'sub_frame'. Cannot be specified if 'excludedResourceTypes'
37303730- * is specified. If neither of them is specified, all resource types except 'main_frame' are matched.
37313731- * Optional.
37323732- */
37333733- resourceTypes?: ResourceType[];
37343734- /**
37353735- * List of resource types which the rule won't match. Cannot be specified if 'resourceTypes' is specified.
37363736- * If neither of them is specified, all resource types except 'main_frame' are matched.
37373737- * Optional.
37383738- */
37393739- excludedResourceTypes?: ResourceType[];
37403740- /**
37413741- * List of HTTP request methods which the rule can match. Should be a lower-case method such as 'connect', 'delete', 'get',
37423742- * 'head', 'options', 'patch', 'post', 'put'.'
37433743- * Optional.
37443744- */
37453745- requestMethods?: string[];
37463746- /**
37473747- * List of request methods which the rule won't match. Cannot be specified if 'requestMethods' is specified.
37483748- * If neither of them is specified, all request methods are matched.
37493749- * Optional.
37503750- */
37513751- excludedRequestMethods?: string[];
37523752- /**
37533753- * Specifies whether the network request is first-party or third-party to the domain from which it originated. If omitted,
37543754- * all requests are matched.
37553755- * Optional.
37563756- */
37573757- domainType?: RuleConditionDomainTypeEnum;
37583758- /**
37593759- * List of tabIds which the rule should match. An ID of -1 matches requests which don't originate from a tab.
37603760- * Only supported for session-scoped rules.
37613761- * Optional.
37623762- */
37633763- tabIds?: number[];
37643764- /**
37653765- * List of tabIds which the rule should not match. An ID of -1 excludes requests which don't originate from a tab.
37663766- * Only supported for session-scoped rules.
37673767- * Optional.
37683768- */
37693769- excludedTabIds?: number[];
37703770- }
37713771- type RuleActionTypeEnum = "block" | "redirect" | "allow" | "upgradeScheme" | "modifyHeaders" | "allowAllRequests";
37723772- /**
37733773- * Describes how the redirect should be performed. Only valid when type is 'redirect'.
37743774- */
37753775- interface RuleActionRedirectType {
37763776- /**
37773777- * Path relative to the extension directory. Should start with '/'.
37783778- * Optional.
37793779- */
37803780- extensionPath?: string;
37813781- /**
37823782- * Url transformations to perform.
37833783- * Optional.
37843784- */
37853785- transform?: URLTransform;
37863786- /**
37873787- * The redirect url. Redirects to JavaScript urls are not allowed.
37883788- * Optional.
37893789- */
37903790- url?: string;
37913791- /**
37923792- * Substitution pattern for rules which specify a 'regexFilter'. The first match of regexFilter within the url will be
37933793- * replaced with this pattern. Within regexSubstitution, backslash-escaped digits (\1 to \9)
37943794- * can be used to insert the corresponding capture groups. \0 refers to the entire matching text.
37953795- * Optional.
37963796- */
37973797- regexSubstitution?: string;
37983798- }
37993799- interface RuleActionRequestHeadersItemType {
38003800- /**
38013801- * The name of the request header to be modified.
38023802- */
38033803- header: string;
38043804- /**
38053805- * The operation to be performed on a header.
38063806- */
38073807- operation: "append" | "set" | "remove";
38083808- /**
38093809- * The new value for the header. Must be specified for the 'append' and 'set' operations.
38103810- * Optional.
38113811- */
38123812- value?: string;
38133813- }
38143814- interface RuleActionResponseHeadersItemType {
38153815- /**
38163816- * The name of the response header to be modified.
38173817- */
38183818- header: string;
38193819- /**
38203820- * The operation to be performed on a header.
38213821- */
38223822- operation: "append" | "set" | "remove";
38233823- /**
38243824- * The new value for the header. Must be specified for the 'append' and 'set' operations.
38253825- * Optional.
38263826- */
38273827- value?: string;
38283828- }
38293829- /**
38303830- * The action to take if this rule is matched.
38313831- */
38323832- interface RuleActionType {
38333833- type: RuleActionTypeEnum;
38343834- /**
38353835- * Describes how the redirect should be performed. Only valid when type is 'redirect'.
38363836- * Optional.
38373837- */
38383838- redirect?: RuleActionRedirectType;
38393839- /**
38403840- * The request headers to modify for the request. Only valid when type is 'modifyHeaders'.
38413841- * Optional.
38423842- */
38433843- requestHeaders?: RuleActionRequestHeadersItemType[];
38443844- /**
38453845- * The response headers to modify for the request. Only valid when type is 'modifyHeaders'.
38463846- * Optional.
38473847- */
38483848- responseHeaders?: RuleActionResponseHeadersItemType[];
38493849- }
38503850- interface Static {
38513851- /**
38523852- * Modifies the current set of dynamic rules for the extension. The rules with IDs listed in options.
38533853- * removeRuleIds are first removed, and then the rules given in options.addRules are added.
38543854- * These rules are persisted across browser sessions and extension updates.
38553855- *
38563856- * @returns Called when the dynamic rules have been updated
38573857- */
38583858- updateDynamicRules(options: UpdateDynamicRulesOptionsType): Promise<void>;
38593859- /**
38603860- * Modifies the current set of session scoped rules for the extension. The rules with IDs listed in options.
38613861- * removeRuleIds are first removed, and then the rules given in options.addRules are added.
38623862- * These rules are not persisted across sessions and are backed in memory.
38633863- *
38643864- * @returns Called when the session rules have been updated
38653865- */
38663866- updateSessionRules(options: UpdateSessionRulesOptionsType): Promise<void>;
38673867- /**
38683868- * Returns the ids for the current set of enabled static rulesets.
38693869- */
38703870- getEnabledRulesets(): Promise<string[]>;
38713871- /**
38723872- * Modifies the static rulesets enabled/disabled state.
38733873- */
38743874- updateEnabledRulesets(updateRulesetOptions: UpdateEnabledRulesetsUpdateRulesetOptionsType): Promise<void>;
38753875- /**
38763876- * Modified individual static rules enabled/disabled state. Changes to rules belonging to a disabled ruleset will take
38773877- * effect when the ruleset becomes enabled.
38783878- */
38793879- updateStaticRules(options: UpdateStaticRulesOptionsType): Promise<void>;
38803880- /**
38813881- * Returns the remaining number of static rules an extension can enable
38823882- */
38833883- getAvailableStaticRuleCount(): Promise<number>;
38843884- /**
38853885- * Returns the list of individual disabled static rules from a given static ruleset id.
38863886- */
38873887- getDisabledRuleIds(options: GetDisabledRuleIdsOptionsType): Promise<number[]>;
38883888- /**
38893889- * Returns the current set of dynamic rules for the extension.
38903890- *
38913891- * @param filter Optional. An object to filter the set of dynamic rules for the extension.
38923892- */
38933893- getDynamicRules(filter?: GetRulesFilter): Promise<Rule[]>;
38943894- /**
38953895- * Returns the current set of session scoped rules for the extension.
38963896- *
38973897- * @param filter Optional. An object to filter the set of session scoped rules for the extension.
38983898- */
38993899- getSessionRules(filter?: GetRulesFilter): Promise<Rule[]>;
39003900- /**
39013901- * Checks if the given regular expression will be supported as a 'regexFilter' rule condition.
39023902- */
39033903- isRegexSupported(regexOptions: IsRegexSupportedRegexOptionsType): Promise<IsRegexSupportedCallbackResultType>;
39043904- /**
39053905- * Checks if any of the extension's declarativeNetRequest rules would match a hypothetical request.
39063906- *
39073907- * @param request The details of the request to test.
39083908- * @param options Optional.
39093909- * @returns Called with the details of matched rules.
39103910- */
39113911- testMatchOutcome(request: TestMatchOutcomeRequestType, options?: TestMatchOutcomeOptionsType): Promise<TestMatchOutcomeCallbackResultType>;
39123912- /**
39133913- * Ruleset ID for the dynamic rules added by the extension.
39143914- */
39153915- DYNAMIC_RULESET_ID: "_dynamic";
39163916- /**
39173917- * The minimum number of static rules guaranteed to an extension across its enabled static rulesets.
39183918- * Any rules above this limit will count towards the global static rule limit.
39193919- */
39203920- GUARANTEED_MINIMUM_STATIC_RULES: number;
39213921- /**
39223922- * The maximum number of static Rulesets an extension can specify as part of the rule_resources manifest key.
39233923- */
39243924- MAX_NUMBER_OF_STATIC_RULESETS: number;
39253925- /**
39263926- * The maximum number of static rules that can be disabled on each static ruleset.
39273927- */
39283928- MAX_NUMBER_OF_DISABLED_STATIC_RULES: number;
39293929- /**
39303930- * The maximum number of static Rulesets an extension can enable at any one time.
39313931- */
39323932- MAX_NUMBER_OF_ENABLED_STATIC_RULESETS: number;
39333933- /**
39343934- * Deprecated property returning the maximum number of dynamic and session rules an extension can add,
39353935- * replaced by MAX_NUMBER_OF_DYNAMIC_RULES/MAX_NUMBER_OF_SESSION_RULES.
39363936- */
39373937- MAX_NUMBER_OF_DYNAMIC_AND_SESSION_RULES: number;
39383938- /**
39393939- * The maximum number of dynamic session rules an extension can add.
39403940- */
39413941- MAX_NUMBER_OF_DYNAMIC_RULES: number;
39423942- /**
39433943- * The maximum number of dynamic session rules an extension can add.
39443944- */
39453945- MAX_NUMBER_OF_SESSION_RULES: number;
39463946- /**
39473947- * The maximum number of regular expression rules that an extension can add. This limit is evaluated separately for the set
39483948- * of session rules, dynamic rules and those specified in the rule_resources file.
39493949- */
39503950- MAX_NUMBER_OF_REGEX_RULES: number;
39513951- /**
39523952- * Ruleset ID for the session-scoped rules added by the extension.
39533953- */
39543954- SESSION_RULESET_ID: "_session";
39553955- }
39563956- }
39573957- /**
39583958- * Namespace: browser.devtools
39593959- */
39603960- namespace Devtools {
39613961- interface Static {
39623962- inspectedWindow: InspectedWindow.Static;
39633963- network: Network.Static;
39643964- panels: Panels.Static;
39653965- }
39663966- }
39673967- /**
39683968- * Namespace: browser.dns
39693969- */
39703970- namespace Dns {
39713971- /**
39723972- * An object encapsulating a DNS Record.
39733973- */
39743974- interface DNSRecord {
39753975- /**
39763976- * The canonical hostname for this record. this value is empty if the record was not fetched with the 'canonical_name'
39773977- * flag.
39783978- * Optional.
39793979- */
39803980- canonicalName?: string;
39813981- /**
39823982- * Record retreived with TRR.
39833983- */
39843984- isTRR: string;
39853985- addresses: string[];
39863986- }
39873987- type ResolveFlags = ResolveFlagsItemEnum[];
39883988- type ResolveFlagsItemEnum = "allow_name_collisions" | "bypass_cache" | "canonical_name" | "disable_ipv4" | "disable_ipv6" | "disable_trr" | "offline" | "priority_low" | "priority_medium" | "speculate";
39893989- interface Static {
39903990- /**
39913991- * Resolves a hostname to a DNS record.
39923992- *
39933993- * @param flags Optional.
39943994- */
39953995- resolve(hostname: string, flags?: ResolveFlags): Promise<DNSRecord>;
39963996- }
39973997- }
39983998- /**
39993999- * Namespace: browser.downloads
40004000- */
40014001- namespace Downloads {
40024002- type FilenameConflictAction = "uniquify" | "overwrite" | "prompt";
40034003- type InterruptReason = "FILE_FAILED" | "FILE_ACCESS_DENIED" | "FILE_NO_SPACE" | "FILE_NAME_TOO_LONG" | "FILE_TOO_LARGE" | "FILE_VIRUS_INFECTED" | "FILE_TRANSIENT_ERROR" | "FILE_BLOCKED" | "FILE_SECURITY_CHECK_FAILED" | "FILE_TOO_SHORT" | "NETWORK_FAILED" | "NETWORK_TIMEOUT" | "NETWORK_DISCONNECTED" | "NETWORK_SERVER_DOWN" | "NETWORK_INVALID_REQUEST" | "SERVER_FAILED" | "SERVER_NO_RANGE" | "SERVER_BAD_CONTENT" | "SERVER_UNAUTHORIZED" | "SERVER_CERT_PROBLEM" | "SERVER_FORBIDDEN" | "USER_CANCELED" | "USER_SHUTDOWN" | "CRASH";
40044004- /**
40054005- * <dl><dt>file</dt><dd>The download's filename is suspicious.</dd><dt>url</dt><dd>The download's URL is known to be
40064006- * malicious.</dd><dt>content</dt><dd>The downloaded file is known to be malicious.</dd><dt>uncommon</dt><dd>
40074007- * The download's URL is not commonly downloaded and could be dangerous.</dd><dt>safe</dt><dd>
40084008- * The download presents no known danger to the user's computer.</dd></dl>These string constants will never change,
40094009- * however the set of DangerTypes may change.
40104010- */
40114011- type DangerType = "file" | "url" | "content" | "uncommon" | "host" | "unwanted" | "safe" | "accepted";
40124012- /**
40134013- * <dl><dt>in_progress</dt><dd>The download is currently receiving data from the server.</dd><dt>interrupted</dt><dd>
40144014- * An error broke the connection with the file host.</dd><dt>complete</dt><dd>The download completed successfully.</dd></dl>
40154015- * These string constants will never change, however the set of States may change.
40164016- */
40174017- type State = "in_progress" | "interrupted" | "complete";
40184018- interface DownloadItem {
40194019- /**
40204020- * An identifier that is persistent across browser sessions.
40214021- */
40224022- id: number;
40234023- /**
40244024- * Absolute URL.
40254025- */
40264026- url: string;
40274027- /**
40284028- * Optional.
40294029- */
40304030- referrer?: string;
40314031- /**
40324032- * Absolute local path.
40334033- */
40344034- filename: string;
40354035- /**
40364036- * False if this download is recorded in the history, true if it is not recorded.
40374037- */
40384038- incognito: boolean;
40394039- /**
40404040- * The cookie store ID of the contextual identity.
40414041- * Optional.
40424042- */
40434043- cookieStoreId?: string;
40444044- /**
40454045- * Indication of whether this download is thought to be safe or known to be suspicious.
40464046- */
40474047- danger: DangerType;
40484048- /**
40494049- * The file's MIME type.
40504050- * Optional.
40514051- */
40524052- mime?: string;
40534053- /**
40544054- * Number of milliseconds between the unix epoch and when this download began.
40554055- */
40564056- startTime: string;
40574057- /**
40584058- * Number of milliseconds between the unix epoch and when this download ended.
40594059- * Optional.
40604060- */
40614061- endTime?: string;
40624062- /**
40634063- * Optional.
40644064- */
40654065- estimatedEndTime?: string;
40664066- /**
40674067- * Indicates whether the download is progressing, interrupted, or complete.
40684068- */
40694069- state: State;
40704070- /**
40714071- * True if the download has stopped reading data from the host, but kept the connection open.
40724072- */
40734073- paused: boolean;
40744074- canResume: boolean;
40754075- /**
40764076- * Number indicating why a download was interrupted.
40774077- * Optional.
40784078- */
40794079- error?: InterruptReason;
40804080- /**
40814081- * Number of bytes received so far from the host, without considering file compression.
40824082- */
40834083- bytesReceived: number;
40844084- /**
40854085- * Number of bytes in the whole file, without considering file compression, or -1 if unknown.
40864086- */
40874087- totalBytes: number;
40884088- /**
40894089- * Number of bytes in the whole file post-decompression, or -1 if unknown.
40904090- */
40914091- fileSize: number;
40924092- exists: boolean;
40934093- /**
40944094- * Optional.
40954095- */
40964096- byExtensionId?: string;
40974097- /**
40984098- * Optional.
40994099- */
41004100- byExtensionName?: string;
41014101- }
41024102- interface StringDelta {
41034103- /**
41044104- * Optional.
41054105- */
41064106- current?: string;
41074107- /**
41084108- * Optional.
41094109- */
41104110- previous?: string;
41114111- }
41124112- interface DoubleDelta {
41134113- /**
41144114- * Optional.
41154115- */
41164116- current?: number;
41174117- /**
41184118- * Optional.
41194119- */
41204120- previous?: number;
41214121- }
41224122- interface BooleanDelta {
41234123- /**
41244124- * Optional.
41254125- */
41264126- current?: boolean;
41274127- /**
41284128- * Optional.
41294129- */
41304130- previous?: boolean;
41314131- }
41324132- /**
41334133- * A time specified as a Date object, a number or string representing milliseconds since the epoch, or an ISO 8601 string
41344134- */
41354135- type DownloadTime = string | ExtensionTypes.DateType;
41364136- /**
41374137- * Parameters that combine to specify a predicate that can be used to select a set of downloads.
41384138- * Used for example in search() and erase()
41394139- */
41404140- interface DownloadQuery {
41414141- /**
41424142- * This array of search terms limits results to <a href='#type-DownloadItem'>DownloadItems</a> whose <code>filename</code>
41434143- * or <code>url</code> contain all of the search terms that do not begin with a dash '-' and none of the search terms that
41444144- * do begin with a dash.
41454145- * Optional.
41464146- */
41474147- query?: string[];
41484148- /**
41494149- * Limits results to downloads that started before the given ms since the epoch.
41504150- * Optional.
41514151- */
41524152- startedBefore?: DownloadTime;
41534153- /**
41544154- * Limits results to downloads that started after the given ms since the epoch.
41554155- * Optional.
41564156- */
41574157- startedAfter?: DownloadTime;
41584158- /**
41594159- * Limits results to downloads that ended before the given ms since the epoch.
41604160- * Optional.
41614161- */
41624162- endedBefore?: DownloadTime;
41634163- /**
41644164- * Limits results to downloads that ended after the given ms since the epoch.
41654165- * Optional.
41664166- */
41674167- endedAfter?: DownloadTime;
41684168- /**
41694169- * Limits results to downloads whose totalBytes is greater than the given integer.
41704170- * Optional.
41714171- */
41724172- totalBytesGreater?: number;
41734173- /**
41744174- * Limits results to downloads whose totalBytes is less than the given integer.
41754175- * Optional.
41764176- */
41774177- totalBytesLess?: number;
41784178- /**
41794179- * Limits results to <a href='#type-DownloadItem'>DownloadItems</a> whose <code>filename</code>
41804180- * matches the given regular expression.
41814181- * Optional.
41824182- */
41834183- filenameRegex?: string;
41844184- /**
41854185- * Limits results to <a href='#type-DownloadItem'>DownloadItems</a> whose <code>url</code>
41864186- * matches the given regular expression.
41874187- * Optional.
41884188- */
41894189- urlRegex?: string;
41904190- /**
41914191- * Setting this integer limits the number of results. Otherwise, all matching <a href='#type-DownloadItem'>DownloadItems</a>
41924192- * will be returned.
41934193- * Optional.
41944194- */
41954195- limit?: number;
41964196- /**
41974197- * Setting elements of this array to <a href='#type-DownloadItem'>DownloadItem</a> properties in order to sort the search
41984198- * results. For example, setting <code>orderBy='startTime'</code> sorts the <a href='#type-DownloadItem'>DownloadItems</a>
41994199- * by their start time in ascending order. To specify descending order, prefix <code>orderBy</code>
42004200- * with a hyphen: '-startTime'.
42014201- * Optional.
42024202- */
42034203- orderBy?: string[];
42044204- /**
42054205- * Optional.
42064206- */
42074207- id?: number;
42084208- /**
42094209- * Absolute URL.
42104210- * Optional.
42114211- */
42124212- url?: string;
42134213- /**
42144214- * Absolute local path.
42154215- * Optional.
42164216- */
42174217- filename?: string;
42184218- /**
42194219- * The cookie store ID of the contextual identity.
42204220- * Optional.
42214221- */
42224222- cookieStoreId?: string;
42234223- /**
42244224- * Indication of whether this download is thought to be safe or known to be suspicious.
42254225- * Optional.
42264226- */
42274227- danger?: DangerType;
42284228- /**
42294229- * The file's MIME type.
42304230- * Optional.
42314231- */
42324232- mime?: string;
42334233- /**
42344234- * Optional.
42354235- */
42364236- startTime?: string;
42374237- /**
42384238- * Optional.
42394239- */
42404240- endTime?: string;
42414241- /**
42424242- * Indicates whether the download is progressing, interrupted, or complete.
42434243- * Optional.
42444244- */
42454245- state?: State;
42464246- /**
42474247- * True if the download has stopped reading data from the host, but kept the connection open.
42484248- * Optional.
42494249- */
42504250- paused?: boolean;
42514251- /**
42524252- * Why a download was interrupted.
42534253- * Optional.
42544254- */
42554255- error?: InterruptReason;
42564256- /**
42574257- * Number of bytes received so far from the host, without considering file compression.
42584258- * Optional.
42594259- */
42604260- bytesReceived?: number;
42614261- /**
42624262- * Number of bytes in the whole file, without considering file compression, or -1 if unknown.
42634263- * Optional.
42644264- */
42654265- totalBytes?: number;
42664266- /**
42674267- * Number of bytes in the whole file post-decompression, or -1 if unknown.
42684268- * Optional.
42694269- */
42704270- fileSize?: number;
42714271- /**
42724272- * Optional.
42734273- */
42744274- exists?: boolean;
42754275- }
42764276- /**
42774277- * What to download and how.
42784278- */
42794279- interface DownloadOptionsType {
42804280- /**
42814281- * The URL to download.
42824282- */
42834283- url: string;
42844284- /**
42854285- * A file path relative to the Downloads directory to contain the downloaded file.
42864286- * Optional.
42874287- */
42884288- filename?: string;
42894289- /**
42904290- * Whether to associate the download with a private browsing session.
42914291- * Optional.
42924292- */
42934293- incognito?: boolean;
42944294- /**
42954295- * The cookie store ID of the contextual identity; requires "cookies" permission.
42964296- * Optional.
42974297- */
42984298- cookieStoreId?: string;
42994299- /**
43004300- * Optional.
43014301- */
43024302- conflictAction?: FilenameConflictAction;
43034303- /**
43044304- * Use a file-chooser to allow the user to select a filename. If the option is not specified,
43054305- * the file chooser will be shown only if the Firefox "Always ask you where to save files" option is enabled (i.e.
43064306- * the pref <code>browser.download.useDownloadDir</code> is set to <code>false</code>).
43074307- * Optional.
43084308- */
43094309- saveAs?: boolean;
43104310- /**
43114311- * The HTTP method to use if the URL uses the HTTP[S] protocol.
43124312- * Optional.
43134313- */
43144314- method?: DownloadOptionsTypeMethodEnum;
43154315- /**
43164316- * Extra HTTP headers to send with the request if the URL uses the HTTP[s] protocol. Each header is represented as a
43174317- * dictionary containing the keys <code>name</code> and either <code>value</code> or <code>binaryValue</code>,
43184318- * restricted to those allowed by XMLHttpRequest.
43194319- * Optional.
43204320- */
43214321- headers?: DownloadOptionsTypeHeadersItemType[];
43224322- /**
43234323- * Post body.
43244324- * Optional.
43254325- */
43264326- body?: string;
43274327- /**
43284328- * When this flag is set to <code>true</code>, then the browser will allow downloads to proceed after encountering HTTP
43294329- * errors such as <code>404 Not Found</code>.
43304330- * Optional.
43314331- */
43324332- allowHttpErrors?: boolean;
43334333- }
43344334- interface GetFileIconOptionsType {
43354335- /**
43364336- * The size of the icon. The returned icon will be square with dimensions size * size pixels.
43374337- * The default size for the icon is 32x32 pixels.
43384338- * Optional.
43394339- */
43404340- size?: number;
43414341- }
43424342- interface OnChangedDownloadDeltaType {
43434343- /**
43444344- * The <code>id</code> of the <a href='#type-DownloadItem'>DownloadItem</a> that changed.
43454345- */
43464346- id: number;
43474347- /**
43484348- * Describes a change in a <a href='#type-DownloadItem'>DownloadItem</a>'s <code>url</code>.
43494349- * Optional.
43504350- */
43514351- url?: StringDelta;
43524352- /**
43534353- * Describes a change in a <a href='#type-DownloadItem'>DownloadItem</a>'s <code>filename</code>.
43544354- * Optional.
43554355- */
43564356- filename?: StringDelta;
43574357- /**
43584358- * Describes a change in a <a href='#type-DownloadItem'>DownloadItem</a>'s <code>danger</code>.
43594359- * Optional.
43604360- */
43614361- danger?: StringDelta;
43624362- /**
43634363- * Describes a change in a <a href='#type-DownloadItem'>DownloadItem</a>'s <code>mime</code>.
43644364- * Optional.
43654365- */
43664366- mime?: StringDelta;
43674367- /**
43684368- * Describes a change in a <a href='#type-DownloadItem'>DownloadItem</a>'s <code>startTime</code>.
43694369- * Optional.
43704370- */
43714371- startTime?: StringDelta;
43724372- /**
43734373- * Describes a change in a <a href='#type-DownloadItem'>DownloadItem</a>'s <code>endTime</code>.
43744374- * Optional.
43754375- */
43764376- endTime?: StringDelta;
43774377- /**
43784378- * Describes a change in a <a href='#type-DownloadItem'>DownloadItem</a>'s <code>state</code>.
43794379- * Optional.
43804380- */
43814381- state?: StringDelta;
43824382- /**
43834383- * Optional.
43844384- */
43854385- canResume?: BooleanDelta;
43864386- /**
43874387- * Describes a change in a <a href='#type-DownloadItem'>DownloadItem</a>'s <code>paused</code>.
43884388- * Optional.
43894389- */
43904390- paused?: BooleanDelta;
43914391- /**
43924392- * Describes a change in a <a href='#type-DownloadItem'>DownloadItem</a>'s <code>error</code>.
43934393- * Optional.
43944394- */
43954395- error?: StringDelta;
43964396- /**
43974397- * Describes a change in a <a href='#type-DownloadItem'>DownloadItem</a>'s <code>totalBytes</code>.
43984398- * Optional.
43994399- */
44004400- totalBytes?: DoubleDelta;
44014401- /**
44024402- * Describes a change in a <a href='#type-DownloadItem'>DownloadItem</a>'s <code>fileSize</code>.
44034403- * Optional.
44044404- */
44054405- fileSize?: DoubleDelta;
44064406- /**
44074407- * Optional.
44084408- */
44094409- exists?: BooleanDelta;
44104410- }
44114411- /**
44124412- * The HTTP method to use if the URL uses the HTTP[S] protocol.
44134413- */
44144414- type DownloadOptionsTypeMethodEnum = "GET" | "POST";
44154415- interface DownloadOptionsTypeHeadersItemType {
44164416- /**
44174417- * Name of the HTTP header.
44184418- */
44194419- name: string;
44204420- /**
44214421- * Value of the HTTP header.
44224422- */
44234423- value: string;
44244424- }
44254425- interface Static {
44264426- /**
44274427- * Download a URL. If the URL uses the HTTP[S] protocol, then the request will include all cookies currently set for its
44284428- * hostname. If both <code>filename</code> and <code>saveAs</code> are specified, then the Save As dialog will be displayed,
44294429- * pre-populated with the specified <code>filename</code>. If the download started successfully, <code>callback</code>
44304430- * will be called with the new <a href='#type-DownloadItem'>DownloadItem</a>'s <code>downloadId</code>.
44314431- * If there was an error starting the download, then <code>callback</code> will be called with <code>
44324432- * downloadId=undefined</code> and <a href='extension.html#property-lastError'>chrome.extension.lastError</a>
44334433- * will contain a descriptive string. The error strings are not guaranteed to remain backwards compatible between releases.
44344434- * You must not parse it.
44354435- *
44364436- * @param options What to download and how.
44374437- */
44384438- download(options: DownloadOptionsType): Promise<number>;
44394439- /**
44404440- * Find <a href='#type-DownloadItem'>DownloadItems</a>. Set <code>query</code> to the empty object to get all <a
44414441- * href='#type-DownloadItem'>DownloadItems</a>. To get a specific <a href='#type-DownloadItem'>DownloadItem</a>,
44424442- * set only the <code>id</code> field.
44434443- */
44444444- search(query: DownloadQuery): Promise<DownloadItem[]>;
44454445- /**
44464446- * Pause the download. If the request was successful the download is in a paused state. Otherwise <a href='extension.
44474447- * html#property-lastError'>chrome.extension.lastError</a> contains an error message.
44484448- * The request will fail if the download is not active.
44494449- *
44504450- * @param downloadId The id of the download to pause.
44514451- */
44524452- pause(downloadId: number): Promise<void>;
44534453- /**
44544454- * Resume a paused download. If the request was successful the download is in progress and unpaused.
44554455- * Otherwise <a href='extension.html#property-lastError'>chrome.extension.lastError</a> contains an error message.
44564456- * The request will fail if the download is not active.
44574457- *
44584458- * @param downloadId The id of the download to resume.
44594459- */
44604460- resume(downloadId: number): Promise<void>;
44614461- /**
44624462- * Cancel a download. When <code>callback</code> is run, the download is cancelled, completed,
44634463- * interrupted or doesn't exist anymore.
44644464- *
44654465- * @param downloadId The id of the download to cancel.
44664466- */
44674467- cancel(downloadId: number): Promise<void>;
44684468- /**
44694469- * Retrieve an icon for the specified download. For new downloads, file icons are available after the <a
44704470- * href='#event-onCreated'>onCreated</a> event has been received. The image returned by this function while a download is
44714471- * in progress may be different from the image returned after the download is complete.
44724472- * Icon retrieval is done by querying the underlying operating system or toolkit depending on the platform.
44734473- * The icon that is returned will therefore depend on a number of factors including state of the download, platform,
44744474- * registered file types and visual theme. If a file icon cannot be determined, <a href='extension.
44754475- * html#property-lastError'>chrome.extension.lastError</a> will contain an error message.
44764476- *
44774477- * @param downloadId The identifier for the download.
44784478- * @param options Optional.
44794479- */
44804480- getFileIcon(downloadId: number, options?: GetFileIconOptionsType): Promise<string>;
44814481- /**
44824482- * Open the downloaded file.
44834483- */
44844484- open(downloadId: number): Promise<void>;
44854485- /**
44864486- * Show the downloaded file in its folder in a file manager.
44874487- */
44884488- show(downloadId: number): Promise<boolean>;
44894489- showDefaultFolder(): void;
44904490- /**
44914491- * Erase matching <a href='#type-DownloadItem'>DownloadItems</a> from history
44924492- */
44934493- erase(query: DownloadQuery): Promise<number[]>;
44944494- removeFile(downloadId: number): Promise<void>;
44954495- /**
44964496- * This event fires with the <a href='#type-DownloadItem'>DownloadItem</a> object when a download begins.
44974497- */
44984498- onCreated: Events.Event<(downloadItem: DownloadItem) => void>;
44994499- /**
45004500- * Fires with the <code>downloadId</code> when a download is erased from history.
45014501- *
45024502- * @param downloadId The <code>id</code> of the <a href='#type-DownloadItem'>DownloadItem</a> that was erased.
45034503- */
45044504- onErased: Events.Event<(downloadId: number) => void>;
45054505- /**
45064506- * When any of a <a href='#type-DownloadItem'>DownloadItem</a>'s properties except <code>bytesReceived</code> changes,
45074507- * this event fires with the <code>downloadId</code> and an object containing the properties that changed.
45084508- */
45094509- onChanged: Events.Event<(downloadDelta: OnChangedDownloadDeltaType) => void>;
45104510- }
45114511- }
45124512- /**
45134513- * Namespace: browser.events
45144514- */
45154515- namespace Events {
45164516- /**
45174517- * Description of a declarative rule for handling events.
45184518- */
45194519- interface Rule {
45204520- /**
45214521- * Optional identifier that allows referencing this rule.
45224522- * Optional.
45234523- */
45244524- id?: string;
45254525- /**
45264526- * Tags can be used to annotate rules and perform operations on sets of rules.
45274527- * Optional.
45284528- */
45294529- tags?: string[];
45304530- /**
45314531- * List of conditions that can trigger the actions.
45324532- */
45334533- conditions: unknown[];
45344534- /**
45354535- * List of actions that are triggered if one of the condtions is fulfilled.
45364536- */
45374537- actions: unknown[];
45384538- /**
45394539- * Optional priority of this rule. Defaults to 100.
45404540- * Optional.
45414541- */
45424542- priority?: number;
45434543- }
45444544- /**
45454545- * An object which allows the addition and removal of listeners for a Chrome event.
45464546- */
45474547- // eslint-disable-next-line @typescript-eslint/no-explicit-any
45484548- interface Event<T extends (...args: any[]) => any> {
45494549- /**
45504550- * Registers an event listener <em>callback</em> to an event.
45514551- *
45524552- * @param callback Called when an event occurs. The parameters of this function depend on the type of event.
45534553- * @param ...params Further parameters, depending on the event.
45544554- */
45554555- addListener(callback: T, ...params: unknown[]): void;
45564556- /**
45574557- * Deregisters an event listener <em>callback</em> from an event.
45584558- *
45594559- * @param callback Listener that shall be unregistered.
45604560- */
45614561- removeListener(callback: T): void;
45624562- /**
45634563- * @param callback Listener whose registration status shall be tested.
45644564- * @returns True if <em>callback</em> is registered to the event.
45654565- */
45664566- hasListener(callback: T): boolean;
45674567- }
45684568- /**
45694569- * Filters URLs for various criteria. See <a href='events#filtered'>event filtering</a>. All criteria are case sensitive.
45704570- */
45714571- interface UrlFilter {
45724572- /**
45734573- * Matches if the host name of the URL contains a specified string. To test whether a host name component has a prefix
45744574- * 'foo', use hostContains: '.foo'. This matches 'www.foobar.com' and 'foo.com', because an implicit dot is added at the
45754575- * beginning of the host name. Similarly, hostContains can be used to match against component suffix ('foo.')
45764576- * and to exactly match against components ('.foo.'). Suffix- and exact-matching for the last components need to be done
45774577- * separately using hostSuffix, because no implicit dot is added at the end of the host name.
45784578- * Optional.
45794579- */
45804580- hostContains?: string;
45814581- /**
45824582- * Matches if the host name of the URL is equal to a specified string.
45834583- * Optional.
45844584- */
45854585- hostEquals?: string;
45864586- /**
45874587- * Matches if the host name of the URL starts with a specified string.
45884588- * Optional.
45894589- */
45904590- hostPrefix?: string;
45914591- /**
45924592- * Matches if the host name of the URL ends with a specified string.
45934593- * Optional.
45944594- */
45954595- hostSuffix?: string;
45964596- /**
45974597- * Matches if the path segment of the URL contains a specified string.
45984598- * Optional.
45994599- */
46004600- pathContains?: string;
46014601- /**
46024602- * Matches if the path segment of the URL is equal to a specified string.
46034603- * Optional.
46044604- */
46054605- pathEquals?: string;
46064606- /**
46074607- * Matches if the path segment of the URL starts with a specified string.
46084608- * Optional.
46094609- */
46104610- pathPrefix?: string;
46114611- /**
46124612- * Matches if the path segment of the URL ends with a specified string.
46134613- * Optional.
46144614- */
46154615- pathSuffix?: string;
46164616- /**
46174617- * Matches if the query segment of the URL contains a specified string.
46184618- * Optional.
46194619- */
46204620- queryContains?: string;
46214621- /**
46224622- * Matches if the query segment of the URL is equal to a specified string.
46234623- * Optional.
46244624- */
46254625- queryEquals?: string;
46264626- /**
46274627- * Matches if the query segment of the URL starts with a specified string.
46284628- * Optional.
46294629- */
46304630- queryPrefix?: string;
46314631- /**
46324632- * Matches if the query segment of the URL ends with a specified string.
46334633- * Optional.
46344634- */
46354635- querySuffix?: string;
46364636- /**
46374637- * Matches if the URL (without fragment identifier) contains a specified string. Port numbers are stripped from the URL if
46384638- * they match the default port number.
46394639- * Optional.
46404640- */
46414641- urlContains?: string;
46424642- /**
46434643- * Matches if the URL (without fragment identifier) is equal to a specified string. Port numbers are stripped from the URL
46444644- * if they match the default port number.
46454645- * Optional.
46464646- */
46474647- urlEquals?: string;
46484648- /**
46494649- * Matches if the URL (without fragment identifier) matches a specified regular expression.
46504650- * Port numbers are stripped from the URL if they match the default port number. The regular expressions use the <a
46514651- * href="https://github.com/google/re2/blob/master/doc/syntax.txt">RE2 syntax</a>.
46524652- * Optional.
46534653- */
46544654- urlMatches?: string;
46554655- /**
46564656- * Matches if the URL without query segment and fragment identifier matches a specified regular expression.
46574657- * Port numbers are stripped from the URL if they match the default port number. The regular expressions use the <a
46584658- * href="https://github.com/google/re2/blob/master/doc/syntax.txt">RE2 syntax</a>.
46594659- * Optional.
46604660- */
46614661- originAndPathMatches?: string;
46624662- /**
46634663- * Matches if the URL (without fragment identifier) starts with a specified string. Port numbers are stripped from the URL
46644664- * if they match the default port number.
46654665- * Optional.
46664666- */
46674667- urlPrefix?: string;
46684668- /**
46694669- * Matches if the URL (without fragment identifier) ends with a specified string. Port numbers are stripped from the URL if
46704670- * they match the default port number.
46714671- * Optional.
46724672- */
46734673- urlSuffix?: string;
46744674- /**
46754675- * Matches if the scheme of the URL is equal to any of the schemes specified in the array.
46764676- * Optional.
46774677- */
46784678- schemes?: string[];
46794679- /**
46804680- * Matches if the port of the URL is contained in any of the specified port lists. For example <code>[80, 443, [1000, 1200]]
46814681- * </code> matches all requests on port 80, 443 and in the range 1000-1200.
46824682- * Optional.
46834683- */
46844684- ports?: Array<number | [
46854685- number,
46864686- number
46874687- ]>;
46884688- }
46894689- interface Static {
46904690- [s: string]: unknown;
46914691- }
46924692- }
46934693- /**
46944694- * Namespace: browser.experiments
46954695- */
46964696- namespace Experiments {
46974697- interface ExperimentAPI {
46984698- schema: ExperimentURL;
46994699- /**
47004700- * Optional.
47014701- */
47024702- parent?: ExperimentAPIParentType;
47034703- /**
47044704- * Optional.
47054705- */
47064706- child?: ExperimentAPIChildType;
47074707- }
47084708- type ExperimentURL = string;
47094709- type APIPaths = APIPath[];
47104710- type APIPath = string[];
47114711- type APIEvents = APIEvent[];
47124712- type APIEvent = "startup";
47134713- type APIParentScope = "addon_parent" | "content_parent" | "devtools_parent";
47144714- type APIChildScope = "addon_child" | "content_child" | "devtools_child";
47154715- interface ExperimentAPIParentType {
47164716- /**
47174717- * Optional.
47184718- */
47194719- events?: APIEvents;
47204720- /**
47214721- * Optional.
47224722- */
47234723- paths?: APIPaths;
47244724- script: ExperimentURL;
47254725- /**
47264726- * Optional.
47274727- */
47284728- scopes?: APIParentScope[];
47294729- }
47304730- interface ExperimentAPIChildType {
47314731- paths: APIPaths;
47324732- script: ExperimentURL;
47334733- scopes: APIChildScope[];
47344734- }
47354735- interface Static {
47364736- [s: string]: unknown;
47374737- }
47384738- }
47394739- /**
47404740- * Namespace: browser.extensionTypes
47414741- */
47424742- namespace ExtensionTypes {
47434743- /**
47444744- * The format of an image.
47454745- */
47464746- type ImageFormat = "jpeg" | "png";
47474747- /**
47484748- * Details about the format, quality, area and scale of the capture.
47494749- */
47504750- interface ImageDetails {
47514751- /**
47524752- * The format of the resulting image. Default is <code>"jpeg"</code>.
47534753- * Optional.
47544754- */
47554755- format?: ImageFormat;
47564756- /**
47574757- * When format is <code>"jpeg"</code>, controls the quality of the resulting image. This value is ignored for PNG images.
47584758- * As quality is decreased, the resulting image will have more visual artifacts, and the number of bytes needed to store
47594759- * it will decrease.
47604760- * Optional.
47614761- */
47624762- quality?: number;
47634763- /**
47644764- * The area of the document to capture, in CSS pixels, relative to the page. If omitted, capture the visible viewport.
47654765- * Optional.
47664766- */
47674767- rect?: ImageDetailsRectType;
47684768- /**
47694769- * The scale of the resulting image. Defaults to <code>devicePixelRatio</code>.
47704770- * Optional.
47714771- */
47724772- scale?: number;
47734773- /**
47744774- * If true, temporarily resets the scroll position of the document to 0. Only takes effect if rect is also specified.
47754775- * Optional.
47764776- */
47774777- resetScrollPosition?: boolean;
47784778- }
47794779- /**
47804780- * The soonest that the JavaScript or CSS will be injected into the tab.
47814781- */
47824782- type RunAt = "document_start" | "document_end" | "document_idle";
47834783- /**
47844784- * The JavaScript world for a script to execute within. <code>ISOLATED</code> is the default execution environment of
47854785- * content scripts, <code>MAIN</code> is the web page's execution environment.
47864786- */
47874787- type ExecutionWorld = "ISOLATED" | "MAIN";
47884788- /**
47894789- * The origin of the CSS to inject, this affects the cascading order (priority) of the stylesheet.
47904790- */
47914791- type CSSOrigin = "user" | "author";
47924792- /**
47934793- * Details of the script or CSS to inject. Either the code or the file property must be set,
47944794- * but both may not be set at the same time.
47954795- */
47964796- interface InjectDetails {
47974797- /**
47984798- * JavaScript or CSS code to inject.<br><br><b>Warning:</b><br>Be careful using the <code>code</code> parameter.
47994799- * Incorrect use of it may open your extension to <a href="https://en.wikipedia.org/wiki/Cross-site_scripting">
48004800- * cross site scripting</a> attacks.
48014801- * Optional.
48024802- */
48034803- code?: string;
48044804- /**
48054805- * JavaScript or CSS file to inject.
48064806- * Optional.
48074807- */
48084808- file?: string;
48094809- /**
48104810- * If allFrames is <code>true</code>, implies that the JavaScript or CSS should be injected into all frames of current page.
48114811- * By default, it's <code>false</code> and is only injected into the top frame.
48124812- * Optional.
48134813- */
48144814- allFrames?: boolean;
48154815- /**
48164816- * If matchAboutBlank is true, then the code is also injected in about:blank and about:srcdoc frames if your extension has
48174817- * access to its parent document. Code cannot be inserted in top-level about:-frames. By default it is <code>false</code>.
48184818- * Optional.
48194819- */
48204820- matchAboutBlank?: boolean;
48214821- /**
48224822- * The ID of the frame to inject the script into. This may not be used in combination with <code>allFrames</code>.
48234823- * Optional.
48244824- */
48254825- frameId?: number;
48264826- /**
48274827- * The soonest that the JavaScript or CSS will be injected into the tab. Defaults to "document_idle".
48284828- * Optional.
48294829- */
48304830- runAt?: RunAt;
48314831- /**
48324832- * The css origin of the stylesheet to inject. Defaults to "author".
48334833- * Optional.
48344834- */
48354835- cssOrigin?: CSSOrigin;
48364836- }
48374837- type DateType = string | number | Date;
48384838- type ExtensionFileOrCode = ExtensionFileOrCodeC1Type | ExtensionFileOrCodeC2Type;
48394839- /**
48404840- * A plain JSON value
48414841- */
48424842- interface PlainJSONValue {
48434843- [s: string]: unknown;
48444844- }
48454845- /**
48464846- * The area of the document to capture, in CSS pixels, relative to the page. If omitted, capture the visible viewport.
48474847- */
48484848- interface ImageDetailsRectType {
48494849- x: number;
48504850- y: number;
48514851- width: number;
48524852- height: number;
48534853- }
48544854- interface ExtensionFileOrCodeC1Type {
48554855- file: Browser.Manifest.ExtensionURL;
48564856- }
48574857- interface ExtensionFileOrCodeC2Type {
48584858- code: string;
48594859- }
48604860- interface Static {
48614861- [s: string]: unknown;
48624862- }
48634863- }
48644864- /**
48654865- * Namespace: browser.extension
48664866- */
48674867- namespace Extension {
48684868- /**
48694869- * The type of extension view.
48704870- */
48714871- type ViewType = "tab" | "popup" | "sidebar";
48724872- interface GetViewsFetchPropertiesType {
48734873- /**
48744874- * The type of view to get. If omitted, returns all views (including background pages and tabs). Valid values: 'tab',
48754875- * 'popup', 'sidebar'.
48764876- * Optional.
48774877- */
48784878- type?: ViewType;
48794879- /**
48804880- * The window to restrict the search to. If omitted, returns all views.
48814881- * Optional.
48824882- */
48834883- windowId?: number;
48844884- /**
48854885- * Find a view according to a tab id. If this field is omitted, returns all views.
48864886- * Optional.
48874887- */
48884888- tabId?: number;
48894889- }
48904890- interface Static {
48914891- /**
48924892- * Returns an array of the JavaScript 'window' objects for each of the pages running inside the current extension.
48934893- *
48944894- * @param fetchProperties Optional.
48954895- * @returns Array of global objects
48964896- */
48974897- getViews(fetchProperties?: GetViewsFetchPropertiesType): Window[];
48984898- /**
48994899- * Returns the JavaScript 'window' object for the background page running inside the current extension.
49004900- * Returns null if the extension has no background page.
49014901- */
49024902- getBackgroundPage(): Window;
49034903- /**
49044904- * Retrieves the state of the extension's access to Incognito-mode (as determined by the user-controlled 'Allowed in
49054905- * Incognito' checkbox.
49064906- */
49074907- isAllowedIncognitoAccess(): Promise<boolean>;
49084908- /**
49094909- * Retrieves the state of the extension's access to the 'file://' scheme (as determined by the user-controlled 'Allow
49104910- * access to File URLs' checkbox.
49114911- */
49124912- isAllowedFileSchemeAccess(): Promise<boolean>;
49134913- /**
49144914- * True for content scripts running inside incognito tabs, and for extension pages running inside an incognito process.
49154915- * The latter only applies to extensions with 'split' incognito_behavior.
49164916- * Optional.
49174917- */
49184918- inIncognitoContext?: boolean;
49194919- }
49204920- }
49214921- /**
49224922- * Namespace: browser.find
49234923- */
49244924- namespace Find {
49254925- interface RangeData {
49264926- /**
49274927- * The index of the frame containing the match. 0 corresponds to the parent window. Note that the order of objects in the
49284928- * rangeData array will sequentially line up with the order of frame indexes: for example,
49294929- * framePos for the first sequence of rangeData objects will be 0, framePos for the next sequence will be 1, and so on.
49304930- */
49314931- framePos: number;
49324932- /**
49334933- * The ordinal position of the text node in which the match started.
49344934- */
49354935- startTextNodePos: number;
49364936- /**
49374937- * The ordinal position of the text node in which the match ended.
49384938- */
49394939- endTextNodePos: number;
49404940- /**
49414941- * The ordinal string position of the start of the matched word within start text node.
49424942- * If match word include in single text node, Extension can get match word between startOffset and endOffset string index
49434943- * in the single text node.
49444944- */
49454945- startOffset: number;
49464946- /**
49474947- * The ordinal string position of the end of the matched word within end text node.
49484948- */
49494949- endOffset: number;
49504950- }
49514951- interface Rectangle {
49524952- /**
49534953- * Pixels from the top.
49544954- */
49554955- top: number;
49564956- /**
49574957- * Pixels from the left.
49584958- */
49594959- left: number;
49604960- /**
49614961- * Pixels from the bottom.
49624962- */
49634963- bottom: number;
49644964- /**
49654965- * Pixels from the right.
49664966- */
49674967- right: number;
49684968- }
49694969- interface RectsAndTexts {
49704970- /**
49714971- * Rectangles relative to the top-left of the viewport.
49724972- */
49734973- rectList: Rectangle[];
49744974- /**
49754975- * an array of strings, corresponding to the rectList array. The entry at textList[i]
49764976- * contains the part of the match bounded by the rectangle at rectList[i].
49774977- */
49784978- textList: string[];
49794979- }
49804980- interface RectData {
49814981- /**
49824982- * The index of the frame containing the match. 0 corresponds to the parent window. Note that the order of objects in the
49834983- * rangeData array will sequentially line up with the order of frame indexes: for example,
49844984- * framePos for the first sequence of rangeData objects will be 0, framePos for the next sequence will be 1, and so on.
49854985- */
49864986- rectsAndTexts: RectsAndTexts;
49874987- /**
49884988- * The complete text of the match.
49894989- */
49904990- text: string;
49914991- }
49924992- interface FindResult {
49934993- /**
49944994- * The number of results found.
49954995- */
49964996- count: number;
49974997- /**
49984998- * If includeRangeData was given in the options parameter, then this property will be included.
49994999- * It is provided as an array of RangeData objects, one for each match. Each RangeData object describes where in the DOM
50005000- * tree the match was found. This would enable, for example, an extension to get the text surrounding each match,
50015001- * so as to display context for the matches. The items correspond to the items given in rectData, so rangeData[i]
50025002- * describes the same match as rectData[i].
50035003- * Optional.
50045004- */
50055005- rangeData?: RangeData[];
50065006- /**
50075007- * If includeRectData was given in the options parameter, then this property will be included.
50085008- * It is an array of RectData objects. It contains client rectangles for all the text matched in the search,
50095009- * relative to the top-left of the viewport. Extensions can use this to provide custom highlighting of the results.
50105010- * Optional.
50115011- */
50125012- rectData?: RectData[];
50135013- }
50145014- /**
50155015- * Search parameters.
50165016- */
50175017- interface FindParamsType {
50185018- /**
50195019- * Tab to query. Defaults to the active tab.
50205020- * Optional.
50215021- */
50225022- tabId?: number;
50235023- /**
50245024- * Find only ranges with case sensitive match.
50255025- * Optional.
50265026- */
50275027- caseSensitive?: boolean;
50285028- /**
50295029- * Find only ranges with diacritic sensitive match.
50305030- * Optional.
50315031- */
50325032- matchDiacritics?: boolean;
50335033- /**
50345034- * Find only ranges that match entire word.
50355035- * Optional.
50365036- */
50375037- entireWord?: boolean;
50385038- /**
50395039- * Return rectangle data which describes visual position of search results.
50405040- * Optional.
50415041- */
50425042- includeRectData?: boolean;
50435043- /**
50445044- * Return range data which provides range data in a serializable form.
50455045- * Optional.
50465046- */
50475047- includeRangeData?: boolean;
50485048- }
50495049- /**
50505050- * highlightResults parameters
50515051- */
50525052- interface HighlightResultsParamsType {
50535053- /**
50545054- * Found range to be highlighted. Default highlights all ranges.
50555055- * Optional.
50565056- */
50575057- rangeIndex?: number;
50585058- /**
50595059- * Tab to highlight. Defaults to the active tab.
50605060- * Optional.
50615061- */
50625062- tabId?: number;
50635063- /**
50645064- * Don't scroll to highlighted item.
50655065- * Optional.
50665066- */
50675067- noScroll?: boolean;
50685068- }
50695069- interface Static {
50705070- /**
50715071- * Search for text in document and store found ranges in array, in document order.
50725072- *
50735073- * @param queryphrase The string to search for.
50745074- * @param params Optional. Search parameters.
50755075- */
50765076- find(queryphrase: string, params?: FindParamsType): Promise<FindResult>;
50775077- /**
50785078- * Highlight a range
50795079- *
50805080- * @param params Optional. highlightResults parameters
50815081- */
50825082- highlightResults(params?: HighlightResultsParamsType): Promise<void>;
50835083- /**
50845084- * Remove all highlighting from previous searches.
50855085- *
50865086- * @param tabId Optional. Tab to highlight. Defaults to the active tab.
50875087- */
50885088- removeHighlighting(tabId?: number): Promise<void>;
50895089- }
50905090- }
50915091- /**
50925092- * Namespace: browser.geckoProfiler
50935093- */
50945094- namespace GeckoProfiler {
50955095- type ProfilerFeature = "java" | "js" | "mainthreadio" | "fileio" | "fileioall" | "nomarkerstacks" | "screenshots" | "seqstyle" | "stackwalk" | "jsallocations" | "nostacksampling" | "nativeallocations" | "ipcmessages" | "audiocallbacktracing" | "cpu" | "notimerresolutionchange" | "cpuallthreads" | "samplingallthreads" | "markersallthreads" | "unregisteredthreads" | "processcpu" | "power" | "responsiveness" | "cpufreq" | "bandwidth" | "memory" | "tracing" | "sandbox" | "flows";
50965096- type supports = "windowLength";
50975097- interface StartSettingsType {
50985098- /**
50995099- * The maximum size in bytes of the buffer used to store profiling data. A larger value allows capturing a profile that
51005100- * covers a greater amount of time.
51015101- */
51025102- bufferSize: number;
51035103- /**
51045104- * The length of the window of time that's kept in the buffer. Any collected samples are discarded as soon as they are
51055105- * older than the number of seconds specified in this setting. Zero means no duration restriction.
51065106- * Optional.
51075107- */
51085108- windowLength?: number;
51095109- /**
51105110- * Interval in milliseconds between samples of profiling data. A smaller value will increase the detail of the profiles
51115111- * captured.
51125112- */
51135113- interval: number;
51145114- /**
51155115- * A list of active features for the profiler.
51165116- */
51175117- features: ProfilerFeature[];
51185118- /**
51195119- * A list of thread names for which to capture profiles.
51205120- * Optional.
51215121- */
51225122- threads?: string[];
51235123- }
51245124- interface Static {
51255125- /**
51265126- * Starts the profiler with the specified settings.
51275127- */
51285128- start(settings: StartSettingsType): void;
51295129- /**
51305130- * Stops the profiler and discards any captured profile data.
51315131- */
51325132- stop(): void;
51335133- /**
51345134- * Pauses the profiler, keeping any profile data that is already written.
51355135- */
51365136- pause(): void;
51375137- /**
51385138- * Resumes the profiler with the settings that were initially used to start it.
51395139- */
51405140- resume(): void;
51415141- /**
51425142- * Gathers the profile data from the current profiling session, and writes it to disk.
51435143- * The returned promise resolves to a path that locates the created file.
51445144- *
51455145- * @param fileName The name of the file inside the profile/profiler directory
51465146- */
51475147- dumpProfileToFile(fileName: string): void;
51485148- /**
51495149- * Gathers the profile data from the current profiling session.
51505150- */
51515151- getProfile(): void;
51525152- /**
51535153- * Gathers the profile data from the current profiling session. The returned promise resolves to an array buffer that
51545154- * contains a JSON string.
51555155- */
51565156- getProfileAsArrayBuffer(): void;
51575157- /**
51585158- * Gathers the profile data from the current profiling session. The returned promise resolves to an array buffer that
51595159- * contains a gzipped JSON string.
51605160- */
51615161- getProfileAsGzippedArrayBuffer(): void;
51625162- /**
51635163- * Gets the debug symbols for a particular library.
51645164- *
51655165- * @param debugName The name of the library's debug file. For example, 'xul.pdb
51665166- * @param breakpadId The Breakpad ID of the library
51675167- */
51685168- getSymbols(debugName: string, breakpadId: string): void;
51695169- /**
51705170- * Fires when the profiler starts/stops running.
51715171- *
51725172- * @param isRunning Whether the profiler is running or not. Pausing the profiler will not affect this value.
51735173- */
51745174- onRunning: Events.Event<(isRunning: boolean) => void>;
51755175- }
51765176- }
51775177- /**
51785178- * Namespace: browser.history
51795179- */
51805180- namespace History {
51815181- /**
51825182- * The $(topic:transition-types)[transition type] for this visit from its referrer.
51835183- */
51845184- type TransitionType = "link" | "typed" | "auto_bookmark" | "auto_subframe" | "manual_subframe" | "generated" | "auto_toplevel" | "form_submit" | "reload" | "keyword" | "keyword_generated";
51855185- /**
51865186- * An object encapsulating one result of a history query.
51875187- */
51885188- interface HistoryItem {
51895189- /**
51905190- * The unique identifier for the item.
51915191- */
51925192- id: string;
51935193- /**
51945194- * The URL navigated to by a user.
51955195- * Optional.
51965196- */
51975197- url?: string;
51985198- /**
51995199- * The title of the page when it was last loaded.
52005200- * Optional.
52015201- */
52025202- title?: string;
52035203- /**
52045204- * When this page was last loaded, represented in milliseconds since the epoch.
52055205- * Optional.
52065206- */
52075207- lastVisitTime?: number;
52085208- /**
52095209- * The number of times the user has navigated to this page.
52105210- * Optional.
52115211- */
52125212- visitCount?: number;
52135213- /**
52145214- * The number of times the user has navigated to this page by typing in the address.
52155215- * Optional.
52165216- */
52175217- typedCount?: number;
52185218- }
52195219- /**
52205220- * An object encapsulating one visit to a URL.
52215221- */
52225222- interface VisitItem {
52235223- /**
52245224- * The unique identifier for the item.
52255225- */
52265226- id: string;
52275227- /**
52285228- * The unique identifier for this visit.
52295229- */
52305230- visitId: string;
52315231- /**
52325232- * When this visit occurred, represented in milliseconds since the epoch.
52335233- * Optional.
52345234- */
52355235- visitTime?: number;
52365236- /**
52375237- * The visit ID of the referrer.
52385238- */
52395239- referringVisitId: string;
52405240- /**
52415241- * The $(topic:transition-types)[transition type] for this visit from its referrer.
52425242- */
52435243- transition: TransitionType;
52445244- }
52455245- interface SearchQueryType {
52465246- /**
52475247- * A free-text query to the history service. Leave empty to retrieve all pages.
52485248- */
52495249- text: string;
52505250- /**
52515251- * Limit results to those visited after this date. If not specified, this defaults to 24 hours in the past.
52525252- * Optional.
52535253- */
52545254- startTime?: ExtensionTypes.DateType;
52555255- /**
52565256- * Limit results to those visited before this date.
52575257- * Optional.
52585258- */
52595259- endTime?: ExtensionTypes.DateType;
52605260- /**
52615261- * The maximum number of results to retrieve. Defaults to 100.
52625262- * Optional.
52635263- */
52645264- maxResults?: number;
52655265- }
52665266- interface GetVisitsDetailsType {
52675267- /**
52685268- * The URL for which to retrieve visit information. It must be in the format as returned from a call to history.search.
52695269- */
52705270- url: string;
52715271- }
52725272- interface AddUrlDetailsType {
52735273- /**
52745274- * The URL to add. Must be a valid URL that can be added to history.
52755275- */
52765276- url: string;
52775277- /**
52785278- * The title of the page.
52795279- * Optional.
52805280- */
52815281- title?: string;
52825282- /**
52835283- * The $(topic:transition-types)[transition type] for this visit from its referrer.
52845284- * Optional.
52855285- */
52865286- transition?: TransitionType;
52875287- /**
52885288- * The date when this visit occurred.
52895289- * Optional.
52905290- */
52915291- visitTime?: ExtensionTypes.DateType;
52925292- }
52935293- interface DeleteUrlDetailsType {
52945294- /**
52955295- * The URL to remove.
52965296- */
52975297- url: string;
52985298- }
52995299- interface DeleteRangeRangeType {
53005300- /**
53015301- * Items added to history after this date.
53025302- */
53035303- startTime: ExtensionTypes.DateType;
53045304- /**
53055305- * Items added to history before this date.
53065306- */
53075307- endTime: ExtensionTypes.DateType;
53085308- }
53095309- interface OnVisitRemovedRemovedType {
53105310- /**
53115311- * True if all history was removed. If true, then urls will be empty.
53125312- */
53135313- allHistory: boolean;
53145314- urls: string[];
53155315- }
53165316- interface OnTitleChangedChangedType {
53175317- /**
53185318- * The URL for which the title has changed
53195319- */
53205320- url: string;
53215321- /**
53225322- * The new title for the URL.
53235323- */
53245324- title: string;
53255325- }
53265326- interface Static {
53275327- /**
53285328- * Searches the history for the last visit time of each page matching the query.
53295329- */
53305330- search(query: SearchQueryType): Promise<HistoryItem[]>;
53315331- /**
53325332- * Retrieves information about visits to a URL.
53335333- */
53345334- getVisits(details: GetVisitsDetailsType): Promise<VisitItem[]>;
53355335- /**
53365336- * Adds a URL to the history with a default visitTime of the current time and a default $(topic:transition-types)
53375337- * [transition type] of "link".
53385338- */
53395339- addUrl(details: AddUrlDetailsType): Promise<void>;
53405340- /**
53415341- * Removes all occurrences of the given URL from the history.
53425342- */
53435343- deleteUrl(details: DeleteUrlDetailsType): Promise<void>;
53445344- /**
53455345- * Removes all items within the specified date range from the history. Pages will not be removed from the history unless
53465346- * all visits fall within the range.
53475347- */
53485348- deleteRange(range: DeleteRangeRangeType): Promise<void>;
53495349- /**
53505350- * Deletes all items from the history.
53515351- */
53525352- deleteAll(): Promise<void>;
53535353- /**
53545354- * Fired when a URL is visited, providing the HistoryItem data for that URL. This event fires before the page has loaded.
53555355- */
53565356- onVisited: Events.Event<(result: HistoryItem) => void>;
53575357- /**
53585358- * Fired when one or more URLs are removed from the history service. When all visits have been removed the URL is purged
53595359- * from history.
53605360- */
53615361- onVisitRemoved: Events.Event<(removed: OnVisitRemovedRemovedType) => void>;
53625362- /**
53635363- * Fired when the title of a URL is changed in the browser history.
53645364- */
53655365- onTitleChanged: Events.Event<(changed: OnTitleChangedChangedType) => void>;
53665366- }
53675367- }
53685368- /**
53695369- * Namespace: browser.i18n
53705370- */
53715371- namespace I18n {
53725372- /**
53735373- * An ISO language code such as <code>en</code> or <code>fr</code>. For a complete list of languages supported by this
53745374- * method, see <a href='http://src.chromium.org/viewvc/chrome/trunk/src/third_party/cld/languages/internal/languages.cc'>
53755375- * kLanguageInfoTable</a>. For an unknown language, <code>und</code> will be returned, which means that [percentage]
53765376- * of the text is unknown to CLD
53775377- */
53785378- type LanguageCode = string;
53795379- /**
53805380- * LanguageDetectionResult object that holds detected langugae reliability and array of DetectedLanguage
53815381- */
53825382- interface DetectLanguageCallbackResultType {
53835383- /**
53845384- * CLD detected language reliability
53855385- */
53865386- isReliable: boolean;
53875387- /**
53885388- * array of detectedLanguage
53895389- */
53905390- languages: DetectLanguageCallbackResultTypeLanguagesItemType[];
53915391- }
53925392- /**
53935393- * DetectedLanguage object that holds detected ISO language code and its percentage in the input string
53945394- */
53955395- interface DetectLanguageCallbackResultTypeLanguagesItemType {
53965396- language: LanguageCode;
53975397- /**
53985398- * The percentage of the detected language
53995399- */
54005400- percentage: number;
54015401- }
54025402- interface Static {
54035403- /**
54045404- * Gets the accept-languages of the browser. This is different from the locale used by the browser; to get the locale,
54055405- * use $(ref:i18n.getUILanguage).
54065406- */
54075407- getAcceptLanguages(): Promise<LanguageCode[]>;
54085408- /**
54095409- * Gets the localized string for the specified message. If the message is missing, this method returns an empty string ('').
54105410- * If the format of the <code>getMessage()</code> call is wrong — for example, <em>messageName</em>
54115411- * is not a string or the <em>substitutions</em> array has more than 9 elements — this method returns <code>
54125412- * undefined</code>.
54135413- *
54145414- * @param messageName The name of the message, as specified in the <code>$(topic:i18n-messages)[messages.json]</code> file.
54155415- * @param substitutions Optional. Substitution strings, if the message requires any.
54165416- * @returns Message localized for current locale.
54175417- */
54185418- getMessage(messageName: string, substitutions?: string[] | string): Promise<string>;
54195419- /**
54205420- * Gets the browser UI language of the browser. This is different from $(ref:i18n.getAcceptLanguages)
54215421- * which returns the preferred user languages.
54225422- *
54235423- * @returns The browser UI language code such as en-US or fr-FR.
54245424- */
54255425- getUILanguage(): string;
54265426- /**
54275427- * Detects the language of the provided text using CLD.
54285428- *
54295429- * @param text User input string to be translated.
54305430- */
54315431- detectLanguage(text: string): Promise<DetectLanguageCallbackResultType>;
54325432- }
54335433- }
54345434- /**
54355435- * Namespace: browser.identity
54365436- */
54375437- namespace Identity {
54385438- /**
54395439- * An object encapsulating an OAuth account id.
54405440- */
54415441- interface AccountInfo {
54425442- /**
54435443- * A unique identifier for the account. This ID will not change for the lifetime of the account.
54445444- */
54455445- id: string;
54465446- }
54475447- interface LaunchWebAuthFlowDetailsType {
54485448- url: Browser.Manifest.HttpURL;
54495449- /**
54505450- * Optional.
54515451- */
54525452- interactive?: boolean;
54535453- }
54545454- interface Static {
54555455- /**
54565456- * Starts an auth flow at the specified URL.
54575457- */
54585458- launchWebAuthFlow(details: LaunchWebAuthFlowDetailsType): Promise<string>;
54595459- /**
54605460- * Generates a redirect URL to be used in |launchWebAuthFlow|.
54615461- *
54625462- * @param path Optional. The path appended to the end of the generated URL.
54635463- */
54645464- getRedirectURL(path?: string): Promise<string>;
54655465- }
54665466- }
54675467- /**
54685468- * Namespace: browser.idle
54695469- */
54705470- namespace Idle {
54715471- type IdleState = "active" | "idle" | "locked";
54725472- interface Static {
54735473- /**
54745474- * Returns "idle" if the user has not generated any input for a specified number of seconds, or "active" otherwise.
54755475- *
54765476- * @param detectionIntervalInSeconds The system is considered idle if detectionIntervalInSeconds seconds have elapsed since
54775477- * the last user input detected.
54785478- */
54795479- queryState(detectionIntervalInSeconds: number): Promise<IdleState>;
54805480- /**
54815481- * Sets the interval, in seconds, used to determine when the system is in an idle state for onStateChanged events.
54825482- * The default interval is 60 seconds.
54835483- *
54845484- * @param intervalInSeconds Threshold, in seconds, used to determine when the system is in an idle state.
54855485- */
54865486- setDetectionInterval(intervalInSeconds: number): void;
54875487- /**
54885488- * Fired when the system changes to an active or idle state. The event fires with "idle" if the the user has not generated
54895489- * any input for a specified number of seconds, and "active" when the user generates input on an idle system.
54905490- */
54915491- onStateChanged: Events.Event<(newState: IdleState) => void>;
54925492- }
54935493- }
54945494- /**
54955495- * Namespace: browser.management
54965496- */
54975497- namespace Management {
54985498- /**
54995499- * Information about an icon belonging to an extension.
55005500- */
55015501- interface IconInfo {
55025502- /**
55035503- * A number representing the width and height of the icon. Likely values include (but are not limited to) 128, 48, 24,
55045504- * and 16.
55055505- */
55065506- size: number;
55075507- /**
55085508- * The URL for this icon image. To display a grayscale version of the icon (to indicate that an extension is disabled,
55095509- * for example), append <code>?grayscale=true</code> to the URL.
55105510- */
55115511- url: string;
55125512- }
55135513- /**
55145514- * A reason the item is disabled.
55155515- */
55165516- type ExtensionDisabledReason = "unknown" | "permissions_increase";
55175517- /**
55185518- * The type of this extension, 'extension' or 'theme'.
55195519- */
55205520- type ExtensionType = "extension" | "theme";
55215521- /**
55225522- * How the extension was installed. One of<br><var>development</var>: The extension was loaded unpacked in developer mode,
55235523- * <br><var>normal</var>: The extension was installed normally via an .xpi file,<br><var>sideload</var>
55245524- * : The extension was installed by other software on the machine,<br><var>admin</var>
55255525- * : The extension was installed by policy,<br><var>other</var>: The extension was installed by other means.
55265526- */
55275527- type ExtensionInstallType = "development" | "normal" | "sideload" | "admin" | "other";
55285528- /**
55295529- * Information about an installed extension.
55305530- */
55315531- interface ExtensionInfo {
55325532- /**
55335533- * The extension's unique identifier.
55345534- */
55355535- id: string;
55365536- /**
55375537- * The name of this extension.
55385538- */
55395539- name: string;
55405540- /**
55415541- * A short version of the name of this extension.
55425542- * Optional.
55435543- */
55445544- shortName?: string;
55455545- /**
55465546- * The description of this extension.
55475547- */
55485548- description: string;
55495549- /**
55505550- * The <a href='manifest/version'>version</a> of this extension.
55515551- */
55525552- version: string;
55535553- /**
55545554- * The <a href='manifest/version#version_name'>version name</a> of this extension if the manifest specified one.
55555555- * Optional.
55565556- */
55575557- versionName?: string;
55585558- /**
55595559- * Whether this extension can be disabled or uninstalled by the user.
55605560- */
55615561- mayDisable: boolean;
55625562- /**
55635563- * Whether it is currently enabled or disabled.
55645564- */
55655565- enabled: boolean;
55665566- /**
55675567- * A reason the item is disabled.
55685568- * Optional.
55695569- */
55705570- disabledReason?: ExtensionDisabledReason;
55715571- /**
55725572- * The type of this extension, 'extension' or 'theme'.
55735573- */
55745574- type: ExtensionType;
55755575- /**
55765576- * The URL of the homepage of this extension.
55775577- * Optional.
55785578- */
55795579- homepageUrl?: string;
55805580- /**
55815581- * The update URL of this extension.
55825582- * Optional.
55835583- */
55845584- updateUrl?: string;
55855585- /**
55865586- * The url for the item's options page, if it has one.
55875587- */
55885588- optionsUrl: string;
55895589- /**
55905590- * A list of icon information. Note that this just reflects what was declared in the manifest,
55915591- * and the actual image at that url may be larger or smaller than what was declared,
55925592- * so you might consider using explicit width and height attributes on img tags referencing these images.
55935593- * See the <a href='manifest/icons'>manifest documentation on icons</a> for more details.
55945594- * Optional.
55955595- */
55965596- icons?: IconInfo[];
55975597- /**
55985598- * Returns a list of API based permissions.
55995599- * Optional.
56005600- */
56015601- permissions?: string[];
56025602- /**
56035603- * Returns a list of host based permissions.
56045604- * Optional.
56055605- */
56065606- hostPermissions?: string[];
56075607- /**
56085608- * How the extension was installed.
56095609- */
56105610- installType: ExtensionInstallType;
56115611- }
56125612- interface InstallOptionsType {
56135613- /**
56145614- * URL pointing to the XPI file on addons.mozilla.org or similar.
56155615- */
56165616- url: Browser.Manifest.HttpURL;
56175617- /**
56185618- * A hash of the XPI file, using sha256 or stronger.
56195619- * Optional.
56205620- */
56215621- hash?: string;
56225622- }
56235623- interface InstallCallbackResultType {
56245624- id: Browser.Manifest.ExtensionID;
56255625- }
56265626- interface UninstallSelfOptionsType {
56275627- /**
56285628- * Whether or not a confirm-uninstall dialog should prompt the user. Defaults to false.
56295629- * Optional.
56305630- */
56315631- showConfirmDialog?: boolean;
56325632- /**
56335633- * The message to display to a user when being asked to confirm removal of the extension.
56345634- * Optional.
56355635- */
56365636- dialogMessage?: string;
56375637- }
56385638- interface Static {
56395639- /**
56405640- * Returns a list of information about installed extensions.
56415641- */
56425642- getAll(): Promise<ExtensionInfo[]>;
56435643- /**
56445644- * Returns information about the installed extension that has the given ID.
56455645- *
56465646- * @param id The ID from an item of $(ref:management.ExtensionInfo).
56475647- */
56485648- get(id: Browser.Manifest.ExtensionID): Promise<ExtensionInfo>;
56495649- /**
56505650- * Installs and enables a theme extension from the given url.
56515651- */
56525652- install(options: InstallOptionsType): Promise<InstallCallbackResultType>;
56535653- /**
56545654- * Returns information about the calling extension. Note: This function can be used without requesting the 'management'
56555655- * permission in the manifest.
56565656- */
56575657- getSelf(): Promise<ExtensionInfo>;
56585658- /**
56595659- * Uninstalls the calling extension. Note: This function can be used without requesting the 'management' permission in the
56605660- * manifest.
56615661- *
56625662- * @param options Optional.
56635663- */
56645664- uninstallSelf(options?: UninstallSelfOptionsType): Promise<void>;
56655665- /**
56665666- * Enables or disables the given add-on.
56675667- *
56685668- * @param id ID of the add-on to enable/disable.
56695669- * @param enabled Whether to enable or disable the add-on.
56705670- */
56715671- setEnabled(id: string, enabled: boolean): Promise<void>;
56725672- /**
56735673- * Fired when an addon has been disabled.
56745674- */
56755675- onDisabled: Events.Event<(info: ExtensionInfo) => void>;
56765676- /**
56775677- * Fired when an addon has been enabled.
56785678- */
56795679- onEnabled: Events.Event<(info: ExtensionInfo) => void>;
56805680- /**
56815681- * Fired when an addon has been installed.
56825682- */
56835683- onInstalled: Events.Event<(info: ExtensionInfo) => void>;
56845684- /**
56855685- * Fired when an addon has been uninstalled.
56865686- */
56875687- onUninstalled: Events.Event<(info: ExtensionInfo) => void>;
56885688- }
56895689- }
56905690- /**
56915691- * Namespace: browser.manifest
56925692- */
56935693- namespace Manifest {
56945694- /**
56955695- * Common properties for all manifest.json files
56965696- */
56975697- interface ManifestBase {
56985698- manifest_version: number;
56995699- /**
57005700- * The applications property is deprecated, please use 'browser_specific_settings'
57015701- * Optional.
57025702- */
57035703- applications?: DeprecatedApplications;
57045704- /**
57055705- * Optional.
57065706- */
57075707- browser_specific_settings?: BrowserSpecificSettings;
57085708- /**
57095709- * Name must be at least 2, and should be at most 75 characters
57105710- */
57115711- name: string;
57125712- /**
57135713- * Optional.
57145714- */
57155715- short_name?: string;
57165716- /**
57175717- * Optional.
57185718- */
57195719- description?: string;
57205720- /**
57215721- * Optional.
57225722- */
57235723- author?: string;
57245724- version: string;
57255725- /**
57265726- * Optional.
57275727- */
57285728- homepage_url?: string;
57295729- /**
57305730- * Optional.
57315731- */
57325732- install_origins?: string[];
57335733- /**
57345734- * Optional.
57355735- */
57365736- developer?: ManifestBaseDeveloperType;
57375737- /**
57385738- * In addition to the version field, which is used for update purposes, version_name can be set to a descriptive version
57395739- * string and will be used for display purposes if present. If no version_name is present,
57405740- * the version field will be used for display purposes as well.
57415741- * Optional.
57425742- */
57435743- version_name?: string;
57445744- }
57455745- /**
57465746- * Represents a WebExtension manifest.json file
57475747- */
57485748- interface WebExtensionManifest extends ManifestBase {
57495749- /**
57505750- * Optional.
57515751- */
57525752- minimum_chrome_version?: string;
57535753- /**
57545754- * Optional.
57555755- */
57565756- minimum_opera_version?: string;
57575757- /**
57585758- * Optional.
57595759- */
57605760- icons?: Record<string, ExtensionFileUrl>;
57615761- /**
57625762- * The 'split' value is not supported.
57635763- * Optional.
57645764- */
57655765- incognito?: WebExtensionManifestIncognitoEnum;
57665766- /**
57675767- * Optional.
57685768- */
57695769- background?: WebExtensionManifestBackgroundType;
57705770- /**
57715771- * Alias property for options_ui.page, ignored when options_ui.page is set. When using this property the options page is
57725772- * always opened in a new tab.
57735773- * Optional.
57745774- */
57755775- options_page?: ExtensionURL;
57765776- /**
57775777- * Optional.
57785778- */
57795779- options_ui?: WebExtensionManifestOptionsUiType;
57805780- /**
57815781- * Optional.
57825782- */
57835783- content_scripts?: ContentScript[];
57845784- /**
57855785- * Optional.
57865786- */
57875787- content_security_policy?: string | WebExtensionManifestContentSecurityPolicyC2Type;
57885788- /**
57895789- * Optional.
57905790- */
57915791- permissions?: PermissionOrOrigin[] | Permission[];
57925792- /**
57935793- * Optional.
57945794- */
57955795- granted_host_permissions?: boolean;
57965796- /**
57975797- * Optional.
57985798- */
57995799- host_permissions?: MatchPattern[];
58005800- /**
58015801- * Optional.
58025802- */
58035803- optional_host_permissions?: MatchPattern[];
58045804- /**
58055805- * Optional.
58065806- */
58075807- optional_permissions?: OptionalPermissionOrOrigin[];
58085808- /**
58095809- * Optional.
58105810- */
58115811- web_accessible_resources?: string[] | WebExtensionManifestWebAccessibleResourcesC2ItemType[];
58125812- /**
58135813- * Optional.
58145814- */
58155815- hidden?: boolean;
58165816- /**
58175817- * Optional.
58185818- */
58195819- action?: ActionManifest;
58205820- /**
58215821- * Optional.
58225822- */
58235823- browser_action?: ActionManifest;
58245824- /**
58255825- * Optional.
58265826- */
58275827- chrome_settings_overrides?: WebExtensionManifestChromeSettingsOverridesType;
58285828- /**
58295829- * Optional.
58305830- */
58315831- commands?: Record<string, WebExtensionManifestCommandsType>;
58325832- /**
58335833- * Optional.
58345834- */
58355835- declarative_net_request?: WebExtensionManifestDeclarativeNetRequestType;
58365836- /**
58375837- * Optional.
58385838- */
58395839- devtools_page?: ExtensionURL;
58405840- /**
58415841- * Optional.
58425842- */
58435843- experiment_apis?: WebExtensionManifestExperimentApisType;
58445844- /**
58455845- * A list of protocol handler definitions.
58465846- * Optional.
58475847- */
58485848- protocol_handlers?: ProtocolHandler[];
58495849- /**
58505850- * Optional.
58515851- */
58525852- default_locale?: string;
58535853- /**
58545854- * Optional.
58555855- */
58565856- l10n_resources?: string[];
58575857- /**
58585858- * Optional.
58595859- */
58605860- omnibox?: WebExtensionManifestOmniboxType;
58615861- /**
58625862- * Optional.
58635863- */
58645864- page_action?: WebExtensionManifestPageActionType;
58655865- /**
58665866- * Optional.
58675867- */
58685868- sidebar_action?: WebExtensionManifestSidebarActionType;
58695869- /**
58705870- * Optional.
58715871- */
58725872- theme_experiment?: ThemeExperiment;
58735873- /**
58745874- * Optional.
58755875- */
58765876- chrome_url_overrides?: WebExtensionManifestChromeUrlOverridesType;
58775877- /**
58785878- * Optional.
58795879- */
58805880- user_scripts?: WebExtensionManifestUserScriptsType;
58815881- }
58825882- /**
58835883- * Represents a WebExtension language pack manifest.json file
58845884- */
58855885- interface WebExtensionLangpackManifest extends ManifestBase {
58865886- langpack_id: string;
58875887- languages: Record<string, WebExtensionLangpackManifestLanguagesPatternType>;
58885888- /**
58895889- * Optional.
58905890- */
58915891- sources?: Record<string, WebExtensionLangpackManifestSourcesPatternType>;
58925892- }
58935893- /**
58945894- * Represents a WebExtension dictionary manifest.json file
58955895- */
58965896- interface WebExtensionDictionaryManifest extends ManifestBase {
58975897- dictionaries: Record<string, string>;
58985898- }
58995899- interface ThemeIcons {
59005900- /**
59015901- * A light icon to use for dark themes
59025902- */
59035903- light: ExtensionURL;
59045904- /**
59055905- * The dark icon to use for light themes
59065906- */
59075907- dark: ExtensionURL;
59085908- /**
59095909- * The size of the icons
59105910- */
59115911- size: number;
59125912- }
59135913- type OptionalOnlyPermission = "trialML" | "userScripts";
59145914- type OptionalPermissionNoPrompt = "idle" | "cookies" | "menus.overrideContext" | "scripting" | "search" | "tabGroups" | "activeTab" | "webRequest" | "webRequestAuthProvider" | "webRequestBlocking" | "webRequestFilterResponse" | "webRequestFilterResponse.serviceWorkerScript";
59155915- type OptionalPermission = OptionalPermissionNoPrompt | "clipboardRead" | "clipboardWrite" | "geolocation" | "notifications" | "bookmarks" | "browserSettings" | "browsingData" | "declarativeNetRequestFeedback" | "devtools" | "downloads" | "downloads.open" | "find" | "history" | "management" | "pkcs11" | "privacy" | "proxy" | "nativeMessaging" | "sessions" | "tabs" | "tabHide" | "topSites" | "webNavigation" | "identity.email";
59165916- type OptionalPermissionOrOrigin = OptionalPermission | OptionalOnlyPermission | MatchPattern;
59175917- type PermissionPrivileged = "mozillaAddons" | "activityLog" | "networkStatus" | "normandyAddonStudy";
59185918- type CommonDataCollectionPermission = "authenticationInfo" | "bookmarksInfo" | "browsingActivity" | "financialAndPaymentInfo" | "healthInfo" | "locationInfo" | "personalCommunications" | "personallyIdentifyingInfo" | "searchTerms" | "websiteActivity" | "websiteContent";
59195919- type DataCollectionPermission = CommonDataCollectionPermission | "none";
59205920- type OptionalDataCollectionPermission = CommonDataCollectionPermission | "technicalAndInteraction";
59215921- type PermissionNoPrompt = OptionalPermissionNoPrompt | PermissionPrivileged | "alarms" | "storage" | "unlimitedStorage" | "captivePortal" | "contextualIdentities" | "declarativeNetRequestWithHostAccess" | "dns" | "geckoProfiler" | "identity" | "menus" | "contextMenus" | "theme";
59225922- type Permission = PermissionNoPrompt | OptionalPermission | "declarativeNetRequest" | string;
59235923- type PermissionOrOrigin = Permission | MatchPattern;
59245924- type HttpURL = string;
59255925- type ExtensionURL = string;
59265926- type ExtensionFileUrl = string;
59275927- type ImageDataOrExtensionURL = string;
59285928- type ExtensionID = string;
59295929- interface FirefoxSpecificProperties {
59305930- /**
59315931- * Optional.
59325932- */
59335933- id?: ExtensionID;
59345934- /**
59355935- * Optional.
59365936- */
59375937- update_url?: string;
59385938- /**
59395939- * Optional.
59405940- */
59415941- strict_min_version?: string;
59425942- /**
59435943- * Optional.
59445944- */
59455945- strict_max_version?: string;
59465946- /**
59475947- * Optional.
59485948- */
59495949- admin_install_only?: boolean;
59505950- /**
59515951- * Optional.
59525952- */
59535953- data_collection_permissions?: FirefoxSpecificPropertiesDataCollectionPermissionsType;
59545954- }
59555955- interface GeckoAndroidSpecificProperties {
59565956- /**
59575957- * Optional.
59585958- */
59595959- strict_min_version?: string;
59605960- /**
59615961- * Optional.
59625962- */
59635963- strict_max_version?: string;
59645964- }
59655965- interface DeprecatedApplications {
59665966- /**
59675967- * Optional.
59685968- */
59695969- gecko?: FirefoxSpecificProperties;
59705970- }
59715971- interface BrowserSpecificSettings {
59725972- /**
59735973- * Optional.
59745974- */
59755975- gecko?: FirefoxSpecificProperties;
59765976- /**
59775977- * Optional.
59785978- */
59795979- gecko_android?: GeckoAndroidSpecificProperties;
59805980- }
59815981- type MatchPattern = "<all_urls>" | MatchPatternRestricted | MatchPatternUnestricted;
59825982- /**
59835983- * Same as MatchPattern above, but excludes <all_urls>
59845984- */
59855985- type MatchPatternRestricted = string;
59865986- /**
59875987- * Mostly unrestricted match patterns for privileged add-ons. This should technically be rejected for unprivileged add-ons,
59885988- * but, reasons. The MatchPattern class will still refuse privileged schemes for those extensions.
59895989- */
59905990- type MatchPatternUnestricted = string;
59915991- /**
59925992- * Details of the script or CSS to inject. Either the code or the file property must be set,
59935993- * but both may not be set at the same time. Based on InjectDetails, but using underscore rather than camel case naming
59945994- * conventions.
59955995- */
59965996- interface ContentScript {
59975997- matches: MatchPattern[];
59985998- /**
59995999- * Optional.
60006000- */
60016001- exclude_matches?: MatchPattern[];
60026002- /**
60036003- * Optional.
60046004- */
60056005- include_globs?: string[];
60066006- /**
60076007- * Optional.
60086008- */
60096009- exclude_globs?: string[];
60106010- /**
60116011- * The list of CSS files to inject
60126012- * Optional.
60136013- */
60146014- css?: ExtensionURL[];
60156015- /**
60166016- * The list of JS files to inject
60176017- * Optional.
60186018- */
60196019- js?: ExtensionURL[];
60206020- /**
60216021- * If allFrames is <code>true</code>, implies that the JavaScript or CSS should be injected into all frames of current page.
60226022- * By default, it's <code>false</code> and is only injected into the top frame.
60236023- * Optional.
60246024- */
60256025- all_frames?: boolean;
60266026- /**
60276027- * If match_about_blank is true, then the code is also injected in about:blank and about:srcdoc frames if your extension
60286028- * has access to its parent document. Ignored if match_origin_as_fallback is specified. By default it is <code>false</code>.
60296029- * Optional.
60306030- */
60316031- match_about_blank?: boolean;
60326032- /**
60336033- * If match_origin_as_fallback is true, then the code is also injected in about:, data:,
60346034- * blob: when their origin matches the pattern in 'matches', even if the actual document origin is opaque (due to the use
60356035- * of CSP sandbox or iframe sandbox). Match patterns in 'matches' must specify a wildcard path glob. By default it is <code>
60366036- * false</code>.
60376037- * Optional.
60386038- */
60396039- match_origin_as_fallback?: boolean;
60406040- /**
60416041- * The soonest that the JavaScript or CSS will be injected into the tab. Defaults to "document_idle".
60426042- * Optional.
60436043- */
60446044- run_at?: Browser.ExtensionTypes.RunAt;
60456045- /**
60466046- * The JavaScript world for a script to execute within. Defaults to "ISOLATED".
60476047- * Optional.
60486048- */
60496049- world?: Browser.ExtensionTypes.ExecutionWorld;
60506050- }
60516051- type IconPath = Record<string, ExtensionFileUrl> | ExtensionFileUrl;
60526052- type IconImageData = Record<string, ImageData> | ImageData;
60536053- interface ActionManifest {
60546054- /**
60556055- * Optional.
60566056- */
60576057- default_title?: string;
60586058- /**
60596059- * Optional.
60606060- */
60616061- default_icon?: IconPath;
60626062- /**
60636063- * Specifies icons to use for dark and light themes
60646064- * Optional.
60656065- */
60666066- theme_icons?: ThemeIcons[];
60676067- /**
60686068- * Optional.
60696069- */
60706070- default_popup?: string;
60716071- /**
60726072- * Deprecated in Manifest V3.
60736073- * Optional.
60746074- */
60756075- browser_style?: boolean;
60766076- /**
60776077- * Defines the location the browserAction will appear by default. The default location is navbar.
60786078- * Optional.
60796079- */
60806080- default_area?: ActionManifestDefaultAreaEnum;
60816081- }
60826082- type KeyName = string;
60836083- /**
60846084- * Represents a protocol handler definition.
60856085- */
60866086- interface ProtocolHandler {
60876087- /**
60886088- * A user-readable title string for the protocol handler. This will be displayed to the user in interface objects as needed.
60896089- */
60906090- name: string;
60916091- /**
60926092- * The protocol the site wishes to handle, specified as a string. For example, you can register to handle SMS text message
60936093- * links by registering to handle the "sms" scheme.
60946094- */
60956095- protocol: "bitcoin" | "dat" | "dweb" | "ftp" | "geo" | "gopher" | "im" | "ipfs" | "ipns" | "irc" | "ircs" | "magnet" | "mailto" | "matrix" | "mms" | "news" | "nntp" | "sip" | "sms" | "smsto" | "ssb" | "ssh" | "tel" | "urn" | "webcal" | "wtai" | "xmpp" | string;
60966096- /**
60976097- * The URL of the handler, as a string. This string should include "%s" as a placeholder which will be replaced with the
60986098- * escaped URL of the document to be handled. This URL might be a true URL, or it could be a phone number, email address,
60996099- * or so forth.
61006100- */
61016101- uriTemplate: ExtensionURL | HttpURL;
61026102- }
61036103- type ThemeColor = string | [
61046104- number,
61056105- number,
61066106- number
61076107- ] | [
61086108- number,
61096109- number,
61106110- number,
61116111- number
61126112- ];
61136113- interface ThemeExperiment {
61146114- /**
61156115- * Optional.
61166116- */
61176117- stylesheet?: ExtensionURL;
61186118- /**
61196119- * Optional.
61206120- */
61216121- images?: ThemeExperimentImagesType;
61226122- /**
61236123- * Optional.
61246124- */
61256125- colors?: ThemeExperimentColorsType;
61266126- /**
61276127- * Optional.
61286128- */
61296129- properties?: ThemeExperimentPropertiesType;
61306130- }
61316131- interface ThemeType {
61326132- /**
61336133- * Optional.
61346134- */
61356135- images?: ThemeTypeImagesType;
61366136- /**
61376137- * Optional.
61386138- */
61396139- colors?: ThemeTypeColorsType;
61406140- /**
61416141- * Optional.
61426142- */
61436143- properties?: ThemeTypePropertiesType;
61446144- }
61456145- /**
61466146- * Contents of manifest.json for a static theme
61476147- */
61486148- interface ThemeManifest extends Browser.Manifest.ManifestBase {
61496149- theme: ThemeType;
61506150- /**
61516151- * Optional.
61526152- */
61536153- dark_theme?: ThemeType;
61546154- /**
61556155- * Optional.
61566156- */
61576157- default_locale?: string;
61586158- /**
61596159- * Optional.
61606160- */
61616161- theme_experiment?: ThemeExperiment;
61626162- /**
61636163- * Optional.
61646164- */
61656165- icons?: Record<string, string>;
61666166- }
61676167- interface ManifestBaseDeveloperType {
61686168- /**
61696169- * Optional.
61706170- */
61716171- name?: string;
61726172- /**
61736173- * Optional.
61746174- */
61756175- url?: string;
61766176- }
61776177- /**
61786178- * The 'split' value is not supported.
61796179- */
61806180- type WebExtensionManifestIncognitoEnum = "not_allowed" | "spanning" | "split";
61816181- /**
61826182- * Only supported for page/scripts; not for service_worker yet, see bug 1775574
61836183- */
61846184- type WebExtensionManifestBackgroundTypeEnum = "module" | "classic";
61856185- type WebExtensionManifestBackgroundPreferredEnvironmentItemEnum = "service_worker" | "document";
61866186- interface WebExtensionManifestBackgroundType {
61876187- /**
61886188- * Optional.
61896189- */
61906190- service_worker?: ExtensionURL;
61916191- /**
61926192- * Optional.
61936193- */
61946194- page?: ExtensionURL;
61956195- /**
61966196- * Optional.
61976197- */
61986198- scripts?: ExtensionURL[];
61996199- /**
62006200- * Only supported for page/scripts; not for service_worker yet, see bug 1775574
62016201- * Optional.
62026202- */
62036203- type?: WebExtensionManifestBackgroundTypeEnum;
62046204- /**
62056205- * Optional.
62066206- */
62076207- persistent?: boolean;
62086208- /**
62096209- * Optional.
62106210- */
62116211- preferred_environment?: WebExtensionManifestBackgroundPreferredEnvironmentItemEnum[];
62126212- }
62136213- interface WebExtensionManifestOptionsUiType {
62146214- page: ExtensionURL;
62156215- /**
62166216- * Defaults to true in Manifest V2; Deprecated in Manifest V3.
62176217- * Optional.
62186218- */
62196219- browser_style?: boolean;
62206220- /**
62216221- * chrome_style is ignored in Firefox. Its replacement (browser_style) has been deprecated.
62226222- * Optional.
62236223- */
62246224- chrome_style?: boolean;
62256225- /**
62266226- * Optional.
62276227- */
62286228- open_in_tab?: boolean;
62296229- }
62306230- interface WebExtensionManifestContentSecurityPolicyC2Type {
62316231- /**
62326232- * The Content Security Policy used for extension pages.
62336233- * Optional.
62346234- */
62356235- extension_pages?: string;
62366236- /**
62376237- * In addition, Manifest V3 disallows certain CSP modifications for `extension_pages` that were permitted in Manifest V2.
62386238- * The `script-src`, `object-src`, and `worker-src` directives may only have the following values:
62396239- * - `self`
62406240- * - `none` - Any localhost source, (`http://localhost`, `http://127.0.0.1`, or any port on those domains)
62416241- * Optional.
62426242- */
62436243- sandbox?: string;
62446244- }
62456245- interface WebExtensionManifestWebAccessibleResourcesC2ItemType {
62466246- resources: string[];
62476247- /**
62486248- * Optional.
62496249- */
62506250- matches?: MatchPattern[];
62516251- /**
62526252- * Optional.
62536253- */
62546254- extension_ids?: Array<ExtensionID | "*">;
62556255- }
62566256- interface WebExtensionManifestChromeSettingsOverridesSearchProviderType {
62576257- name: string;
62586258- /**
62596259- * Optional.
62606260- */
62616261- keyword?: string | string[];
62626262- search_url: string;
62636263- /**
62646264- * Optional.
62656265- */
62666266- favicon_url?: string;
62676267- /**
62686268- * Optional.
62696269- */
62706270- suggest_url?: string;
62716271- /**
62726272- * GET parameters to the search_url as a query string.
62736273- * Optional.
62746274- */
62756275- search_url_get_params?: string;
62766276- /**
62776277- * POST parameters to the search_url as a query string.
62786278- * Optional.
62796279- */
62806280- search_url_post_params?: string;
62816281- /**
62826282- * GET parameters to the suggest_url as a query string.
62836283- * Optional.
62846284- */
62856285- suggest_url_get_params?: string;
62866286- /**
62876287- * POST parameters to the suggest_url as a query string.
62886288- * Optional.
62896289- */
62906290- suggest_url_post_params?: string;
62916291- /**
62926292- * Encoding of the search term.
62936293- * Optional.
62946294- */
62956295- encoding?: string;
62966296- /**
62976297- * Sets the default engine to a built-in engine only.
62986298- * Optional.
62996299- */
63006300- is_default?: boolean;
63016301- }
63026302- interface WebExtensionManifestChromeSettingsOverridesType {
63036303- /**
63046304- * Optional.
63056305- */
63066306- homepage?: string;
63076307- /**
63086308- * Optional.
63096309- */
63106310- search_provider?: WebExtensionManifestChromeSettingsOverridesSearchProviderType;
63116311- }
63126312- interface WebExtensionManifestCommandsSuggestedKeyType {
63136313- /**
63146314- * Optional.
63156315- */
63166316- default?: KeyName;
63176317- /**
63186318- * Optional.
63196319- */
63206320- mac?: KeyName;
63216321- /**
63226322- * Optional.
63236323- */
63246324- linux?: KeyName;
63256325- /**
63266326- * Optional.
63276327- */
63286328- windows?: KeyName;
63296329- /**
63306330- * Optional.
63316331- */
63326332- chromeos?: string;
63336333- /**
63346334- * Optional.
63356335- */
63366336- android?: string;
63376337- /**
63386338- * Optional.
63396339- */
63406340- ios?: string;
63416341- }
63426342- interface WebExtensionManifestCommandsType {
63436343- /**
63446344- * Optional.
63456345- */
63466346- suggested_key?: WebExtensionManifestCommandsSuggestedKeyType;
63476347- /**
63486348- * Optional.
63496349- */
63506350- description?: string;
63516351- }
63526352- interface WebExtensionManifestDeclarativeNetRequestRuleResourcesItemType {
63536353- /**
63546354- * A non-empty string uniquely identifying the ruleset. IDs beginning with '_' are reserved for internal use.
63556355- */
63566356- id: string;
63576357- /**
63586358- * Whether the ruleset is enabled by default.
63596359- */
63606360- enabled: boolean;
63616361- /**
63626362- * The path of the JSON ruleset relative to the extension directory.
63636363- */
63646364- path: Browser.Manifest.ExtensionURL;
63656365- }
63666366- interface WebExtensionManifestDeclarativeNetRequestType {
63676367- rule_resources: WebExtensionManifestDeclarativeNetRequestRuleResourcesItemType[];
63686368- }
63696369- interface WebExtensionManifestExperimentApisType {
63706370- [s: string]: Browser.Experiments.ExperimentAPI;
63716371- }
63726372- interface WebExtensionManifestOmniboxType {
63736373- keyword: string;
63746374- }
63756375- interface WebExtensionManifestPageActionType {
63766376- /**
63776377- * Optional.
63786378- */
63796379- default_title?: string;
63806380- /**
63816381- * Optional.
63826382- */
63836383- default_icon?: IconPath;
63846384- /**
63856385- * Optional.
63866386- */
63876387- default_popup?: string;
63886388- /**
63896389- * Deprecated in Manifest V3.
63906390- * Optional.
63916391- */
63926392- browser_style?: boolean;
63936393- /**
63946394- * Optional.
63956395- */
63966396- show_matches?: MatchPattern[];
63976397- /**
63986398- * Optional.
63996399- */
64006400- hide_matches?: MatchPatternRestricted[];
64016401- /**
64026402- * Optional.
64036403- */
64046404- pinned?: boolean;
64056405- }
64066406- interface WebExtensionManifestSidebarActionType {
64076407- /**
64086408- * Optional.
64096409- */
64106410- default_title?: string;
64116411- /**
64126412- * Optional.
64136413- */
64146414- default_icon?: IconPath;
64156415- /**
64166416- * Defaults to true in Manifest V2; Deprecated in Manifest V3.
64176417- * Optional.
64186418- */
64196419- browser_style?: boolean;
64206420- default_panel: string;
64216421- /**
64226422- * Whether or not the sidebar is opened at install. Default is <code>true</code>.
64236423- * Optional.
64246424- */
64256425- open_at_install?: boolean;
64266426- }
64276427- interface WebExtensionManifestChromeUrlOverridesType {
64286428- /**
64296429- * Optional.
64306430- */
64316431- newtab?: ExtensionURL;
64326432- }
64336433- interface WebExtensionManifestUserScriptsType {
64346434- /**
64356435- * Optional.
64366436- */
64376437- api_script?: Browser.Manifest.ExtensionURL;
64386438- }
64396439- interface WebExtensionLangpackManifestLanguagesPatternType {
64406440- chrome_resources: Record<string, ExtensionURL | Record<string, ExtensionURL>>;
64416441- version: string;
64426442- }
64436443- interface WebExtensionLangpackManifestSourcesPatternType {
64446444- base_path: ExtensionURL;
64456445- /**
64466446- * Optional.
64476447- */
64486448- paths?: string[];
64496449- }
64506450- interface FirefoxSpecificPropertiesDataCollectionPermissionsType {
64516451- /**
64526452- * Optional.
64536453- */
64546454- required?: DataCollectionPermission[];
64556455- /**
64566456- * Optional.
64576457- */
64586458- optional?: OptionalDataCollectionPermission[];
64596459- }
64606460- /**
64616461- * Defines the location the browserAction will appear by default. The default location is navbar.
64626462- */
64636463- type ActionManifestDefaultAreaEnum = "navbar" | "menupanel" | "tabstrip" | "personaltoolbar";
64646464- interface ThemeExperimentImagesType {
64656465- [s: string]: unknown;
64666466- }
64676467- interface ThemeExperimentColorsType {
64686468- [s: string]: unknown;
64696469- }
64706470- interface ThemeExperimentPropertiesType {
64716471- [s: string]: unknown;
64726472- }
64736473- interface ThemeTypeImagesType {
64746474- /**
64756475- * Optional.
64766476- */
64776477- additional_backgrounds?: ImageDataOrExtensionURL[];
64786478- /**
64796479- * Optional.
64806480- */
64816481- theme_frame?: ImageDataOrExtensionURL;
64826482- }
64836483- interface ThemeTypeColorsType {
64846484- /**
64856485- * Optional.
64866486- */
64876487- tab_selected?: ThemeColor;
64886488- /**
64896489- * Optional.
64906490- */
64916491- frame?: ThemeColor;
64926492- /**
64936493- * Optional.
64946494- */
64956495- frame_inactive?: ThemeColor;
64966496- /**
64976497- * Optional.
64986498- */
64996499- tab_background_text?: ThemeColor;
65006500- /**
65016501- * Optional.
65026502- */
65036503- tab_background_separator?: ThemeColor;
65046504- /**
65056505- * Optional.
65066506- */
65076507- tab_loading?: ThemeColor;
65086508- /**
65096509- * Optional.
65106510- */
65116511- tab_text?: ThemeColor;
65126512- /**
65136513- * Optional.
65146514- */
65156515- tab_line?: ThemeColor;
65166516- /**
65176517- * Optional.
65186518- */
65196519- toolbar?: ThemeColor;
65206520- /**
65216521- * This color property is an alias of 'bookmark_text'.
65226522- * Optional.
65236523- */
65246524- toolbar_text?: ThemeColor;
65256525- /**
65266526- * Optional.
65276527- */
65286528- bookmark_text?: ThemeColor;
65296529- /**
65306530- * Optional.
65316531- */
65326532- toolbar_field?: ThemeColor;
65336533- /**
65346534- * Optional.
65356535- */
65366536- toolbar_field_text?: ThemeColor;
65376537- /**
65386538- * Optional.
65396539- */
65406540- toolbar_field_border?: ThemeColor;
65416541- /**
65426542- * Optional.
65436543- */
65446544- toolbar_top_separator?: ThemeColor;
65456545- /**
65466546- * Optional.
65476547- */
65486548- toolbar_bottom_separator?: ThemeColor;
65496549- /**
65506550- * Optional.
65516551- */
65526552- toolbar_vertical_separator?: ThemeColor;
65536553- /**
65546554- * Optional.
65556555- */
65566556- icons?: ThemeColor;
65576557- /**
65586558- * Optional.
65596559- */
65606560- icons_attention?: ThemeColor;
65616561- /**
65626562- * Optional.
65636563- */
65646564- button_background_hover?: ThemeColor;
65656565- /**
65666566- * Optional.
65676567- */
65686568- button_background_active?: ThemeColor;
65696569- /**
65706570- * Optional.
65716571- */
65726572- popup?: ThemeColor;
65736573- /**
65746574- * Optional.
65756575- */
65766576- popup_text?: ThemeColor;
65776577- /**
65786578- * Optional.
65796579- */
65806580- popup_border?: ThemeColor;
65816581- /**
65826582- * Optional.
65836583- */
65846584- toolbar_field_focus?: ThemeColor;
65856585- /**
65866586- * Optional.
65876587- */
65886588- toolbar_field_text_focus?: ThemeColor;
65896589- /**
65906590- * Optional.
65916591- */
65926592- toolbar_field_border_focus?: ThemeColor;
65936593- /**
65946594- * Optional.
65956595- */
65966596- popup_highlight?: ThemeColor;
65976597- /**
65986598- * Optional.
65996599- */
66006600- popup_highlight_text?: ThemeColor;
66016601- /**
66026602- * Optional.
66036603- */
66046604- ntp_background?: ThemeColor;
66056605- /**
66066606- * Optional.
66076607- */
66086608- ntp_card_background?: ThemeColor;
66096609- /**
66106610- * Optional.
66116611- */
66126612- ntp_text?: ThemeColor;
66136613- /**
66146614- * Optional.
66156615- */
66166616- sidebar?: ThemeColor;
66176617- /**
66186618- * Optional.
66196619- */
66206620- sidebar_border?: ThemeColor;
66216621- /**
66226622- * Optional.
66236623- */
66246624- sidebar_text?: ThemeColor;
66256625- /**
66266626- * Optional.
66276627- */
66286628- sidebar_highlight?: ThemeColor;
66296629- /**
66306630- * Optional.
66316631- */
66326632- sidebar_highlight_text?: ThemeColor;
66336633- /**
66346634- * Optional.
66356635- */
66366636- toolbar_field_highlight?: ThemeColor;
66376637- /**
66386638- * Optional.
66396639- */
66406640- toolbar_field_highlight_text?: ThemeColor;
66416641- }
66426642- type ThemeTypePropertiesAdditionalBackgroundsAlignmentItemEnum = "bottom" | "center" | "left" | "right" | "top" | "center bottom" | "center center" | "center top" | "left bottom" | "left center" | "left top" | "right bottom" | "right center" | "right top";
66436643- type ThemeTypePropertiesAdditionalBackgroundsTilingItemEnum = "no-repeat" | "repeat" | "repeat-x" | "repeat-y";
66446644- type ThemeTypePropertiesColorSchemeEnum = "auto" | "light" | "dark" | "system";
66456645- type ThemeTypePropertiesContentColorSchemeEnum = "auto" | "light" | "dark" | "system";
66466646- interface ThemeTypePropertiesType {
66476647- /**
66486648- * Optional.
66496649- */
66506650- additional_backgrounds_alignment?: ThemeTypePropertiesAdditionalBackgroundsAlignmentItemEnum[];
66516651- /**
66526652- * Optional.
66536653- */
66546654- additional_backgrounds_tiling?: ThemeTypePropertiesAdditionalBackgroundsTilingItemEnum[];
66556655- /**
66566656- * Optional.
66576657- */
66586658- color_scheme?: ThemeTypePropertiesColorSchemeEnum;
66596659- /**
66606660- * Optional.
66616661- */
66626662- content_color_scheme?: ThemeTypePropertiesContentColorSchemeEnum;
66636663- }
66646664- interface Static {
66656665- [s: string]: unknown;
66666666- }
66676667- }
66686668- /**
66696669- * Namespace: browser.contextMenus
66706670- */
66716671- namespace ContextMenus {
66726672- interface Static extends Menus.Static {
66736673- [s: string]: unknown;
66746674- }
66756675- }
66766676- /**
66776677- * Namespace: browser.menus
66786678- */
66796679- namespace Menus {
66806680- /**
66816681- * The different contexts a menu can appear in. Specifying 'all' is equivalent to the combination of all other contexts
66826682- * except for 'tab' and 'tools_menu'.
66836683- */
66846684- type ContextType = "all" | "page" | "frame" | "selection" | "link" | "editable" | "password" | "image" | "video" | "audio" | "launcher" | "bookmark" | "page_action" | "tab" | "tools_menu" | "browser_action" | "action";
66856685- /**
66866686- * The type of menu item.
66876687- */
66886688- type ItemType = "normal" | "checkbox" | "radio" | "separator";
66896689- /**
66906690- * Information sent when a context menu item is clicked.
66916691- */
66926692- interface OnClickData {
66936693- /**
66946694- * The ID of the menu item that was clicked.
66956695- */
66966696- menuItemId: number | string;
66976697- /**
66986698- * The parent ID, if any, for the item clicked.
66996699- * Optional.
67006700- */
67016701- parentMenuItemId?: number | string;
67026702- /**
67036703- * The type of view where the menu is clicked. May be unset if the menu is not associated with a view.
67046704- * Optional.
67056705- */
67066706- viewType?: Browser.Extension.ViewType;
67076707- /**
67086708- * One of 'image', 'video', or 'audio' if the context menu was activated on one of these types of elements.
67096709- * Optional.
67106710- */
67116711- mediaType?: string;
67126712- /**
67136713- * If the element is a link, the text of that link.
67146714- * Optional.
67156715- */
67166716- linkText?: string;
67176717- /**
67186718- * If the element is a link, the URL it points to.
67196719- * Optional.
67206720- */
67216721- linkUrl?: string;
67226722- /**
67236723- * Will be present for elements with a 'src' URL.
67246724- * Optional.
67256725- */
67266726- srcUrl?: string;
67276727- /**
67286728- * The URL of the page where the menu item was clicked. This property is not set if the click occured in a context where
67296729- * there is no current page, such as in a launcher context menu.
67306730- * Optional.
67316731- */
67326732- pageUrl?: string;
67336733- /**
67346734- * The id of the frame of the element where the context menu was clicked.
67356735- * Optional.
67366736- */
67376737- frameId?: number;
67386738- /**
67396739- * The URL of the frame of the element where the context menu was clicked, if it was in a frame.
67406740- * Optional.
67416741- */
67426742- frameUrl?: string;
67436743- /**
67446744- * The text for the context selection, if any.
67456745- * Optional.
67466746- */
67476747- selectionText?: string;
67486748- /**
67496749- * A flag indicating whether the element is editable (text input, textarea, etc.).
67506750- */
67516751- editable: boolean;
67526752- /**
67536753- * A flag indicating the state of a checkbox or radio item before it was clicked.
67546754- * Optional.
67556755- */
67566756- wasChecked?: boolean;
67576757- /**
67586758- * A flag indicating the state of a checkbox or radio item after it is clicked.
67596759- * Optional.
67606760- */
67616761- checked?: boolean;
67626762- /**
67636763- * The id of the bookmark where the context menu was clicked, if it was on a bookmark.
67646764- * Optional.
67656765- */
67666766- bookmarkId?: string;
67676767- /**
67686768- * An array of keyboard modifiers that were held while the menu item was clicked.
67696769- */
67706770- modifiers: OnClickDataModifiersItemEnum[];
67716771- /**
67726772- * An integer value of button by which menu item was clicked.
67736773- * Optional.
67746774- */
67756775- button?: number;
67766776- /**
67776777- * An identifier of the clicked element, if any. Use menus.getTargetElement in the page to find the corresponding element.
67786778- * Optional.
67796779- */
67806780- targetElementId?: number;
67816781- }
67826782- interface CreateCreatePropertiesType {
67836783- /**
67846784- * The type of menu item. Defaults to 'normal' if not specified.
67856785- * Optional.
67866786- */
67876787- type?: ItemType;
67886788- /**
67896789- * The unique ID to assign to this item. Mandatory for event pages. Cannot be the same as another ID for this extension.
67906790- * Optional.
67916791- */
67926792- id?: string;
67936793- /**
67946794- * Optional.
67956795- */
67966796- icons?: Record<string, string>;
67976797- /**
67986798- * The text to be displayed in the item; this is <em>required</em> unless <code>type</code> is 'separator'.
67996799- * When the context is 'selection', you can use <code>%s</code> within the string to show the selected text. For example,
68006800- * if this parameter's value is "Translate '%s' to Pig Latin" and the user selects the word "cool",
68016801- * the context menu item for the selection is "Translate 'cool' to Pig Latin".
68026802- * Optional.
68036803- */
68046804- title?: string;
68056805- /**
68066806- * The initial state of a checkbox or radio item: true for selected and false for unselected.
68076807- * Only one radio item can be selected at a time in a given group of radio items.
68086808- * Optional.
68096809- */
68106810- checked?: boolean;
68116811- /**
68126812- * List of contexts this menu item will appear in. Defaults to ['page'] if not specified.
68136813- * Optional.
68146814- */
68156815- contexts?: ContextType[];
68166816- /**
68176817- * List of view types where the menu item will be shown. Defaults to any view, including those without a viewType.
68186818- * Optional.
68196819- */
68206820- viewTypes?: Browser.Extension.ViewType[];
68216821- /**
68226822- * Whether the item is visible in the menu.
68236823- * Optional.
68246824- */
68256825- visible?: boolean;
68266826- /**
68276827- * A function that will be called back when the menu item is clicked. Event pages cannot use this; instead,
68286828- * they should register a listener for $(ref:contextMenus.onClicked).
68296829- *
68306830- * @param info Information about the item clicked and the context where the click happened.
68316831- * @param tab The details of the tab where the click took place. Note: this parameter only present for extensions.
68326832- */
68336833- onclick?(info: OnClickData, tab: Browser.Tabs.Tab): void;
68346834- /**
68356835- * The ID of a parent menu item; this makes the item a child of a previously added item.
68366836- * Optional.
68376837- */
68386838- parentId?: number | string;
68396839- /**
68406840- * Lets you restrict the item to apply only to documents whose URL matches one of the given patterns.
68416841- * (This applies to frames as well.) For details on the format of a pattern, see $(topic:match_patterns)[Match Patterns].
68426842- * Optional.
68436843- */
68446844- documentUrlPatterns?: string[];
68456845- /**
68466846- * Similar to documentUrlPatterns, but lets you filter based on the src attribute of img/audio/video tags and the href of
68476847- * anchor tags.
68486848- * Optional.
68496849- */
68506850- targetUrlPatterns?: string[];
68516851- /**
68526852- * Whether this context menu item is enabled or disabled. Defaults to true.
68536853- * Optional.
68546854- */
68556855- enabled?: boolean;
68566856- /**
68576857- * Specifies a command to issue for the context click.
68586858- * Optional.
68596859- */
68606860- command?: string | "_execute_browser_action" | "_execute_page_action" | "_execute_sidebar_action" | "_execute_action" | "_execute_page_action" | "_execute_sidebar_action";
68616861- }
68626862- /**
68636863- * The properties to update. Accepts the same values as the create function.
68646864- */
68656865- interface UpdateUpdatePropertiesType {
68666866- /**
68676867- * Optional.
68686868- */
68696869- type?: ItemType;
68706870- /**
68716871- * Optional.
68726872- */
68736873- icons?: Record<string, string>;
68746874- /**
68756875- * Optional.
68766876- */
68776877- title?: string;
68786878- /**
68796879- * Optional.
68806880- */
68816881- checked?: boolean;
68826882- /**
68836883- * Optional.
68846884- */
68856885- contexts?: ContextType[];
68866886- /**
68876887- * Optional.
68886888- */
68896889- viewTypes?: Browser.Extension.ViewType[];
68906890- /**
68916891- * Whether the item is visible in the menu.
68926892- * Optional.
68936893- */
68946894- visible?: boolean;
68956895- /**
68966896- * @param tab The details of the tab where the click took place. Note: this parameter only present for extensions.
68976897- */
68986898- onclick?(info: OnClickData, tab: Browser.Tabs.Tab): void;
68996899- /**
69006900- * Note: You cannot change an item to be a child of one of its own descendants.
69016901- * Optional.
69026902- */
69036903- parentId?: number | string;
69046904- /**
69056905- * Optional.
69066906- */
69076907- documentUrlPatterns?: string[];
69086908- /**
69096909- * Optional.
69106910- */
69116911- targetUrlPatterns?: string[];
69126912- /**
69136913- * Optional.
69146914- */
69156915- enabled?: boolean;
69166916- }
69176917- interface OverrideContextContextOptionsType {
69186918- /**
69196919- * Whether to also include default menu items in the menu.
69206920- * Optional.
69216921- */
69226922- showDefaults?: boolean;
69236923- /**
69246924- * ContextType to override, to allow menu items from other extensions in the menu. Currently only 'bookmark' and 'tab' are
69256925- * supported. showDefaults cannot be used with this option.
69266926- * Optional.
69276927- */
69286928- context?: OverrideContextContextOptionsTypeContextEnum;
69296929- /**
69306930- * Required when context is 'bookmark'. Requires 'bookmark' permission.
69316931- * Optional.
69326932- */
69336933- bookmarkId?: string;
69346934- /**
69356935- * Required when context is 'tab'. Requires 'tabs' permission.
69366936- * Optional.
69376937- */
69386938- tabId?: number;
69396939- }
69406940- /**
69416941- * Information about the context of the menu action and the created menu items. For more information about each property,
69426942- * see OnClickData. The following properties are only set if the extension has host permissions for the given context:
69436943- * linkUrl, linkText, srcUrl, pageUrl, frameUrl, selectionText.
69446944- */
69456945- interface OnShownInfoType {
69466946- /**
69476947- * A list of IDs of the menu items that were shown.
69486948- */
69496949- menuIds: Array<number | string>;
69506950- /**
69516951- * A list of all contexts that apply to the menu.
69526952- */
69536953- contexts: ContextType[];
69546954- /**
69556955- * Optional.
69566956- */
69576957- viewType?: Browser.Extension.ViewType;
69586958- editable: boolean;
69596959- /**
69606960- * Optional.
69616961- */
69626962- mediaType?: string;
69636963- /**
69646964- * Optional.
69656965- */
69666966- linkUrl?: string;
69676967- /**
69686968- * Optional.
69696969- */
69706970- linkText?: string;
69716971- /**
69726972- * Optional.
69736973- */
69746974- srcUrl?: string;
69756975- /**
69766976- * Optional.
69776977- */
69786978- pageUrl?: string;
69796979- /**
69806980- * Optional.
69816981- */
69826982- frameUrl?: string;
69836983- /**
69846984- * Optional.
69856985- */
69866986- selectionText?: string;
69876987- /**
69886988- * Optional.
69896989- */
69906990- targetElementId?: number;
69916991- }
69926992- type OnClickDataModifiersItemEnum = "Shift" | "Alt" | "Command" | "Ctrl" | "MacCtrl";
69936993- /**
69946994- * ContextType to override, to allow menu items from other extensions in the menu. Currently only 'bookmark' and 'tab' are
69956995- * supported. showDefaults cannot be used with this option.
69966996- */
69976997- type OverrideContextContextOptionsTypeContextEnum = "bookmark" | "tab";
69986998- interface Static {
69996999- /**
70007000- * Creates a new context menu item. Note that if an error occurs during creation, you may not find out until the creation
70017001- * callback fires (the details will be in $(ref:runtime.lastError)).
70027002- *
70037003- * @param callback Optional. Called when the item has been created in the browser. If there were any problems creating the
70047004- * item, details will be available in $(ref:runtime.lastError).
70057005- * @returns The ID of the newly created item.
70067006- */
70077007- create(createProperties: CreateCreatePropertiesType, callback?: () => void): number | string;
70087008- /**
70097009- * Updates a previously created context menu item.
70107010- *
70117011- * @param id The ID of the item to update.
70127012- * @param updateProperties The properties to update. Accepts the same values as the create function.
70137013- * @returns Called when the context menu has been updated.
70147014- */
70157015- update(id: number | string, updateProperties: UpdateUpdatePropertiesType): Promise<void>;
70167016- /**
70177017- * Removes a context menu item.
70187018- *
70197019- * @param menuItemId The ID of the context menu item to remove.
70207020- * @returns Called when the context menu has been removed.
70217021- */
70227022- remove(menuItemId: number | string): Promise<void>;
70237023- /**
70247024- * Removes all context menu items added by this extension.
70257025- *
70267026- * @returns Called when removal is complete.
70277027- */
70287028- removeAll(): Promise<void>;
70297029- /**
70307030- * Show the matching menu items from this extension instead of the default menu. This should be called during a
70317031- * 'contextmenu' DOM event handler, and only applies to the menu that opens after this event.
70327032- */
70337033- overrideContext(contextOptions: OverrideContextContextOptionsType): void;
70347034- /**
70357035- * Updates the extension items in the shown menu, including changes that have been made since the menu was shown.
70367036- * Has no effect if the menu is hidden. Rebuilding a shown menu is an expensive operation,
70377037- * only invoke this method when necessary.
70387038- */
70397039- refresh(): Promise<void>;
70407040- /**
70417041- * Retrieve the element that was associated with a recent contextmenu event.
70427042- *
70437043- * @param targetElementId The identifier of the clicked element, available as info.targetElementId in the menus.onShown,
70447044- * onClicked or onclick event.
70457045- */
70467046- getTargetElement(targetElementId: number): Element;
70477047- /**
70487048- * Fired when a context menu item is clicked.
70497049- *
70507050- * @param info Information about the item clicked and the context where the click happened.
70517051- * @param tab Optional. The details of the tab where the click took place. If the click did not take place in a tab,
70527052- * this parameter will be missing.
70537053- */
70547054- onClicked: Events.Event<(info: OnClickData, tab: Browser.Tabs.Tab | undefined) => void>;
70557055- /**
70567056- * Fired when a menu is shown. The extension can add, modify or remove menu items and call menus.refresh()
70577057- * to update the menu.
70587058- *
70597059- * @param info Information about the context of the menu action and the created menu items.
70607060- * For more information about each property, see OnClickData. The following properties are only set if the extension has
70617061- * host permissions for the given context: linkUrl, linkText, srcUrl, pageUrl, frameUrl, selectionText.
70627062- * @param tab The details of the tab where the menu was opened.
70637063- */
70647064- onShown: Events.Event<(info: OnShownInfoType, tab: Browser.Tabs.Tab) => void>;
70657065- /**
70667066- * Fired when a menu is hidden. This event is only fired if onShown has fired before.
70677067- */
70687068- onHidden: Events.Event<() => void>;
70697069- /**
70707070- * The maximum number of top level extension items that can be added to an extension action context menu.
70717071- * Any items beyond this limit will be ignored.
70727072- */
70737073- ACTION_MENU_TOP_LEVEL_LIMIT: 6;
70747074- }
70757075- }
70767076- /**
70777077- * Namespace: browser.networkStatus
70787078- */
70797079- namespace NetworkStatus {
70807080- interface NetworkLinkInfo {
70817081- /**
70827082- * Status of the network link, if "unknown" then link is usually assumed to be "up"
70837083- */
70847084- status: NetworkLinkInfoStatusEnum;
70857085- /**
70867086- * If known, the type of network connection that is avialable.
70877087- */
70887088- type: NetworkLinkInfoTypeEnum;
70897089- /**
70907090- * If known, the network id or name.
70917091- * Optional.
70927092- */
70937093- id?: string;
70947094- }
70957095- /**
70967096- * Status of the network link, if "unknown" then link is usually assumed to be "up"
70977097- */
70987098- type NetworkLinkInfoStatusEnum = "unknown" | "up" | "down";
70997099- /**
71007100- * If known, the type of network connection that is avialable.
71017101- */
71027102- type NetworkLinkInfoTypeEnum = "unknown" | "ethernet" | "usb" | "wifi" | "wimax" | "mobile";
71037103- interface Static {
71047104- /**
71057105- * Returns the $(ref:NetworkLinkInfo) of the current network connection.
71067106- */
71077107- getLinkInfo(): void;
71087108- /**
71097109- * Fired when the network connection state changes.
71107110- */
71117111- onConnectionChanged: Events.Event<(details: NetworkLinkInfo) => void>;
71127112- }
71137113- }
71147114- /**
71157115- * Namespace: browser.normandyAddonStudy
71167116- */
71177117- namespace NormandyAddonStudy {
71187118- interface Study {
71197119- /**
71207120- * The ID of the recipe for the study.
71217121- */
71227122- recipeId: number;
71237123- /**
71247124- * A slug to identify the study.
71257125- */
71267126- slug: string;
71277127- /**
71287128- * The name presented on about:studies.
71297129- */
71307130- userFacingName: string;
71317131- /**
71327132- * The description presented on about:studies.
71337133- */
71347134- userFacingDescription: string;
71357135- /**
71367136- * The study branch in which the user is enrolled.
71377137- */
71387138- branch: string;
71397139- /**
71407140- * The state of the study.
71417141- */
71427142- active: boolean;
71437143- /**
71447144- * The ID of the extension installed by the study.
71457145- */
71467146- addonId: string;
71477147- /**
71487148- * The URL of the XPI that was downloaded and installed by the study.
71497149- */
71507150- addonUrl: string;
71517151- /**
71527152- * The version of the extension installed by the study.
71537153- */
71547154- addonVersion: string;
71557155- /**
71567156- * The start date for the study.
71577157- */
71587158- studyStartDate: ExtensionTypes.DateType;
71597159- /**
71607160- * The end date for the study.
71617161- */
71627162- studyEndDate: ExtensionTypes.DateType;
71637163- /**
71647164- * The record ID for the extension in Normandy server's database.
71657165- */
71667166- extensionApiId: number;
71677167- /**
71687168- * A hash of the extension XPI file.
71697169- */
71707170- extensionHash: string;
71717171- /**
71727172- * The algorithm used to hash the extension XPI file.
71737173- */
71747174- extensionHashAlgorithm: string;
71757175- }
71767176- interface Static {
71777177- /**
71787178- * Returns a study object for the current study.
71797179- */
71807180- getStudy(): void;
71817181- /**
71827182- * Marks the study as ended and then uninstalls the addon.
71837183- *
71847184- * @param reason The reason why the study is ending.
71857185- */
71867186- endStudy(reason: string): void;
71877187- /**
71887188- * Returns an object with metadata about the client which may be required for constructing survey URLs.
71897189- */
71907190- getClientMetadata(): void;
71917191- /**
71927192- * Fired when a user unenrolls from a study but before the addon is uninstalled.
71937193- *
71947194- * @param reason The reason why the study is ending.
71957195- */
71967196- onUnenroll: Events.Event<(reason: string) => void>;
71977197- }
71987198- }
71997199- /**
72007200- * Namespace: browser.notifications
72017201- */
72027202- namespace Notifications {
72037203- type TemplateType = "basic" | "image" | "list" | "progress";
72047204- type PermissionLevel = "granted" | "denied";
72057205- interface NotificationItem {
72067206- /**
72077207- * Title of one item of a list notification.
72087208- */
72097209- title: string;
72107210- /**
72117211- * Additional details about this item.
72127212- */
72137213- message: string;
72147214- }
72157215- interface CreateNotificationOptions {
72167216- /**
72177217- * Which type of notification to display.
72187218- */
72197219- type: TemplateType;
72207220- /**
72217221- * A URL to the sender's avatar, app icon, or a thumbnail for image notifications.
72227222- * Optional.
72237223- */
72247224- iconUrl?: string;
72257225- /**
72267226- * A URL to the app icon mask.
72277227- * Optional.
72287228- */
72297229- appIconMaskUrl?: string;
72307230- /**
72317231- * Title of the notification (e.g. sender name for email).
72327232- */
72337233- title: string;
72347234- /**
72357235- * Main notification content.
72367236- */
72377237- message: string;
72387238- /**
72397239- * Alternate notification content with a lower-weight font.
72407240- * Optional.
72417241- */
72427242- contextMessage?: string;
72437243- /**
72447244- * Priority ranges from -2 to 2. -2 is lowest priority. 2 is highest. Zero is default.
72457245- * Optional.
72467246- */
72477247- priority?: number;
72487248- /**
72497249- * A timestamp associated with the notification, in milliseconds past the epoch.
72507250- * Optional.
72517251- */
72527252- eventTime?: number;
72537253- /**
72547254- * A URL to the image thumbnail for image-type notifications.
72557255- * Optional.
72567256- */
72577257- imageUrl?: string;
72587258- /**
72597259- * Items for multi-item notifications.
72607260- * Optional.
72617261- */
72627262- items?: NotificationItem[];
72637263- /**
72647264- * Current progress ranges from 0 to 100.
72657265- * Optional.
72667266- */
72677267- progress?: number;
72687268- /**
72697269- * Whether to show UI indicating that the app will visibly respond to clicks on the body of a notification.
72707270- * Optional.
72717271- */
72727272- isClickable?: boolean;
72737273- }
72747274- interface UpdateNotificationOptions {
72757275- /**
72767276- * Which type of notification to display.
72777277- * Optional.
72787278- */
72797279- type?: TemplateType;
72807280- /**
72817281- * A URL to the sender's avatar, app icon, or a thumbnail for image notifications.
72827282- * Optional.
72837283- */
72847284- iconUrl?: string;
72857285- /**
72867286- * A URL to the app icon mask.
72877287- * Optional.
72887288- */
72897289- appIconMaskUrl?: string;
72907290- /**
72917291- * Title of the notification (e.g. sender name for email).
72927292- * Optional.
72937293- */
72947294- title?: string;
72957295- /**
72967296- * Main notification content.
72977297- * Optional.
72987298- */
72997299- message?: string;
73007300- /**
73017301- * Alternate notification content with a lower-weight font.
73027302- * Optional.
73037303- */
73047304- contextMessage?: string;
73057305- /**
73067306- * Priority ranges from -2 to 2. -2 is lowest priority. 2 is highest. Zero is default.
73077307- * Optional.
73087308- */
73097309- priority?: number;
73107310- /**
73117311- * A timestamp associated with the notification, in milliseconds past the epoch.
73127312- * Optional.
73137313- */
73147314- eventTime?: number;
73157315- /**
73167316- * A URL to the image thumbnail for image-type notifications.
73177317- * Optional.
73187318- */
73197319- imageUrl?: string;
73207320- /**
73217321- * Items for multi-item notifications.
73227322- * Optional.
73237323- */
73247324- items?: NotificationItem[];
73257325- /**
73267326- * Current progress ranges from 0 to 100.
73277327- * Optional.
73287328- */
73297329- progress?: number;
73307330- /**
73317331- * Whether to show UI indicating that the app will visibly respond to clicks on the body of a notification.
73327332- * Optional.
73337333- */
73347334- isClickable?: boolean;
73357335- }
73367336- interface Static {
73377337- /**
73387338- * Creates and displays a notification.
73397339- *
73407340- * @param notificationId Optional. Identifier of the notification. If it is empty, this method generates an id.
73417341- * If it matches an existing notification, this method first clears that notification before proceeding with the create
73427342- * operation.
73437343- * @param options Contents of the notification.
73447344- */
73457345- create(notificationId: string | undefined, options: CreateNotificationOptions): Promise<string>;
73467346- /**
73477347- * Creates and displays a notification.
73487348- *
73497349- * @param options Contents of the notification.
73507350- */
73517351- create(options: CreateNotificationOptions): Promise<string>;
73527352- /**
73537353- * Clears an existing notification.
73547354- *
73557355- * @param notificationId The id of the notification to be updated.
73567356- */
73577357- clear(notificationId: string): Promise<boolean>;
73587358- /**
73597359- * Retrieves all the notifications.
73607360- */
73617361- getAll(): Promise<Record<string, CreateNotificationOptions>>;
73627362- /**
73637363- * Fired when the notification closed, either by the system or by user action.
73647364- *
73657365- * @param notificationId The notificationId of the closed notification.
73667366- * @param byUser True if the notification was closed by the user.
73677367- */
73687368- onClosed: Events.Event<(notificationId: string, byUser: boolean) => void>;
73697369- /**
73707370- * Fired when the user clicked in a non-button area of the notification.
73717371- *
73727372- * @param notificationId The notificationId of the clicked notification.
73737373- */
73747374- onClicked: Events.Event<(notificationId: string) => void>;
73757375- /**
73767376- * Fired when the user pressed a button in the notification.
73777377- *
73787378- * @param notificationId The notificationId of the clicked notification.
73797379- * @param buttonIndex The index of the button clicked by the user.
73807380- */
73817381- onButtonClicked: Events.Event<(notificationId: string, buttonIndex: number) => void>;
73827382- /**
73837383- * Fired when the notification is shown.
73847384- *
73857385- * @param notificationId The notificationId of the shown notification.
73867386- */
73877387- onShown: Events.Event<(notificationId: string) => void>;
73887388- }
73897389- }
73907390- /**
73917391- * Namespace: browser.omnibox
73927392- */
73937393- namespace Omnibox {
73947394- /**
73957395- * The style type.
73967396- */
73977397- type DescriptionStyleType = "url" | "match" | "dim";
73987398- /**
73997399- * The window disposition for the omnibox query. This is the recommended context to display results. For example,
74007400- * if the omnibox command is to navigate to a certain URL, a disposition of 'newForegroundTab' means the navigation should
74017401- * take place in a new selected tab.
74027402- */
74037403- type OnInputEnteredDisposition = "currentTab" | "newForegroundTab" | "newBackgroundTab";
74047404- /**
74057405- * A suggest result.
74067406- */
74077407- interface SuggestResult {
74087408- /**
74097409- * The text that is put into the URL bar, and that is sent to the extension when the user chooses this entry.
74107410- */
74117411- content: string;
74127412- /**
74137413- * The text that is displayed in the URL dropdown. Can contain XML-style markup for styling.
74147414- * The supported tags are 'url' (for a literal URL), 'match' (for highlighting text that matched what the user's query),
74157415- * and 'dim' (for dim helper text). The styles can be nested, eg. <dim><match>dimmed match</match></dim>.
74167416- * You must escape the five predefined entities to display them as text: stackoverflow.com/a/1091953/89484
74177417- */
74187418- description: string;
74197419- /**
74207420- * Whether the suggest result can be deleted by the user.
74217421- * Optional.
74227422- */
74237423- deletable?: boolean;
74247424- }
74257425- /**
74267426- * A suggest result.
74277427- */
74287428- interface DefaultSuggestResult {
74297429- /**
74307430- * The text that is displayed in the URL dropdown.
74317431- */
74327432- description: string;
74337433- }
74347434- interface Static {
74357435- /**
74367436- * Sets the description and styling for the default suggestion. The default suggestion is the text that is displayed in the
74377437- * first suggestion row underneath the URL bar.
74387438- *
74397439- * @param suggestion A partial SuggestResult object, without the 'content' parameter.
74407440- */
74417441- setDefaultSuggestion(suggestion: DefaultSuggestResult): void;
74427442- /**
74437443- * User has started a keyword input session by typing the extension's keyword. This is guaranteed to be sent exactly once
74447444- * per input session, and before any onInputChanged events.
74457445- */
74467446- onInputStarted: Events.Event<() => void>;
74477447- /**
74487448- * User has changed what is typed into the omnibox.
74497449- *
74507450- * @param suggest A callback passed to the onInputChanged event used for sending suggestions back to the browser.
74517451- */
74527452- onInputChanged: Events.Event<(text: string, suggest: (suggestResults: SuggestResult[]) => void) => void>;
74537453- /**
74547454- * User has accepted what is typed into the omnibox.
74557455- */
74567456- onInputEntered: Events.Event<(text: string, disposition: OnInputEnteredDisposition) => void>;
74577457- /**
74587458- * User has ended the keyword input session without accepting the input.
74597459- */
74607460- onInputCancelled: Events.Event<() => void>;
74617461- /**
74627462- * User has deleted a suggested result.
74637463- */
74647464- onDeleteSuggestion: Events.Event<(text: string) => void>;
74657465- }
74667466- }
74677467- /**
74687468- * Namespace: browser.pageAction
74697469- */
74707470- namespace PageAction {
74717471- /**
74727472- * Pixel data for an image. Must be an ImageData object (for example, from a <code>canvas</code> element).
74737473- */
74747474- interface ImageDataType extends ImageData {
74757475- [s: string]: unknown;
74767476- }
74777477- /**
74787478- * Information sent when a page action is clicked.
74797479- */
74807480- interface OnClickData {
74817481- /**
74827482- * An array of keyboard modifiers that were held while the menu item was clicked.
74837483- */
74847484- modifiers: OnClickDataModifiersItemEnum[];
74857485- /**
74867486- * An integer value of button by which menu item was clicked.
74877487- * Optional.
74887488- */
74897489- button?: number;
74907490- }
74917491- interface IsShownDetailsType {
74927492- /**
74937493- * Specify the tab to get the shownness from.
74947494- */
74957495- tabId: number;
74967496- }
74977497- interface SetTitleDetailsType {
74987498- /**
74997499- * The id of the tab for which you want to modify the page action.
75007500- */
75017501- tabId: number;
75027502- /**
75037503- * The tooltip string.
75047504- */
75057505- title: string | null;
75067506- }
75077507- interface GetTitleDetailsType {
75087508- /**
75097509- * Specify the tab to get the title from.
75107510- */
75117511- tabId: number;
75127512- }
75137513- interface SetIconDetailsType {
75147514- /**
75157515- * The id of the tab for which you want to modify the page action.
75167516- */
75177517- tabId: number;
75187518- /**
75197519- * Either an ImageData object or a dictionary {size -> ImageData} representing icon to be set.
75207520- * If the icon is specified as a dictionary, the actual image to be used is chosen depending on screen's pixel density.
75217521- * If the number of image pixels that fit into one screen space unit equals <code>scale</code>, then image with size <code>
75227522- * scale</code> * 19 will be selected. Initially only scales 1 and 2 will be supported.
75237523- * At least one image must be specified. Note that 'details.imageData = foo' is equivalent to 'details.
75247524- * imageData = {'19': foo}'
75257525- * Optional.
75267526- */
75277527- imageData?: ImageDataType | Record<string, ImageDataType>;
75287528- /**
75297529- * Either a relative image path or a dictionary {size -> relative image path} pointing to icon to be set.
75307530- * If the icon is specified as a dictionary, the actual image to be used is chosen depending on screen's pixel density.
75317531- * If the number of image pixels that fit into one screen space unit equals <code>scale</code>, then image with size <code>
75327532- * scale</code> * 19 will be selected. Initially only scales 1 and 2 will be supported.
75337533- * At least one image must be specified. Note that 'details.path = foo' is equivalent to 'details.imageData = {'19': foo}'
75347534- * Optional.
75357535- */
75367536- path?: string | Record<string, string>;
75377537- }
75387538- interface SetPopupDetailsType {
75397539- /**
75407540- * The id of the tab for which you want to modify the page action.
75417541- */
75427542- tabId: number;
75437543- /**
75447544- * The html file to show in a popup. If set to the empty string (''), no popup is shown.
75457545- */
75467546- popup: string | null;
75477547- }
75487548- interface GetPopupDetailsType {
75497549- /**
75507550- * Specify the tab to get the popup from.
75517551- */
75527552- tabId: number;
75537553- }
75547554- type OnClickDataModifiersItemEnum = "Shift" | "Alt" | "Command" | "Ctrl" | "MacCtrl";
75557555- interface Static {
75567556- /**
75577557- * Shows the page action. The page action is shown whenever the tab is selected.
75587558- *
75597559- * @param tabId The id of the tab for which you want to modify the page action.
75607560- */
75617561- show(tabId: number): Promise<void>;
75627562- /**
75637563- * Hides the page action.
75647564- *
75657565- * @param tabId The id of the tab for which you want to modify the page action.
75667566- */
75677567- hide(tabId: number): Promise<void>;
75687568- /**
75697569- * Checks whether the page action is shown.
75707570- */
75717571- isShown(details: IsShownDetailsType): Promise<boolean>;
75727572- /**
75737573- * Sets the title of the page action. This is displayed in a tooltip over the page action.
75747574- */
75757575- setTitle(details: SetTitleDetailsType): void;
75767576- /**
75777577- * Gets the title of the page action.
75787578- */
75797579- getTitle(details: GetTitleDetailsType): Promise<string>;
75807580- /**
75817581- * Sets the icon for the page action. The icon can be specified either as the path to an image file or as the pixel data
75827582- * from a canvas element, or as dictionary of either one of those. Either the <b>path</b> or the <b>imageData</b>
75837583- * property must be specified.
75847584- */
75857585- setIcon(details: SetIconDetailsType): Promise<void>;
75867586- /**
75877587- * Sets the html document to be opened as a popup when the user clicks on the page action's icon.
75887588- */
75897589- setPopup(details: SetPopupDetailsType): Promise<void>;
75907590- /**
75917591- * Gets the html document set as the popup for this page action.
75927592- */
75937593- getPopup(details: GetPopupDetailsType): Promise<string>;
75947594- /**
75957595- * Opens the extension page action in the active window.
75967596- */
75977597- openPopup(): Promise<void>;
75987598- /**
75997599- * Fired when a page action icon is clicked. This event will not fire if the page action has a popup.
76007600- *
76017601- * @param info Optional.
76027602- */
76037603- onClicked: Events.Event<(tab: Browser.Tabs.Tab, info: OnClickData | undefined) => void>;
76047604- }
76057605- }
76067606- /**
76077607- * Namespace: browser.permissions
76087608- */
76097609- namespace Permissions {
76107610- interface Permissions {
76117611- /**
76127612- * Optional.
76137613- */
76147614- permissions?: Array<Browser.Manifest.OptionalPermission | Browser.Manifest.OptionalOnlyPermission>;
76157615- /**
76167616- * Optional.
76177617- */
76187618- origins?: Browser.Manifest.MatchPattern[];
76197619- /**
76207620- * Optional.
76217621- */
76227622- data_collection?: Browser.Manifest.OptionalDataCollectionPermission[];
76237623- }
76247624- interface AnyPermissions {
76257625- /**
76267626- * Optional.
76277627- */
76287628- permissions?: Array<Browser.Manifest.Permission | Browser.Manifest.OptionalOnlyPermission>;
76297629- /**
76307630- * Optional.
76317631- */
76327632- origins?: Browser.Manifest.MatchPattern[];
76337633- /**
76347634- * Optional.
76357635- */
76367636- data_collection?: Browser.Manifest.OptionalDataCollectionPermission[];
76377637- }
76387638- interface Static {
76397639- /**
76407640- * Get a list of all the extension's permissions.
76417641- */
76427642- getAll(): Promise<AnyPermissions>;
76437643- /**
76447644- * Check if the extension has the given permissions.
76457645- */
76467646- contains(permissions: AnyPermissions): Promise<boolean>;
76477647- /**
76487648- * Request the given permissions.
76497649- */
76507650- request(permissions: Permissions): Promise<boolean>;
76517651- /**
76527652- * Relinquish the given permissions.
76537653- */
76547654- remove(permissions: Permissions): Promise<boolean>;
76557655- /**
76567656- * Fired when the extension acquires new permissions.
76577657- */
76587658- onAdded: Events.Event<(permissions: Permissions) => void>;
76597659- /**
76607660- * Fired when permissions are removed from the extension.
76617661- */
76627662- onRemoved: Events.Event<(permissions: Permissions) => void>;
76637663- }
76647664- }
76657665- /**
76667666- * Namespace: browser.pkcs11
76677667- */
76687668- namespace Pkcs11 {
76697669- interface Token {
76707670- /**
76717671- * Name of the token.
76727672- */
76737673- name: string;
76747674- /**
76757675- * Name of the token's manufacturer.
76767676- */
76777677- manufacturer: string;
76787678- /**
76797679- * Hardware version, as a PKCS #11 version number (two 32-bit integers separated with a dot, like "1.0".
76807680- */
76817681- HWVersion: string;
76827682- /**
76837683- * Firmware version, as a PKCS #11 version number (two 32-bit integers separated with a dot, like "1.0".
76847684- */
76857685- FWVersion: string;
76867686- /**
76877687- * Serial number, whose format is defined by the token specification.
76887688- */
76897689- serial: string;
76907690- /**
76917691- * true if the token is logged on already, false otherwise.
76927692- */
76937693- isLoggedIn: boolean;
76947694- }
76957695- interface ModuleSlot {
76967696- /**
76977697- * The name of the slot.
76987698- */
76997699- name: string;
77007700- /**
77017701- * The token of the slot.
77027702- */
77037703- token: Token | null;
77047704- }
77057705- interface Static {
77067706- /**
77077707- * checks whether a PKCS#11 module, given by name, is installed
77087708- */
77097709- isModuleInstalled(name: string): Promise<boolean>;
77107710- /**
77117711- * Install a PKCS#11 module with a given name
77127712- *
77137713- * @param flags Optional.
77147714- */
77157715- installModule(name: string, flags?: number): Promise<void>;
77167716- /**
77177717- * Remove an installed PKCS#11 module from firefox
77187718- */
77197719- uninstallModule(name: string): Promise<void>;
77207720- /**
77217721- * Enumerate a module's slots, each with their name and whether a token is present
77227722- */
77237723- getModuleSlots(name: string): Promise<undefined>;
77247724- }
77257725- }
77267726- /**
77277727- * Namespace: browser.privacy
77287728- */
77297729- namespace Privacy {
77307730- interface Static {
77317731- network: Network.Static;
77327732- services: Services.Static;
77337733- websites: Websites.Static;
77347734- }
77357735- }
77367736- /**
77377737- * Namespace: browser.proxy
77387738- */
77397739- namespace Proxy {
77407740- /**
77417741- * An object which describes proxy settings.
77427742- */
77437743- interface ProxyConfig {
77447744- /**
77457745- * The type of proxy to use.
77467746- * Optional.
77477747- */
77487748- proxyType?: ProxyConfigProxyTypeEnum;
77497749- /**
77507750- * The address of the http proxy, can include a port.
77517751- * Optional.
77527752- */
77537753- http?: string;
77547754- /**
77557755- * Use the http proxy server for all protocols.
77567756- * Optional.
77577757- */
77587758- httpProxyAll?: boolean;
77597759- /**
77607760- * The address of the ssl proxy, can include a port.
77617761- * Optional.
77627762- */
77637763- ssl?: string;
77647764- /**
77657765- * The address of the socks proxy, can include a port.
77667766- * Optional.
77677767- */
77687768- socks?: string;
77697769- /**
77707770- * The version of the socks proxy.
77717771- * Optional.
77727772- */
77737773- socksVersion?: number;
77747774- /**
77757775- * A list of hosts which should not be proxied.
77767776- * Optional.
77777777- */
77787778- passthrough?: string;
77797779- /**
77807780- * A URL to use to configure the proxy.
77817781- * Optional.
77827782- */
77837783- autoConfigUrl?: string;
77847784- /**
77857785- * Do not prompt for authentication if password is saved.
77867786- * Optional.
77877787- */
77887788- autoLogin?: boolean;
77897789- /**
77907790- * Proxy DNS when using SOCKS. DNS queries get leaked to the network when set to false. True by default for SOCKS v5.
77917791- * False by default for SOCKS v4.
77927792- * Optional.
77937793- */
77947794- proxyDNS?: boolean;
77957795- /**
77967796- * If true (the default value), do not use newer TLS protocol features that might have interoperability problems on the
77977797- * Internet. This is intended only for use with critical infrastructure like the updates,
77987798- * and is only available to privileged addons.
77997799- * Optional.
78007800- */
78017801- respectBeConservative?: boolean;
78027802- }
78037803- interface OnRequestDetailsType {
78047804- /**
78057805- * The ID of the request. Request IDs are unique within a browser session. As a result,
78067806- * they could be used to relate different events of the same request.
78077807- */
78087808- requestId: string;
78097809- url: string;
78107810- /**
78117811- * Standard HTTP method.
78127812- */
78137813- method: string;
78147814- /**
78157815- * The value 0 indicates that the request happens in the main frame; a positive value indicates the ID of a subframe in
78167816- * which the request happens. If the document of a (sub-)frame is loaded (<code>type</code> is <code>main_frame</code>
78177817- * or <code>sub_frame</code>), <code>frameId</code> indicates the ID of this frame, not the ID of the outer frame.
78187818- * Frame IDs are unique within a tab.
78197819- */
78207820- frameId: number;
78217821- /**
78227822- * ID of frame that wraps the frame which sent the request. Set to -1 if no parent frame exists.
78237823- */
78247824- parentFrameId: number;
78257825- /**
78267826- * True for private browsing requests.
78277827- * Optional.
78287828- */
78297829- incognito?: boolean;
78307830- /**
78317831- * The cookie store ID of the contextual identity.
78327832- * Optional.
78337833- */
78347834- cookieStoreId?: string;
78357835- /**
78367836- * URL of the resource that triggered this request.
78377837- * Optional.
78387838- */
78397839- originUrl?: string;
78407840- /**
78417841- * URL of the page into which the requested resource will be loaded.
78427842- * Optional.
78437843- */
78447844- documentUrl?: string;
78457845- /**
78467846- * The ID of the tab in which the request takes place. Set to -1 if the request isn't related to a tab.
78477847- */
78487848- tabId: number;
78497849- /**
78507850- * How the requested resource will be used.
78517851- */
78527852- type: Browser.WebRequest.ResourceType;
78537853- /**
78547854- * The time when this signal is triggered, in milliseconds since the epoch.
78557855- */
78567856- timeStamp: number;
78577857- /**
78587858- * Indicates if this response was fetched from disk cache.
78597859- */
78607860- fromCache: boolean;
78617861- /**
78627862- * The HTTP request headers that are going to be sent out with this request.
78637863- * Optional.
78647864- */
78657865- requestHeaders?: Browser.WebRequest.HttpHeaders;
78667866- /**
78677867- * Url classification if the request has been classified.
78687868- */
78697869- urlClassification: Browser.WebRequest.UrlClassification;
78707870- /**
78717871- * Indicates if this request and its content window hierarchy is third party.
78727872- */
78737873- thirdParty: boolean;
78747874- }
78757875- interface OnErrorErrorType {
78767876- [s: string]: unknown;
78777877- }
78787878- /**
78797879- * The type of proxy to use.
78807880- */
78817881- type ProxyConfigProxyTypeEnum = "none" | "autoDetect" | "system" | "manual" | "autoConfig";
78827882- /**
78837883- * Fired when proxy data is needed for a request.
78847884- */
78857885- interface OnRequestEvent extends Events.Event<(details: OnRequestDetailsType) => void> {
78867886- /**
78877887- * Registers an event listener <em>callback</em> to an event.
78887888- *
78897889- * @param callback Called when an event occurs. The parameters of this function depend on the type of event.
78907890- * @param filter A set of filters that restricts the events that will be sent to this listener.
78917891- * @param extraInfoSpec Optional. Array of extra information that should be passed to the listener function.
78927892- */
78937893- addListener(callback: (details: OnRequestDetailsType) => void, filter: Browser.WebRequest.RequestFilter, extraInfoSpec?: string[]): void;
78947894- }
78957895- interface Static {
78967896- /**
78977897- * Fired when proxy data is needed for a request.
78987898- */
78997899- onRequest: OnRequestEvent;
79007900- /**
79017901- * Notifies about errors caused by the invalid use of the proxy API.
79027902- */
79037903- onError: Events.Event<(error: OnErrorErrorType) => void>;
79047904- /**
79057905- * Configures proxy settings. This setting's value is an object of type ProxyConfig.
79067906- */
79077907- settings: Browser.Types.Setting;
79087908- }
79097909- }
79107910- /**
79117911- * Namespace: browser.runtime
79127912- */
79137913- namespace Runtime {
79147914- /**
79157915- * A filter to match against existing extension context. Matching contexts must match all specified filters.
79167916- */
79177917- interface ContextFilter {
79187918- /**
79197919- * Optional.
79207920- */
79217921- contextIds?: string[];
79227922- /**
79237923- * Optional.
79247924- */
79257925- contextTypes?: ContextType[];
79267926- /**
79277927- * Optional.
79287928- */
79297929- documentIds?: string[];
79307930- /**
79317931- * Optional.
79327932- */
79337933- documentOrigins?: string[];
79347934- /**
79357935- * Optional.
79367936- */
79377937- documentUrls?: string[];
79387938- /**
79397939- * Optional.
79407940- */
79417941- frameIds?: number[];
79427942- /**
79437943- * Optional.
79447944- */
79457945- tabIds?: number[];
79467946- /**
79477947- * Optional.
79487948- */
79497949- windowIds?: number[];
79507950- /**
79517951- * Optional.
79527952- */
79537953- incognito?: boolean;
79547954- }
79557955- /**
79567956- * The type of extension view.
79577957- */
79587958- type ContextType = "BACKGROUND" | "POPUP" | "SIDE_PANEL" | "TAB";
79597959- /**
79607960- * A context hosting extension content
79617961- */
79627962- interface ExtensionContext {
79637963- /**
79647964- * An unique identifier associated to this context
79657965- */
79667966- contextId: string;
79677967- /**
79687968- * The type of the context
79697969- */
79707970- contextType: ContextType;
79717971- /**
79727972- * The origin of the document associated with this context, or undefined if it is not hosted in a document
79737973- * Optional.
79747974- */
79757975- documentOrigin?: string;
79767976- /**
79777977- * The URL of the document associated with this context, or undefined if it is not hosted in a document
79787978- * Optional.
79797979- */
79807980- documentUrl?: string;
79817981- /**
79827982- * Whether the context is associated with an private browsing context.
79837983- */
79847984- incognito: boolean;
79857985- /**
79867986- * The frame ID for this context, or -1 if it is not hosted in a frame.
79877987- */
79887988- frameId: number;
79897989- /**
79907990- * The tab ID for this context, or -1 if it is not hosted in a tab.
79917991- */
79927992- tabId: number;
79937993- /**
79947994- * The window ID for this context, or -1 if it is not hosted in a window.
79957995- */
79967996- windowId: number;
79977997- }
79987998- /**
79997999- * An object which allows two way communication with other pages.
80008000- */
80018001- interface Port {
80028002- name: string;
80038003- disconnect(): void;
80048004- onDisconnect: Events.Event<(port: Port) => void>;
80058005- onMessage: Events.Event<(message: unknown, port: Port) => void>;
80068006- /**
80078007- * Send a message to the other end. This takes one argument, which is a JSON object representing the message to send.
80088008- * It will be delivered to any script listening to the port's onMessage event, or to the native application if this port
80098009- * is connected to a native application.
80108010- */
80118011- postMessage(message: unknown): void;
80128012- /**
80138013- * This property will <b>only</b> be present on ports passed to onConnect/onConnectExternal listeners.
80148014- * Optional.
80158015- */
80168016- sender?: MessageSender;
80178017- /**
80188018- * If the port was disconnected due to an error, this will be set to an object with a string property message,
80198019- * giving you more information about the error. See onDisconnect.
80208020- * Optional.
80218021- */
80228022- error?: PortErrorType;
80238023- }
80248024- /**
80258025- * An object containing information about the script context that sent a message or request.
80268026- */
80278027- interface MessageSender {
80288028- /**
80298029- * The $(ref:tabs.Tab) which opened the connection, if any. This property will <strong>only</strong>
80308030- * be present when the connection was opened from a tab (including content scripts), and <strong>only</strong>
80318031- * if the receiver is an extension, not an app.
80328032- * Optional.
80338033- */
80348034- tab?: Browser.Tabs.Tab;
80358035- /**
80368036- * The $(topic:frame_ids)[frame] that opened the connection. 0 for top-level frames, positive for child frames.
80378037- * This will only be set when <code>tab</code> is set.
80388038- * Optional.
80398039- */
80408040- frameId?: number;
80418041- /**
80428042- * The ID of the extension or app that opened the connection, if any.
80438043- * Optional.
80448044- */
80458045- id?: string;
80468046- /**
80478047- * The URL of the page or frame that opened the connection. If the sender is in an iframe,
80488048- * it will be iframe's URL not the URL of the page which hosts it.
80498049- * Optional.
80508050- */
80518051- url?: string;
80528052- /**
80538053- * The worldId of the USER_SCRIPT world that sent the message. Only present on onUserScriptMessage and onUserScriptConnect
80548054- * (in port.sender) events.
80558055- * Optional.
80568056- */
80578057- userScriptWorldId?: string;
80588058- }
80598059- /**
80608060- * The operating system the browser is running on.
80618061- */
80628062- type PlatformOs = "mac" | "win" | "android" | "cros" | "linux" | "openbsd";
80638063- /**
80648064- * The machine's processor architecture.
80658065- */
80668066- type PlatformArch = "aarch64" | "arm" | "ppc64" | "s390x" | "sparc64" | "x86-32" | "x86-64" | "noarch";
80678067- /**
80688068- * An object containing information about the current platform.
80698069- */
80708070- interface PlatformInfo {
80718071- /**
80728072- * The operating system the browser is running on.
80738073- */
80748074- os: PlatformOs;
80758075- /**
80768076- * The machine's processor architecture.
80778077- */
80788078- arch: PlatformArch;
80798079- }
80808080- /**
80818081- * An object containing information about the current browser.
80828082- */
80838083- interface BrowserInfo {
80848084- /**
80858085- * The name of the browser, for example 'Firefox'.
80868086- */
80878087- name: string;
80888088- /**
80898089- * The name of the browser vendor, for example 'Mozilla'.
80908090- */
80918091- vendor: string;
80928092- /**
80938093- * The browser's version, for example '42.0.0' or '0.8.1pre'.
80948094- */
80958095- version: string;
80968096- /**
80978097- * The browser's build ID/date, for example '20160101'.
80988098- */
80998099- buildID: string;
81008100- }
81018101- /**
81028102- * Result of the update check.
81038103- */
81048104- type RequestUpdateCheckStatus = "throttled" | "no_update" | "update_available";
81058105- /**
81068106- * The reason that this event is being dispatched.
81078107- */
81088108- type OnInstalledReason = "install" | "update" | "browser_update";
81098109- /**
81108110- * The reason that the event is being dispatched. 'app_update' is used when the restart is needed because the application
81118111- * is updated to a newer version. 'os_update' is used when the restart is needed because the browser/OS is updated to a
81128112- * newer version. 'periodic' is used when the system runs for more than the permitted uptime set in the enterprise policy.
81138113- */
81148114- type OnRestartRequiredReason = "app_update" | "os_update" | "periodic";
81158115- /**
81168116- * The performance warning event category, e.g. 'content_script'.
81178117- */
81188118- type OnPerformanceWarningCategory = "content_script";
81198119- /**
81208120- * The performance warning event severity. Will be 'high' for serious and user-visible issues.
81218121- */
81228122- type OnPerformanceWarningSeverity = "low" | "medium" | "high";
81238123- /**
81248124- * The third parameter is a function to call (at most once) when you have a response.
81258125- * The argument should be any JSON-ifiable object. If you have more than one <code>onMessage</code>
81268126- * listener in the same document, then only one may send a response. <code>sendResponse</code>
81278127- * becomes invalid when the event listener returns, unless you return true from the event listener to indicate you wish to
81288128- * send a response asynchronously (this will keep the message channel open to the other end until <code>sendResponse</code>
81298129- * is called).
81308130- */
81318131- type OnMessageListenerCallback = (message: unknown, sender: MessageSender, sendResponse: (response: unknown) => void) => true;
81328132- /**
81338133- * The return value should be a promise of any JSON-ifiable object. If you have more than one <code>onMessage</code>
81348134- * listener in the same document, then only one may send a response.
81358135- */
81368136- type OnMessageListenerAsync = (message: unknown, sender: MessageSender) => Promise<unknown>;
81378137- type OnMessageListenerNoResponse = (message: unknown, sender: MessageSender) => void;
81388138- type OnMessageListener = OnMessageListenerCallback | OnMessageListenerAsync | OnMessageListenerNoResponse;
81398139- /**
81408140- * If an update is available, this contains more information about the available update.
81418141- */
81428142- interface RequestUpdateCheckCallbackDetailsType {
81438143- /**
81448144- * The version of the available update.
81458145- */
81468146- version: string;
81478147- }
81488148- interface ConnectConnectInfoType {
81498149- /**
81508150- * Will be passed into onConnect for processes that are listening for the connection event.
81518151- * Optional.
81528152- */
81538153- name?: string;
81548154- /**
81558155- * Whether the TLS channel ID will be passed into onConnectExternal for processes that are listening for the connection
81568156- * event.
81578157- * Optional.
81588158- */
81598159- includeTlsChannelId?: boolean;
81608160- }
81618161- interface SendMessageOptionsType {
81628162- [s: string]: unknown;
81638163- }
81648164- interface OnInstalledDetailsType {
81658165- /**
81668166- * The reason that this event is being dispatched.
81678167- */
81688168- reason: OnInstalledReason;
81698169- /**
81708170- * Indicates the previous version of the extension, which has just been updated. This is present only if 'reason' is
81718171- * 'update'.
81728172- * Optional.
81738173- */
81748174- previousVersion?: string;
81758175- /**
81768176- * Indicates whether the addon is installed as a temporary extension.
81778177- */
81788178- temporary: boolean;
81798179- }
81808180- /**
81818181- * The manifest details of the available update.
81828182- */
81838183- interface OnUpdateAvailableDetailsType {
81848184- /**
81858185- * The version number of the available update.
81868186- */
81878187- version: string;
81888188- }
81898189- interface OnPerformanceWarningDetailsType {
81908190- /**
81918191- * The performance warning event category, e.g. 'content_script'.
81928192- */
81938193- category: OnPerformanceWarningCategory;
81948194- /**
81958195- * The performance warning event severity, e.g. 'high'.
81968196- */
81978197- severity: OnPerformanceWarningSeverity;
81988198- /**
81998199- * The $(ref:tabs.Tab) that the performance warning relates to, if any.
82008200- * Optional.
82018201- */
82028202- tabId?: number;
82038203- /**
82048204- * An explanation of what the warning means, and hopefully how to address it.
82058205- */
82068206- description: string;
82078207- }
82088208- /**
82098209- * This will be defined during an API method callback if there was an error
82108210- */
82118211- interface PropertyLastErrorType {
82128212- /**
82138213- * Details about the error which occurred.
82148214- * Optional.
82158215- */
82168216- message?: string;
82178217- }
82188218- /**
82198219- * If the port was disconnected due to an error, this will be set to an object with a string property message,
82208220- * giving you more information about the error. See onDisconnect.
82218221- */
82228222- interface PortErrorType {
82238223- message: string;
82248224- }
82258225- interface Static {
82268226- /**
82278227- * Retrieves the JavaScript 'window' object for the background page running inside the current extension/app.
82288228- * If the background page is an event page, the system will ensure it is loaded before calling the callback.
82298229- * If there is no background page, an error is set.
82308230- */
82318231- getBackgroundPage(): Promise<Window>;
82328232- /**
82338233- * Fetches information about active contexts associated with this extension
82348234- *
82358235- * @param filter A filter to find matching context.
82368236- */
82378237- getContexts(filter: ContextFilter): Promise<ExtensionContext[]>;
82388238- /**
82398239- * <p>Open your Extension's options page, if possible.</p><p>The precise behavior may depend on your manifest's <code>
82408240- * $(topic:optionsV2)[options_ui]</code> or <code>$(topic:options)[options_page]</code> key,
82418241- * or what the browser happens to support at the time.</p><p>If your Extension does not declare an options page,
82428242- * or the browser failed to create one for some other reason, the callback will set $(ref:lastError).</p>
82438243- */
82448244- openOptionsPage(): Promise<void>;
82458245- /**
82468246- * Returns details about the app or extension from the manifest. The object returned is a serialization of the full
82478247- * $(topic:manifest)[manifest file].
82488248- *
82498249- * @returns The manifest details.
82508250- */
82518251- getManifest(): Promise<Manifest.WebExtensionManifest>;
82528252- /**
82538253- * Converts a relative path within an app/extension install directory to a fully-qualified URL.
82548254- *
82558255- * @param path A path to a resource within an app/extension expressed relative to its install directory.
82568256- * @returns The fully-qualified URL to the resource.
82578257- */
82588258- getURL(path: string): Promise<string>;
82598259- /**
82608260- * Get the frameId of any window global or frame element.
82618261- *
82628262- * @param target A WindowProxy or a Browsing Context container element (IFrame, Frame, Embed, Object) for the target frame.
82638263- * @returns The frameId of the target frame, or -1 if it doesn't exist.
82648264- */
82658265- getFrameId(target: unknown): number;
82668266- /**
82678267- * Sets the URL to be visited upon uninstallation. This may be used to clean up server-side data, do analytics,
82688268- * and implement surveys. Maximum 1023 characters.
82698269- *
82708270- * @param url Optional. URL to be opened after the extension is uninstalled. This URL must have an http: or https: scheme.
82718271- * Set an empty string to not open a new tab upon uninstallation.
82728272- * @returns Called when the uninstall URL is set. If the given URL is invalid, $(ref:runtime.lastError) will be set.
82738273- */
82748274- setUninstallURL(url?: string): Promise<void>;
82758275- /**
82768276- * Reloads the app or extension.
82778277- */
82788278- reload(): void;
82798279- /**
82808280- * Requests an update check for this app/extension.
82818281- */
82828282- requestUpdateCheck(): Promise<[
82838283- RequestUpdateCheckStatus,
82848284- RequestUpdateCheckCallbackDetailsType
82858285- ]>;
82868286- /**
82878287- * Attempts to connect to connect listeners within an extension/app (such as the background page), or other extensions/apps.
82888288- * This is useful for content scripts connecting to their extension processes, inter-app/extension communication,
82898289- * and $(topic:manifest/externally_connectable)[web messaging]. Note that this does not connect to any listeners in a
82908290- * content script. Extensions may connect to content scripts embedded in tabs via $(ref:tabs.connect).
82918291- *
82928292- * @param extensionId Optional. The ID of the extension or app to connect to. If omitted,
82938293- * a connection will be attempted with your own extension. Required if sending messages from a web page for
82948294- * $(topic:manifest/externally_connectable)[web messaging].
82958295- * @param connectInfo Optional.
82968296- * @returns Port through which messages can be sent and received. The port's $(ref:runtime.Port onDisconnect)
82978297- * event is fired if the extension/app does not exist.
82988298- */
82998299- connect(extensionId?: string, connectInfo?: ConnectConnectInfoType): Port;
83008300- /**
83018301- * Attempts to connect to connect listeners within an extension/app (such as the background page), or other extensions/apps.
83028302- * This is useful for content scripts connecting to their extension processes, inter-app/extension communication,
83038303- * and $(topic:manifest/externally_connectable)[web messaging]. Note that this does not connect to any listeners in a
83048304- * content script. Extensions may connect to content scripts embedded in tabs via $(ref:tabs.connect).
83058305- *
83068306- * @param connectInfo Optional.
83078307- * @returns Port through which messages can be sent and received. The port's $(ref:runtime.Port onDisconnect)
83088308- * event is fired if the extension/app does not exist.
83098309- */
83108310- connect(connectInfo?: ConnectConnectInfoType): Port;
83118311- /**
83128312- * Connects to a native application in the host machine.
83138313- *
83148314- * @param application The name of the registered application to connect to.
83158315- * @returns Port through which messages can be sent and received with the application
83168316- */
83178317- connectNative(application: string): Port;
83188318- /**
83198319- * Sends a single message to event listeners within your extension/app or a different extension/app.
83208320- * Similar to $(ref:runtime.connect) but only sends a single message, with an optional response.
83218321- * If sending to your extension, the $(ref:runtime.onMessage) event will be fired in each page, or $(ref:runtime.
83228322- * onMessageExternal), if a different extension. Note that extensions cannot send messages to content scripts using this
83238323- * method. To send messages to content scripts, use $(ref:tabs.sendMessage).
83248324- *
83258325- * @param extensionId Optional. The ID of the extension/app to send the message to. If omitted,
83268326- * the message will be sent to your own extension/app. Required if sending messages from a web page for
83278327- * $(topic:manifest/externally_connectable)[web messaging].
83288328- * @param options Optional.
83298329- */
83308330- // eslint-disable-next-line @definitelytyped/no-unnecessary-generics
83318331- sendMessage<TMessage = unknown, TResponse = unknown>(extensionId: string | undefined, message: TMessage, options?: SendMessageOptionsType): Promise<TResponse>;
83328332- /**
83338333- * Sends a single message to event listeners within your extension/app or a different extension/app.
83348334- * Similar to $(ref:runtime.connect) but only sends a single message, with an optional response.
83358335- * If sending to your extension, the $(ref:runtime.onMessage) event will be fired in each page, or $(ref:runtime.
83368336- * onMessageExternal), if a different extension. Note that extensions cannot send messages to content scripts using this
83378337- * method. To send messages to content scripts, use $(ref:tabs.sendMessage).
83388338- *
83398339- * @param options Optional.
83408340- */
83418341- // eslint-disable-next-line @definitelytyped/no-unnecessary-generics
83428342- sendMessage<TMessage = unknown, TResponse = unknown>(message: TMessage, options?: SendMessageOptionsType): Promise<TResponse>;
83438343- /**
83448344- * Send a single message to a native application.
83458345- *
83468346- * @param application The name of the native messaging host.
83478347- * @param message The message that will be passed to the native messaging host.
83488348- */
83498349- // eslint-disable-next-line @definitelytyped/no-unnecessary-generics
83508350- sendNativeMessage<TMessage = unknown, TResponse = unknown>(application: string, message: TMessage): Promise<TResponse>;
83518351- /**
83528352- * Returns information about the current browser.
83538353- *
83548354- * @returns Called with results
83558355- */
83568356- getBrowserInfo(): Promise<BrowserInfo>;
83578357- /**
83588358- * Returns information about the current platform.
83598359- *
83608360- * @returns Called with results
83618361- */
83628362- getPlatformInfo(): Promise<PlatformInfo>;
83638363- /**
83648364- * Fired when a profile that has this extension installed first starts up. This event is not fired for incognito profiles.
83658365- */
83668366- onStartup: Events.Event<() => void>;
83678367- /**
83688368- * Fired when the extension is first installed, when the extension is updated to a new version,
83698369- * and when the browser is updated to a new version.
83708370- */
83718371- onInstalled: Events.Event<(details: OnInstalledDetailsType) => void>;
83728372- /**
83738373- * Sent to the event page just before it is unloaded. This gives the extension opportunity to do some clean up.
83748374- * Note that since the page is unloading, any asynchronous operations started while handling this event are not guaranteed
83758375- * to complete. If more activity for the event page occurs before it gets unloaded the onSuspendCanceled event will be sent
83768376- * and the page won't be unloaded.
83778377- */
83788378- onSuspend: Events.Event<() => void>;
83798379- /**
83808380- * Sent after onSuspend to indicate that the app won't be unloaded after all.
83818381- */
83828382- onSuspendCanceled: Events.Event<() => void>;
83838383- /**
83848384- * Fired when an update is available, but isn't installed immediately because the app is currently running.
83858385- * If you do nothing, the update will be installed the next time the background page gets unloaded,
83868386- * if you want it to be installed sooner you can explicitly call $(ref:runtime.reload).
83878387- * If your extension is using a persistent background page, the background page of course never gets unloaded,
83888388- * so unless you call $(ref:runtime.reload) manually in response to this event the update will not get installed until the
83898389- * next time the browser itself restarts. If no handlers are listening for this event,
83908390- * and your extension has a persistent background page, it behaves as if $(ref:runtime.reload)
83918391- * is called in response to this event.
83928392- *
83938393- * @param details The manifest details of the available update.
83948394- */
83958395- onUpdateAvailable: Events.Event<(details: OnUpdateAvailableDetailsType) => void>;
83968396- /**
83978397- * Fired when a connection is made from either an extension process or a content script.
83988398- */
83998399- onConnect: Events.Event<(port: Port) => void>;
84008400- /**
84018401- * Fired when a connection is made from a USER_SCRIPT world registered through the userScripts API.
84028402- */
84038403- onUserScriptConnect: Events.Event<(port: Port) => void>;
84048404- /**
84058405- * Fired when a connection is made from another extension.
84068406- */
84078407- onConnectExternal: Events.Event<(port: Port) => void>;
84088408- /**
84098409- * Fired when a message is sent from either an extension process or a content script.
84108410- */
84118411- onMessage: Events.Event<OnMessageListener>;
84128412- /**
84138413- * Fired when a message is sent from another extension/app. Cannot be used in a content script.
84148414- */
84158415- onMessageExternal: Events.Event<OnMessageListener>;
84168416- /**
84178417- * Fired when a message is sent from a USER_SCRIPT world registered through the userScripts API.
84188418- */
84198419- onUserScriptMessage: Events.Event<OnMessageListener>;
84208420- /**
84218421- * Fired when a runtime performance issue is detected with the extension. Observe this event to be proactively notified of
84228422- * runtime performance problems with the extension.
84238423- */
84248424- onPerformanceWarning: Events.Event<(details: OnPerformanceWarningDetailsType) => void>;
84258425- /**
84268426- * This will be defined during an API method callback if there was an error
84278427- * Optional.
84288428- */
84298429- lastError?: PropertyLastErrorType;
84308430- /**
84318431- * The ID of the extension/app.
84328432- */
84338433- id: string;
84348434- }
84358435- }
84368436- /**
84378437- * Namespace: browser.scripting
84388438- */
84398439- namespace Scripting {
84408440- /**
84418441- * Details of a script injection
84428442- */
84438443- interface ScriptInjection {
84448444- /**
84458445- * The arguments to curry into a provided function. This is only valid if the <code>func</code> parameter is specified.
84468446- * These arguments must be JSON-serializable.
84478447- * Optional.
84488448- */
84498449- args?: unknown[];
84508450- /**
84518451- * The path of the JS files to inject, relative to the extension's root directory. Exactly one of <code>files</code>
84528452- * and <code>func</code> must be specified.
84538453- * Optional.
84548454- */
84558455- files?: string[];
84568456- /**
84578457- * A JavaScript function to inject. This function will be serialized, and then deserialized for injection.
84588458- * This means that any bound parameters and execution context will be lost. Exactly one of <code>files</code> and <code>
84598459- * func</code> must be specified.
84608460- *
84618461- * @param ...args The arguments
84628462- * @returns The return value
84638463- */
84648464- func?(...args: unknown[]): unknown;
84658465- /**
84668466- * Details specifying the target into which to inject the script.
84678467- */
84688468- target: InjectionTarget;
84698469- /**
84708470- * Optional.
84718471- */
84728472- world?: ExecutionWorld;
84738473- /**
84748474- * Whether the injection should be triggered in the target as soon as possible (but not necessarily prior to page load).
84758475- * Optional.
84768476- */
84778477- injectImmediately?: boolean;
84788478- }
84798479- /**
84808480- * Result of a script injection.
84818481- */
84828482- interface InjectionResult {
84838483- /**
84848484- * The frame ID associated with the injection.
84858485- */
84868486- frameId: number;
84878487- /**
84888488- * The result of the script execution.
84898489- * Optional.
84908490- */
84918491- result?: unknown;
84928492- /**
84938493- * The error property is set when the script execution failed. The value is typically an (Error)
84948494- * object with a message property, but could be any value (including primitives and undefined)
84958495- * if the script threw or rejected with such a value.
84968496- * Optional.
84978497- */
84988498- error?: unknown;
84998499- /**
85008500- * Whether the script should inject into all frames within the tab. Defaults to false.
85018501- * This must not be true if frameIds is specified.
85028502- * Optional.
85038503- */
85048504- allFrames?: boolean;
85058505- }
85068506- /**
85078507- * Details of the script to insert.
85088508- */
85098509- interface InjectionTarget {
85108510- /**
85118511- * The IDs of specific frames to inject into.
85128512- * Optional.
85138513- */
85148514- frameIds?: number[];
85158515- /**
85168516- * Whether the script should inject into all frames within the tab. Defaults to false.
85178517- * This must not be true if frameIds is specified.
85188518- * Optional.
85198519- */
85208520- allFrames?: boolean;
85218521- /**
85228522- * The ID of the tab into which to inject.
85238523- */
85248524- tabId: number;
85258525- }
85268526- interface CSSInjection {
85278527- /**
85288528- * A string containing the CSS to inject. Exactly one of <code>files</code> and <code>css</code> must be specified.
85298529- * Optional.
85308530- */
85318531- css?: string;
85328532- /**
85338533- * The path of the CSS files to inject, relative to the extension's root directory. Exactly one of <code>files</code>
85348534- * and <code>css</code> must be specified.
85358535- * Optional.
85368536- */
85378537- files?: string[];
85388538- /**
85398539- * The style origin for the injection. Defaults to <code>'AUTHOR'</code>.
85408540- * Optional.
85418541- */
85428542- origin?: CSSInjectionOriginEnum;
85438543- /**
85448544- * Details specifying the target into which to inject the CSS.
85458545- */
85468546- target: InjectionTarget;
85478547- }
85488548- interface ContentScriptFilter {
85498549- /**
85508550- * The IDs of specific scripts to retrieve with <code>getRegisteredContentScripts()</code> or to unregister with <code>
85518551- * unregisterContentScripts()</code>.
85528552- * Optional.
85538553- */
85548554- ids?: string[];
85558555- }
85568556- /**
85578557- * The JavaScript world for a script to execute within. <code>ISOLATED</code> is the default execution environment of
85588558- * content scripts, <code>MAIN</code> is the web page's execution environment.
85598559- */
85608560- type ExecutionWorld = "ISOLATED" | "MAIN";
85618561- interface RegisteredContentScript {
85628562- /**
85638563- * If specified true, it will inject into all frames, even if the frame is not the top-most frame in the tab.
85648564- * Each frame is checked independently for URL requirements; it will not inject into child frames if the URL requirements
85658565- * are not met. Defaults to false, meaning that only the top frame is matched.
85668566- * Optional.
85678567- */
85688568- allFrames?: boolean;
85698569- /**
85708570- * Excludes pages that this content script would otherwise be injected into.
85718571- * Optional.
85728572- */
85738573- excludeMatches?: string[];
85748574- /**
85758575- * The id of the content script, specified in the API call.
85768576- */
85778577- id: string;
85788578- /**
85798579- * The list of JavaScript files to be injected into matching pages. These are injected in the order they appear in this
85808580- * array.
85818581- * Optional.
85828582- */
85838583- js?: Browser.Manifest.ExtensionURL[];
85848584- /**
85858585- * Specifies which pages this content script will be injected into. Must be specified for <code>registerContentScripts()
85868586- * </code>.
85878587- * Optional.
85888588- */
85898589- matches?: string[];
85908590- /**
85918591- * If matchOriginAsFallback is true, then the code is also injected in about:, data:,
85928592- * blob: when their origin matches the pattern in 'matches', even if the actual document origin is opaque (due to the use
85938593- * of CSP sandbox or iframe sandbox). Match patterns in 'matches' must specify a wildcard path glob. By default it is <code>
85948594- * false</code>.
85958595- * Optional.
85968596- */
85978597- matchOriginAsFallback?: boolean;
85988598- /**
85998599- * Specifies when JavaScript files are injected into the web page. The preferred and default value is <code>
86008600- * document_idle</code>.
86018601- * Optional.
86028602- */
86038603- runAt?: Browser.ExtensionTypes.RunAt;
86048604- /**
86058605- * The JavaScript world for a script to execute within. Defaults to "ISOLATED".
86068606- * Optional.
86078607- */
86088608- world?: ExecutionWorld;
86098609- /**
86108610- * Specifies if this content script will persist into future sessions. This is currently NOT supported.
86118611- * Optional.
86128612- */
86138613- persistAcrossSessions?: boolean;
86148614- /**
86158615- * The list of CSS files to be injected into matching pages. These are injected in the order they appear in this array.
86168616- * Optional.
86178617- */
86188618- css?: Browser.Manifest.ExtensionURL[];
86198619- }
86208620- /**
86218621- * The origin for a style change. See style origins for more info.
86228622- *
86238623- * "AUTHOR": The author origin is the style origin which contains all of the styles which are part of the document,
86248624- * whether embedded within the HTML or loaded from an external stylesheet file.
86258625- * "USER": The user origin is the style origin containing any CSS that the user of the web browser has added.
86268626- * These may be from adding styles using a developer tool or from a browser extension that automatically applies custom
86278627- * styles to content, such as Stylus or Stylish.
86288628- */
86298629- type StyleOrigin = "AUTHOR" | "USER";
86308630- /**
86318631- * Details of the css to insert.
86328632- */
86338633- interface CSSInjection {
86348634- /**
86358635- * A string containing the CSS to inject. Exactly one of files and css must be specified.
86368636- * Optional.
86378637- */
86388638- css?: string;
86398639- /**
86408640- * The path of the CSS files to inject, relative to the extension's root directory. NOTE: Currently a maximum of one file
86418641- * is supported. Exactly one of files and css must be specified.
86428642- * Optional.
86438643- */
86448644- files?: string[];
86458645- /**
86468646- * The style origin for the injection. Defaults to 'AUTHOR'.
86478647- * Optional.
86488648- */
86498649- origin?: StyleOrigin;
86508650- /**
86518651- * Details specifying the target into which to insert the CSS.
86528652- */
86538653- target: InjectionTarget;
86548654- }
86558655- interface UpdateContentScriptsScriptsItemType extends RegisteredContentScript {
86568656- /**
86578657- * Specifies if this content script will persist into future sessions.
86588658- * Optional.
86598659- */
86608660- persistAcrossSessions?: boolean;
86618661- }
86628662- /**
86638663- * The style origin for the injection. Defaults to <code>'AUTHOR'</code>.
86648664- */
86658665- type CSSInjectionOriginEnum = "USER" | "AUTHOR";
86668666- interface Static {
86678667- /**
86688668- * Injects a script into a target context. The script will be run at <code>document_idle</code>.
86698669- *
86708670- * @param injection The details of the script which to inject.
86718671- * @returns Invoked upon completion of the injection. The resulting array contains the result of execution for each frame
86728672- * where the injection succeeded.
86738673- */
86748674- executeScript(injection: ScriptInjection): Promise<InjectionResult[]>;
86758675- /**
86768676- * Inserts a CSS stylesheet into a target context. If multiple frames are specified, unsuccessful injections are ignored.
86778677- *
86788678- * @param injection The details of the styles to insert.
86798679- * @returns Invoked upon completion of the injection.
86808680- */
86818681- insertCSS(injection: CSSInjection): Promise<void>;
86828682- /**
86838683- * Removes a CSS stylesheet that was previously inserted by this extension from a target context.
86848684- *
86858685- * @param injection The details of the styles to remove. Note that the <code>css</code>, <code>files</code>, and <code>
86868686- * origin</code> properties must exactly match the stylesheet inserted through <code>insertCSS</code>.
86878687- * Attempting to remove a non-existent stylesheet is a no-op.
86888688- * @returns Invoked upon completion of the injection.
86898689- */
86908690- removeCSS(injection: CSSInjection): Promise<void>;
86918691- /**
86928692- * Registers one or more content scripts for this extension.
86938693- *
86948694- * @param scripts Contains a list of scripts to be registered. If there are errors during script parsing/file validation,
86958695- * or if the IDs specified already exist, then no scripts are registered.
86968696- * @returns Invoked upon completion of the registration.
86978697- */
86988698- registerContentScripts(scripts: RegisteredContentScript[]): Promise<void>;
86998699- /**
87008700- * Returns all dynamically registered content scripts for this extension that match the given filter.
87018701- *
87028702- * @param filter Optional. An object to filter the extension's dynamically registered scripts.
87038703- * @returns The resulting array contains the registered content scripts.
87048704- */
87058705- getRegisteredContentScripts(filter?: ContentScriptFilter): Promise<RegisteredContentScript[]>;
87068706- /**
87078707- * Unregisters one or more content scripts for this extension.
87088708- *
87098709- * @param filter Optional. If specified, only unregisters dynamic content scripts which match the filter. Otherwise,
87108710- * all of the extension's dynamic content scripts are unregistered.
87118711- * @returns Invoked upon completion of the unregistration.
87128712- */
87138713- unregisterContentScripts(filter?: ContentScriptFilter): Promise<void>;
87148714- /**
87158715- * Updates one or more content scripts for this extension.
87168716- *
87178717- * @param scripts Contains a list of scripts to be updated. If there are errors during script parsing/file validation,
87188718- * or if the IDs specified do not already exist, then no scripts are updated.
87198719- * @returns Invoked when scripts have been updated.
87208720- */
87218721- updateContentScripts(scripts: UpdateContentScriptsScriptsItemType[]): Promise<void>;
87228722- }
87238723- }
87248724- /**
87258725- * Namespace: browser.search
87268726- */
87278727- namespace Search {
87288728- /**
87298729- * An object encapsulating a search engine
87308730- */
87318731- interface SearchEngine {
87328732- name: string;
87338733- isDefault: boolean;
87348734- /**
87358735- * Optional.
87368736- */
87378737- alias?: string;
87388738- /**
87398739- * Optional.
87408740- */
87418741- favIconUrl?: string;
87428742- }
87438743- /**
87448744- * Location where search results should be displayed.
87458745- */
87468746- type Disposition = "CURRENT_TAB" | "NEW_TAB" | "NEW_WINDOW";
87478747- interface SearchSearchPropertiesType {
87488748- /**
87498749- * Terms to search for.
87508750- */
87518751- query: string;
87528752- /**
87538753- * Search engine to use. Uses the default if not specified.
87548754- * Optional.
87558755- */
87568756- engine?: string;
87578757- /**
87588758- * Location where search results should be displayed. NEW_TAB is the default.
87598759- * Optional.
87608760- */
87618761- disposition?: Disposition;
87628762- /**
87638763- * The ID of the tab for the search results. If not specified, a new tab is created, unless disposition is set.
87648764- * tabId cannot be used with disposition.
87658765- * Optional.
87668766- */
87678767- tabId?: number;
87688768- }
87698769- interface QueryQueryInfoType {
87708770- /**
87718771- * String to query with the default search provider.
87728772- */
87738773- text: string;
87748774- /**
87758775- * Location where search results should be displayed. CURRENT_TAB is the default.
87768776- * Optional.
87778777- */
87788778- disposition?: Disposition;
87798779- /**
87808780- * Location where search results should be displayed. tabId cannot be used with disposition.
87818781- * Optional.
87828782- */
87838783- tabId?: number;
87848784- }
87858785- interface Static {
87868786- /**
87878787- * Gets a list of search engines.
87888788- *
87898789- * @returns A Promise that will be fulfilled with an array of search engine objects.
87908790- */
87918791- get(): Promise<SearchEngine[]>;
87928792- /**
87938793- * Perform a search.
87948794- */
87958795- search(searchProperties: SearchSearchPropertiesType): Promise<void>;
87968796- /**
87978797- * Use the chrome.search API to search via the default provider.
87988798- */
87998799- query(queryInfo: QueryQueryInfoType): Promise<void>;
88008800- }
88018801- }
88028802- /**
88038803- * Namespace: browser.sessions
88048804- */
88058805- namespace Sessions {
88068806- interface Filter {
88078807- /**
88088808- * The maximum number of entries to be fetched in the requested list. Omit this parameter to fetch the maximum number of
88098809- * entries ($(ref:sessions.MAX_SESSION_RESULTS)).
88108810- * Optional.
88118811- */
88128812- maxResults?: number;
88138813- }
88148814- interface Session {
88158815- /**
88168816- * The time when the window or tab was closed or modified, represented in milliseconds since the epoch.
88178817- */
88188818- lastModified: number;
88198819- /**
88208820- * The $(ref:tabs.Tab), if this entry describes a tab. Either this or $(ref:sessions.Session.window) will be set.
88218821- * Optional.
88228822- */
88238823- tab?: Browser.Tabs.Tab;
88248824- /**
88258825- * The $(ref:windows.Window), if this entry describes a window. Either this or $(ref:sessions.Session.tab) will be set.
88268826- * Optional.
88278827- */
88288828- window?: Browser.Windows.Window;
88298829- }
88308830- interface Device {
88318831- info: string;
88328832- /**
88338833- * The name of the foreign device.
88348834- */
88358835- deviceName: string;
88368836- /**
88378837- * A list of open window sessions for the foreign device, sorted from most recently to least recently modified session.
88388838- */
88398839- sessions: Session[];
88408840- }
88418841- interface Static {
88428842- /**
88438843- * Forget a recently closed tab.
88448844- *
88458845- * @param windowId The windowId of the window to which the recently closed tab to be forgotten belongs.
88468846- * @param sessionId The sessionId (closedId) of the recently closed tab to be forgotten.
88478847- */
88488848- forgetClosedTab(windowId: number, sessionId: string): Promise<void>;
88498849- /**
88508850- * Forget a recently closed window.
88518851- *
88528852- * @param sessionId The sessionId (closedId) of the recently closed window to be forgotten.
88538853- */
88548854- forgetClosedWindow(sessionId: string): Promise<void>;
88558855- /**
88568856- * Gets the list of recently closed tabs and/or windows.
88578857- *
88588858- * @param filter Optional.
88598859- */
88608860- getRecentlyClosed(filter?: Filter): Promise<Session[]>;
88618861- /**
88628862- * Reopens a $(ref:windows.Window) or $(ref:tabs.Tab), with an optional callback to run when the entry has been restored.
88638863- *
88648864- * @param sessionId Optional. The $(ref:windows.Window.sessionId), or $(ref:tabs.Tab.sessionId) to restore.
88658865- * If this parameter is not specified, the most recently closed session is restored.
88668866- */
88678867- restore(sessionId?: string): Promise<Session>;
88688868- /**
88698869- * Set a key/value pair on a given tab.
88708870- *
88718871- * @param tabId The id of the tab that the key/value pair is being set on.
88728872- * @param key The key which corresponds to the value being set.
88738873- * @param value The value being set.
88748874- */
88758875- setTabValue(tabId: number, key: string, value: unknown): Promise<void>;
88768876- /**
88778877- * Retrieve a value that was set for a given key on a given tab.
88788878- *
88798879- * @param tabId The id of the tab whose value is being retrieved from.
88808880- * @param key The key which corresponds to the value.
88818881- */
88828882- getTabValue(tabId: number, key: string): Promise<unknown>;
88838883- /**
88848884- * Remove a key/value pair that was set on a given tab.
88858885- *
88868886- * @param tabId The id of the tab whose key/value pair is being removed.
88878887- * @param key The key which corresponds to the value.
88888888- */
88898889- removeTabValue(tabId: number, key: string): Promise<void>;
88908890- /**
88918891- * Set a key/value pair on a given window.
88928892- *
88938893- * @param windowId The id of the window that the key/value pair is being set on.
88948894- * @param key The key which corresponds to the value being set.
88958895- * @param value The value being set.
88968896- */
88978897- setWindowValue(windowId: number, key: string, value: unknown): Promise<void>;
88988898- /**
88998899- * Retrieve a value that was set for a given key on a given window.
89008900- *
89018901- * @param windowId The id of the window whose value is being retrieved from.
89028902- * @param key The key which corresponds to the value.
89038903- */
89048904- getWindowValue(windowId: number, key: string): Promise<unknown>;
89058905- /**
89068906- * Remove a key/value pair that was set on a given window.
89078907- *
89088908- * @param windowId The id of the window whose key/value pair is being removed.
89098909- * @param key The key which corresponds to the value.
89108910- */
89118911- removeWindowValue(windowId: number, key: string): Promise<void>;
89128912- /**
89138913- * Fired when recently closed tabs and/or windows are changed. This event does not monitor synced sessions changes.
89148914- */
89158915- onChanged: Events.Event<() => void>;
89168916- /**
89178917- * The maximum number of $(ref:sessions.Session) that will be included in a requested list.
89188918- */
89198919- MAX_SESSION_RESULTS: 25;
89208920- }
89218921- }
89228922- /**
89238923- * Namespace: browser.sidebarAction
89248924- */
89258925- namespace SidebarAction {
89268926- /**
89278927- * Pixel data for an image. Must be an ImageData object (for example, from a <code>canvas</code> element).
89288928- */
89298929- interface ImageDataType extends ImageData {
89308930- [s: string]: unknown;
89318931- }
89328932- interface SetTitleDetailsType {
89338933- /**
89348934- * The string the sidebar action should display when moused over.
89358935- */
89368936- title: string | null;
89378937- /**
89388938- * Sets the sidebar title for the tab specified by tabId. Automatically resets when the tab is closed.
89398939- * Optional.
89408940- */
89418941- tabId?: number;
89428942- /**
89438943- * Sets the sidebar title for the window specified by windowId.
89448944- * Optional.
89458945- */
89468946- windowId?: number;
89478947- }
89488948- interface GetTitleDetailsType {
89498949- /**
89508950- * Specify the tab to get the title from. If no tab nor window is specified, the global title is returned.
89518951- * Optional.
89528952- */
89538953- tabId?: number;
89548954- /**
89558955- * Specify the window to get the title from. If no tab nor window is specified, the global title is returned.
89568956- * Optional.
89578957- */
89588958- windowId?: number;
89598959- }
89608960- interface SetIconDetailsType {
89618961- /**
89628962- * Either an ImageData object or a dictionary {size -> ImageData} representing icon to be set.
89638963- * If the icon is specified as a dictionary, the actual image to be used is chosen depending on screen's pixel density.
89648964- * If the number of image pixels that fit into one screen space unit equals <code>scale</code>, then image with size <code>
89658965- * scale</code> * 19 will be selected. Initially only scales 1 and 2 will be supported.
89668966- * At least one image must be specified. Note that 'details.imageData = foo' is equivalent to 'details.
89678967- * imageData = {'19': foo}'
89688968- * Optional.
89698969- */
89708970- imageData?: ImageDataType | Record<string, ImageDataType>;
89718971- /**
89728972- * Either a relative image path or a dictionary {size -> relative image path} pointing to icon to be set.
89738973- * If the icon is specified as a dictionary, the actual image to be used is chosen depending on screen's pixel density.
89748974- * If the number of image pixels that fit into one screen space unit equals <code>scale</code>, then image with size <code>
89758975- * scale</code> * 19 will be selected. Initially only scales 1 and 2 will be supported.
89768976- * At least one image must be specified. Note that 'details.path = foo' is equivalent to 'details.imageData = {'19': foo}'
89778977- * Optional.
89788978- */
89798979- path?: string | SetIconDetailsTypePathC2Type;
89808980- /**
89818981- * Sets the sidebar icon for the tab specified by tabId. Automatically resets when the tab is closed.
89828982- * Optional.
89838983- */
89848984- tabId?: number;
89858985- /**
89868986- * Sets the sidebar icon for the window specified by windowId.
89878987- * Optional.
89888988- */
89898989- windowId?: number;
89908990- }
89918991- interface SetPanelDetailsType {
89928992- /**
89938993- * Sets the sidebar url for the tab specified by tabId. Automatically resets when the tab is closed.
89948994- * Optional.
89958995- */
89968996- tabId?: number;
89978997- /**
89988998- * Sets the sidebar url for the window specified by windowId.
89998999- * Optional.
90009000- */
90019001- windowId?: number;
90029002- /**
90039003- * The url to the html file to show in a sidebar. If set to the empty string (''), no sidebar is shown.
90049004- */
90059005- panel: string | null;
90069006- }
90079007- interface GetPanelDetailsType {
90089008- /**
90099009- * Specify the tab to get the panel from. If no tab nor window is specified, the global panel is returned.
90109010- * Optional.
90119011- */
90129012- tabId?: number;
90139013- /**
90149014- * Specify the window to get the panel from. If no tab nor window is specified, the global panel is returned.
90159015- * Optional.
90169016- */
90179017- windowId?: number;
90189018- }
90199019- interface IsOpenDetailsType {
90209020- /**
90219021- * Specify the window to get the openness from.
90229022- * Optional.
90239023- */
90249024- windowId?: number;
90259025- }
90269026- interface SetIconDetailsTypePathC2Type {
90279027- [s: string]: unknown;
90289028- }
90299029- interface Static {
90309030- /**
90319031- * Sets the title of the sidebar action. This shows up in the tooltip.
90329032- */
90339033- setTitle(details: SetTitleDetailsType): Promise<void>;
90349034- /**
90359035- * Gets the title of the sidebar action.
90369036- */
90379037- getTitle(details: GetTitleDetailsType): Promise<string>;
90389038- /**
90399039- * Sets the icon for the sidebar action. The icon can be specified either as the path to an image file or as the pixel data
90409040- * from a canvas element, or as dictionary of either one of those. Either the <strong>path</strong> or the <strong>
90419041- * imageData</strong> property must be specified.
90429042- */
90439043- setIcon(details: SetIconDetailsType): Promise<void>;
90449044- /**
90459045- * Sets the url to the html document to be opened in the sidebar when the user clicks on the sidebar action's icon.
90469046- */
90479047- setPanel(details: SetPanelDetailsType): Promise<void>;
90489048- /**
90499049- * Gets the url to the html document set as the panel for this sidebar action.
90509050- */
90519051- getPanel(details: GetPanelDetailsType): Promise<string>;
90529052- /**
90539053- * Opens the extension sidebar in the active window.
90549054- */
90559055- open(): Promise<void>;
90569056- /**
90579057- * Closes the extension sidebar in the active window if the sidebar belongs to the extension.
90589058- */
90599059- close(): Promise<void>;
90609060- /**
90619061- * Toggles the extension sidebar in the active window.
90629062- */
90639063- toggle(): Promise<void>;
90649064- /**
90659065- * Checks whether the sidebar action is open.
90669066- */
90679067- isOpen(details: IsOpenDetailsType): Promise<boolean>;
90689068- }
90699069- }
90709070- /**
90719071- * Namespace: browser.storage
90729072- */
90739073- namespace Storage {
90749074- interface StorageChange {
90759075- /**
90769076- * The old value of the item, if there was an old value.
90779077- * Optional.
90789078- */
90799079- oldValue?: unknown;
90809080- /**
90819081- * The new value of the item, if there is a new value.
90829082- * Optional.
90839083- */
90849084- newValue?: unknown;
90859085- }
90869086- interface StorageArea {
90879087- /**
90889088- * Gets one or more items from storage.
90899089- *
90909090- * @param keys Optional. A single key to get, list of keys to get, or a dictionary specifying default values (see
90919091- * description of the object). An empty list or object will return an empty result object. Pass in <code>null</code>
90929092- * to get the entire contents of storage.
90939093- * @returns Callback with storage items, or on failure (in which case $(ref:runtime.lastError) will be set).
90949094- */
90959095- get(keys?: null | string | string[] | Record<string, unknown>): Promise<Record<string, unknown>>;
90969096- /**
90979097- * Sets multiple items.
90989098- *
90999099- * @param items <p>An object which gives each key/value pair to update storage with. Any other key/value pairs in storage
91009100- * will not be affected.</p><p>Primitive values such as numbers will serialize as expected. Values with a <code>
91019101- * typeof</code> <code>"object"</code> and <code>"function"</code> will typically serialize to <code>{}</code>,
91029102- * with the exception of <code>Array</code> (serializes as expected), <code>Date</code>, and <code>Regex</code>
91039103- * (serialize using their <code>String</code> representation).</p>
91049104- * @returns Callback on success, or on failure (in which case $(ref:runtime.lastError) will be set).
91059105- */
91069106- set(items: Record<string, unknown>): Promise<void>;
91079107- /**
91089108- * Removes one or more items from storage.
91099109- *
91109110- * @param keys A single key or a list of keys for items to remove.
91119111- * @returns Callback on success, or on failure (in which case $(ref:runtime.lastError) will be set).
91129112- */
91139113- remove(keys: string | string[]): Promise<void>;
91149114- /**
91159115- * Removes all items from storage.
91169116- *
91179117- * @returns Callback on success, or on failure (in which case $(ref:runtime.lastError) will be set).
91189118- */
91199119- clear(): Promise<void>;
91209120- /**
91219121- * Fired when one or more items change.
91229122- *
91239123- * @param changes Object mapping each key that changed to its corresponding $(ref:storage.StorageChange) for that item.
91249124- */
91259125- onChanged: Events.Event<(changes: StorageAreaOnChangedChangesType) => void>;
91269126- }
91279127- interface StorageAreaWithUsage {
91289128- /**
91299129- * Gets one or more items from storage.
91309130- *
91319131- * @param keys Optional. A single key to get, list of keys to get, or a dictionary specifying default values (see
91329132- * description of the object). An empty list or object will return an empty result object. Pass in <code>null</code>
91339133- * to get the entire contents of storage.
91349134- * @returns Callback with storage items, or on failure (in which case $(ref:runtime.lastError) will be set).
91359135- */
91369136- get(keys?: null | string | string[] | Record<string, unknown>): Promise<Record<string, unknown>>;
91379137- /**
91389138- * Gets the amount of space (in bytes) being used by one or more items.
91399139- *
91409140- * @param keys Optional. A single key or list of keys to get the total usage for. An empty list will return 0.
91419141- * Pass in <code>null</code> to get the total usage of all of storage.
91429142- * @returns Callback with the amount of space being used by storage, or on failure (in which case $(ref:runtime.lastError)
91439143- * will be set).
91449144- */
91459145- getBytesInUse(keys?: null | string | string[]): Promise<number>;
91469146- /**
91479147- * Sets multiple items.
91489148- *
91499149- * @param items <p>An object which gives each key/value pair to update storage with. Any other key/value pairs in storage
91509150- * will not be affected.</p><p>Primitive values such as numbers will serialize as expected. Values with a <code>
91519151- * typeof</code> <code>"object"</code> and <code>"function"</code> will typically serialize to <code>{}</code>,
91529152- * with the exception of <code>Array</code> (serializes as expected), <code>Date</code>, and <code>Regex</code>
91539153- * (serialize using their <code>String</code> representation).</p>
91549154- * @returns Callback on success, or on failure (in which case $(ref:runtime.lastError) will be set).
91559155- */
91569156- set(items: Record<string, unknown>): Promise<void>;
91579157- /**
91589158- * Removes one or more items from storage.
91599159- *
91609160- * @param keys A single key or a list of keys for items to remove.
91619161- * @returns Callback on success, or on failure (in which case $(ref:runtime.lastError) will be set).
91629162- */
91639163- remove(keys: string | string[]): Promise<void>;
91649164- /**
91659165- * Removes all items from storage.
91669166- *
91679167- * @returns Callback on success, or on failure (in which case $(ref:runtime.lastError) will be set).
91689168- */
91699169- clear(): Promise<void>;
91709170- /**
91719171- * Fired when one or more items change.
91729172- *
91739173- * @param changes Object mapping each key that changed to its corresponding $(ref:storage.StorageChange) for that item.
91749174- */
91759175- onChanged: Events.Event<(changes: StorageAreaWithUsageOnChangedChangesType) => void>;
91769176- }
91779177- /**
91789178- * Object mapping each key that changed to its corresponding $(ref:storage.StorageChange) for that item.
91799179- */
91809180- interface StorageAreaOnChangedChangesType {
91819181- [s: string]: StorageChange;
91829182- }
91839183- /**
91849184- * Object mapping each key that changed to its corresponding $(ref:storage.StorageChange) for that item.
91859185- */
91869186- interface StorageAreaWithUsageOnChangedChangesType {
91879187- [s: string]: StorageChange;
91889188- }
91899189- interface Static {
91909190- /**
91919191- * Fired when one or more items change.
91929192- *
91939193- * @param changes Object mapping each key that changed to its corresponding $(ref:storage.StorageChange) for that item.
91949194- * @param areaName The name of the storage area (<code>"sync"</code>, <code>"local"</code> or <code>"managed"</code>)
91959195- * the changes are for.
91969196- */
91979197- onChanged: Events.Event<(changes: Record<string, StorageChange>, areaName: string) => void>;
91989198- /**
91999199- * Items in the <code>sync</code> storage area are synced by the browser.
92009200- */
92019201- sync: StorageAreaWithUsage;
92029202- /**
92039203- * Items in the <code>local</code> storage area are local to each machine.
92049204- */
92059205- local: StorageArea;
92069206- /**
92079207- * Items in the <code>managed</code> storage area are set by administrators or native applications,
92089208- * and are read-only for the extension; trying to modify this namespace results in an error.
92099209- */
92109210- managed: StorageArea;
92119211- /**
92129212- * Items in the <code>session</code> storage area are kept in memory, and only until the either browser or extension is
92139213- * closed or reloaded.
92149214- */
92159215- session: StorageAreaWithUsage;
92169216- }
92179217- }
92189218- /**
92199219- * Namespace: browser.tabGroups
92209220- */
92219221- namespace TabGroups {
92229222- /**
92239223- * The group's color, using 'grey' spelling for compatibility with Chromium.
92249224- */
92259225- type Color = "blue" | "cyan" | "grey" | "green" | "orange" | "pink" | "purple" | "red" | "yellow";
92269226- /**
92279227- * State of a tab group inside of an open window.
92289228- */
92299229- interface TabGroup {
92309230- /**
92319231- * Whether the tab group is collapsed or expanded in the tab strip.
92329232- */
92339233- collapsed: boolean;
92349234- /**
92359235- * User-selected color name for the tab group's label/icons.
92369236- */
92379237- color: Color;
92389238- /**
92399239- * Unique ID of the tab group.
92409240- */
92419241- id: number;
92429242- /**
92439243- * User-defined name of the tab group.
92449244- * Optional.
92459245- */
92469246- title?: string;
92479247- /**
92489248- * Window that the tab group is in.
92499249- */
92509250- windowId: number;
92519251- }
92529252- interface MoveMovePropertiesType {
92539253- index: number;
92549254- /**
92559255- * Optional.
92569256- */
92579257- windowId?: number;
92589258- }
92599259- interface QueryQueryInfoType {
92609260- /**
92619261- * Optional.
92629262- */
92639263- collapsed?: boolean;
92649264- /**
92659265- * Optional.
92669266- */
92679267- color?: Color;
92689268- /**
92699269- * Optional.
92709270- */
92719271- title?: string;
92729272- /**
92739273- * Optional.
92749274- */
92759275- windowId?: number;
92769276- }
92779277- interface UpdateUpdatePropertiesType {
92789278- /**
92799279- * Optional.
92809280- */
92819281- collapsed?: boolean;
92829282- /**
92839283- * Optional.
92849284- */
92859285- color?: Color;
92869286- /**
92879287- * Optional.
92889288- */
92899289- title?: string;
92909290- }
92919291- interface OnRemovedRemoveInfoType {
92929292- /**
92939293- * True when the tab group is being closed because its window is being closed.
92949294- */
92959295- isWindowClosing: boolean;
92969296- }
92979297- interface Static {
92989298- /**
92999299- * Retrieves details about the specified group.
93009300- */
93019301- get(groupId: number): Promise<TabGroup>;
93029302- /**
93039303- * Move a group within, or to another window.
93049304- */
93059305- move(groupId: number, moveProperties: MoveMovePropertiesType): Promise<TabGroup>;
93069306- /**
93079307- * Return all grups, or find groups with specified properties.
93089308- */
93099309- query(queryInfo: QueryQueryInfoType): Promise<TabGroup[]>;
93109310- /**
93119311- * Modifies state of a specified group.
93129312- */
93139313- update(groupId: number, updateProperties: UpdateUpdatePropertiesType): Promise<TabGroup>;
93149314- /**
93159315- * Fired when a tab group is created.
93169316- */
93179317- onCreated: Events.Event<(group: TabGroup) => void>;
93189318- /**
93199319- * Fired when a tab group is moved, within a window or to another window.
93209320- */
93219321- onMoved: Events.Event<(group: TabGroup) => void>;
93229322- /**
93239323- * Fired when a tab group is removed.
93249324- */
93259325- onRemoved: Events.Event<(group: TabGroup, removeInfo: OnRemovedRemoveInfoType) => void>;
93269326- /**
93279327- * Fired when a tab group is updated.
93289328- */
93299329- onUpdated: Events.Event<(group: TabGroup) => void>;
93309330- /**
93319331- * An ID that represents the absence of a group.
93329332- */
93339333- TAB_GROUP_ID_NONE: -1;
93349334- }
93359335- }
93369336- /**
93379337- * Namespace: browser.tabs
93389338- */
93399339- namespace Tabs {
93409340- /**
93419341- * An event that caused a muted state change.
93429342- *
93439343- * "user": A user input action has set/overridden the muted state.
93449344- * "capture": Tab capture started, forcing a muted state change.
93459345- * "extension": An extension, identified by the extensionId field, set the muted state.
93469346- */
93479347- type MutedInfoReason = "user" | "capture" | "extension";
93489348- /**
93499349- * Tab muted state and the reason for the last state change.
93509350- */
93519351- interface MutedInfo {
93529352- /**
93539353- * Whether the tab is prevented from playing sound (but hasn't necessarily recently produced sound).
93549354- * Equivalent to whether the muted audio indicator is showing.
93559355- */
93569356- muted: boolean;
93579357- /**
93589358- * The reason the tab was muted or unmuted. Not set if the tab's mute state has never been changed.
93599359- * Optional.
93609360- */
93619361- reason?: MutedInfoReason;
93629362- /**
93639363- * The ID of the extension that changed the muted state. Not set if an extension was not the reason the muted state last
93649364- * changed.
93659365- * Optional.
93669366- */
93679367- extensionId?: string;
93689368- }
93699369- /**
93709370- * Tab sharing state for screen, microphone and camera.
93719371- */
93729372- interface SharingState {
93739373- /**
93749374- * If the tab is sharing the screen the value will be one of "Screen", "Window", or "Application",
93759375- * or undefined if not screen sharing.
93769376- * Optional.
93779377- */
93789378- screen?: string;
93799379- /**
93809380- * True if the tab is using the camera.
93819381- */
93829382- camera: boolean;
93839383- /**
93849384- * True if the tab is using the microphone.
93859385- */
93869386- microphone: boolean;
93879387- }
93889388- interface Tab {
93899389- /**
93909390- * The ID of the tab. Tab IDs are unique within a browser session. Under some circumstances a Tab may not be assigned an ID,
93919391- * for example when querying foreign tabs using the $(ref:sessions) API, in which case a session ID may be present.
93929392- * Tab ID can also be set to $(ref:tabs.TAB_ID_NONE) for apps and devtools windows.
93939393- * Optional.
93949394- */
93959395- id?: number;
93969396- /**
93979397- * The zero-based index of the tab within its window.
93989398- */
93999399- index: number;
94009400- /**
94019401- * The ID of the window the tab is contained within.
94029402- * Optional.
94039403- */
94049404- windowId?: number;
94059405- /**
94069406- * The ID of the tab that opened this tab, if any. This property is only present if the opener tab still exists.
94079407- * Optional.
94089408- */
94099409- openerTabId?: number;
94109410- /**
94119411- * Whether the tab is highlighted. Works as an alias of active
94129412- */
94139413- highlighted: boolean;
94149414- /**
94159415- * Whether the tab is active in its window. (Does not necessarily mean the window is focused.)
94169416- */
94179417- active: boolean;
94189418- /**
94199419- * Whether the tab is pinned.
94209420- */
94219421- pinned: boolean;
94229422- /**
94239423- * The last time the tab was accessed as the number of milliseconds since epoch.
94249424- * Optional.
94259425- */
94269426- lastAccessed?: number;
94279427- /**
94289428- * Whether the tab has produced sound over the past couple of seconds (but it might not be heard if also muted).
94299429- * Equivalent to whether the speaker audio indicator is showing.
94309430- * Optional.
94319431- */
94329432- audible?: boolean;
94339433- /**
94349434- * Whether the tab can be discarded automatically by the browser when resources are low.
94359435- * Optional.
94369436- */
94379437- autoDiscardable?: boolean;
94389438- /**
94399439- * Current tab muted state and the reason for the last state change.
94409440- * Optional.
94419441- */
94429442- mutedInfo?: MutedInfo;
94439443- /**
94449444- * The URL the tab is displaying. This property is only present if the extension's manifest includes the <code>"tabs"</code>
94459445- * permission.
94469446- * Optional.
94479447- */
94489448- url?: string;
94499449- /**
94509450- * The title of the tab. This property is only present if the extension's manifest includes the <code>"tabs"</code>
94519451- * permission.
94529452- * Optional.
94539453- */
94549454- title?: string;
94559455- /**
94569456- * The URL of the tab's favicon. This property is only present if the extension's manifest includes the <code>"tabs"</code>
94579457- * permission. It may also be an empty string if the tab is loading.
94589458- * Optional.
94599459- */
94609460- favIconUrl?: string;
94619461- /**
94629462- * Either <em>loading</em> or <em>complete</em>.
94639463- * Optional.
94649464- */
94659465- status?: string;
94669466- /**
94679467- * True while the tab is not loaded with content.
94689468- * Optional.
94699469- */
94709470- discarded?: boolean;
94719471- /**
94729472- * Whether the tab is in an incognito window.
94739473- */
94749474- incognito: boolean;
94759475- /**
94769476- * The width of the tab in pixels.
94779477- * Optional.
94789478- */
94799479- width?: number;
94809480- /**
94819481- * The height of the tab in pixels.
94829482- * Optional.
94839483- */
94849484- height?: number;
94859485- /**
94869486- * True if the tab is hidden.
94879487- * Optional.
94889488- */
94899489- hidden?: boolean;
94909490- /**
94919491- * The session ID used to uniquely identify a Tab obtained from the $(ref:sessions) API.
94929492- * Optional.
94939493- */
94949494- sessionId?: string;
94959495- /**
94969496- * The CookieStoreId used for the tab.
94979497- * Optional.
94989498- */
94999499- cookieStoreId?: string;
95009500- /**
95019501- * Whether the document in the tab can be rendered in reader mode.
95029502- * Optional.
95039503- */
95049504- isArticle?: boolean;
95059505- /**
95069506- * Whether the document in the tab is being rendered in reader mode.
95079507- * Optional.
95089508- */
95099509- isInReaderMode?: boolean;
95109510- /**
95119511- * Current tab sharing state for screen, microphone and camera.
95129512- * Optional.
95139513- */
95149514- sharingState?: SharingState;
95159515- /**
95169516- * Whether the tab is drawing attention.
95179517- * Optional.
95189518- */
95199519- attention?: boolean;
95209520- /**
95219521- * The ID of this tab's successor, if any; $(ref:tabs.TAB_ID_NONE) otherwise.
95229522- * Optional.
95239523- */
95249524- successorTabId?: number;
95259525- /**
95269526- * The ID of the group that the tab belongs to.
95279527- * Optional.
95289528- */
95299529- groupId?: number;
95309530- /**
95319531- * The URL the tab is navigating to, before it has committed. This property is only present if the extension's manifest
95329532- * includes the "tabs" permission and there is a pending navigation.
95339533- * Optional.
95349534- */
95359535- pendingUrl?: string;
95369536- }
95379537- /**
95389538- * Defines how zoom changes are handled, i.e. which entity is responsible for the actual scaling of the page; defaults to
95399539- * <code>automatic</code>.
95409540- *
95419541- * "automatic": Zoom changes are handled automatically by the browser.
95429542- * "manual": Overrides the automatic handling of zoom changes. The <code>onZoomChange</code> event will still be dispatched,
95439543- * and it is the responsibility of the extension to listen for this event and manually scale the page.
95449544- * This mode does not support <code>per-origin</code> zooming, and will thus ignore the <code>scope</code>
95459545- * zoom setting and assume <code>per-tab</code>.
95469546- * "disabled": Disables all zooming in the tab. The tab will revert to the default zoom level,
95479547- * and all attempted zoom changes will be ignored.
95489548- */
95499549- type ZoomSettingsMode = "automatic" | "manual" | "disabled";
95509550- /**
95519551- * Defines whether zoom changes will persist for the page's origin, or only take effect in this tab; defaults to <code>
95529552- * per-origin</code> when in <code>automatic</code> mode, and <code>per-tab</code> otherwise.
95539553- *
95549554- * "per-origin": Zoom changes will persist in the zoomed page's origin, i.e. all other tabs navigated to that same origin
95559555- * will be zoomed as well. Moreover, <code>per-origin</code> zoom changes are saved with the origin,
95569556- * meaning that when navigating to other pages in the same origin, they will all be zoomed to the same zoom factor.
95579557- * The <code>per-origin</code> scope is only available in the <code>automatic</code> mode.
95589558- * "per-tab": Zoom changes only take effect in this tab, and zoom changes in other tabs will not affect the zooming of this
95599559- * tab. Also, <code>per-tab</code> zoom changes are reset on navigation; navigating a tab will always load pages with their
95609560- * <code>per-origin</code> zoom factors.
95619561- */
95629562- type ZoomSettingsScope = "per-origin" | "per-tab";
95639563- /**
95649564- * Defines how zoom changes in a tab are handled and at what scope.
95659565- */
95669566- interface ZoomSettings {
95679567- /**
95689568- * Defines how zoom changes are handled, i.e. which entity is responsible for the actual scaling of the page; defaults to
95699569- * <code>automatic</code>.
95709570- * Optional.
95719571- */
95729572- mode?: ZoomSettingsMode;
95739573- /**
95749574- * Defines whether zoom changes will persist for the page's origin, or only take effect in this tab; defaults to <code>
95759575- * per-origin</code> when in <code>automatic</code> mode, and <code>per-tab</code> otherwise.
95769576- * Optional.
95779577- */
95789578- scope?: ZoomSettingsScope;
95799579- /**
95809580- * Used to return the default zoom level for the current tab in calls to tabs.getZoomSettings.
95819581- * Optional.
95829582- */
95839583- defaultZoomFactor?: number;
95849584- }
95859585- /**
95869586- * Defines the page settings to be used when saving a page as a pdf file.
95879587- */
95889588- interface PageSettings {
95899589- /**
95909590- * The name of the file. May include optional .pdf extension.
95919591- * Optional.
95929592- */
95939593- toFileName?: string;
95949594- /**
95959595- * The page size unit: 0 = inches, 1 = millimeters. Default: 0.
95969596- * Optional.
95979597- */
95989598- paperSizeUnit?: number;
95999599- /**
96009600- * The paper width in paper size units. Default: 8.5.
96019601- * Optional.
96029602- */
96039603- paperWidth?: number;
96049604- /**
96059605- * The paper height in paper size units. Default: 11.0.
96069606- * Optional.
96079607- */
96089608- paperHeight?: number;
96099609- /**
96109610- * The page content orientation: 0 = portrait, 1 = landscape. Default: 0.
96119611- * Optional.
96129612- */
96139613- orientation?: number;
96149614- /**
96159615- * The page content scaling factor: 1.0 = 100% = normal size. Default: 1.0.
96169616- * Optional.
96179617- */
96189618- scaling?: number;
96199619- /**
96209620- * Whether the page content should shrink to fit the page width (overrides scaling). Default: true.
96219621- * Optional.
96229622- */
96239623- shrinkToFit?: boolean;
96249624- /**
96259625- * Whether the page background colors should be shown. Default: false.
96269626- * Optional.
96279627- */
96289628- showBackgroundColors?: boolean;
96299629- /**
96309630- * Whether the page background images should be shown. Default: false.
96319631- * Optional.
96329632- */
96339633- showBackgroundImages?: boolean;
96349634- /**
96359635- * The spacing between the left header/footer and the left edge of the paper (inches). Default: 0.
96369636- * Optional.
96379637- */
96389638- edgeLeft?: number;
96399639- /**
96409640- * The spacing between the right header/footer and the right edge of the paper (inches). Default: 0.
96419641- * Optional.
96429642- */
96439643- edgeRight?: number;
96449644- /**
96459645- * The spacing between the top of the headers and the top edge of the paper (inches). Default: 0
96469646- * Optional.
96479647- */
96489648- edgeTop?: number;
96499649- /**
96509650- * The spacing between the bottom of the footers and the bottom edge of the paper (inches). Default: 0.
96519651- * Optional.
96529652- */
96539653- edgeBottom?: number;
96549654- /**
96559655- * The margin between the page content and the left edge of the paper (inches). Default: 0.5.
96569656- * Optional.
96579657- */
96589658- marginLeft?: number;
96599659- /**
96609660- * The margin between the page content and the right edge of the paper (inches). Default: 0.5.
96619661- * Optional.
96629662- */
96639663- marginRight?: number;
96649664- /**
96659665- * The margin between the page content and the top edge of the paper (inches). Default: 0.5.
96669666- * Optional.
96679667- */
96689668- marginTop?: number;
96699669- /**
96709670- * The margin between the page content and the bottom edge of the paper (inches). Default: 0.5.
96719671- * Optional.
96729672- */
96739673- marginBottom?: number;
96749674- /**
96759675- * The text for the page's left header. Default: '&T'.
96769676- * Optional.
96779677- */
96789678- headerLeft?: string;
96799679- /**
96809680- * The text for the page's center header. Default: ''.
96819681- * Optional.
96829682- */
96839683- headerCenter?: string;
96849684- /**
96859685- * The text for the page's right header. Default: '&U'.
96869686- * Optional.
96879687- */
96889688- headerRight?: string;
96899689- /**
96909690- * The text for the page's left footer. Default: '&PT'.
96919691- * Optional.
96929692- */
96939693- footerLeft?: string;
96949694- /**
96959695- * The text for the page's center footer. Default: ''.
96969696- * Optional.
96979697- */
96989698- footerCenter?: string;
96999699- /**
97009700- * The text for the page's right footer. Default: '&D'.
97019701- * Optional.
97029702- */
97039703- footerRight?: string;
97049704- }
97059705- /**
97069706- * Whether the tabs have completed loading.
97079707- */
97089708- type TabStatus = "loading" | "complete";
97099709- /**
97109710- * The type of window.
97119711- */
97129712- type WindowType = "normal" | "popup" | "panel" | "app" | "devtools";
97139713- /**
97149714- * Event names supported in onUpdated.
97159715- */
97169716- type UpdatePropertyName = "attention" | "audible" | "autoDiscardable" | "discarded" | "favIconUrl" | "groupId" | "hidden" | "isArticle" | "mutedInfo" | "pinned" | "sharingState" | "status" | "title" | "url";
97179717- /**
97189718- * An object describing filters to apply to tabs.onUpdated events.
97199719- */
97209720- interface UpdateFilter {
97219721- /**
97229722- * A list of URLs or URL patterns. Events that cannot match any of the URLs will be filtered out.
97239723- * Filtering with urls requires the <code>"tabs"</code> or <code>"activeTab"</code> permission.
97249724- * Optional.
97259725- */
97269726- urls?: string[];
97279727- /**
97289728- * A list of property names. Events that do not match any of the names will be filtered out.
97299729- * Optional.
97309730- */
97319731- properties?: UpdatePropertyName[];
97329732- /**
97339733- * Optional.
97349734- */
97359735- tabId?: number;
97369736- /**
97379737- * Optional.
97389738- */
97399739- windowId?: number;
97409740- }
97419741- interface ConnectConnectInfoType {
97429742- /**
97439743- * Will be passed into onConnect for content scripts that are listening for the connection event.
97449744- * Optional.
97459745- */
97469746- name?: string;
97479747- /**
97489748- * Open a port to a specific $(topic:frame_ids)[frame] identified by <code>frameId</code> instead of all frames in the tab.
97499749- * Optional.
97509750- */
97519751- frameId?: number;
97529752- }
97539753- interface SendMessageOptionsType {
97549754- /**
97559755- * Send a message to a specific $(topic:frame_ids)[frame] identified by <code>frameId</code>
97569756- * instead of all frames in the tab.
97579757- * Optional.
97589758- */
97599759- frameId?: number;
97609760- }
97619761- interface CreateCreatePropertiesType {
97629762- /**
97639763- * The window to create the new tab in. Defaults to the $(topic:current-window)[current window].
97649764- * Optional.
97659765- */
97669766- windowId?: number;
97679767- /**
97689768- * The position the tab should take in the window. The provided value will be clamped to between zero and the number of
97699769- * tabs in the window.
97709770- * Optional.
97719771- */
97729772- index?: number;
97739773- /**
97749774- * The URL to navigate the tab to initially. Fully-qualified URLs must include a scheme (i.e. 'http://www.google.com',
97759775- * not 'www.google.com'). Relative URLs will be relative to the current page within the extension.
97769776- * Defaults to the New Tab Page.
97779777- * Optional.
97789778- */
97799779- url?: string;
97809780- /**
97819781- * Whether the tab should become the active tab in the window. Does not affect whether the window is focused (see
97829782- * $(ref:windows.update)). Defaults to <var>true</var>.
97839783- * Optional.
97849784- */
97859785- active?: boolean;
97869786- /**
97879787- * Whether the tab should be pinned. Defaults to <var>false</var>
97889788- * Optional.
97899789- */
97909790- pinned?: boolean;
97919791- /**
97929792- * The ID of the tab that opened this tab. If specified, the opener tab must be in the same window as the newly created tab.
97939793- * Optional.
97949794- */
97959795- openerTabId?: number;
97969796- /**
97979797- * The CookieStoreId for the tab that opened this tab.
97989798- * Optional.
97999799- */
98009800- cookieStoreId?: string;
98019801- /**
98029802- * Whether the document in the tab should be opened in reader mode.
98039803- * Optional.
98049804- */
98059805- openInReaderMode?: boolean;
98069806- /**
98079807- * Whether the tab is marked as 'discarded' when created.
98089808- * Optional.
98099809- */
98109810- discarded?: boolean;
98119811- /**
98129812- * The title used for display if the tab is created in discarded mode.
98139813- * Optional.
98149814- */
98159815- title?: string;
98169816- /**
98179817- * Whether the tab should be muted when created.
98189818- * Optional.
98199819- */
98209820- muted?: boolean;
98219821- }
98229822- interface DuplicateDuplicatePropertiesType {
98239823- /**
98249824- * The position the new tab should take in the window. The provided value will be clamped to between zero and the number of
98259825- * tabs in the window.
98269826- * Optional.
98279827- */
98289828- index?: number;
98299829- /**
98309830- * Whether the tab should become the active tab in the window. Does not affect whether the window is focused (see
98319831- * $(ref:windows.update)). Defaults to <var>true</var>.
98329832- * Optional.
98339833- */
98349834- active?: boolean;
98359835- }
98369836- interface QueryQueryInfoType {
98379837- /**
98389838- * Whether the tabs are active in their windows.
98399839- * Optional.
98409840- */
98419841- active?: boolean;
98429842- /**
98439843- * Whether the tabs are drawing attention.
98449844- * Optional.
98459845- */
98469846- attention?: boolean;
98479847- /**
98489848- * Whether the tabs are pinned.
98499849- * Optional.
98509850- */
98519851- pinned?: boolean;
98529852- /**
98539853- * Whether the tabs are audible.
98549854- * Optional.
98559855- */
98569856- audible?: boolean;
98579857- /**
98589858- * Whether the tabs can be discarded automatically by the browser when resources are low.
98599859- * Optional.
98609860- */
98619861- autoDiscardable?: boolean;
98629862- /**
98639863- * Whether the tabs are muted.
98649864- * Optional.
98659865- */
98669866- muted?: boolean;
98679867- /**
98689868- * Whether the tabs are highlighted. Works as an alias of active.
98699869- * Optional.
98709870- */
98719871- highlighted?: boolean;
98729872- /**
98739873- * Whether the tabs are in the $(topic:current-window)[current window].
98749874- * Optional.
98759875- */
98769876- currentWindow?: boolean;
98779877- /**
98789878- * Whether the tabs are in the last focused window.
98799879- * Optional.
98809880- */
98819881- lastFocusedWindow?: boolean;
98829882- /**
98839883- * Whether the tabs have completed loading.
98849884- * Optional.
98859885- */
98869886- status?: TabStatus;
98879887- /**
98889888- * True while the tabs are not loaded with content.
98899889- * Optional.
98909890- */
98919891- discarded?: boolean;
98929892- /**
98939893- * True while the tabs are hidden.
98949894- * Optional.
98959895- */
98969896- hidden?: boolean;
98979897- /**
98989898- * Match page titles against a pattern.
98999899- * Optional.
99009900- */
99019901- title?: string;
99029902- /**
99039903- * Match tabs against one or more $(topic:match_patterns)[URL patterns]. Note that fragment identifiers are not matched.
99049904- * Optional.
99059905- */
99069906- url?: string | string[];
99079907- /**
99089908- * The ID of the parent window, or $(ref:windows.WINDOW_ID_CURRENT) for the $(topic:current-window)[current window].
99099909- * Optional.
99109910- */
99119911- windowId?: number;
99129912- /**
99139913- * The type of window the tabs are in.
99149914- * Optional.
99159915- */
99169916- windowType?: WindowType;
99179917- /**
99189918- * The position of the tabs within their windows.
99199919- * Optional.
99209920- */
99219921- index?: number;
99229922- /**
99239923- * The CookieStoreId used for the tab.
99249924- * Optional.
99259925- */
99269926- cookieStoreId?: string[] | string;
99279927- /**
99289928- * The ID of the tab that opened this tab. If specified, the opener tab must be in the same window as this tab.
99299929- * Optional.
99309930- */
99319931- openerTabId?: number;
99329932- /**
99339933- * The ID of the group that the tabs are in, or $(ref:tabGroups.TAB_GROUP_ID_NONE) (-1) for ungrouped tabs.
99349934- * Optional.
99359935- */
99369936- groupId?: number;
99379937- /**
99389938- * True for any screen sharing, or a string to specify type of screen sharing.
99399939- * Optional.
99409940- */
99419941- screen?: "Screen" | "Window" | "Application" | boolean;
99429942- /**
99439943- * True if the tab is using the camera.
99449944- * Optional.
99459945- */
99469946- camera?: boolean;
99479947- /**
99489948- * True if the tab is using the microphone.
99499949- * Optional.
99509950- */
99519951- microphone?: boolean;
99529952- }
99539953- interface HighlightHighlightInfoType {
99549954- /**
99559955- * The window that contains the tabs.
99569956- * Optional.
99579957- */
99589958- windowId?: number;
99599959- /**
99609960- * If true, the $(ref:windows.Window) returned will have a <var>tabs</var> property that contains a list of the $(ref:tabs.
99619961- * Tab) objects. The <code>Tab</code> objects only contain the <code>url</code>, <code>title</code> and <code>
99629962- * favIconUrl</code> properties if the extension's manifest file includes the <code>"tabs"</code> permission. If false,
99639963- * the $(ref:windows.Window) won't have the <var>tabs</var> property.
99649964- * Optional.
99659965- */
99669966- populate?: boolean;
99679967- /**
99689968- * One or more tab indices to highlight.
99699969- */
99709970- tabs: number[] | number;
99719971- }
99729972- interface UpdateUpdatePropertiesType {
99739973- /**
99749974- * A URL to navigate the tab to.
99759975- * Optional.
99769976- */
99779977- url?: string;
99789978- /**
99799979- * Whether the tab should be active. Does not affect whether the window is focused (see $(ref:windows.update)).
99809980- * Optional.
99819981- */
99829982- active?: boolean;
99839983- /**
99849984- * Whether the tab should be discarded automatically by the browser when resources are low.
99859985- * Optional.
99869986- */
99879987- autoDiscardable?: boolean;
99889988- /**
99899989- * Adds or removes the tab from the current selection.
99909990- * Optional.
99919991- */
99929992- highlighted?: boolean;
99939993- /**
99949994- * Whether the tab should be pinned.
99959995- * Optional.
99969996- */
99979997- pinned?: boolean;
99989998- /**
99999999- * Whether the tab should be muted.
1000010000- * Optional.
1000110001- */
1000210002- muted?: boolean;
1000310003- /**
1000410004- * The ID of the tab that opened this tab. If specified, the opener tab must be in the same window as this tab.
1000510005- * Optional.
1000610006- */
1000710007- openerTabId?: number;
1000810008- /**
1000910009- * Whether the load should replace the current history entry for the tab.
1001010010- * Optional.
1001110011- */
1001210012- loadReplace?: boolean;
1001310013- /**
1001410014- * The ID of this tab's successor. If specified, the successor tab must be in the same window as this tab.
1001510015- * Optional.
1001610016- */
1001710017- successorTabId?: number;
1001810018- }
1001910019- interface MoveMovePropertiesType {
1002010020- /**
1002110021- * Defaults to the window the tab is currently in.
1002210022- * Optional.
1002310023- */
1002410024- windowId?: number;
1002510025- /**
1002610026- * The position to move the window to. -1 will place the tab at the end of the window.
1002710027- */
1002810028- index: number;
1002910029- }
1003010030- interface ReloadReloadPropertiesType {
1003110031- /**
1003210032- * Whether using any local cache. Default is false.
1003310033- * Optional.
1003410034- */
1003510035- bypassCache?: boolean;
1003610036- }
1003710037- interface MoveInSuccessionOptionsType {
1003810038- /**
1003910039- * Whether to move the tabs before (false) or after (true) tabId in the succession. Defaults to false.
1004010040- * Optional.
1004110041- */
1004210042- append?: boolean;
1004310043- /**
1004410044- * Whether to link up the current predecessors or successor (depending on options.append)
1004510045- * of tabId to the other side of the chain after it is prepended or appended. If true,
1004610046- * one of the following happens: if options.append is false, the first tab in the array is set as the successor of any
1004710047- * current predecessors of tabId; if options.append is true, the current successor of tabId is set as the successor of the
1004810048- * last tab in the array. Defaults to false.
1004910049- * Optional.
1005010050- */
1005110051- insert?: boolean;
1005210052- }
1005310053- interface GroupOptionsType {
1005410054- /**
1005510055- * The tab ID or list of tab IDs to add to the specified group.
1005610056- */
1005710057- tabIds: number | number[];
1005810058- /**
1005910059- * The ID of the group to add the tabs to. If not specified, a new group will be created.
1006010060- * Optional.
1006110061- */
1006210062- groupId?: number;
1006310063- /**
1006410064- * Configurations for creating a group. Cannot be used if groupId is already specified.
1006510065- * Optional.
1006610066- */
1006710067- createProperties?: GroupOptionsTypeCreatePropertiesType;
1006810068- }
1006910069- /**
1007010070- * Lists the changes to the state of the tab that was updated.
1007110071- */
1007210072- interface OnUpdatedChangeInfoType {
1007310073- /**
1007410074- * The tab's new attention state.
1007510075- * Optional.
1007610076- */
1007710077- attention?: boolean;
1007810078- /**
1007910079- * The tab's new audible state.
1008010080- * Optional.
1008110081- */
1008210082- audible?: boolean;
1008310083- /**
1008410084- * The tab's new autoDiscardable state.
1008510085- * Optional.
1008610086- */
1008710087- autoDiscardable?: boolean;
1008810088- /**
1008910089- * True while the tab is not loaded with content.
1009010090- * Optional.
1009110091- */
1009210092- discarded?: boolean;
1009310093- /**
1009410094- * The tab's new favicon URL. This property is only present if the extension's manifest includes the <code>"tabs"</code>
1009510095- * permission.
1009610096- * Optional.
1009710097- */
1009810098- favIconUrl?: string;
1009910099- /**
1010010100- * The tab's new hidden state.
1010110101- * Optional.
1010210102- */
1010310103- hidden?: boolean;
1010410104- /**
1010510105- * Whether the document in the tab can be rendered in reader mode.
1010610106- * Optional.
1010710107- */
1010810108- isArticle?: boolean;
1010910109- /**
1011010110- * The tab's new muted state and the reason for the change.
1011110111- * Optional.
1011210112- */
1011310113- mutedInfo?: MutedInfo;
1011410114- /**
1011510115- * The tab's new pinned state.
1011610116- * Optional.
1011710117- */
1011810118- pinned?: boolean;
1011910119- /**
1012010120- * The tab's new sharing state for screen, microphone and camera.
1012110121- * Optional.
1012210122- */
1012310123- sharingState?: SharingState;
1012410124- /**
1012510125- * The status of the tab. Can be either <em>loading</em> or <em>complete</em>.
1012610126- * Optional.
1012710127- */
1012810128- status?: string;
1012910129- /**
1013010130- * The title of the tab if it has changed. This property is only present if the extension's manifest includes the <code>
1013110131- * "tabs"</code> permission.
1013210132- * Optional.
1013310133- */
1013410134- title?: string;
1013510135- /**
1013610136- * The tab's URL if it has changed. This property is only present if the extension's manifest includes the <code>
1013710137- * "tabs"</code> permission.
1013810138- * Optional.
1013910139- */
1014010140- url?: string;
1014110141- }
1014210142- interface OnMovedMoveInfoType {
1014310143- windowId: number;
1014410144- fromIndex: number;
1014510145- toIndex: number;
1014610146- }
1014710147- interface OnActivatedActiveInfoType {
1014810148- /**
1014910149- * The ID of the tab that has become active.
1015010150- */
1015110151- tabId: number;
1015210152- /**
1015310153- * The ID of the tab that was previously active, if that tab is still open.
1015410154- * Optional.
1015510155- */
1015610156- previousTabId?: number;
1015710157- /**
1015810158- * The ID of the window the active tab changed inside of.
1015910159- */
1016010160- windowId: number;
1016110161- }
1016210162- interface OnHighlightedHighlightInfoType {
1016310163- /**
1016410164- * The window whose tabs changed.
1016510165- */
1016610166- windowId: number;
1016710167- /**
1016810168- * All highlighted tabs in the window.
1016910169- */
1017010170- tabIds: number[];
1017110171- }
1017210172- interface OnDetachedDetachInfoType {
1017310173- oldWindowId: number;
1017410174- oldPosition: number;
1017510175- }
1017610176- interface OnAttachedAttachInfoType {
1017710177- newWindowId: number;
1017810178- newPosition: number;
1017910179- }
1018010180- interface OnRemovedRemoveInfoType {
1018110181- /**
1018210182- * The window whose tab is closed.
1018310183- */
1018410184- windowId: number;
1018510185- /**
1018610186- * True when the tab is being closed because its window is being closed.
1018710187- */
1018810188- isWindowClosing: boolean;
1018910189- }
1019010190- interface OnZoomChangeZoomChangeInfoType {
1019110191- tabId: number;
1019210192- oldZoomFactor: number;
1019310193- newZoomFactor: number;
1019410194- zoomSettings: ZoomSettings;
1019510195- }
1019610196- /**
1019710197- * Configurations for creating a group. Cannot be used if groupId is already specified.
1019810198- */
1019910199- interface GroupOptionsTypeCreatePropertiesType {
1020010200- /**
1020110201- * The window of the new group. Defaults to the current window.
1020210202- * Optional.
1020310203- */
1020410204- windowId?: number;
1020510205- }
1020610206- /**
1020710207- * Fired when a tab is updated.
1020810208- */
1020910209- interface OnUpdatedEvent extends Events.Event<(tabId: number, changeInfo: OnUpdatedChangeInfoType, tab: Tab) => void> {
1021010210- /**
1021110211- * Registers an event listener <em>callback</em> to an event.
1021210212- *
1021310213- * @param callback Called when an event occurs. The parameters of this function depend on the type of event.
1021410214- * @param filter Optional. A set of filters that restricts the events that will be sent to this listener.
1021510215- */
1021610216- addListener(callback: (tabId: number, changeInfo: OnUpdatedChangeInfoType, tab: Tab) => void, filter?: UpdateFilter): void;
1021710217- }
1021810218- interface Static {
1021910219- /**
1022010220- * Retrieves details about the specified tab.
1022110221- */
1022210222- get(tabId: number): Promise<Tab>;
1022310223- /**
1022410224- * Gets the tab that this script call is being made from. May be undefined if called from a non-tab context (for example: a
1022510225- * background page or popup view).
1022610226- */
1022710227- getCurrent(): Promise<Tab>;
1022810228- /**
1022910229- * Connects to the content script(s) in the specified tab. The $(ref:runtime.onConnect)
1023010230- * event is fired in each content script running in the specified tab for the current extension. For more details,
1023110231- * see $(topic:messaging)[Content Script Messaging].
1023210232- *
1023310233- * @param connectInfo Optional.
1023410234- * @returns A port that can be used to communicate with the content scripts running in the specified tab.
1023510235- * The port's $(ref:runtime.Port) event is fired if the tab closes or does not exist.
1023610236- */
1023710237- connect(tabId: number, connectInfo?: ConnectConnectInfoType): Browser.Runtime.Port;
1023810238- /**
1023910239- * Sends a single message to the content script(s) in the specified tab, with an optional callback to run when a response
1024010240- * is sent back. The $(ref:runtime.onMessage) event is fired in each content script running in the specified tab for the
1024110241- * current extension.
1024210242- *
1024310243- * @param options Optional.
1024410244- */
1024510245- // eslint-disable-next-line @definitelytyped/no-unnecessary-generics
1024610246- sendMessage<TMessage = unknown, TResponse = unknown>(tabId: number, message: TMessage, options?: SendMessageOptionsType): Promise<TResponse>;
1024710247- /**
1024810248- * Creates a new tab.
1024910249- */
1025010250- create(createProperties: CreateCreatePropertiesType): Promise<Tab>;
1025110251- /**
1025210252- * Duplicates a tab.
1025310253- *
1025410254- * @param tabId The ID of the tab which is to be duplicated.
1025510255- * @param duplicateProperties Optional.
1025610256- */
1025710257- duplicate(tabId: number, duplicateProperties?: DuplicateDuplicatePropertiesType): Promise<Tab>;
1025810258- /**
1025910259- * Gets all tabs that have the specified properties, or all tabs if no properties are specified.
1026010260- */
1026110261- query(queryInfo: QueryQueryInfoType): Promise<Tab[]>;
1026210262- /**
1026310263- * Highlights the given tabs.
1026410264- */
1026510265- highlight(highlightInfo: HighlightHighlightInfoType): Promise<Browser.Windows.Window>;
1026610266- /**
1026710267- * Modifies the properties of a tab. Properties that are not specified in <var>updateProperties</var> are not modified.
1026810268- *
1026910269- * @param tabId Optional. Defaults to the selected tab of the $(topic:current-window)[current window].
1027010270- */
1027110271- update(tabId: number | undefined, updateProperties: UpdateUpdatePropertiesType): Promise<Tab>;
1027210272- /**
1027310273- * Modifies the properties of a tab. Properties that are not specified in <var>updateProperties</var> are not modified.
1027410274- */
1027510275- update(updateProperties: UpdateUpdatePropertiesType): Promise<Tab>;
1027610276- /**
1027710277- * Moves one or more tabs to a new position within its window, or to a new window. Note that tabs can only be moved to and
1027810278- * from normal (window.type === "normal") windows.
1027910279- *
1028010280- * @param tabIds The tab or list of tabs to move.
1028110281- */
1028210282- move(tabIds: number | number[], moveProperties: MoveMovePropertiesType): Promise<Tab | Tab[]>;
1028310283- /**
1028410284- * Reload a tab.
1028510285- *
1028610286- * @param tabId Optional. The ID of the tab to reload; defaults to the selected tab of the current window.
1028710287- * @param reloadProperties Optional.
1028810288- */
1028910289- reload(tabId?: number, reloadProperties?: ReloadReloadPropertiesType): Promise<void>;
1029010290- /**
1029110291- * Warm up a tab
1029210292- *
1029310293- * @param tabId The ID of the tab to warm up.
1029410294- */
1029510295- warmup(tabId: number): Promise<void>;
1029610296- /**
1029710297- * Closes one or more tabs.
1029810298- *
1029910299- * @param tabIds The tab or list of tabs to close.
1030010300- */
1030110301- remove(tabIds: number | number[]): Promise<void>;
1030210302- /**
1030310303- * discards one or more tabs.
1030410304- *
1030510305- * @param tabIds The tab or list of tabs to discard.
1030610306- */
1030710307- discard(tabIds: number | number[]): Promise<void>;
1030810308- /**
1030910309- * Detects the primary language of the content in a tab.
1031010310- *
1031110311- * @param tabId Optional. Defaults to the active tab of the $(topic:current-window)[current window].
1031210312- */
1031310313- detectLanguage(tabId?: number): Promise<string>;
1031410314- /**
1031510315- * Toggles reader mode for the document in the tab.
1031610316- *
1031710317- * @param tabId Optional. Defaults to the active tab of the $(topic:current-window)[current window].
1031810318- */
1031910319- toggleReaderMode(tabId?: number): Promise<void>;
1032010320- /**
1032110321- * Captures an area of a specified tab. You must have $(topic:declare_permissions)[<all_urls>]
1032210322- * permission to use this method.
1032310323- *
1032410324- * @param tabId Optional. The tab to capture. Defaults to the active tab of the current window.
1032510325- * @param options Optional.
1032610326- */
1032710327- captureTab(tabId?: number, options?: Browser.ExtensionTypes.ImageDetails): Promise<string>;
1032810328- /**
1032910329- * Captures an area of the currently active tab in the specified window. You must have <all_urls> or activeTab
1033010330- * permission to use this method.
1033110331- *
1033210332- * @param windowId Optional. The target window. Defaults to the $(topic:current-window)[current window].
1033310333- * @param options Optional.
1033410334- */
1033510335- captureVisibleTab(windowId?: number, options?: Browser.ExtensionTypes.ImageDetails): Promise<string>;
1033610336- /**
1033710337- * Injects JavaScript code into a page. For details, see the $(topic:content_scripts)[programmatic injection]
1033810338- * section of the content scripts doc.
1033910339- *
1034010340- * @param tabId Optional. The ID of the tab in which to run the script; defaults to the active tab of the current window.
1034110341- * @param details Details of the script to run.
1034210342- * @returns Called after all the JavaScript has been executed.
1034310343- */
1034410344- executeScript(tabId: number | undefined, details: Browser.ExtensionTypes.InjectDetails): Promise<unknown[]>;
1034510345- /**
1034610346- * Injects JavaScript code into a page. For details, see the $(topic:content_scripts)[programmatic injection]
1034710347- * section of the content scripts doc.
1034810348- *
1034910349- * @param details Details of the script to run.
1035010350- * @returns Called after all the JavaScript has been executed.
1035110351- */
1035210352- executeScript(details: Browser.ExtensionTypes.InjectDetails): Promise<unknown[]>;
1035310353- /**
1035410354- * Injects CSS into a page. For details, see the $(topic:content_scripts)[programmatic injection]
1035510355- * section of the content scripts doc.
1035610356- *
1035710357- * @param tabId Optional. The ID of the tab in which to insert the CSS; defaults to the active tab of the current window.
1035810358- * @param details Details of the CSS text to insert.
1035910359- * @returns Called when all the CSS has been inserted.
1036010360- */
1036110361- insertCSS(tabId: number | undefined, details: Browser.ExtensionTypes.InjectDetails): Promise<void>;
1036210362- /**
1036310363- * Injects CSS into a page. For details, see the $(topic:content_scripts)[programmatic injection]
1036410364- * section of the content scripts doc.
1036510365- *
1036610366- * @param details Details of the CSS text to insert.
1036710367- * @returns Called when all the CSS has been inserted.
1036810368- */
1036910369- insertCSS(details: Browser.ExtensionTypes.InjectDetails): Promise<void>;
1037010370- /**
1037110371- * Removes injected CSS from a page. For details, see the $(topic:content_scripts)[programmatic injection]
1037210372- * section of the content scripts doc.
1037310373- *
1037410374- * @param tabId Optional. The ID of the tab from which to remove the injected CSS; defaults to the active tab of the
1037510375- * current window.
1037610376- * @param details Details of the CSS text to remove.
1037710377- * @returns Called when all the CSS has been removed.
1037810378- */
1037910379- removeCSS(tabId: number | undefined, details: Browser.ExtensionTypes.InjectDetails): Promise<void>;
1038010380- /**
1038110381- * Removes injected CSS from a page. For details, see the $(topic:content_scripts)[programmatic injection]
1038210382- * section of the content scripts doc.
1038310383- *
1038410384- * @param details Details of the CSS text to remove.
1038510385- * @returns Called when all the CSS has been removed.
1038610386- */
1038710387- removeCSS(details: Browser.ExtensionTypes.InjectDetails): Promise<void>;
1038810388- /**
1038910389- * Zooms a specified tab.
1039010390- *
1039110391- * @param tabId Optional. The ID of the tab to zoom; defaults to the active tab of the current window.
1039210392- * @param zoomFactor The new zoom factor. Use a value of 0 here to set the tab to its current default zoom factor.
1039310393- * Values greater than zero specify a (possibly non-default) zoom factor for the tab.
1039410394- * @returns Called after the zoom factor has been changed.
1039510395- */
1039610396- setZoom(tabId: number | undefined, zoomFactor: number): Promise<void>;
1039710397- /**
1039810398- * Zooms a specified tab.
1039910399- *
1040010400- * @param zoomFactor The new zoom factor. Use a value of 0 here to set the tab to its current default zoom factor.
1040110401- * Values greater than zero specify a (possibly non-default) zoom factor for the tab.
1040210402- * @returns Called after the zoom factor has been changed.
1040310403- */
1040410404- setZoom(zoomFactor: number): Promise<void>;
1040510405- /**
1040610406- * Gets the current zoom factor of a specified tab.
1040710407- *
1040810408- * @param tabId Optional. The ID of the tab to get the current zoom factor from; defaults to the active tab of the current
1040910409- * window.
1041010410- * @returns Called with the tab's current zoom factor after it has been fetched.
1041110411- */
1041210412- getZoom(tabId?: number): Promise<number>;
1041310413- /**
1041410414- * Sets the zoom settings for a specified tab, which define how zoom changes are handled.
1041510415- * These settings are reset to defaults upon navigating the tab.
1041610416- *
1041710417- * @param tabId Optional. The ID of the tab to change the zoom settings for; defaults to the active tab of the current
1041810418- * window.
1041910419- * @param zoomSettings Defines how zoom changes are handled and at what scope.
1042010420- * @returns Called after the zoom settings have been changed.
1042110421- */
1042210422- setZoomSettings(tabId: number | undefined, zoomSettings: ZoomSettings): Promise<void>;
1042310423- /**
1042410424- * Sets the zoom settings for a specified tab, which define how zoom changes are handled.
1042510425- * These settings are reset to defaults upon navigating the tab.
1042610426- *
1042710427- * @param zoomSettings Defines how zoom changes are handled and at what scope.
1042810428- * @returns Called after the zoom settings have been changed.
1042910429- */
1043010430- setZoomSettings(zoomSettings: ZoomSettings): Promise<void>;
1043110431- /**
1043210432- * Gets the current zoom settings of a specified tab.
1043310433- *
1043410434- * @param tabId Optional. The ID of the tab to get the current zoom settings from; defaults to the active tab of the
1043510435- * current window.
1043610436- * @returns Called with the tab's current zoom settings.
1043710437- */
1043810438- getZoomSettings(tabId?: number): Promise<ZoomSettings>;
1043910439- /**
1044010440- * Prints page in active tab.
1044110441- */
1044210442- print(): void;
1044310443- /**
1044410444- * Shows print preview for page in active tab.
1044510445- *
1044610446- * @returns Called after print preview entered.
1044710447- */
1044810448- printPreview(): Promise<void>;
1044910449- /**
1045010450- * Saves page in active tab as a PDF file.
1045110451- *
1045210452- * @param pageSettings The page settings used to save the PDF file.
1045310453- * @returns Called after save as dialog closed.
1045410454- */
1045510455- saveAsPDF(pageSettings: PageSettings): Promise<string>;
1045610456- /**
1045710457- * Shows one or more tabs.
1045810458- *
1045910459- * @param tabIds The TAB ID or list of TAB IDs to show.
1046010460- */
1046110461- show(tabIds: number | number[]): Promise<void>;
1046210462- /**
1046310463- * Hides one or more tabs. The <code>"tabHide"</code> permission is required to hide tabs. Not all tabs are hidable.
1046410464- * Returns an array of hidden tabs.
1046510465- *
1046610466- * @param tabIds The TAB ID or list of TAB IDs to hide.
1046710467- */
1046810468- hide(tabIds: number | number[]): Promise<number[]>;
1046910469- /**
1047010470- * Removes an array of tabs from their lines of succession and prepends or appends them in a chain to another tab.
1047110471- *
1047210472- * @param tabIds An array of tab IDs to move in the line of succession. For each tab in the array,
1047310473- * the tab's current predecessors will have their successor set to the tab's current successor,
1047410474- * and each tab will then be set to be the successor of the previous tab in the array.
1047510475- * Any tabs not in the same window as the tab indicated by the second argument (or the first tab in the array,
1047610476- * if no second argument) will be skipped.
1047710477- * @param tabId Optional. The ID of a tab to set as the successor of the last tab in the array, or $(ref:tabs.TAB_ID_NONE)
1047810478- * to leave the last tab without a successor. If options.append is true, then this tab is made the predecessor of the
1047910479- * first tab in the array instead.
1048010480- * @param options Optional.
1048110481- */
1048210482- moveInSuccession(tabIds: number[], tabId?: number, options?: MoveInSuccessionOptionsType): void;
1048310483- /**
1048410484- * Navigate to next page in tab's history, if available
1048510485- *
1048610486- * @param tabId Optional. The ID of the tab to navigate forward.
1048710487- */
1048810488- goForward(tabId?: number): Promise<void>;
1048910489- /**
1049010490- * Navigate to previous page in tab's history, if available.
1049110491- *
1049210492- * @param tabId Optional. The ID of the tab to navigate backward.
1049310493- */
1049410494- goBack(tabId?: number): Promise<void>;
1049510495- /**
1049610496- * Adds one or more tabs to a specified group, or if no group is specified, adds the given tabs to a newly created group.
1049710497- */
1049810498- group(options: GroupOptionsType): Promise<number>;
1049910499- /**
1050010500- * Removes one or more tabs from their respective groups. If any groups become empty, they are deleted.
1050110501- *
1050210502- * @param tabIds The tab ID or list of tab IDs to remove from their respective groups.
1050310503- */
1050410504- ungroup(tabIds: number | number[]): void;
1050510505- /**
1050610506- * Fired when a tab is created. Note that the tab's URL may not be set at the time this event fired,
1050710507- * but you can listen to onUpdated events to be notified when a URL is set.
1050810508- *
1050910509- * @param tab Details of the tab that was created.
1051010510- */
1051110511- onCreated: Events.Event<(tab: Tab) => void>;
1051210512- /**
1051310513- * Fired when a tab is updated.
1051410514- */
1051510515- onUpdated: OnUpdatedEvent;
1051610516- /**
1051710517- * Fired when a tab is moved within a window. Only one move event is fired, representing the tab the user directly moved.
1051810518- * Move events are not fired for the other tabs that must move in response. This event is not fired when a tab is moved
1051910519- * between windows. For that, see $(ref:tabs.onDetached).
1052010520- */
1052110521- onMoved: Events.Event<(tabId: number, moveInfo: OnMovedMoveInfoType) => void>;
1052210522- /**
1052310523- * Fires when the active tab in a window changes. Note that the tab's URL may not be set at the time this event fired,
1052410524- * but you can listen to onUpdated events to be notified when a URL is set.
1052510525- */
1052610526- onActivated: Events.Event<(activeInfo: OnActivatedActiveInfoType) => void>;
1052710527- /**
1052810528- * Fired when the highlighted or selected tabs in a window changes.
1052910529- */
1053010530- onHighlighted: Events.Event<(highlightInfo: OnHighlightedHighlightInfoType) => void>;
1053110531- /**
1053210532- * Fired when a tab is detached from a window, for example because it is being moved between windows.
1053310533- */
1053410534- onDetached: Events.Event<(tabId: number, detachInfo: OnDetachedDetachInfoType) => void>;
1053510535- /**
1053610536- * Fired when a tab is attached to a window, for example because it was moved between windows.
1053710537- */
1053810538- onAttached: Events.Event<(tabId: number, attachInfo: OnAttachedAttachInfoType) => void>;
1053910539- /**
1054010540- * Fired when a tab is closed.
1054110541- */
1054210542- onRemoved: Events.Event<(tabId: number, removeInfo: OnRemovedRemoveInfoType) => void>;
1054310543- /**
1054410544- * Fired when a tab is replaced with another tab due to prerendering or instant.
1054510545- */
1054610546- onReplaced: Events.Event<(addedTabId: number, removedTabId: number) => void>;
1054710547- /**
1054810548- * Fired when a tab is zoomed.
1054910549- */
1055010550- onZoomChange: Events.Event<(ZoomChangeInfo: OnZoomChangeZoomChangeInfoType) => void>;
1055110551- /**
1055210552- * An ID which represents the absence of a browser tab.
1055310553- */
1055410554- TAB_ID_NONE: -1;
1055510555- }
1055610556- }
1055710557- /**
1055810558- * Namespace: browser.theme
1055910559- */
1056010560- namespace Theme {
1056110561- /**
1056210562- * Info provided in the onUpdated listener.
1056310563- */
1056410564- interface ThemeUpdateInfo {
1056510565- /**
1056610566- * The new theme after update
1056710567- */
1056810568- theme: ThemeUpdateInfoThemeType;
1056910569- /**
1057010570- * The id of the window the theme has been applied to
1057110571- * Optional.
1057210572- */
1057310573- windowId?: number;
1057410574- }
1057510575- /**
1057610576- * The new theme after update
1057710577- */
1057810578- interface ThemeUpdateInfoThemeType {
1057910579- [s: string]: unknown;
1058010580- }
1058110581- interface Static {
1058210582- /**
1058310583- * Returns the current theme for the specified window or the last focused window.
1058410584- *
1058510585- * @param windowId Optional. The window for which we want the theme.
1058610586- */
1058710587- getCurrent(windowId?: number): Promise<Manifest.ThemeType>;
1058810588- /**
1058910589- * Make complete updates to the theme. Resolves when the update has completed.
1059010590- *
1059110591- * @param windowId Optional. The id of the window to update. No id updates all windows.
1059210592- * @param details The properties of the theme to update.
1059310593- */
1059410594- update(windowId: number | undefined, details: Browser.Manifest.ThemeType): Promise<void>;
1059510595- /**
1059610596- * Make complete updates to the theme. Resolves when the update has completed.
1059710597- *
1059810598- * @param details The properties of the theme to update.
1059910599- */
1060010600- update(details: Browser.Manifest.ThemeType): Promise<void>;
1060110601- /**
1060210602- * Removes the updates made to the theme.
1060310603- *
1060410604- * @param windowId Optional. The id of the window to reset. No id resets all windows.
1060510605- */
1060610606- reset(windowId?: number): Promise<void>;
1060710607- /**
1060810608- * Fired when a new theme has been applied
1060910609- *
1061010610- * @param updateInfo Details of the theme update
1061110611- */
1061210612- onUpdated: Events.Event<(updateInfo: ThemeUpdateInfo) => void>;
1061310613- }
1061410614- }
1061510615- /**
1061610616- * Namespace: browser.topSites
1061710617- */
1061810618- namespace TopSites {
1061910619- /**
1062010620- * An object encapsulating a most visited URL, such as the URLs on the new tab page.
1062110621- */
1062210622- interface MostVisitedURL {
1062310623- /**
1062410624- * The most visited URL.
1062510625- */
1062610626- url: string;
1062710627- /**
1062810628- * The title of the page.
1062910629- * Optional.
1063010630- */
1063110631- title?: string;
1063210632- /**
1063310633- * Data URL for the favicon, if available.
1063410634- * Optional.
1063510635- */
1063610636- favicon?: string;
1063710637- /**
1063810638- * The entry type, either <code>url</code> for a normal page link, or <code>search</code> for a search shortcut.
1063910639- * Optional.
1064010640- */
1064110641- type?: MostVisitedURLTypeEnum;
1064210642- }
1064310643- interface GetOptionsType {
1064410644- /**
1064510645- * The number of top sites to return, defaults to the value used by Firefox
1064610646- * Optional.
1064710647- */
1064810648- limit?: number;
1064910649- /**
1065010650- * Limit the result to a single top site link per domain
1065110651- * Optional.
1065210652- */
1065310653- onePerDomain?: boolean;
1065410654- /**
1065510655- * Include sites that the user has blocked from appearing on the Firefox new tab.
1065610656- * Optional.
1065710657- */
1065810658- includeBlocked?: boolean;
1065910659- /**
1066010660- * Include sites favicon if available.
1066110661- * Optional.
1066210662- */
1066310663- includeFavicon?: boolean;
1066410664- /**
1066510665- * Include sites that the user has pinned on the Firefox new tab.
1066610666- * Optional.
1066710667- */
1066810668- includePinned?: boolean;
1066910669- /**
1067010670- * Include search shortcuts appearing on the Firefox new tab.
1067110671- * Optional.
1067210672- */
1067310673- includeSearchShortcuts?: boolean;
1067410674- /**
1067510675- * Return the sites that exactly appear on the user's new-tab page. When true, all other options are ignored except limit
1067610676- * and includeFavicon. If the user disabled newtab Top Sites, the newtab parameter will be ignored.
1067710677- * Optional.
1067810678- */
1067910679- newtab?: boolean;
1068010680- }
1068110681- /**
1068210682- * The entry type, either <code>url</code> for a normal page link, or <code>search</code> for a search shortcut.
1068310683- */
1068410684- type MostVisitedURLTypeEnum = "url" | "search";
1068510685- interface Static {
1068610686- /**
1068710687- * Gets a list of top sites.
1068810688- *
1068910689- * @param options Optional.
1069010690- */
1069110691- get(options?: GetOptionsType): Promise<MostVisitedURL[]>;
1069210692- }
1069310693- }
1069410694- /**
1069510695- * Namespace: browser.trial
1069610696- */
1069710697- namespace Trial {
1069810698- interface Static {
1069910699- ml: Ml.Static;
1070010700- }
1070110701- }
1070210702- /**
1070310703- * Namespace: browser.types
1070410704- */
1070510705- namespace Types {
1070610706- /**
1070710707- * The scope of the Setting. One of<ul><li><var>regular</var>: setting for the regular profile (which is inherited by the
1070810708- * incognito profile if not overridden elsewhere),</li><li><var>regular_only</var>: setting for the regular profile only
1070910709- * (not inherited by the incognito profile),</li><li><var>incognito_persistent</var>: setting for the incognito profile
1071010710- * that survives browser restarts (overrides regular preferences),</li><li><var>incognito_session_only</var>
1071110711- * : setting for the incognito profile that can only be set during an incognito session and is deleted when the incognito
1071210712- * session ends (overrides regular and incognito_persistent preferences).</li></ul> Only <var>regular</var>
1071310713- * is supported by Firefox at this time.
1071410714- */
1071510715- type SettingScope = "regular" | "regular_only" | "incognito_persistent" | "incognito_session_only";
1071610716- /**
1071710717- * One of<ul><li><var>not_controllable</var>: cannot be controlled by any extension</li><li><var>
1071810718- * controlled_by_other_extensions</var>: controlled by extensions with higher precedence</li><li><var>
1071910719- * controllable_by_this_extension</var>: can be controlled by this extension</li><li><var>controlled_by_this_extension</var>
1072010720- * : controlled by this extension</li></ul>
1072110721- */
1072210722- type LevelOfControl = "not_controllable" | "controlled_by_other_extensions" | "controllable_by_this_extension" | "controlled_by_this_extension";
1072310723- interface Setting {
1072410724- /**
1072510725- * Gets the value of a setting.
1072610726- *
1072710727- * @param details Which setting to consider.
1072810728- */
1072910729- get(details: SettingGetDetailsType): Promise<SettingGetCallbackDetailsType>;
1073010730- /**
1073110731- * Sets the value of a setting.
1073210732- *
1073310733- * @param details Which setting to change.
1073410734- * @returns Called at the completion of the set operation.
1073510735- */
1073610736- set(details: SettingSetDetailsType): Promise<void>;
1073710737- /**
1073810738- * Clears the setting, restoring any default value.
1073910739- *
1074010740- * @param details Which setting to clear.
1074110741- * @returns Called at the completion of the clear operation.
1074210742- */
1074310743- clear(details: SettingClearDetailsType): Promise<void>;
1074410744- /**
1074510745- * Fired after the setting changes.
1074610746- */
1074710747- onChange: Events.Event<(details: SettingOnChangeDetailsType) => void>;
1074810748- }
1074910749- interface SettingOnChangeDetailsType {
1075010750- /**
1075110751- * The value of the setting after the change.
1075210752- */
1075310753- value: unknown;
1075410754- /**
1075510755- * The level of control of the setting.
1075610756- */
1075710757- levelOfControl: Browser.Types.LevelOfControl;
1075810758- /**
1075910759- * Whether the value that has changed is specific to the incognito session.<br/>This property will <em>only</em>
1076010760- * be present if the user has enabled the extension in incognito mode.
1076110761- * Optional.
1076210762- */
1076310763- incognitoSpecific?: boolean;
1076410764- }
1076510765- /**
1076610766- * Which setting to consider.
1076710767- */
1076810768- interface SettingGetDetailsType {
1076910769- /**
1077010770- * Whether to return the value that applies to the incognito session (default false).
1077110771- * Optional.
1077210772- */
1077310773- incognito?: boolean;
1077410774- }
1077510775- /**
1077610776- * Details of the currently effective value.
1077710777- */
1077810778- interface SettingGetCallbackDetailsType {
1077910779- /**
1078010780- * The value of the setting.
1078110781- */
1078210782- value: unknown;
1078310783- /**
1078410784- * The level of control of the setting.
1078510785- */
1078610786- levelOfControl: Browser.Types.LevelOfControl;
1078710787- /**
1078810788- * Whether the effective value is specific to the incognito session.<br/>This property will <em>only</em>
1078910789- * be present if the <var>incognito</var> property in the <var>details</var> parameter of <code>get()</code> was true.
1079010790- * Optional.
1079110791- */
1079210792- incognitoSpecific?: boolean;
1079310793- }
1079410794- /**
1079510795- * Which setting to change.
1079610796- */
1079710797- interface SettingSetDetailsType {
1079810798- /**
1079910799- * The value of the setting. <br/>Note that every setting has a specific value type, which is described together with the
1080010800- * setting. An extension should <em>not</em> set a value of a different type.
1080110801- */
1080210802- value: unknown;
1080310803- /**
1080410804- * Where to set the setting (default: regular).
1080510805- * Optional.
1080610806- */
1080710807- scope?: Browser.Types.SettingScope;
1080810808- }
1080910809- /**
1081010810- * Which setting to clear.
1081110811- */
1081210812- interface SettingClearDetailsType {
1081310813- /**
1081410814- * Where to clear the setting (default: regular).
1081510815- * Optional.
1081610816- */
1081710817- scope?: Browser.Types.SettingScope;
1081810818- }
1081910819- interface Static {
1082010820- [s: string]: unknown;
1082110821- }
1082210822- }
1082310823- /**
1082410824- * Namespace: browser.userScripts
1082510825- */
1082610826- namespace UserScripts {
1082710827- /**
1082810828- * Details of a user script
1082910829- */
1083010830- interface UserScriptOptions {
1083110831- /**
1083210832- * The list of JS files to inject
1083310833- */
1083410834- js: Browser.ExtensionTypes.ExtensionFileOrCode[];
1083510835- /**
1083610836- * An opaque user script metadata value
1083710837- * Optional.
1083810838- */
1083910839- scriptMetadata?: Browser.ExtensionTypes.PlainJSONValue;
1084010840- matches: Browser.Manifest.MatchPattern[];
1084110841- /**
1084210842- * Optional.
1084310843- */
1084410844- excludeMatches?: Browser.Manifest.MatchPattern[];
1084510845- /**
1084610846- * Optional.
1084710847- */
1084810848- includeGlobs?: string[];
1084910849- /**
1085010850- * Optional.
1085110851- */
1085210852- excludeGlobs?: string[];
1085310853- /**
1085410854- * If allFrames is <code>true</code>, implies that the JavaScript should be injected into all frames of current page.
1085510855- * By default, it's <code>false</code> and is only injected into the top frame.
1085610856- * Optional.
1085710857- */
1085810858- allFrames?: boolean;
1085910859- /**
1086010860- * If matchAboutBlank is true, then the code is also injected in about:blank and about:srcdoc frames if your extension has
1086110861- * access to its parent document. Code cannot be inserted in top-level about:-frames. By default it is <code>false</code>.
1086210862- * Optional.
1086310863- */
1086410864- matchAboutBlank?: boolean;
1086510865- /**
1086610866- * The soonest that the JavaScript will be injected into the tab. Defaults to "document_idle".
1086710867- * Optional.
1086810868- */
1086910869- runAt?: Browser.ExtensionTypes.RunAt;
1087010870- /**
1087110871- * limit the set of matched tabs to those that belong to the given cookie store id
1087210872- * Optional.
1087310873- */
1087410874- cookieStoreId?: string[] | string;
1087510875- }
1087610876- /**
1087710877- * An object that represents a user script registered programmatically
1087810878- */
1087910879- interface RegisteredUserScript {
1088010880- /**
1088110881- * The ID of the user script specified in the API call. This property must not start with a '_' as it's reserved as a
1088210882- * prefix for generated script IDs.
1088310883- */
1088410884- id: string;
1088510885- /**
1088610886- * If allFrames is <code>true</code>, implies that the JavaScript should be injected into all frames of current page.
1088710887- * By default, it's <code>false</code> and is only injected into the top frame.
1088810888- * Optional.
1088910889- */
1089010890- allFrames?: boolean;
1089110891- /**
1089210892- * The list of ScriptSource objects defining sources of scripts to be injected into matching pages.
1089310893- */
1089410894- js: ScriptSource[];
1089510895- /**
1089610896- * At least one of matches or includeGlobs should be non-empty. The script runs in documents whose URL match either pattern.
1089710897- * Optional.
1089810898- */
1089910899- matches?: Browser.Manifest.MatchPattern[];
1090010900- /**
1090110901- * Optional.
1090210902- */
1090310903- excludeMatches?: Browser.Manifest.MatchPattern[];
1090410904- /**
1090510905- * At least one of matches or includeGlobs should be non-empty. The script runs in documents whose URL match either pattern.
1090610906- * Optional.
1090710907- */
1090810908- includeGlobs?: string[];
1090910909- /**
1091010910- * Optional.
1091110911- */
1091210912- excludeGlobs?: string[];
1091310913- /**
1091410914- * The soonest that the JavaScript will be injected into the tab. Defaults to "document_idle".
1091510915- * Optional.
1091610916- */
1091710917- runAt?: Browser.ExtensionTypes.RunAt;
1091810918- /**
1091910919- * The JavaScript script for a script to execute within. Defaults to "USER_SCRIPT".
1092010920- * Optional.
1092110921- */
1092210922- world?: ExecutionWorld;
1092310923- /**
1092410924- * If specified, specifies a specific user script world ID to execute in. Only valid if `world` is omitted or is
1092510925- * `USER_SCRIPT`. If `worldId` is omitted, the script will execute in the default user script world ("").
1092610926- * Values with leading underscores (`_`) are reserved. The maximum length is 256.
1092710927- * Optional.
1092810928- */
1092910929- worldId?: string;
1093010930- }
1093110931- /**
1093210932- * The JavaScript world for a script to execute within. <code>USER_SCRIPT</code> is the default execution environment of
1093310933- * user scripts, <code>MAIN</code> is the web page's execution environment.
1093410934- */
1093510935- type ExecutionWorld = "MAIN" | "USER_SCRIPT";
1093610936- /**
1093710937- * Optional filter to use with getScripts() and unregister().
1093810938- */
1093910939- interface UserScriptFilter {
1094010940- /**
1094110941- * Optional.
1094210942- */
1094310943- ids?: string[];
1094410944- }
1094510945- /**
1094610946- * Object with file xor code property. Equivalent to the ExtensionFileOrCode, except the file remains a relative URL.
1094710947- */
1094810948- type ScriptSource = ScriptSourceC1Type | ScriptSourceC2Type;
1094910949- /**
1095010950- * The configuration of a USER_SCRIPT world.
1095110951- */
1095210952- interface WorldProperties {
1095310953- /**
1095410954- * The identifier of the world. Values with leading underscores (`_`) are reserved. The maximum length is 256.
1095510955- * Defaults to the default USER_SCRIPT world ("").
1095610956- * Optional.
1095710957- */
1095810958- worldId?: string;
1095910959- /**
1096010960- * The world's Content Security Policy. Defaults to the CSP of regular content scripts,
1096110961- * which prohibits dynamic code execution such as eval.
1096210962- * Optional.
1096310963- */
1096410964- csp?: string;
1096510965- /**
1096610966- * Whether the runtime.sendMessage and runtime.connect methods are exposed. Defaults to not exposing these messaging APIs.
1096710967- * Optional.
1096810968- */
1096910969- messaging?: boolean;
1097010970- }
1097110971- /**
1097210972- * An object that represents a user script registered programmatically
1097310973- */
1097410974- interface RegisterCallbackLegacyRegisteredUserScriptType {
1097510975- /**
1097610976- * Unregister a user script registered programmatically
1097710977- */
1097810978- unregister(): Promise<void>;
1097910979- }
1098010980- interface UpdateScriptsItemType extends Omit<RegisteredUserScript, "js"> {
1098110981- /**
1098210982- * Optional.
1098310983- */
1098410984- js?: ScriptSource[];
1098510985- }
1098610986- interface ScriptSourceC1Type {
1098710987- /**
1098810988- * The path of the JavaScript file to inject relative to the extension's root directory.
1098910989- */
1099010990- file: string;
1099110991- }
1099210992- interface ScriptSourceC2Type {
1099310993- code: string;
1099410994- }
1099510995- interface Static {
1099610996- /**
1099710997- * Register a user script programmatically given its $(ref:userScripts.UserScriptOptions),
1099810998- * and resolves to an object with the unregister() function
1099910999- */
1100011000- register(userScriptOptions: UserScriptOptions): Promise<RegisterCallbackLegacyRegisteredUserScriptType>;
1100111001- /**
1100211002- * Registers one or more user scripts for this extension.
1100311003- *
1100411004- * @param scripts List of user scripts to be registered.
1100511005- */
1100611006- register(scripts: RegisteredUserScript[]): void;
1100711007- /**
1100811008- * Updates one or more user scripts for this extension.
1100911009- *
1101011010- * @param scripts List of user scripts to be updated.
1101111011- */
1101211012- update(scripts: UpdateScriptsItemType[]): void;
1101311013- /**
1101411014- * Unregisters all dynamically-registered user scripts for this extension.
1101511015- *
1101611016- * @param filter Optional. If specified, this method unregisters only the user scripts that match it.
1101711017- */
1101811018- unregister(filter?: UserScriptFilter): void;
1101911019- /**
1102011020- * Returns all dynamically-registered user scripts for this extension.
1102111021- *
1102211022- * @param filter Optional. If specified, this method returns only the user scripts that match it.
1102311023- */
1102411024- getScripts(filter?: UserScriptFilter): Promise<RegisteredUserScript[]>;
1102511025- /**
1102611026- * Configures the environment for scripts running in a USER_SCRIPT world.
1102711027- *
1102811028- * @param properties The desired configuration for a USER_SCRIPT world.
1102911029- */
1103011030- configureWorld(properties: WorldProperties): void;
1103111031- /**
1103211032- * Resets the configuration for a given world. That world will fall back to the default world's configuration.
1103311033- *
1103411034- * @param worldId Optional. The ID of the USER_SCRIPT world to reset. If omitted or empty,
1103511035- * resets the default world's configuration.
1103611036- */
1103711037- resetWorldConfiguration(worldId?: string): void;
1103811038- /**
1103911039- * Returns all registered USER_SCRIPT world configurations.
1104011040- */
1104111041- getWorldConfigurations(): Promise<WorldProperties[]>;
1104211042- }
1104311043- }
1104411044- /**
1104511045- * Namespace: browser.webNavigation
1104611046- */
1104711047- namespace WebNavigation {
1104811048- /**
1104911049- * Cause of the navigation. The same transition types as defined in the history API are used.
1105011050- * These are the same transition types as defined in the $(topic:transition_types)[history API] except with <code>
1105111051- * "start_page"</code> in place of <code>"auto_toplevel"</code> (for backwards compatibility).
1105211052- */
1105311053- type TransitionType = "link" | "typed" | "auto_bookmark" | "auto_subframe" | "manual_subframe" | "generated" | "start_page" | "form_submit" | "reload" | "keyword" | "keyword_generated";
1105411054- type TransitionQualifier = "client_redirect" | "server_redirect" | "forward_back" | "from_address_bar";
1105511055- interface EventUrlFilters {
1105611056- url: Browser.Events.UrlFilter[];
1105711057- }
1105811058- /**
1105911059- * Information about the frame to retrieve information about.
1106011060- */
1106111061- interface GetFrameDetailsType {
1106211062- /**
1106311063- * The ID of the tab in which the frame is.
1106411064- */
1106511065- tabId: number;
1106611066- /**
1106711067- * The ID of the process runs the renderer for this tab.
1106811068- * Optional.
1106911069- */
1107011070- processId?: number;
1107111071- /**
1107211072- * The ID of the frame in the given tab.
1107311073- */
1107411074- frameId: number;
1107511075- }
1107611076- /**
1107711077- * Information about the requested frame, null if the specified frame ID and/or tab ID are invalid.
1107811078- */
1107911079- interface GetFrameCallbackDetailsType {
1108011080- /**
1108111081- * True if the last navigation in this frame was interrupted by an error, i.e. the onErrorOccurred event fired.
1108211082- * Optional.
1108311083- */
1108411084- errorOccurred?: boolean;
1108511085- /**
1108611086- * The URL currently associated with this frame, if the frame identified by the frameId existed at one point in the given
1108711087- * tab. The fact that an URL is associated with a given frameId does not imply that the corresponding frame still exists.
1108811088- */
1108911089- url: string;
1109011090- /**
1109111091- * The ID of the tab in which the frame is.
1109211092- */
1109311093- tabId: number;
1109411094- /**
1109511095- * The ID of the frame. 0 indicates that this is the main frame; a positive value indicates the ID of a subframe.
1109611096- */
1109711097- frameId: number;
1109811098- /**
1109911099- * ID of frame that wraps the frame. Set to -1 of no parent frame exists.
1110011100- */
1110111101- parentFrameId: number;
1110211102- }
1110311103- /**
1110411104- * Information about the tab to retrieve all frames from.
1110511105- */
1110611106- interface GetAllFramesDetailsType {
1110711107- /**
1110811108- * The ID of the tab.
1110911109- */
1111011110- tabId: number;
1111111111- }
1111211112- interface GetAllFramesCallbackDetailsItemType {
1111311113- /**
1111411114- * True if the last navigation in this frame was interrupted by an error, i.e. the onErrorOccurred event fired.
1111511115- * Optional.
1111611116- */
1111711117- errorOccurred?: boolean;
1111811118- /**
1111911119- * The ID of the tab in which the frame is.
1112011120- */
1112111121- tabId: number;
1112211122- /**
1112311123- * The ID of the frame. 0 indicates that this is the main frame; a positive value indicates the ID of a subframe.
1112411124- */
1112511125- frameId: number;
1112611126- /**
1112711127- * ID of frame that wraps the frame. Set to -1 of no parent frame exists.
1112811128- */
1112911129- parentFrameId: number;
1113011130- /**
1113111131- * The URL currently associated with this frame.
1113211132- */
1113311133- url: string;
1113411134- }
1113511135- interface OnBeforeNavigateDetailsType {
1113611136- /**
1113711137- * The ID of the tab in which the navigation is about to occur.
1113811138- */
1113911139- tabId: number;
1114011140- url: string;
1114111141- /**
1114211142- * 0 indicates the navigation happens in the tab content window; a positive value indicates navigation in a subframe.
1114311143- * Frame IDs are unique for a given tab and process.
1114411144- */
1114511145- frameId: number;
1114611146- /**
1114711147- * ID of frame that wraps the frame. Set to -1 of no parent frame exists.
1114811148- */
1114911149- parentFrameId: number;
1115011150- /**
1115111151- * The time when the browser was about to start the navigation, in milliseconds since the epoch.
1115211152- */
1115311153- timeStamp: number;
1115411154- }
1115511155- interface OnCommittedDetailsType {
1115611156- /**
1115711157- * The ID of the tab in which the navigation occurs.
1115811158- */
1115911159- tabId: number;
1116011160- url: string;
1116111161- /**
1116211162- * 0 indicates the navigation happens in the tab content window; a positive value indicates navigation in a subframe.
1116311163- * Frame IDs are unique within a tab.
1116411164- */
1116511165- frameId: number;
1116611166- /**
1116711167- * Cause of the navigation.
1116811168- */
1116911169- transitionType: TransitionType;
1117011170- /**
1117111171- * A list of transition qualifiers.
1117211172- */
1117311173- transitionQualifiers: TransitionQualifier[];
1117411174- /**
1117511175- * The time when the navigation was committed, in milliseconds since the epoch.
1117611176- */
1117711177- timeStamp: number;
1117811178- }
1117911179- interface OnDOMContentLoadedDetailsType {
1118011180- /**
1118111181- * The ID of the tab in which the navigation occurs.
1118211182- */
1118311183- tabId: number;
1118411184- url: string;
1118511185- /**
1118611186- * 0 indicates the navigation happens in the tab content window; a positive value indicates navigation in a subframe.
1118711187- * Frame IDs are unique within a tab.
1118811188- */
1118911189- frameId: number;
1119011190- /**
1119111191- * The time when the page's DOM was fully constructed, in milliseconds since the epoch.
1119211192- */
1119311193- timeStamp: number;
1119411194- }
1119511195- interface OnCompletedDetailsType {
1119611196- /**
1119711197- * The ID of the tab in which the navigation occurs.
1119811198- */
1119911199- tabId: number;
1120011200- url: string;
1120111201- /**
1120211202- * 0 indicates the navigation happens in the tab content window; a positive value indicates navigation in a subframe.
1120311203- * Frame IDs are unique within a tab.
1120411204- */
1120511205- frameId: number;
1120611206- /**
1120711207- * The time when the document finished loading, in milliseconds since the epoch.
1120811208- */
1120911209- timeStamp: number;
1121011210- }
1121111211- interface OnErrorOccurredDetailsType {
1121211212- /**
1121311213- * The ID of the tab in which the navigation occurs.
1121411214- */
1121511215- tabId: number;
1121611216- url: string;
1121711217- /**
1121811218- * 0 indicates the navigation happens in the tab content window; a positive value indicates navigation in a subframe.
1121911219- * Frame IDs are unique within a tab.
1122011220- */
1122111221- frameId: number;
1122211222- /**
1122311223- * The time when the error occurred, in milliseconds since the epoch.
1122411224- */
1122511225- timeStamp: number;
1122611226- }
1122711227- interface OnCreatedNavigationTargetDetailsType {
1122811228- /**
1122911229- * The ID of the tab in which the navigation is triggered.
1123011230- */
1123111231- sourceTabId: number;
1123211232- /**
1123311233- * The ID of the process runs the renderer for the source tab.
1123411234- */
1123511235- sourceProcessId: number;
1123611236- /**
1123711237- * The ID of the frame with sourceTabId in which the navigation is triggered. 0 indicates the main frame.
1123811238- */
1123911239- sourceFrameId: number;
1124011240- /**
1124111241- * The URL to be opened in the new window.
1124211242- */
1124311243- url: string;
1124411244- /**
1124511245- * The ID of the tab in which the url is opened
1124611246- */
1124711247- tabId: number;
1124811248- /**
1124911249- * The time when the browser was about to create a new view, in milliseconds since the epoch.
1125011250- */
1125111251- timeStamp: number;
1125211252- }
1125311253- interface OnReferenceFragmentUpdatedDetailsType {
1125411254- /**
1125511255- * The ID of the tab in which the navigation occurs.
1125611256- */
1125711257- tabId: number;
1125811258- url: string;
1125911259- /**
1126011260- * 0 indicates the navigation happens in the tab content window; a positive value indicates navigation in a subframe.
1126111261- * Frame IDs are unique within a tab.
1126211262- */
1126311263- frameId: number;
1126411264- /**
1126511265- * Cause of the navigation.
1126611266- */
1126711267- transitionType: TransitionType;
1126811268- /**
1126911269- * A list of transition qualifiers.
1127011270- */
1127111271- transitionQualifiers: TransitionQualifier[];
1127211272- /**
1127311273- * The time when the navigation was committed, in milliseconds since the epoch.
1127411274- */
1127511275- timeStamp: number;
1127611276- }
1127711277- interface OnTabReplacedDetailsType {
1127811278- /**
1127911279- * The ID of the tab that was replaced.
1128011280- */
1128111281- replacedTabId: number;
1128211282- /**
1128311283- * The ID of the tab that replaced the old tab.
1128411284- */
1128511285- tabId: number;
1128611286- /**
1128711287- * The time when the replacement happened, in milliseconds since the epoch.
1128811288- */
1128911289- timeStamp: number;
1129011290- }
1129111291- interface OnHistoryStateUpdatedDetailsType {
1129211292- /**
1129311293- * The ID of the tab in which the navigation occurs.
1129411294- */
1129511295- tabId: number;
1129611296- url: string;
1129711297- /**
1129811298- * 0 indicates the navigation happens in the tab content window; a positive value indicates navigation in a subframe.
1129911299- * Frame IDs are unique within a tab.
1130011300- */
1130111301- frameId: number;
1130211302- /**
1130311303- * Cause of the navigation.
1130411304- */
1130511305- transitionType: TransitionType;
1130611306- /**
1130711307- * A list of transition qualifiers.
1130811308- */
1130911309- transitionQualifiers: TransitionQualifier[];
1131011310- /**
1131111311- * The time when the navigation was committed, in milliseconds since the epoch.
1131211312- */
1131311313- timeStamp: number;
1131411314- }
1131511315- /**
1131611316- * Fired when a navigation is about to occur.
1131711317- */
1131811318- interface OnBeforeNavigateEvent extends Events.Event<(details: OnBeforeNavigateDetailsType) => void> {
1131911319- /**
1132011320- * Registers an event listener <em>callback</em> to an event.
1132111321- *
1132211322- * @param callback Called when an event occurs. The parameters of this function depend on the type of event.
1132311323- * @param filters Optional. Conditions that the URL being navigated to must satisfy. The 'schemes' and 'ports' fields of
1132411324- * UrlFilter are ignored for this event.
1132511325- */
1132611326- addListener(callback: (details: OnBeforeNavigateDetailsType) => void, filters?: EventUrlFilters): void;
1132711327- }
1132811328- /**
1132911329- * Fired when a navigation is committed. The document (and the resources it refers to, such as images and subframes)
1133011330- * might still be downloading, but at least part of the document has been received from the server and the browser has
1133111331- * decided to switch to the new document.
1133211332- */
1133311333- interface OnCommittedEvent extends Events.Event<(details: OnCommittedDetailsType) => void> {
1133411334- /**
1133511335- * Registers an event listener <em>callback</em> to an event.
1133611336- *
1133711337- * @param callback Called when an event occurs. The parameters of this function depend on the type of event.
1133811338- * @param filters Optional. Conditions that the URL being navigated to must satisfy. The 'schemes' and 'ports' fields of
1133911339- * UrlFilter are ignored for this event.
1134011340- */
1134111341- addListener(callback: (details: OnCommittedDetailsType) => void, filters?: EventUrlFilters): void;
1134211342- }
1134311343- /**
1134411344- * Fired when the page's DOM is fully constructed, but the referenced resources may not finish loading.
1134511345- */
1134611346- interface OnDOMContentLoadedEvent extends Events.Event<(details: OnDOMContentLoadedDetailsType) => void> {
1134711347- /**
1134811348- * Registers an event listener <em>callback</em> to an event.
1134911349- *
1135011350- * @param callback Called when an event occurs. The parameters of this function depend on the type of event.
1135111351- * @param filters Optional. Conditions that the URL being navigated to must satisfy. The 'schemes' and 'ports' fields of
1135211352- * UrlFilter are ignored for this event.
1135311353- */
1135411354- addListener(callback: (details: OnDOMContentLoadedDetailsType) => void, filters?: EventUrlFilters): void;
1135511355- }
1135611356- /**
1135711357- * Fired when a document, including the resources it refers to, is completely loaded and initialized.
1135811358- */
1135911359- interface OnCompletedEvent extends Events.Event<(details: OnCompletedDetailsType) => void> {
1136011360- /**
1136111361- * Registers an event listener <em>callback</em> to an event.
1136211362- *
1136311363- * @param callback Called when an event occurs. The parameters of this function depend on the type of event.
1136411364- * @param filters Optional. Conditions that the URL being navigated to must satisfy. The 'schemes' and 'ports' fields of
1136511365- * UrlFilter are ignored for this event.
1136611366- */
1136711367- addListener(callback: (details: OnCompletedDetailsType) => void, filters?: EventUrlFilters): void;
1136811368- }
1136911369- /**
1137011370- * Fired when an error occurs and the navigation is aborted. This can happen if either a network error occurred,
1137111371- * or the user aborted the navigation.
1137211372- */
1137311373- interface OnErrorOccurredEvent extends Events.Event<(details: OnErrorOccurredDetailsType) => void> {
1137411374- /**
1137511375- * Registers an event listener <em>callback</em> to an event.
1137611376- *
1137711377- * @param callback Called when an event occurs. The parameters of this function depend on the type of event.
1137811378- * @param filters Optional. Conditions that the URL being navigated to must satisfy. The 'schemes' and 'ports' fields of
1137911379- * UrlFilter are ignored for this event.
1138011380- */
1138111381- addListener(callback: (details: OnErrorOccurredDetailsType) => void, filters?: EventUrlFilters): void;
1138211382- }
1138311383- /**
1138411384- * Fired when a new window, or a new tab in an existing window, is created to host a navigation.
1138511385- */
1138611386- interface OnCreatedNavigationTargetEvent extends Events.Event<(details: OnCreatedNavigationTargetDetailsType) => void> {
1138711387- /**
1138811388- * Registers an event listener <em>callback</em> to an event.
1138911389- *
1139011390- * @param callback Called when an event occurs. The parameters of this function depend on the type of event.
1139111391- * @param filters Optional. Conditions that the URL being navigated to must satisfy. The 'schemes' and 'ports' fields of
1139211392- * UrlFilter are ignored for this event.
1139311393- */
1139411394- addListener(callback: (details: OnCreatedNavigationTargetDetailsType) => void, filters?: EventUrlFilters): void;
1139511395- }
1139611396- /**
1139711397- * Fired when the reference fragment of a frame was updated. All future events for that frame will use the updated URL.
1139811398- */
1139911399- interface OnReferenceFragmentUpdatedEvent extends Events.Event<(details: OnReferenceFragmentUpdatedDetailsType) => void> {
1140011400- /**
1140111401- * Registers an event listener <em>callback</em> to an event.
1140211402- *
1140311403- * @param callback Called when an event occurs. The parameters of this function depend on the type of event.
1140411404- * @param filters Optional. Conditions that the URL being navigated to must satisfy. The 'schemes' and 'ports' fields of
1140511405- * UrlFilter are ignored for this event.
1140611406- */
1140711407- addListener(callback: (details: OnReferenceFragmentUpdatedDetailsType) => void, filters?: EventUrlFilters): void;
1140811408- }
1140911409- /**
1141011410- * Fired when the frame's history was updated to a new URL. All future events for that frame will use the updated URL.
1141111411- */
1141211412- interface OnHistoryStateUpdatedEvent extends Events.Event<(details: OnHistoryStateUpdatedDetailsType) => void> {
1141311413- /**
1141411414- * Registers an event listener <em>callback</em> to an event.
1141511415- *
1141611416- * @param callback Called when an event occurs. The parameters of this function depend on the type of event.
1141711417- * @param filters Optional. Conditions that the URL being navigated to must satisfy. The 'schemes' and 'ports' fields of
1141811418- * UrlFilter are ignored for this event.
1141911419- */
1142011420- addListener(callback: (details: OnHistoryStateUpdatedDetailsType) => void, filters?: EventUrlFilters): void;
1142111421- }
1142211422- interface Static {
1142311423- /**
1142411424- * Retrieves information about the given frame. A frame refers to an <iframe> or a <frame> of a web page and is
1142511425- * identified by a tab ID and a frame ID.
1142611426- *
1142711427- * @param details Information about the frame to retrieve information about.
1142811428- */
1142911429- getFrame(details: GetFrameDetailsType): Promise<GetFrameCallbackDetailsType | null>;
1143011430- /**
1143111431- * Retrieves information about all frames of a given tab.
1143211432- *
1143311433- * @param details Information about the tab to retrieve all frames from.
1143411434- */
1143511435- getAllFrames(details: GetAllFramesDetailsType): Promise<GetAllFramesCallbackDetailsItemType[] | null>;
1143611436- /**
1143711437- * Fired when a navigation is about to occur.
1143811438- */
1143911439- onBeforeNavigate: OnBeforeNavigateEvent;
1144011440- /**
1144111441- * Fired when a navigation is committed. The document (and the resources it refers to, such as images and subframes)
1144211442- * might still be downloading, but at least part of the document has been received from the server and the browser has
1144311443- * decided to switch to the new document.
1144411444- */
1144511445- onCommitted: OnCommittedEvent;
1144611446- /**
1144711447- * Fired when the page's DOM is fully constructed, but the referenced resources may not finish loading.
1144811448- */
1144911449- onDOMContentLoaded: OnDOMContentLoadedEvent;
1145011450- /**
1145111451- * Fired when a document, including the resources it refers to, is completely loaded and initialized.
1145211452- */
1145311453- onCompleted: OnCompletedEvent;
1145411454- /**
1145511455- * Fired when an error occurs and the navigation is aborted. This can happen if either a network error occurred,
1145611456- * or the user aborted the navigation.
1145711457- */
1145811458- onErrorOccurred: OnErrorOccurredEvent;
1145911459- /**
1146011460- * Fired when a new window, or a new tab in an existing window, is created to host a navigation.
1146111461- */
1146211462- onCreatedNavigationTarget: OnCreatedNavigationTargetEvent;
1146311463- /**
1146411464- * Fired when the reference fragment of a frame was updated. All future events for that frame will use the updated URL.
1146511465- */
1146611466- onReferenceFragmentUpdated: OnReferenceFragmentUpdatedEvent;
1146711467- /**
1146811468- * Fired when the contents of the tab is replaced by a different (usually previously pre-rendered) tab.
1146911469- */
1147011470- onTabReplaced: Events.Event<(details: OnTabReplacedDetailsType) => void>;
1147111471- /**
1147211472- * Fired when the frame's history was updated to a new URL. All future events for that frame will use the updated URL.
1147311473- */
1147411474- onHistoryStateUpdated: OnHistoryStateUpdatedEvent;
1147511475- }
1147611476- }
1147711477- /**
1147811478- * Namespace: browser.webRequest
1147911479- */
1148011480- namespace WebRequest {
1148111481- type ResourceType = "main_frame" | "sub_frame" | "stylesheet" | "script" | "image" | "object" | "xmlhttprequest" | "xslt" | "ping" | "beacon" | "xml_dtd" | "font" | "media" | "websocket" | "csp_report" | "imageset" | "web_manifest" | "speculative" | "json" | "other";
1148211482- type OnBeforeRequestOptions = "blocking" | "requestBody" | "extraHeaders";
1148311483- type OnBeforeSendHeadersOptions = "requestHeaders" | "blocking" | "extraHeaders";
1148411484- type OnSendHeadersOptions = "requestHeaders" | "extraHeaders";
1148511485- type OnHeadersReceivedOptions = "blocking" | "responseHeaders" | "extraHeaders";
1148611486- type OnAuthRequiredOptions = "responseHeaders" | "blocking" | "asyncBlocking" | "extraHeaders";
1148711487- type OnResponseStartedOptions = "responseHeaders" | "extraHeaders";
1148811488- type OnBeforeRedirectOptions = "responseHeaders" | "extraHeaders";
1148911489- type OnCompletedOptions = "responseHeaders" | "extraHeaders";
1149011490- /**
1149111491- * An object describing filters to apply to webRequest events.
1149211492- */
1149311493- interface RequestFilter {
1149411494- /**
1149511495- * A list of URLs or URL patterns. Requests that cannot match any of the URLs will be filtered out.
1149611496- */
1149711497- urls: string[];
1149811498- /**
1149911499- * A list of request types. Requests that cannot match any of the types will be filtered out.
1150011500- * Optional.
1150111501- */
1150211502- types?: ResourceType[];
1150311503- /**
1150411504- * Optional.
1150511505- */
1150611506- tabId?: number;
1150711507- /**
1150811508- * Optional.
1150911509- */
1151011510- windowId?: number;
1151111511- /**
1151211512- * If provided, requests that do not match the incognito state will be filtered out.
1151311513- * Optional.
1151411514- */
1151511515- incognito?: boolean;
1151611516- }
1151711517- /**
1151811518- * An array of HTTP headers. Each header is represented as a dictionary containing the keys <code>name</code>
1151911519- * and either <code>value</code> or <code>binaryValue</code>.
1152011520- */
1152111521- type HttpHeaders = HttpHeadersItemType[];
1152211522- /**
1152311523- * Returns value for event handlers that have the 'blocking' extraInfoSpec applied. Allows the event handler to modify
1152411524- * network requests.
1152511525- */
1152611526- interface BlockingResponse {
1152711527- /**
1152811528- * If true, the request is cancelled. Used in onBeforeRequest, this prevents the request from being sent.
1152911529- * Optional.
1153011530- */
1153111531- cancel?: boolean;
1153211532- /**
1153311533- * Only used as a response to the onBeforeRequest and onHeadersReceived events. If set,
1153411534- * the original request is prevented from being sent/completed and is instead redirected to the given URL.
1153511535- * Redirections to non-HTTP schemes such as data: are allowed. Redirects initiated by a redirect action use the original
1153611536- * request method for the redirect, with one exception: If the redirect is initiated at the onHeadersReceived stage,
1153711537- * then the redirect will be issued using the GET method.
1153811538- * Optional.
1153911539- */
1154011540- redirectUrl?: string;
1154111541- /**
1154211542- * Only used as a response to the onBeforeRequest event. If set, the original request is prevented from being
1154311543- * sent/completed and is instead upgraded to a secure request. If any extension returns <code>redirectUrl</code>
1154411544- * during onBeforeRequest, <code>upgradeToSecure</code> will have no affect.
1154511545- * Optional.
1154611546- */
1154711547- upgradeToSecure?: boolean;
1154811548- /**
1154911549- * Only used as a response to the onBeforeSendHeaders event. If set, the request is made with these request headers instead.
1155011550- * Optional.
1155111551- */
1155211552- requestHeaders?: HttpHeaders;
1155311553- /**
1155411554- * Only used as a response to the onHeadersReceived event. If set, the server is assumed to have responded with these
1155511555- * response headers instead. Only return <code>responseHeaders</code> if you really want to modify the headers in order to
1155611556- * limit the number of conflicts (only one extension may modify <code>responseHeaders</code> for each request).
1155711557- * Optional.
1155811558- */
1155911559- responseHeaders?: HttpHeaders;
1156011560- /**
1156111561- * Only used as a response to the onAuthRequired event. If set, the request is made using the supplied credentials.
1156211562- * Optional.
1156311563- */
1156411564- authCredentials?: BlockingResponseAuthCredentialsType;
1156511565- }
1156611566- /**
1156711567- * Contains the certificate properties of the request if it is a secure request.
1156811568- */
1156911569- interface CertificateInfo {
1157011570- subject: string;
1157111571- issuer: string;
1157211572- /**
1157311573- * Contains start and end timestamps.
1157411574- */
1157511575- validity: CertificateInfoValidityType;
1157611576- fingerprint: CertificateInfoFingerprintType;
1157711577- serialNumber: string;
1157811578- isBuiltInRoot: boolean;
1157911579- subjectPublicKeyInfoDigest: CertificateInfoSubjectPublicKeyInfoDigestType;
1158011580- /**
1158111581- * Optional.
1158211582- */
1158311583- rawDER?: number[];
1158411584- }
1158511585- type CertificateTransparencyStatus = "not_applicable" | "policy_compliant" | "policy_not_enough_scts" | "policy_not_diverse_scts";
1158611586- type TransportWeaknessReasons = "cipher";
1158711587- /**
1158811588- * Contains the security properties of the request (ie. SSL/TLS information).
1158911589- */
1159011590- interface SecurityInfo {
1159111591- state: SecurityInfoStateEnum;
1159211592- /**
1159311593- * Error message if state is "broken"
1159411594- * Optional.
1159511595- */
1159611596- errorMessage?: string;
1159711597- /**
1159811598- * Protocol version if state is "secure"
1159911599- * Optional.
1160011600- */
1160111601- protocolVersion?: SecurityInfoProtocolVersionEnum;
1160211602- /**
1160311603- * The cipher suite used in this request if state is "secure".
1160411604- * Optional.
1160511605- */
1160611606- cipherSuite?: string;
1160711607- /**
1160811608- * The key exchange algorithm used in this request if state is "secure".
1160911609- * Optional.
1161011610- */
1161111611- keaGroupName?: string;
1161211612- /**
1161311613- * The length (in bits) of the secret key.
1161411614- * Optional.
1161511615- */
1161611616- secretKeyLength?: number;
1161711617- /**
1161811618- * The signature scheme used in this request if state is "secure".
1161911619- * Optional.
1162011620- */
1162111621- signatureSchemeName?: string;
1162211622- /**
1162311623- * Certificate data if state is "secure". Will only contain one entry unless <code>certificateChain</code>
1162411624- * is passed as an option.
1162511625- */
1162611626- certificates: CertificateInfo[];
1162711627- /**
1162811628- * The type of certificate error that was overridden for this connection, if any.
1162911629- * Optional.
1163011630- */
1163111631- overridableErrorCategory?: SecurityInfoOverridableErrorCategoryEnum;
1163211632- /**
1163311633- * Optional.
1163411634- */
1163511635- isExtendedValidation?: boolean;
1163611636- /**
1163711637- * Certificate transparency compliance per RFC 6962. See <code>https://www.certificate-transparency.org/what-is-ct</code>
1163811638- * for more information.
1163911639- * Optional.
1164011640- */
1164111641- certificateTransparencyStatus?: CertificateTransparencyStatus;
1164211642- /**
1164311643- * True if host uses Strict Transport Security and state is "secure".
1164411644- * Optional.
1164511645- */
1164611646- hsts?: boolean;
1164711647- /**
1164811648- * True if host uses Public Key Pinning and state is "secure".
1164911649- * Optional.
1165011650- */
1165111651- hpkp?: string;
1165211652- /**
1165311653- * list of reasons that cause the request to be considered weak, if state is "weak"
1165411654- * Optional.
1165511655- */
1165611656- weaknessReasons?: TransportWeaknessReasons[];
1165711657- /**
1165811658- * True if the TLS connection used Encrypted Client Hello.
1165911659- * Optional.
1166011660- */
1166111661- usedEch?: boolean;
1166211662- /**
1166311663- * True if the TLS connection used Delegated Credentials.
1166411664- * Optional.
1166511665- */
1166611666- usedDelegatedCredentials?: boolean;
1166711667- /**
1166811668- * True if the TLS connection made OCSP requests.
1166911669- * Optional.
1167011670- */
1167111671- usedOcsp?: boolean;
1167211672- /**
1167311673- * True if the TLS connection used a privacy-preserving DNS transport like DNS-over-HTTPS.
1167411674- * Optional.
1167511675- */
1167611676- usedPrivateDns?: boolean;
1167711677- }
1167811678- /**
1167911679- * Contains data uploaded in a URL request.
1168011680- */
1168111681- interface UploadData {
1168211682- /**
1168311683- * An ArrayBuffer with a copy of the data.
1168411684- * Optional.
1168511685- */
1168611686- bytes?: unknown;
1168711687- /**
1168811688- * A string with the file's path and name.
1168911689- * Optional.
1169011690- */
1169111691- file?: string;
1169211692- }
1169311693- /**
1169411694- * Tracking flags that match our internal tracking classification
1169511695- */
1169611696- type UrlClassificationFlags = "fingerprinting" | "fingerprinting_content" | "cryptomining" | "cryptomining_content" | "emailtracking" | "emailtracking_content" | "consentmanager" | "tracking" | "tracking_ad" | "tracking_analytics" | "tracking_social" | "tracking_content" | "any_basic_tracking" | "any_strict_tracking" | "any_social_tracking";
1169711697- /**
1169811698- * If the request has been classified this is an array of $(ref:UrlClassificationFlags).
1169911699- */
1170011700- type UrlClassificationParty = UrlClassificationFlags[];
1170111701- interface UrlClassification {
1170211702- /**
1170311703- * Classification flags if the request has been classified and it is first party.
1170411704- */
1170511705- firstParty: UrlClassificationParty;
1170611706- /**
1170711707- * Classification flags if the request has been classified and it or its window hierarchy is third party.
1170811708- */
1170911709- thirdParty: UrlClassificationParty;
1171011710- }
1171111711- type OnErrorOccurredOptions = "extraHeaders";
1171211712- /**
1171311713- * A BlockingResponse or a Promise<BlockingResponse>
1171411714- */
1171511715- // eslint-disable-next-line @typescript-eslint/no-invalid-void-type
1171611716- type BlockingResponseOrPromiseOrVoid = BlockingResponse | Promise<BlockingResponse> | void;
1171711717- /**
1171811718- * "uninitialized": The StreamFilter is not fully initialized. No methods may be called until a "start" event has been
1171911719- * received.
1172011720- * "transferringdata": The underlying channel is currently transferring data, which will be dispatched via "data" events.
1172111721- * "finishedtransferringdata": The underlying channel has finished transferring data. Data may still be written via write()
1172211722- * calls at this point.
1172311723- * "suspended": Data transfer is currently suspended. It may be resumed by a call to resume().
1172411724- * Data may still be written via write() calls in this state.
1172511725- * "closed": The channel has been closed by a call to close(). No further data wlil be delivered via "data" events,
1172611726- * and no further data may be written via write() calls.
1172711727- * "disconnected": The channel has been disconnected by a call to disconnect(). All further data will be delivered directly,
1172811728- * without passing through the filter. No further events will be dispatched, and no further data may be written by write()
1172911729- * calls.
1173011730- * "failed": An error has occurred and the channel is disconnected. The `error`, property contains the details of the error.
1173111731- */
1173211732- type StreamFilterStatus = "uninitialized" | "transferringdata" | "finishedtransferringdata" | "suspended" | "closed" | "disconnected" | "failed";
1173311733- /**
1173411734- * An interface which allows an extension to intercept, and optionally modify, response data from an HTTP request.
1173511735- */
1173611736- interface StreamFilter {
1173711737- /**
1173811738- * Returns the current status of the stream.
1173911739- */
1174011740- status: StreamFilterStatus;
1174111741- /**
1174211742- * After an "error" event has been dispatched, this contains a message describing the error.
1174311743- */
1174411744- error: string;
1174511745- /**
1174611746- * Creates a stream filter for the given add-on and the given extension ID.
1174711747- */
1174811748- create(requestId: number, addonId: string): void;
1174911749- /**
1175011750- * Suspends processing of the request. After this is called, no further data will be delivered until the request is resumed.
1175111751- */
1175211752- suspend(): void;
1175311753- /**
1175411754- * Resumes delivery of data for a suspended request.
1175511755- */
1175611756- resume(): void;
1175711757- /**
1175811758- * Closes the request. After this is called, no more data may be written to the stream,
1175911759- * and no further data will be delivered. This *must* be called after the consumer is finished writing data,
1176011760- * unless disconnect() has already been called.
1176111761- */
1176211762- close(): void;
1176311763- /**
1176411764- * Disconnects the stream filter from the request. After this is called, no further data will be delivered to the filter,
1176511765- * and any unprocessed data will be written directly to the output stream.
1176611766- */
1176711767- disconnect(): void;
1176811768- /**
1176911769- * Writes a chunk of data to the output stream. This may not be called before the "start" event has been received.
1177011770- */
1177111771- write(data: ArrayBuffer | Uint8Array): void;
1177211772- /**
1177311773- * Dispatched with a StreamFilterDataEvent whenever incoming data is available on the stream.
1177411774- * This data will not be delivered to the output stream unless it is explicitly written via a write() call.
1177511775- */
1177611776- ondata?: (data: StreamFilterEventData) => void;
1177711777- /**
1177811778- * Dispatched when the stream is opened, and is about to begin delivering data.
1177911779- */
1178011780- onstart?: (data: StreamFilterEventData) => void;
1178111781- /**
1178211782- * Dispatched when the stream has closed, and has no more data to deliver. The output stream remains open and writable
1178311783- * until close() is called.
1178411784- */
1178511785- onstop?: (data: StreamFilterEventData) => void;
1178611786- /**
1178711787- * Dispatched when an error has occurred. No further data may be read or written after this point.
1178811788- */
1178911789- onerror?: (data: StreamFilterEventData) => void;
1179011790- }
1179111791- interface StreamFilterEventData {
1179211792- /**
1179311793- * Contains a chunk of data read from the input stream.
1179411794- */
1179511795- data: ArrayBuffer;
1179611796- }
1179711797- interface GetSecurityInfoOptionsType {
1179811798- /**
1179911799- * Include the entire certificate chain.
1180011800- * Optional.
1180111801- */
1180211802- certificateChain?: boolean;
1180311803- /**
1180411804- * Include raw certificate data for processing by the extension.
1180511805- * Optional.
1180611806- */
1180711807- rawDER?: boolean;
1180811808- }
1180911809- interface OnBeforeRequestDetailsType {
1181011810- /**
1181111811- * The ID of the request. Request IDs are unique within a browser session. As a result,
1181211812- * they could be used to relate different events of the same request.
1181311813- */
1181411814- requestId: string;
1181511815- url: string;
1181611816- /**
1181711817- * Standard HTTP method.
1181811818- */
1181911819- method: string;
1182011820- /**
1182111821- * The value 0 indicates that the request happens in the main frame; a positive value indicates the ID of a subframe in
1182211822- * which the request happens. If the document of a (sub-)frame is loaded (<code>type</code> is <code>main_frame</code>
1182311823- * or <code>sub_frame</code>), <code>frameId</code> indicates the ID of this frame, not the ID of the outer frame.
1182411824- * Frame IDs are unique within a tab.
1182511825- */
1182611826- frameId: number;
1182711827- /**
1182811828- * ID of frame that wraps the frame which sent the request. Set to -1 if no parent frame exists.
1182911829- */
1183011830- parentFrameId: number;
1183111831- /**
1183211832- * True for private browsing requests.
1183311833- * Optional.
1183411834- */
1183511835- incognito?: boolean;
1183611836- /**
1183711837- * The cookie store ID of the contextual identity.
1183811838- * Optional.
1183911839- */
1184011840- cookieStoreId?: string;
1184111841- /**
1184211842- * URL of the resource that triggered this request.
1184311843- * Optional.
1184411844- */
1184511845- originUrl?: string;
1184611846- /**
1184711847- * URL of the page into which the requested resource will be loaded.
1184811848- * Optional.
1184911849- */
1185011850- documentUrl?: string;
1185111851- /**
1185211852- * Contains the HTTP request body data. Only provided if extraInfoSpec contains 'requestBody'.
1185311853- * Optional.
1185411854- */
1185511855- requestBody?: OnBeforeRequestDetailsTypeRequestBodyType;
1185611856- /**
1185711857- * The ID of the tab in which the request takes place. Set to -1 if the request isn't related to a tab.
1185811858- */
1185911859- tabId: number;
1186011860- /**
1186111861- * How the requested resource will be used.
1186211862- */
1186311863- type: ResourceType;
1186411864- /**
1186511865- * The time when this signal is triggered, in milliseconds since the epoch.
1186611866- */
1186711867- timeStamp: number;
1186811868- /**
1186911869- * Tracking classification if the request has been classified.
1187011870- * Optional.
1187111871- */
1187211872- urlClassification?: UrlClassification;
1187311873- /**
1187411874- * Indicates if this request and its content window hierarchy is third party.
1187511875- */
1187611876- thirdParty: boolean;
1187711877- /**
1187811878- * URL of the resource that triggered this request (on chrome).
1187911879- * Optional.
1188011880- */
1188111881- initiator?: string;
1188211882- }
1188311883- interface OnBeforeSendHeadersDetailsType {
1188411884- /**
1188511885- * The ID of the request. Request IDs are unique within a browser session. As a result,
1188611886- * they could be used to relate different events of the same request.
1188711887- */
1188811888- requestId: string;
1188911889- url: string;
1189011890- /**
1189111891- * Standard HTTP method.
1189211892- */
1189311893- method: string;
1189411894- /**
1189511895- * The value 0 indicates that the request happens in the main frame; a positive value indicates the ID of a subframe in
1189611896- * which the request happens. If the document of a (sub-)frame is loaded (<code>type</code> is <code>main_frame</code>
1189711897- * or <code>sub_frame</code>), <code>frameId</code> indicates the ID of this frame, not the ID of the outer frame.
1189811898- * Frame IDs are unique within a tab.
1189911899- */
1190011900- frameId: number;
1190111901- /**
1190211902- * ID of frame that wraps the frame which sent the request. Set to -1 if no parent frame exists.
1190311903- */
1190411904- parentFrameId: number;
1190511905- /**
1190611906- * True for private browsing requests.
1190711907- * Optional.
1190811908- */
1190911909- incognito?: boolean;
1191011910- /**
1191111911- * The cookie store ID of the contextual identity.
1191211912- * Optional.
1191311913- */
1191411914- cookieStoreId?: string;
1191511915- /**
1191611916- * URL of the resource that triggered this request.
1191711917- * Optional.
1191811918- */
1191911919- originUrl?: string;
1192011920- /**
1192111921- * URL of the page into which the requested resource will be loaded.
1192211922- * Optional.
1192311923- */
1192411924- documentUrl?: string;
1192511925- /**
1192611926- * The ID of the tab in which the request takes place. Set to -1 if the request isn't related to a tab.
1192711927- */
1192811928- tabId: number;
1192911929- /**
1193011930- * How the requested resource will be used.
1193111931- */
1193211932- type: ResourceType;
1193311933- /**
1193411934- * The time when this signal is triggered, in milliseconds since the epoch.
1193511935- */
1193611936- timeStamp: number;
1193711937- /**
1193811938- * The HTTP request headers that are going to be sent out with this request.
1193911939- * Optional.
1194011940- */
1194111941- requestHeaders?: HttpHeaders;
1194211942- /**
1194311943- * Tracking classification if the request has been classified.
1194411944- * Optional.
1194511945- */
1194611946- urlClassification?: UrlClassification;
1194711947- /**
1194811948- * Indicates if this request and its content window hierarchy is third party.
1194911949- */
1195011950- thirdParty: boolean;
1195111951- /**
1195211952- * URL of the resource that triggered this request (on chrome).
1195311953- * Optional.
1195411954- */
1195511955- initiator?: string;
1195611956- }
1195711957- interface OnSendHeadersDetailsType {
1195811958- /**
1195911959- * The ID of the request. Request IDs are unique within a browser session. As a result,
1196011960- * they could be used to relate different events of the same request.
1196111961- */
1196211962- requestId: string;
1196311963- url: string;
1196411964- /**
1196511965- * Standard HTTP method.
1196611966- */
1196711967- method: string;
1196811968- /**
1196911969- * The value 0 indicates that the request happens in the main frame; a positive value indicates the ID of a subframe in
1197011970- * which the request happens. If the document of a (sub-)frame is loaded (<code>type</code> is <code>main_frame</code>
1197111971- * or <code>sub_frame</code>), <code>frameId</code> indicates the ID of this frame, not the ID of the outer frame.
1197211972- * Frame IDs are unique within a tab.
1197311973- */
1197411974- frameId: number;
1197511975- /**
1197611976- * ID of frame that wraps the frame which sent the request. Set to -1 if no parent frame exists.
1197711977- */
1197811978- parentFrameId: number;
1197911979- /**
1198011980- * True for private browsing requests.
1198111981- * Optional.
1198211982- */
1198311983- incognito?: boolean;
1198411984- /**
1198511985- * The cookie store ID of the contextual identity.
1198611986- * Optional.
1198711987- */
1198811988- cookieStoreId?: string;
1198911989- /**
1199011990- * URL of the resource that triggered this request.
1199111991- * Optional.
1199211992- */
1199311993- originUrl?: string;
1199411994- /**
1199511995- * URL of the page into which the requested resource will be loaded.
1199611996- * Optional.
1199711997- */
1199811998- documentUrl?: string;
1199911999- /**
1200012000- * The ID of the tab in which the request takes place. Set to -1 if the request isn't related to a tab.
1200112001- */
1200212002- tabId: number;
1200312003- /**
1200412004- * How the requested resource will be used.
1200512005- */
1200612006- type: ResourceType;
1200712007- /**
1200812008- * The time when this signal is triggered, in milliseconds since the epoch.
1200912009- */
1201012010- timeStamp: number;
1201112011- /**
1201212012- * The HTTP request headers that have been sent out with this request.
1201312013- * Optional.
1201412014- */
1201512015- requestHeaders?: HttpHeaders;
1201612016- /**
1201712017- * Tracking classification if the request has been classified.
1201812018- * Optional.
1201912019- */
1202012020- urlClassification?: UrlClassification;
1202112021- /**
1202212022- * Indicates if this request and its content window hierarchy is third party.
1202312023- */
1202412024- thirdParty: boolean;
1202512025- /**
1202612026- * URL of the resource that triggered this request (on chrome).
1202712027- * Optional.
1202812028- */
1202912029- initiator?: string;
1203012030- }
1203112031- interface OnHeadersReceivedDetailsType {
1203212032- /**
1203312033- * The ID of the request. Request IDs are unique within a browser session. As a result,
1203412034- * they could be used to relate different events of the same request.
1203512035- */
1203612036- requestId: string;
1203712037- url: string;
1203812038- /**
1203912039- * Standard HTTP method.
1204012040- */
1204112041- method: string;
1204212042- /**
1204312043- * The value 0 indicates that the request happens in the main frame; a positive value indicates the ID of a subframe in
1204412044- * which the request happens. If the document of a (sub-)frame is loaded (<code>type</code> is <code>main_frame</code>
1204512045- * or <code>sub_frame</code>), <code>frameId</code> indicates the ID of this frame, not the ID of the outer frame.
1204612046- * Frame IDs are unique within a tab.
1204712047- */
1204812048- frameId: number;
1204912049- /**
1205012050- * ID of frame that wraps the frame which sent the request. Set to -1 if no parent frame exists.
1205112051- */
1205212052- parentFrameId: number;
1205312053- /**
1205412054- * True for private browsing requests.
1205512055- * Optional.
1205612056- */
1205712057- incognito?: boolean;
1205812058- /**
1205912059- * The cookie store ID of the contextual identity.
1206012060- * Optional.
1206112061- */
1206212062- cookieStoreId?: string;
1206312063- /**
1206412064- * URL of the resource that triggered this request.
1206512065- * Optional.
1206612066- */
1206712067- originUrl?: string;
1206812068- /**
1206912069- * URL of the page into which the requested resource will be loaded.
1207012070- * Optional.
1207112071- */
1207212072- documentUrl?: string;
1207312073- /**
1207412074- * The ID of the tab in which the request takes place. Set to -1 if the request isn't related to a tab.
1207512075- */
1207612076- tabId: number;
1207712077- /**
1207812078- * How the requested resource will be used.
1207912079- */
1208012080- type: ResourceType;
1208112081- /**
1208212082- * The time when this signal is triggered, in milliseconds since the epoch.
1208312083- */
1208412084- timeStamp: number;
1208512085- /**
1208612086- * HTTP status line of the response or the 'HTTP/0.9 200 OK' string for HTTP/0.9 responses (i.e.,
1208712087- * responses that lack a status line).
1208812088- */
1208912089- statusLine: string;
1209012090- /**
1209112091- * The HTTP response headers that have been received with this response.
1209212092- * Optional.
1209312093- */
1209412094- responseHeaders?: HttpHeaders;
1209512095- /**
1209612096- * Standard HTTP status code returned by the server.
1209712097- */
1209812098- statusCode: number;
1209912099- /**
1210012100- * Tracking classification if the request has been classified.
1210112101- * Optional.
1210212102- */
1210312103- urlClassification?: UrlClassification;
1210412104- /**
1210512105- * Indicates if this request and its content window hierarchy is third party.
1210612106- */
1210712107- thirdParty: boolean;
1210812108- /**
1210912109- * URL of the resource that triggered this request (on chrome).
1211012110- * Optional.
1211112111- */
1211212112- initiator?: string;
1211312113- }
1211412114- interface OnAuthRequiredDetailsType {
1211512115- /**
1211612116- * The ID of the request. Request IDs are unique within a browser session. As a result,
1211712117- * they could be used to relate different events of the same request.
1211812118- */
1211912119- requestId: string;
1212012120- url: string;
1212112121- /**
1212212122- * Standard HTTP method.
1212312123- */
1212412124- method: string;
1212512125- /**
1212612126- * The value 0 indicates that the request happens in the main frame; a positive value indicates the ID of a subframe in
1212712127- * which the request happens. If the document of a (sub-)frame is loaded (<code>type</code> is <code>main_frame</code>
1212812128- * or <code>sub_frame</code>), <code>frameId</code> indicates the ID of this frame, not the ID of the outer frame.
1212912129- * Frame IDs are unique within a tab.
1213012130- */
1213112131- frameId: number;
1213212132- /**
1213312133- * ID of frame that wraps the frame which sent the request. Set to -1 if no parent frame exists.
1213412134- */
1213512135- parentFrameId: number;
1213612136- /**
1213712137- * True for private browsing requests.
1213812138- * Optional.
1213912139- */
1214012140- incognito?: boolean;
1214112141- /**
1214212142- * The cookie store ID of the contextual identity.
1214312143- * Optional.
1214412144- */
1214512145- cookieStoreId?: string;
1214612146- /**
1214712147- * URL of the resource that triggered this request.
1214812148- * Optional.
1214912149- */
1215012150- originUrl?: string;
1215112151- /**
1215212152- * URL of the page into which the requested resource will be loaded.
1215312153- * Optional.
1215412154- */
1215512155- documentUrl?: string;
1215612156- /**
1215712157- * The ID of the tab in which the request takes place. Set to -1 if the request isn't related to a tab.
1215812158- */
1215912159- tabId: number;
1216012160- /**
1216112161- * How the requested resource will be used.
1216212162- */
1216312163- type: ResourceType;
1216412164- /**
1216512165- * The time when this signal is triggered, in milliseconds since the epoch.
1216612166- */
1216712167- timeStamp: number;
1216812168- /**
1216912169- * The authentication scheme, e.g. Basic or Digest.
1217012170- */
1217112171- scheme: string;
1217212172- /**
1217312173- * The authentication realm provided by the server, if there is one.
1217412174- * Optional.
1217512175- */
1217612176- realm?: string;
1217712177- /**
1217812178- * The server requesting authentication.
1217912179- */
1218012180- challenger: OnAuthRequiredDetailsTypeChallengerType;
1218112181- /**
1218212182- * True for Proxy-Authenticate, false for WWW-Authenticate.
1218312183- */
1218412184- isProxy: boolean;
1218512185- /**
1218612186- * The HTTP response headers that were received along with this response.
1218712187- * Optional.
1218812188- */
1218912189- responseHeaders?: HttpHeaders;
1219012190- /**
1219112191- * HTTP status line of the response or the 'HTTP/0.9 200 OK' string for HTTP/0.9 responses (i.e.,
1219212192- * responses that lack a status line) or an empty string if there are no headers.
1219312193- */
1219412194- statusLine: string;
1219512195- /**
1219612196- * Standard HTTP status code returned by the server.
1219712197- */
1219812198- statusCode: number;
1219912199- /**
1220012200- * Tracking classification if the request has been classified.
1220112201- * Optional.
1220212202- */
1220312203- urlClassification?: UrlClassification;
1220412204- /**
1220512205- * Indicates if this request and its content window hierarchy is third party.
1220612206- */
1220712207- thirdParty: boolean;
1220812208- /**
1220912209- * URL of the resource that triggered this request (on chrome).
1221012210- * Optional.
1221112211- */
1221212212- initiator?: string;
1221312213- }
1221412214- interface OnResponseStartedDetailsType {
1221512215- /**
1221612216- * The ID of the request. Request IDs are unique within a browser session. As a result,
1221712217- * they could be used to relate different events of the same request.
1221812218- */
1221912219- requestId: string;
1222012220- url: string;
1222112221- /**
1222212222- * Standard HTTP method.
1222312223- */
1222412224- method: string;
1222512225- /**
1222612226- * The value 0 indicates that the request happens in the main frame; a positive value indicates the ID of a subframe in
1222712227- * which the request happens. If the document of a (sub-)frame is loaded (<code>type</code> is <code>main_frame</code>
1222812228- * or <code>sub_frame</code>), <code>frameId</code> indicates the ID of this frame, not the ID of the outer frame.
1222912229- * Frame IDs are unique within a tab.
1223012230- */
1223112231- frameId: number;
1223212232- /**
1223312233- * ID of frame that wraps the frame which sent the request. Set to -1 if no parent frame exists.
1223412234- */
1223512235- parentFrameId: number;
1223612236- /**
1223712237- * True for private browsing requests.
1223812238- * Optional.
1223912239- */
1224012240- incognito?: boolean;
1224112241- /**
1224212242- * The cookie store ID of the contextual identity.
1224312243- * Optional.
1224412244- */
1224512245- cookieStoreId?: string;
1224612246- /**
1224712247- * URL of the resource that triggered this request.
1224812248- * Optional.
1224912249- */
1225012250- originUrl?: string;
1225112251- /**
1225212252- * URL of the page into which the requested resource will be loaded.
1225312253- * Optional.
1225412254- */
1225512255- documentUrl?: string;
1225612256- /**
1225712257- * The ID of the tab in which the request takes place. Set to -1 if the request isn't related to a tab.
1225812258- */
1225912259- tabId: number;
1226012260- /**
1226112261- * How the requested resource will be used.
1226212262- */
1226312263- type: ResourceType;
1226412264- /**
1226512265- * The time when this signal is triggered, in milliseconds since the epoch.
1226612266- */
1226712267- timeStamp: number;
1226812268- /**
1226912269- * The server IP address that the request was actually sent to. Note that it may be a literal IPv6 address.
1227012270- * Optional.
1227112271- */
1227212272- ip?: string;
1227312273- /**
1227412274- * Indicates if this response was fetched from disk cache.
1227512275- */
1227612276- fromCache: boolean;
1227712277- /**
1227812278- * Standard HTTP status code returned by the server.
1227912279- */
1228012280- statusCode: number;
1228112281- /**
1228212282- * The HTTP response headers that were received along with this response.
1228312283- * Optional.
1228412284- */
1228512285- responseHeaders?: HttpHeaders;
1228612286- /**
1228712287- * HTTP status line of the response or the 'HTTP/0.9 200 OK' string for HTTP/0.9 responses (i.e.,
1228812288- * responses that lack a status line) or an empty string if there are no headers.
1228912289- */
1229012290- statusLine: string;
1229112291- /**
1229212292- * Tracking classification if the request has been classified.
1229312293- * Optional.
1229412294- */
1229512295- urlClassification?: UrlClassification;
1229612296- /**
1229712297- * Indicates if this request and its content window hierarchy is third party.
1229812298- */
1229912299- thirdParty: boolean;
1230012300- /**
1230112301- * URL of the resource that triggered this request (on chrome).
1230212302- * Optional.
1230312303- */
1230412304- initiator?: string;
1230512305- }
1230612306- interface OnBeforeRedirectDetailsType {
1230712307- /**
1230812308- * The ID of the request. Request IDs are unique within a browser session. As a result,
1230912309- * they could be used to relate different events of the same request.
1231012310- */
1231112311- requestId: string;
1231212312- url: string;
1231312313- /**
1231412314- * Standard HTTP method.
1231512315- */
1231612316- method: string;
1231712317- /**
1231812318- * The value 0 indicates that the request happens in the main frame; a positive value indicates the ID of a subframe in
1231912319- * which the request happens. If the document of a (sub-)frame is loaded (<code>type</code> is <code>main_frame</code>
1232012320- * or <code>sub_frame</code>), <code>frameId</code> indicates the ID of this frame, not the ID of the outer frame.
1232112321- * Frame IDs are unique within a tab.
1232212322- */
1232312323- frameId: number;
1232412324- /**
1232512325- * ID of frame that wraps the frame which sent the request. Set to -1 if no parent frame exists.
1232612326- */
1232712327- parentFrameId: number;
1232812328- /**
1232912329- * True for private browsing requests.
1233012330- * Optional.
1233112331- */
1233212332- incognito?: boolean;
1233312333- /**
1233412334- * The cookie store ID of the contextual identity.
1233512335- * Optional.
1233612336- */
1233712337- cookieStoreId?: string;
1233812338- /**
1233912339- * URL of the resource that triggered this request.
1234012340- * Optional.
1234112341- */
1234212342- originUrl?: string;
1234312343- /**
1234412344- * URL of the page into which the requested resource will be loaded.
1234512345- * Optional.
1234612346- */
1234712347- documentUrl?: string;
1234812348- /**
1234912349- * The ID of the tab in which the request takes place. Set to -1 if the request isn't related to a tab.
1235012350- */
1235112351- tabId: number;
1235212352- /**
1235312353- * How the requested resource will be used.
1235412354- */
1235512355- type: ResourceType;
1235612356- /**
1235712357- * The time when this signal is triggered, in milliseconds since the epoch.
1235812358- */
1235912359- timeStamp: number;
1236012360- /**
1236112361- * The server IP address that the request was actually sent to. Note that it may be a literal IPv6 address.
1236212362- * Optional.
1236312363- */
1236412364- ip?: string;
1236512365- /**
1236612366- * Indicates if this response was fetched from disk cache.
1236712367- */
1236812368- fromCache: boolean;
1236912369- /**
1237012370- * Standard HTTP status code returned by the server.
1237112371- */
1237212372- statusCode: number;
1237312373- /**
1237412374- * The new URL.
1237512375- */
1237612376- redirectUrl: string;
1237712377- /**
1237812378- * The HTTP response headers that were received along with this redirect.
1237912379- * Optional.
1238012380- */
1238112381- responseHeaders?: HttpHeaders;
1238212382- /**
1238312383- * HTTP status line of the response or the 'HTTP/0.9 200 OK' string for HTTP/0.9 responses (i.e.,
1238412384- * responses that lack a status line) or an empty string if there are no headers.
1238512385- */
1238612386- statusLine: string;
1238712387- /**
1238812388- * Tracking classification if the request has been classified.
1238912389- * Optional.
1239012390- */
1239112391- urlClassification?: UrlClassification;
1239212392- /**
1239312393- * Indicates if this request and its content window hierarchy is third party.
1239412394- */
1239512395- thirdParty: boolean;
1239612396- /**
1239712397- * URL of the resource that triggered this request (on chrome).
1239812398- * Optional.
1239912399- */
1240012400- initiator?: string;
1240112401- }
1240212402- interface OnCompletedDetailsType {
1240312403- /**
1240412404- * The ID of the request. Request IDs are unique within a browser session. As a result,
1240512405- * they could be used to relate different events of the same request.
1240612406- */
1240712407- requestId: string;
1240812408- url: string;
1240912409- /**
1241012410- * Standard HTTP method.
1241112411- */
1241212412- method: string;
1241312413- /**
1241412414- * The value 0 indicates that the request happens in the main frame; a positive value indicates the ID of a subframe in
1241512415- * which the request happens. If the document of a (sub-)frame is loaded (<code>type</code> is <code>main_frame</code>
1241612416- * or <code>sub_frame</code>), <code>frameId</code> indicates the ID of this frame, not the ID of the outer frame.
1241712417- * Frame IDs are unique within a tab.
1241812418- */
1241912419- frameId: number;
1242012420- /**
1242112421- * ID of frame that wraps the frame which sent the request. Set to -1 if no parent frame exists.
1242212422- */
1242312423- parentFrameId: number;
1242412424- /**
1242512425- * True for private browsing requests.
1242612426- * Optional.
1242712427- */
1242812428- incognito?: boolean;
1242912429- /**
1243012430- * The cookie store ID of the contextual identity.
1243112431- * Optional.
1243212432- */
1243312433- cookieStoreId?: string;
1243412434- /**
1243512435- * URL of the resource that triggered this request.
1243612436- * Optional.
1243712437- */
1243812438- originUrl?: string;
1243912439- /**
1244012440- * URL of the page into which the requested resource will be loaded.
1244112441- * Optional.
1244212442- */
1244312443- documentUrl?: string;
1244412444- /**
1244512445- * The ID of the tab in which the request takes place. Set to -1 if the request isn't related to a tab.
1244612446- */
1244712447- tabId: number;
1244812448- /**
1244912449- * How the requested resource will be used.
1245012450- */
1245112451- type: ResourceType;
1245212452- /**
1245312453- * The time when this signal is triggered, in milliseconds since the epoch.
1245412454- */
1245512455- timeStamp: number;
1245612456- /**
1245712457- * The server IP address that the request was actually sent to. Note that it may be a literal IPv6 address.
1245812458- * Optional.
1245912459- */
1246012460- ip?: string;
1246112461- /**
1246212462- * Indicates if this response was fetched from disk cache.
1246312463- */
1246412464- fromCache: boolean;
1246512465- /**
1246612466- * Standard HTTP status code returned by the server.
1246712467- */
1246812468- statusCode: number;
1246912469- /**
1247012470- * The HTTP response headers that were received along with this response.
1247112471- * Optional.
1247212472- */
1247312473- responseHeaders?: HttpHeaders;
1247412474- /**
1247512475- * HTTP status line of the response or the 'HTTP/0.9 200 OK' string for HTTP/0.9 responses (i.e.,
1247612476- * responses that lack a status line) or an empty string if there are no headers.
1247712477- */
1247812478- statusLine: string;
1247912479- /**
1248012480- * Tracking classification if the request has been classified.
1248112481- */
1248212482- urlClassification: UrlClassification;
1248312483- /**
1248412484- * Indicates if this request and its content window hierarchy is third party.
1248512485- */
1248612486- thirdParty: boolean;
1248712487- /**
1248812488- * For http requests, the bytes transferred in the request. Only available in onCompleted.
1248912489- */
1249012490- requestSize: number;
1249112491- /**
1249212492- * For http requests, the bytes received in the request. Only available in onCompleted.
1249312493- */
1249412494- responseSize: number;
1249512495- /**
1249612496- * URL of the resource that triggered this request (on chrome).
1249712497- * Optional.
1249812498- */
1249912499- initiator?: string;
1250012500- }
1250112501- interface OnErrorOccurredDetailsType {
1250212502- /**
1250312503- * The ID of the request. Request IDs are unique within a browser session. As a result,
1250412504- * they could be used to relate different events of the same request.
1250512505- */
1250612506- requestId: string;
1250712507- url: string;
1250812508- /**
1250912509- * Standard HTTP method.
1251012510- */
1251112511- method: string;
1251212512- /**
1251312513- * The value 0 indicates that the request happens in the main frame; a positive value indicates the ID of a subframe in
1251412514- * which the request happens. If the document of a (sub-)frame is loaded (<code>type</code> is <code>main_frame</code>
1251512515- * or <code>sub_frame</code>), <code>frameId</code> indicates the ID of this frame, not the ID of the outer frame.
1251612516- * Frame IDs are unique within a tab.
1251712517- */
1251812518- frameId: number;
1251912519- /**
1252012520- * ID of frame that wraps the frame which sent the request. Set to -1 if no parent frame exists.
1252112521- */
1252212522- parentFrameId: number;
1252312523- /**
1252412524- * True for private browsing requests.
1252512525- * Optional.
1252612526- */
1252712527- incognito?: boolean;
1252812528- /**
1252912529- * The cookie store ID of the contextual identity.
1253012530- * Optional.
1253112531- */
1253212532- cookieStoreId?: string;
1253312533- /**
1253412534- * URL of the resource that triggered this request.
1253512535- * Optional.
1253612536- */
1253712537- originUrl?: string;
1253812538- /**
1253912539- * URL of the page into which the requested resource will be loaded.
1254012540- * Optional.
1254112541- */
1254212542- documentUrl?: string;
1254312543- /**
1254412544- * The ID of the tab in which the request takes place. Set to -1 if the request isn't related to a tab.
1254512545- */
1254612546- tabId: number;
1254712547- /**
1254812548- * How the requested resource will be used.
1254912549- */
1255012550- type: ResourceType;
1255112551- /**
1255212552- * The time when this signal is triggered, in milliseconds since the epoch.
1255312553- */
1255412554- timeStamp: number;
1255512555- /**
1255612556- * The server IP address that the request was actually sent to. Note that it may be a literal IPv6 address.
1255712557- * Optional.
1255812558- */
1255912559- ip?: string;
1256012560- /**
1256112561- * Indicates if this response was fetched from disk cache.
1256212562- */
1256312563- fromCache: boolean;
1256412564- /**
1256512565- * The error description. This string is <em>not</em> guaranteed to remain backwards compatible between releases.
1256612566- * You must not parse and act based upon its content.
1256712567- */
1256812568- error: string;
1256912569- /**
1257012570- * Tracking classification if the request has been classified.
1257112571- * Optional.
1257212572- */
1257312573- urlClassification?: UrlClassification;
1257412574- /**
1257512575- * Indicates if this request and its content window hierarchy is third party.
1257612576- */
1257712577- thirdParty: boolean;
1257812578- /**
1257912579- * URL of the resource that triggered this request (on chrome).
1258012580- * Optional.
1258112581- */
1258212582- initiator?: string;
1258312583- }
1258412584- interface HttpHeadersItemType {
1258512585- /**
1258612586- * Name of the HTTP header.
1258712587- */
1258812588- name: string;
1258912589- /**
1259012590- * Value of the HTTP header if it can be represented by UTF-8.
1259112591- * Optional.
1259212592- */
1259312593- value?: string;
1259412594- /**
1259512595- * Value of the HTTP header if it cannot be represented by UTF-8, stored as individual byte values (0..255).
1259612596- * Optional.
1259712597- */
1259812598- binaryValue?: number[];
1259912599- }
1260012600- /**
1260112601- * Only used as a response to the onAuthRequired event. If set, the request is made using the supplied credentials.
1260212602- */
1260312603- interface BlockingResponseAuthCredentialsType {
1260412604- username: string;
1260512605- password: string;
1260612606- }
1260712607- /**
1260812608- * Contains start and end timestamps.
1260912609- */
1261012610- interface CertificateInfoValidityType {
1261112611- start: number;
1261212612- end: number;
1261312613- }
1261412614- interface CertificateInfoFingerprintType {
1261512615- sha1: string;
1261612616- sha256: string;
1261712617- }
1261812618- interface CertificateInfoSubjectPublicKeyInfoDigestType {
1261912619- sha256: string;
1262012620- }
1262112621- type SecurityInfoStateEnum = "insecure" | "weak" | "broken" | "secure";
1262212622- /**
1262312623- * Protocol version if state is "secure"
1262412624- */
1262512625- type SecurityInfoProtocolVersionEnum = "TLSv1" | "TLSv1.1" | "TLSv1.2" | "TLSv1.3" | "unknown";
1262612626- /**
1262712627- * The type of certificate error that was overridden for this connection, if any.
1262812628- */
1262912629- type SecurityInfoOverridableErrorCategoryEnum = "trust_error" | "domain_mismatch" | "expired_or_not_yet_valid";
1263012630- /**
1263112631- * Contains the HTTP request body data. Only provided if extraInfoSpec contains 'requestBody'.
1263212632- */
1263312633- interface OnBeforeRequestDetailsTypeRequestBodyType {
1263412634- /**
1263512635- * Errors when obtaining request body data.
1263612636- * Optional.
1263712637- */
1263812638- error?: string;
1263912639- /**
1264012640- * If the request method is POST and the body is a sequence of key-value pairs encoded in UTF8,
1264112641- * encoded as either multipart/form-data, or application/x-www-form-urlencoded, this dictionary is present and for each
1264212642- * key contains the list of all values for that key. If the data is of another media type, or if it is malformed,
1264312643- * the dictionary is not present. An example value of this dictionary is {'key': ['value1', 'value2']}.
1264412644- * Optional.
1264512645- */
1264612646- formData?: Record<string, string>;
1264712647- /**
1264812648- * If the request method is PUT or POST, and the body is not already parsed in formData,
1264912649- * then the unparsed request body elements are contained in this array.
1265012650- * Optional.
1265112651- */
1265212652- raw?: UploadData[];
1265312653- }
1265412654- /**
1265512655- * The server requesting authentication.
1265612656- */
1265712657- interface OnAuthRequiredDetailsTypeChallengerType {
1265812658- host: string;
1265912659- port: number;
1266012660- }
1266112661- /**
1266212662- * Fired when a request is about to occur.
1266312663- */
1266412664- interface OnBeforeRequestEvent extends Events.Event<(details: OnBeforeRequestDetailsType) => BlockingResponseOrPromiseOrVoid> {
1266512665- /**
1266612666- * Registers an event listener <em>callback</em> to an event.
1266712667- *
1266812668- * @param callback Called when an event occurs. The parameters of this function depend on the type of event.
1266912669- * @param filter A set of filters that restricts the events that will be sent to this listener.
1267012670- * @param extraInfoSpec Optional. Array of extra information that should be passed to the listener function.
1267112671- */
1267212672- addListener(callback: (details: OnBeforeRequestDetailsType) => BlockingResponseOrPromiseOrVoid, filter: RequestFilter, extraInfoSpec?: OnBeforeRequestOptions[]): void;
1267312673- }
1267412674- /**
1267512675- * Fired before sending an HTTP request, once the request headers are available. This may occur after a TCP connection is
1267612676- * made to the server, but before any HTTP data is sent.
1267712677- */
1267812678- interface OnBeforeSendHeadersEvent extends Events.Event<(details: OnBeforeSendHeadersDetailsType) => BlockingResponseOrPromiseOrVoid> {
1267912679- /**
1268012680- * Registers an event listener <em>callback</em> to an event.
1268112681- *
1268212682- * @param callback Called when an event occurs. The parameters of this function depend on the type of event.
1268312683- * @param filter A set of filters that restricts the events that will be sent to this listener.
1268412684- * @param extraInfoSpec Optional. Array of extra information that should be passed to the listener function.
1268512685- */
1268612686- addListener(callback: (details: OnBeforeSendHeadersDetailsType) => BlockingResponseOrPromiseOrVoid, filter: RequestFilter, extraInfoSpec?: OnBeforeSendHeadersOptions[]): void;
1268712687- }
1268812688- /**
1268912689- * Fired just before a request is going to be sent to the server (modifications of previous onBeforeSendHeaders callbacks
1269012690- * are visible by the time onSendHeaders is fired).
1269112691- */
1269212692- interface OnSendHeadersEvent extends Events.Event<(details: OnSendHeadersDetailsType) => void> {
1269312693- /**
1269412694- * Registers an event listener <em>callback</em> to an event.
1269512695- *
1269612696- * @param callback Called when an event occurs. The parameters of this function depend on the type of event.
1269712697- * @param filter A set of filters that restricts the events that will be sent to this listener.
1269812698- * @param extraInfoSpec Optional. Array of extra information that should be passed to the listener function.
1269912699- */
1270012700- addListener(callback: (details: OnSendHeadersDetailsType) => void, filter: RequestFilter, extraInfoSpec?: OnSendHeadersOptions[]): void;
1270112701- }
1270212702- /**
1270312703- * Fired when HTTP response headers of a request have been received.
1270412704- */
1270512705- interface OnHeadersReceivedEvent extends Events.Event<(details: OnHeadersReceivedDetailsType) => BlockingResponseOrPromiseOrVoid> {
1270612706- /**
1270712707- * Registers an event listener <em>callback</em> to an event.
1270812708- *
1270912709- * @param callback Called when an event occurs. The parameters of this function depend on the type of event.
1271012710- * @param filter A set of filters that restricts the events that will be sent to this listener.
1271112711- * @param extraInfoSpec Optional. Array of extra information that should be passed to the listener function.
1271212712- */
1271312713- addListener(callback: (details: OnHeadersReceivedDetailsType) => BlockingResponseOrPromiseOrVoid, filter: RequestFilter, extraInfoSpec?: OnHeadersReceivedOptions[]): void;
1271412714- }
1271512715- /**
1271612716- * Fired when an authentication failure is received. The listener has three options: it can provide authentication
1271712717- * credentials, it can cancel the request and display the error page, or it can take no action on the challenge.
1271812718- * If bad user credentials are provided, this may be called multiple times for the same request.
1271912719- */
1272012720- interface OnAuthRequiredEvent extends Events.Event<(details: OnAuthRequiredDetailsType) => BlockingResponseOrPromiseOrVoid> {
1272112721- /**
1272212722- * Registers an event listener <em>callback</em> to an event.
1272312723- *
1272412724- * @param callback Called when an event occurs. The parameters of this function depend on the type of event.
1272512725- * @param filter A set of filters that restricts the events that will be sent to this listener.
1272612726- * @param extraInfoSpec Optional. Array of extra information that should be passed to the listener function.
1272712727- */
1272812728- addListener(callback: (details: OnAuthRequiredDetailsType) => BlockingResponseOrPromiseOrVoid, filter: RequestFilter, extraInfoSpec?: OnAuthRequiredOptions[]): void;
1272912729- }
1273012730- /**
1273112731- * Fired when the first byte of the response body is received. For HTTP requests, this means that the status line and
1273212732- * response headers are available.
1273312733- */
1273412734- interface OnResponseStartedEvent extends Events.Event<(details: OnResponseStartedDetailsType) => void> {
1273512735- /**
1273612736- * Registers an event listener <em>callback</em> to an event.
1273712737- *
1273812738- * @param callback Called when an event occurs. The parameters of this function depend on the type of event.
1273912739- * @param filter A set of filters that restricts the events that will be sent to this listener.
1274012740- * @param extraInfoSpec Optional. Array of extra information that should be passed to the listener function.
1274112741- */
1274212742- addListener(callback: (details: OnResponseStartedDetailsType) => void, filter: RequestFilter, extraInfoSpec?: OnResponseStartedOptions[]): void;
1274312743- }
1274412744- /**
1274512745- * Fired when a server-initiated redirect is about to occur.
1274612746- */
1274712747- interface OnBeforeRedirectEvent extends Events.Event<(details: OnBeforeRedirectDetailsType) => void> {
1274812748- /**
1274912749- * Registers an event listener <em>callback</em> to an event.
1275012750- *
1275112751- * @param callback Called when an event occurs. The parameters of this function depend on the type of event.
1275212752- * @param filter A set of filters that restricts the events that will be sent to this listener.
1275312753- * @param extraInfoSpec Optional. Array of extra information that should be passed to the listener function.
1275412754- */
1275512755- addListener(callback: (details: OnBeforeRedirectDetailsType) => void, filter: RequestFilter, extraInfoSpec?: OnBeforeRedirectOptions[]): void;
1275612756- }
1275712757- /**
1275812758- * Fired when a request is completed.
1275912759- */
1276012760- interface OnCompletedEvent extends Events.Event<(details: OnCompletedDetailsType) => void> {
1276112761- /**
1276212762- * Registers an event listener <em>callback</em> to an event.
1276312763- *
1276412764- * @param callback Called when an event occurs. The parameters of this function depend on the type of event.
1276512765- * @param filter A set of filters that restricts the events that will be sent to this listener.
1276612766- * @param extraInfoSpec Optional. Array of extra information that should be passed to the listener function.
1276712767- */
1276812768- addListener(callback: (details: OnCompletedDetailsType) => void, filter: RequestFilter, extraInfoSpec?: OnCompletedOptions[]): void;
1276912769- }
1277012770- /**
1277112771- * Fired when an error occurs.
1277212772- */
1277312773- interface OnErrorOccurredEvent extends Events.Event<(details: OnErrorOccurredDetailsType) => void> {
1277412774- /**
1277512775- * Registers an event listener <em>callback</em> to an event.
1277612776- *
1277712777- * @param callback Called when an event occurs. The parameters of this function depend on the type of event.
1277812778- * @param filter A set of filters that restricts the events that will be sent to this listener.
1277912779- * @param extraInfoSpec Optional. Array of extra information that should be passed to the listener function.
1278012780- */
1278112781- addListener(callback: (details: OnErrorOccurredDetailsType) => void, filter: RequestFilter, extraInfoSpec?: OnErrorOccurredOptions[]): void;
1278212782- }
1278312783- interface Static {
1278412784- /**
1278512785- * Needs to be called when the behavior of the webRequest handlers has changed to prevent incorrect handling due to caching.
1278612786- * This function call is expensive. Don't call it often.
1278712787- */
1278812788- handlerBehaviorChanged(): Promise<void>;
1278912789- /**
1279012790- * ...
1279112791- */
1279212792- filterResponseData(requestId: string): StreamFilter;
1279312793- /**
1279412794- * Retrieves the security information for the request. Returns a promise that will resolve to a SecurityInfo object.
1279512795- *
1279612796- * @param options Optional.
1279712797- */
1279812798- getSecurityInfo(requestId: string, options?: GetSecurityInfoOptionsType): Promise<SecurityInfo>;
1279912799- /**
1280012800- * Fired when a request is about to occur.
1280112801- */
1280212802- onBeforeRequest: OnBeforeRequestEvent;
1280312803- /**
1280412804- * Fired before sending an HTTP request, once the request headers are available. This may occur after a TCP connection is
1280512805- * made to the server, but before any HTTP data is sent.
1280612806- */
1280712807- onBeforeSendHeaders: OnBeforeSendHeadersEvent;
1280812808- /**
1280912809- * Fired just before a request is going to be sent to the server (modifications of previous onBeforeSendHeaders callbacks
1281012810- * are visible by the time onSendHeaders is fired).
1281112811- */
1281212812- onSendHeaders: OnSendHeadersEvent;
1281312813- /**
1281412814- * Fired when HTTP response headers of a request have been received.
1281512815- */
1281612816- onHeadersReceived: OnHeadersReceivedEvent;
1281712817- /**
1281812818- * Fired when an authentication failure is received. The listener has three options: it can provide authentication
1281912819- * credentials, it can cancel the request and display the error page, or it can take no action on the challenge.
1282012820- * If bad user credentials are provided, this may be called multiple times for the same request.
1282112821- */
1282212822- onAuthRequired: OnAuthRequiredEvent;
1282312823- /**
1282412824- * Fired when the first byte of the response body is received. For HTTP requests, this means that the status line and
1282512825- * response headers are available.
1282612826- */
1282712827- onResponseStarted: OnResponseStartedEvent;
1282812828- /**
1282912829- * Fired when a server-initiated redirect is about to occur.
1283012830- */
1283112831- onBeforeRedirect: OnBeforeRedirectEvent;
1283212832- /**
1283312833- * Fired when a request is completed.
1283412834- */
1283512835- onCompleted: OnCompletedEvent;
1283612836- /**
1283712837- * Fired when an error occurs.
1283812838- */
1283912839- onErrorOccurred: OnErrorOccurredEvent;
1284012840- /**
1284112841- * The maximum number of times that <code>handlerBehaviorChanged</code> can be called per 10 minute sustained interval.
1284212842- * <code>handlerBehaviorChanged</code> is an expensive function call that shouldn't be called often.
1284312843- */
1284412844- MAX_HANDLER_BEHAVIOR_CHANGED_CALLS_PER_10_MINUTES: 20;
1284512845- }
1284612846- }
1284712847- /**
1284812848- * Namespace: browser.windows
1284912849- */
1285012850- namespace Windows {
1285112851- /**
1285212852- * The type of browser window this is. Under some circumstances a Window may not be assigned type property,
1285312853- * for example when querying closed windows from the $(ref:sessions) API.
1285412854- */
1285512855- type WindowType = "normal" | "popup" | "panel" | "app" | "devtools";
1285612856- /**
1285712857- * The state of this browser window. Under some circumstances a Window may not be assigned state property,
1285812858- * for example when querying closed windows from the $(ref:sessions) API.
1285912859- */
1286012860- type WindowState = "normal" | "minimized" | "maximized" | "fullscreen" | "docked";
1286112861- interface Window {
1286212862- /**
1286312863- * The ID of the window. Window IDs are unique within a browser session. Under some circumstances a Window may not be
1286412864- * assigned an ID, for example when querying windows using the $(ref:sessions) API, in which case a session ID may be
1286512865- * present.
1286612866- * Optional.
1286712867- */
1286812868- id?: number;
1286912869- /**
1287012870- * Whether the window is currently the focused window.
1287112871- */
1287212872- focused: boolean;
1287312873- /**
1287412874- * The offset of the window from the top edge of the screen in pixels. Under some circumstances a Window may not be
1287512875- * assigned top property, for example when querying closed windows from the $(ref:sessions) API.
1287612876- * Optional.
1287712877- */
1287812878- top?: number;
1287912879- /**
1288012880- * The offset of the window from the left edge of the screen in pixels. Under some circumstances a Window may not be
1288112881- * assigned left property, for example when querying closed windows from the $(ref:sessions) API.
1288212882- * Optional.
1288312883- */
1288412884- left?: number;
1288512885- /**
1288612886- * The width of the window, including the frame, in pixels. Under some circumstances a Window may not be assigned width
1288712887- * property, for example when querying closed windows from the $(ref:sessions) API.
1288812888- * Optional.
1288912889- */
1289012890- width?: number;
1289112891- /**
1289212892- * The height of the window, including the frame, in pixels. Under some circumstances a Window may not be assigned height
1289312893- * property, for example when querying closed windows from the $(ref:sessions) API.
1289412894- * Optional.
1289512895- */
1289612896- height?: number;
1289712897- /**
1289812898- * Array of $(ref:tabs.Tab) objects representing the current tabs in the window.
1289912899- * Optional.
1290012900- */
1290112901- tabs?: Browser.Tabs.Tab[];
1290212902- /**
1290312903- * Whether the window is incognito.
1290412904- */
1290512905- incognito: boolean;
1290612906- /**
1290712907- * The type of browser window this is.
1290812908- * Optional.
1290912909- */
1291012910- type?: WindowType;
1291112911- /**
1291212912- * The state of this browser window.
1291312913- * Optional.
1291412914- */
1291512915- state?: WindowState;
1291612916- /**
1291712917- * Whether the window is set to be always on top.
1291812918- */
1291912919- alwaysOnTop: boolean;
1292012920- /**
1292112921- * The session ID used to uniquely identify a Window obtained from the $(ref:sessions) API.
1292212922- * Optional.
1292312923- */
1292412924- sessionId?: string;
1292512925- /**
1292612926- * The title of the window. Read-only.
1292712927- * Optional.
1292812928- */
1292912929- title?: string;
1293012930- }
1293112931- /**
1293212932- * Specifies what type of browser window to create. The 'panel' and 'detached_panel' types create a popup unless the
1293312933- * '--enable-panels' flag is set.
1293412934- */
1293512935- type CreateType = "normal" | "popup" | "panel" | "detached_panel";
1293612936- /**
1293712937- * Specifies whether the $(ref:windows.Window) returned should contain a list of the $(ref:tabs.Tab) objects.
1293812938- */
1293912939- interface GetInfo {
1294012940- /**
1294112941- * If true, the $(ref:windows.Window) returned will have a <var>tabs</var> property that contains a list of the $(ref:tabs.
1294212942- * Tab) objects. The <code>Tab</code> objects only contain the <code>url</code>, <code>title</code> and <code>
1294312943- * favIconUrl</code> properties if the extension's manifest file includes the <code>"tabs"</code> permission.
1294412944- * Optional.
1294512945- */
1294612946- populate?: boolean;
1294712947- }
1294812948- /**
1294912949- * Specifies properties used to filter the $(ref:windows.Window) returned and to determine whether they should contain a
1295012950- * list of the $(ref:tabs.Tab) objects.
1295112951- */
1295212952- interface GetAllGetInfoType extends GetInfo {
1295312953- /**
1295412954- * If set, the $(ref:windows.Window) returned will be filtered based on its type. If unset the default filter is set to
1295512955- * <code>['app', 'normal', 'panel', 'popup']</code>, with <code>'app'</code> and <code>'panel'</code>
1295612956- * window types limited to the extension's own windows.
1295712957- * Optional.
1295812958- */
1295912959- windowTypes?: WindowType[];
1296012960- }
1296112961- interface CreateCreateDataType {
1296212962- /**
1296312963- * A URL or array of URLs to open as tabs in the window. Fully-qualified URLs must include a scheme (i.e. 'http://www.
1296412964- * google.com', not 'www.google.com'). Relative URLs will be relative to the current page within the extension.
1296512965- * Defaults to the New Tab Page.
1296612966- * Optional.
1296712967- */
1296812968- url?: string | string[];
1296912969- /**
1297012970- * The id of the tab for which you want to adopt to the new window.
1297112971- * Optional.
1297212972- */
1297312973- tabId?: number;
1297412974- /**
1297512975- * The number of pixels to position the new window from the left edge of the screen. If not specified,
1297612976- * the new window is offset naturally from the last focused window. This value is ignored for panels.
1297712977- * Optional.
1297812978- */
1297912979- left?: number;
1298012980- /**
1298112981- * The number of pixels to position the new window from the top edge of the screen. If not specified,
1298212982- * the new window is offset naturally from the last focused window. This value is ignored for panels.
1298312983- * Optional.
1298412984- */
1298512985- top?: number;
1298612986- /**
1298712987- * The width in pixels of the new window, including the frame. If not specified defaults to a natural width.
1298812988- * Optional.
1298912989- */
1299012990- width?: number;
1299112991- /**
1299212992- * The height in pixels of the new window, including the frame. If not specified defaults to a natural height.
1299312993- * Optional.
1299412994- */
1299512995- height?: number;
1299612996- /**
1299712997- * If true, the new window will be focused. If false, the new window will be opened in the background and the currently
1299812998- * focused window will stay focused. Defaults to true.
1299912999- * Optional.
1300013000- */
1300113001- focused?: boolean;
1300213002- /**
1300313003- * Whether the new window should be an incognito window.
1300413004- * Optional.
1300513005- */
1300613006- incognito?: boolean;
1300713007- /**
1300813008- * Specifies what type of browser window to create. The 'panel' and 'detached_panel' types create a popup unless the
1300913009- * '--enable-panels' flag is set.
1301013010- * Optional.
1301113011- */
1301213012- type?: CreateType;
1301313013- /**
1301413014- * The initial state of the window. The 'minimized', 'maximized' and 'fullscreen' states cannot be combined with 'left',
1301513015- * 'top', 'width' or 'height'.
1301613016- * Optional.
1301713017- */
1301813018- state?: WindowState;
1301913019- /**
1302013020- * Allow scripts to close the window.
1302113021- * Optional.
1302213022- */
1302313023- allowScriptsToClose?: boolean;
1302413024- /**
1302513025- * The CookieStoreId to use for all tabs that were created when the window is opened.
1302613026- * Optional.
1302713027- */
1302813028- cookieStoreId?: string;
1302913029- /**
1303013030- * A string to add to the beginning of the window title.
1303113031- * Optional.
1303213032- */
1303313033- titlePreface?: string;
1303413034- }
1303513035- interface UpdateUpdateInfoType {
1303613036- /**
1303713037- * The offset from the left edge of the screen to move the window to in pixels. This value is ignored for panels.
1303813038- * Optional.
1303913039- */
1304013040- left?: number;
1304113041- /**
1304213042- * The offset from the top edge of the screen to move the window to in pixels. This value is ignored for panels.
1304313043- * Optional.
1304413044- */
1304513045- top?: number;
1304613046- /**
1304713047- * The width to resize the window to in pixels. This value is ignored for panels.
1304813048- * Optional.
1304913049- */
1305013050- width?: number;
1305113051- /**
1305213052- * The height to resize the window to in pixels. This value is ignored for panels.
1305313053- * Optional.
1305413054- */
1305513055- height?: number;
1305613056- /**
1305713057- * If true, brings the window to the front. If false, brings the next window in the z-order to the front.
1305813058- * Optional.
1305913059- */
1306013060- focused?: boolean;
1306113061- /**
1306213062- * If true, causes the window to be displayed in a manner that draws the user's attention to the window,
1306313063- * without changing the focused window. The effect lasts until the user changes focus to the window.
1306413064- * This option has no effect if the window already has focus. Set to false to cancel a previous draw attention request.
1306513065- * Optional.
1306613066- */
1306713067- drawAttention?: boolean;
1306813068- /**
1306913069- * The new state of the window. The 'minimized', 'maximized' and 'fullscreen' states cannot be combined with 'left', 'top',
1307013070- * 'width' or 'height'.
1307113071- * Optional.
1307213072- */
1307313073- state?: WindowState;
1307413074- /**
1307513075- * A string to add to the beginning of the window title.
1307613076- * Optional.
1307713077- */
1307813078- titlePreface?: string;
1307913079- }
1308013080- interface Static {
1308113081- /**
1308213082- * Gets details about a window.
1308313083- *
1308413084- * @param getInfo Optional.
1308513085- */
1308613086- get(windowId: number, getInfo?: GetInfo): Promise<Window>;
1308713087- /**
1308813088- * Gets the $(topic:current-window)[current window].
1308913089- *
1309013090- * @param getInfo Optional.
1309113091- */
1309213092- getCurrent(getInfo?: GetInfo): Promise<Window>;
1309313093- /**
1309413094- * Gets the window that was most recently focused — typically the window 'on top'.
1309513095- *
1309613096- * @param getInfo Optional.
1309713097- */
1309813098- getLastFocused(getInfo?: GetInfo): Promise<Window>;
1309913099- /**
1310013100- * Gets all windows.
1310113101- *
1310213102- * @param getInfo Optional. Specifies properties used to filter the $(ref:windows.Window)
1310313103- * returned and to determine whether they should contain a list of the $(ref:tabs.Tab) objects.
1310413104- */
1310513105- getAll(getInfo?: GetAllGetInfoType): Promise<Window[]>;
1310613106- /**
1310713107- * Creates (opens) a new browser with any optional sizing, position or default URL provided.
1310813108- *
1310913109- * @param createData Optional.
1311013110- */
1311113111- create(createData?: CreateCreateDataType): Promise<Window>;
1311213112- /**
1311313113- * Updates the properties of a window. Specify only the properties that you want to change; unspecified properties will be
1311413114- * left unchanged.
1311513115- */
1311613116- update(windowId: number, updateInfo: UpdateUpdateInfoType): Promise<Window>;
1311713117- /**
1311813118- * Removes (closes) a window, and all the tabs inside it.
1311913119- */
1312013120- remove(windowId: number): Promise<void>;
1312113121- /**
1312213122- * Fired when a window is created.
1312313123- *
1312413124- * @param window Details of the window that was created.
1312513125- */
1312613126- onCreated: Events.Event<(window: Window) => void>;
1312713127- /**
1312813128- * Fired when a window is removed (closed).
1312913129- *
1313013130- * @param windowId ID of the removed window.
1313113131- */
1313213132- onRemoved: Events.Event<(windowId: number) => void>;
1313313133- /**
1313413134- * Fired when the currently focused window changes. Will be $(ref:windows.WINDOW_ID_NONE)
1313513135- * if all browser windows have lost focus. Note: On some Linux window managers, WINDOW_ID_NONE will always be sent
1313613136- * immediately preceding a switch from one browser window to another.
1313713137- *
1313813138- * @param windowId ID of the newly focused window.
1313913139- */
1314013140- onFocusChanged: Events.Event<(windowId: number) => void>;
1314113141- /**
1314213142- * The windowId value that represents the absence of a browser window.
1314313143- */
1314413144- WINDOW_ID_NONE: -1;
1314513145- /**
1314613146- * The windowId value that represents the $(topic:current-window)[current window].
1314713147- */
1314813148- WINDOW_ID_CURRENT: -2;
1314913149- }
1315013150- }
1315113151- namespace BrowserSettings {
1315213152- namespace ColorManagement {
1315313153- interface Static {
1315413154- /**
1315513155- * This setting controls the mode used for color management and must be a string from $(ref:browserSettings.
1315613156- * ColorManagementMode)
1315713157- */
1315813158- mode: Browser.Types.Setting;
1315913159- /**
1316013160- * This boolean setting controls whether or not native sRGB color management is used.
1316113161- */
1316213162- useNativeSRGB: Browser.Types.Setting;
1316313163- /**
1316413164- * This boolean setting controls whether or not the WebRender compositor is used.
1316513165- */
1316613166- useWebRenderCompositor: Browser.Types.Setting;
1316713167- }
1316813168- }
1316913169- }
1317013170- namespace Devtools {
1317113171- namespace InspectedWindow {
1317213172- /**
1317313173- * A resource within the inspected page, such as a document, a script, or an image.
1317413174- */
1317513175- interface Resource {
1317613176- /**
1317713177- * The URL of the resource.
1317813178- */
1317913179- url: string;
1318013180- }
1318113181- /**
1318213182- * The options parameter can contain one or more options.
1318313183- */
1318413184- interface EvalOptionsType {
1318513185- [s: string]: unknown;
1318613186- }
1318713187- /**
1318813188- * An object providing details if an exception occurred while evaluating the expression.
1318913189- */
1319013190- interface EvalCallbackExceptionInfoType {
1319113191- /**
1319213192- * Set if the error occurred on the DevTools side before the expression is evaluated.
1319313193- */
1319413194- isError: boolean;
1319513195- /**
1319613196- * Set if the error occurred on the DevTools side before the expression is evaluated.
1319713197- */
1319813198- code: string;
1319913199- /**
1320013200- * Set if the error occurred on the DevTools side before the expression is evaluated.
1320113201- */
1320213202- description: string;
1320313203- /**
1320413204- * Set if the error occurred on the DevTools side before the expression is evaluated,
1320513205- * contains the array of the values that may be substituted into the description string to provide more information about
1320613206- * the cause of the error.
1320713207- */
1320813208- details: unknown[];
1320913209- /**
1321013210- * Set if the evaluated code produces an unhandled exception.
1321113211- */
1321213212- isException: boolean;
1321313213- /**
1321413214- * Set if the evaluated code produces an unhandled exception.
1321513215- */
1321613216- value: string;
1321713217- }
1321813218- interface ReloadReloadOptionsType {
1321913219- /**
1322013220- * When true, the loader will bypass the cache for all inspected page resources loaded before the <code>load</code>
1322113221- * event is fired. The effect is similar to pressing Ctrl+Shift+R in the inspected window or within the Developer Tools
1322213222- * window.
1322313223- * Optional.
1322413224- */
1322513225- ignoreCache?: boolean;
1322613226- /**
1322713227- * If specified, the string will override the value of the <code>User-Agent</code> HTTP header that's sent while loading
1322813228- * the resources of the inspected page. The string will also override the value of the <code>navigator.userAgent</code>
1322913229- * property that's returned to any scripts that are running within the inspected page.
1323013230- * Optional.
1323113231- */
1323213232- userAgent?: string;
1323313233- /**
1323413234- * If specified, the script will be injected into every frame of the inspected page immediately upon load,
1323513235- * before any of the frame's scripts. The script will not be injected after subsequent reloads—for example,
1323613236- * if the user presses Ctrl+R.
1323713237- * Optional.
1323813238- */
1323913239- injectedScript?: string;
1324013240- }
1324113241- interface Static {
1324213242- /**
1324313243- * Evaluates a JavaScript expression in the context of the main frame of the inspected page.
1324413244- * The expression must evaluate to a JSON-compliant object, otherwise an exception is thrown.
1324513245- * The eval function can report either a DevTools-side error or a JavaScript exception that occurs during evaluation.
1324613246- * In either case, the <code>result</code> parameter of the callback is <code>undefined</code>.
1324713247- * In the case of a DevTools-side error, the <code>isException</code> parameter is non-null and has <code>isError</code>
1324813248- * set to true and <code>code</code> set to an error code. In the case of a JavaScript error, <code>isException</code>
1324913249- * is set to true and <code>value</code> is set to the string value of thrown object.
1325013250- *
1325113251- * @param expression An expression to evaluate.
1325213252- * @param options Optional. The options parameter can contain one or more options.
1325313253- * @returns A function called when evaluation completes.
1325413254- */
1325513255- eval(expression: string, options?: EvalOptionsType): Promise<[
1325613256- unknown,
1325713257- EvalCallbackExceptionInfoType
1325813258- ]>;
1325913259- /**
1326013260- * Reloads the inspected page.
1326113261- *
1326213262- * @param reloadOptions Optional.
1326313263- */
1326413264- reload(reloadOptions?: ReloadReloadOptionsType): void;
1326513265- /**
1326613266- * The ID of the tab being inspected. This ID may be used with chrome.tabs.* API.
1326713267- */
1326813268- tabId: number;
1326913269- }
1327013270- }
1327113271- }
1327213272- namespace Devtools {
1327313273- namespace Network {
1327413274- /**
1327513275- * Represents a network request for a document resource (script, image and so on). See HAR Specification for reference.
1327613276- */
1327713277- interface Request {
1327813278- /**
1327913279- * Returns content of the response body.
1328013280- *
1328113281- * @returns A function that receives the response body when the request completes.
1328213282- */
1328313283- getContent(): Promise<[
1328413284- string,
1328513285- string
1328613286- ]>;
1328713287- }
1328813288- /**
1328913289- * A HAR log. See HAR specification for details.
1329013290- */
1329113291- interface GetHARCallbackHarLogType {
1329213292- [s: string]: unknown;
1329313293- }
1329413294- interface Static {
1329513295- /**
1329613296- * Returns HAR log that contains all known network requests.
1329713297- *
1329813298- * @returns A function that receives the HAR log when the request completes.
1329913299- */
1330013300- getHAR(): Promise<GetHARCallbackHarLogType>;
1330113301- /**
1330213302- * Fired when a network request is finished and all request data are available.
1330313303- *
1330413304- * @param request Description of a network request in the form of a HAR entry. See HAR specification for details.
1330513305- */
1330613306- onRequestFinished: Events.Event<(request: Request) => void>;
1330713307- /**
1330813308- * Fired when the inspected window navigates to a new page.
1330913309- *
1331013310- * @param url URL of the new page.
1331113311- */
1331213312- onNavigated: Events.Event<(url: string) => void>;
1331313313- }
1331413314- }
1331513315- }
1331613316- namespace Devtools {
1331713317- namespace Panels {
1331813318- /**
1331913319- * Represents the Elements panel.
1332013320- */
1332113321- interface ElementsPanel {
1332213322- /**
1332313323- * Creates a pane within panel's sidebar.
1332413324- *
1332513325- * @param title Text that is displayed in sidebar caption.
1332613326- * @returns A callback invoked when the sidebar is created.
1332713327- */
1332813328- createSidebarPane(title: string): Promise<ExtensionSidebarPane>;
1332913329- /**
1333013330- * Fired when an object is selected in the panel.
1333113331- */
1333213332- onSelectionChanged: Events.Event<() => void>;
1333313333- }
1333413334- /**
1333513335- * Represents the Sources panel.
1333613336- */
1333713337- interface SourcesPanel {
1333813338- [s: string]: unknown;
1333913339- }
1334013340- /**
1334113341- * Represents a panel created by extension.
1334213342- */
1334313343- interface ExtensionPanel {
1334413344- /**
1334513345- * Fired when the user switches to the panel.
1334613346- *
1334713347- * @param window The JavaScript <code>window</code> object of panel's page.
1334813348- */
1334913349- onShown: Events.Event<(window: Window) => void>;
1335013350- /**
1335113351- * Fired when the user switches away from the panel.
1335213352- */
1335313353- onHidden: Events.Event<() => void>;
1335413354- }
1335513355- /**
1335613356- * A sidebar created by the extension.
1335713357- */
1335813358- interface ExtensionSidebarPane {
1335913359- /**
1336013360- * Sets an expression that is evaluated within the inspected page. The result is displayed in the sidebar pane.
1336113361- *
1336213362- * @param expression An expression to be evaluated in context of the inspected page. JavaScript objects and DOM nodes are
1336313363- * displayed in an expandable tree similar to the console/watch.
1336413364- * @param rootTitle Optional. An optional title for the root of the expression tree.
1336513365- * @returns A callback invoked after the sidebar pane is updated with the expression evaluation results.
1336613366- */
1336713367- setExpression(expression: string, rootTitle?: string): Promise<void>;
1336813368- /**
1336913369- * Sets a JSON-compliant object to be displayed in the sidebar pane.
1337013370- *
1337113371- * @param jsonObject An object to be displayed in context of the inspected page. Evaluated in the context of the caller
1337213372- * (API client).
1337313373- * @param rootTitle Optional. An optional title for the root of the expression tree.
1337413374- * @returns A callback invoked after the sidebar is updated with the object.
1337513375- */
1337613376- setObject(jsonObject: string | unknown[] | Record<string, unknown>, rootTitle?: string): Promise<void>;
1337713377- /**
1337813378- * Sets an HTML page to be displayed in the sidebar pane.
1337913379- *
1338013380- * @param path Relative path of an extension page to display within the sidebar.
1338113381- */
1338213382- setPage(path: Browser.Manifest.ExtensionURL): Promise<void>;
1338313383- /**
1338413384- * Fired when the sidebar pane becomes visible as a result of user switching to the panel that hosts it.
1338513385- *
1338613386- * @param window The JavaScript <code>window</code> object of the sidebar page, if one was set with the <code>setPage()
1338713387- * </code> method.
1338813388- */
1338913389- onShown: Events.Event<(window: Window) => void>;
1339013390- /**
1339113391- * Fired when the sidebar pane becomes hidden as a result of the user switching away from the panel that hosts the sidebar
1339213392- * pane.
1339313393- */
1339413394- onHidden: Events.Event<() => void>;
1339513395- }
1339613396- /**
1339713397- * A button created by the extension.
1339813398- */
1339913399- interface Button {
1340013400- [s: string]: unknown;
1340113401- }
1340213402- interface Static {
1340313403- /**
1340413404- * Creates an extension panel.
1340513405- *
1340613406- * @param title Title that is displayed next to the extension icon in the Developer Tools toolbar.
1340713407- * @param iconPath Path of the panel's icon relative to the extension directory, or an empty string to use the default
1340813408- * extension icon as the panel icon.
1340913409- * @param pagePath Path of the panel's HTML page relative to the extension directory.
1341013410- * @returns A function that is called when the panel is created.
1341113411- */
1341213412- create(title: string, iconPath: "" | Browser.Manifest.ExtensionURL, pagePath: Browser.Manifest.ExtensionURL): Promise<ExtensionPanel>;
1341313413- /**
1341413414- * Fired when the devtools theme changes.
1341513415- *
1341613416- * @param themeName The name of the current devtools theme.
1341713417- */
1341813418- onThemeChanged: Events.Event<(themeName: string) => void>;
1341913419- /**
1342013420- * Elements panel.
1342113421- */
1342213422- elements: ElementsPanel;
1342313423- /**
1342413424- * Sources panel.
1342513425- */
1342613426- sources: SourcesPanel;
1342713427- /**
1342813428- * The name of the current devtools theme.
1342913429- */
1343013430- themeName: string;
1343113431- }
1343213432- }
1343313433- }
1343413434- namespace Privacy {
1343513435- namespace Network {
1343613436- /**
1343713437- * The IP handling policy of WebRTC.
1343813438- */
1343913439- type IPHandlingPolicy = "default" | "default_public_and_private_interfaces" | "default_public_interface_only" | "disable_non_proxied_udp" | "proxy_only";
1344013440- /**
1344113441- * An object which describes TLS minimum and maximum versions.
1344213442- */
1344313443- interface tlsVersionRestrictionConfig {
1344413444- /**
1344513445- * The minimum TLS version supported.
1344613446- * Optional.
1344713447- */
1344813448- minimum?: TlsVersionRestrictionConfigMinimumEnum;
1344913449- /**
1345013450- * The maximum TLS version supported.
1345113451- * Optional.
1345213452- */
1345313453- maximum?: TlsVersionRestrictionConfigMaximumEnum;
1345413454- }
1345513455- /**
1345613456- * The mode for https-only mode.
1345713457- */
1345813458- type HTTPSOnlyModeOption = "always" | "private_browsing" | "never";
1345913459- /**
1346013460- * The minimum TLS version supported.
1346113461- */
1346213462- type TlsVersionRestrictionConfigMinimumEnum = "TLSv1" | "TLSv1.1" | "TLSv1.2" | "TLSv1.3" | "unknown";
1346313463- /**
1346413464- * The maximum TLS version supported.
1346513465- */
1346613466- type TlsVersionRestrictionConfigMaximumEnum = "TLSv1" | "TLSv1.1" | "TLSv1.2" | "TLSv1.3" | "unknown";
1346713467- interface Static {
1346813468- /**
1346913469- * If enabled, the browser attempts to speed up your web browsing experience by pre-resolving DNS entries,
1347013470- * prerendering sites (<code><link rel='prefetch' ...></code>), and preemptively opening TCP and SSL connections to
1347113471- * servers. This preference's value is a boolean, defaulting to <code>true</code>.
1347213472- */
1347313473- networkPredictionEnabled: Browser.Types.Setting;
1347413474- /**
1347513475- * Allow users to enable and disable RTCPeerConnections (aka WebRTC).
1347613476- */
1347713477- peerConnectionEnabled: Browser.Types.Setting;
1347813478- /**
1347913479- * Allow users to specify the media performance/privacy tradeoffs which impacts how WebRTC traffic will be routed and how
1348013480- * much local address information is exposed. This preference's value is of type IPHandlingPolicy, defaulting to <code>
1348113481- * default</code>.
1348213482- */
1348313483- webRTCIPHandlingPolicy: Browser.Types.Setting;
1348413484- /**
1348513485- * This property controls the minimum and maximum TLS versions. This setting's value is an object of
1348613486- * $(ref:tlsVersionRestrictionConfig).
1348713487- */
1348813488- tlsVersionRestriction: Browser.Types.Setting;
1348913489- /**
1349013490- * Allow users to query the mode for 'HTTPS-Only Mode'. This setting's value is of type HTTPSOnlyModeOption,
1349113491- * defaulting to <code>never</code>.
1349213492- */
1349313493- httpsOnlyMode: Browser.Types.Setting;
1349413494- /**
1349513495- * Allow users to query the status of 'Global Privacy Control'. This setting's value is of type boolean,
1349613496- * defaulting to <code>false</code>.
1349713497- */
1349813498- globalPrivacyControl: Browser.Types.Setting;
1349913499- }
1350013500- }
1350113501- }
1350213502- namespace Privacy {
1350313503- namespace Services {
1350413504- interface Static {
1350513505- /**
1350613506- * If enabled, the password manager will ask if you want to save passwords. This preference's value is a boolean,
1350713507- * defaulting to <code>true</code>.
1350813508- */
1350913509- passwordSavingEnabled: Browser.Types.Setting;
1351013510- }
1351113511- }
1351213512- }
1351313513- namespace Privacy {
1351413514- namespace Websites {
1351513515- /**
1351613516- * The mode for tracking protection.
1351713517- */
1351813518- type TrackingProtectionModeOption = "always" | "never" | "private_browsing";
1351913519- /**
1352013520- * The settings for cookies.
1352113521- */
1352213522- interface CookieConfig {
1352313523- /**
1352413524- * The type of cookies to allow.
1352513525- * Optional.
1352613526- */
1352713527- behavior?: CookieConfigBehaviorEnum;
1352813528- }
1352913529- /**
1353013530- * The type of cookies to allow.
1353113531- */
1353213532- type CookieConfigBehaviorEnum = "allow_all" | "reject_all" | "reject_third_party" | "allow_visited" | "reject_trackers" | "reject_trackers_and_partition_foreign";
1353313533- interface Static {
1353413534- /**
1353513535- * If enabled, the browser sends auditing pings when requested by a website (<code><a ping></code>).
1353613536- * The value of this preference is of type boolean, and the default value is <code>true</code>.
1353713537- */
1353813538- hyperlinkAuditingEnabled: Browser.Types.Setting;
1353913539- /**
1354013540- * If enabled, the browser sends <code>referer</code> headers with your requests. Yes,
1354113541- * the name of this preference doesn't match the misspelled header. No, we're not going to change it.
1354213542- * The value of this preference is of type boolean, and the default value is <code>true</code>.
1354313543- */
1354413544- referrersEnabled: Browser.Types.Setting;
1354513545- /**
1354613546- * If enabled, the browser attempts to appear similar to other users by reporting generic information to websites.
1354713547- * This can prevent websites from uniquely identifying users. Examples of data that is spoofed include number of CPU cores,
1354813548- * precision of JavaScript timers, the local timezone, and disabling features such as GamePad support,
1354913549- * and the WebSpeech and Navigator APIs. The value of this preference is of type boolean, and the default value is <code>
1355013550- * false</code>.
1355113551- */
1355213552- resistFingerprinting: Browser.Types.Setting;
1355313553- /**
1355413554- * If enabled, the browser will associate all data (including cookies, HSTS data, cached images, and more)
1355513555- * for any third party domains with the domain in the address bar. This prevents third party trackers from using directly
1355613556- * stored information to identify you across different websites, but may break websites where you login with a third party
1355713557- * account (such as a Facebook or Google login.) The value of this preference is of type boolean,
1355813558- * and the default value is <code>false</code>.
1355913559- */
1356013560- firstPartyIsolate: Browser.Types.Setting;
1356113561- /**
1356213562- * Allow users to specify the mode for tracking protection. This setting's value is of type TrackingProtectionModeOption,
1356313563- * defaulting to <code>private_browsing_only</code>.
1356413564- */
1356513565- trackingProtectionMode: Browser.Types.Setting;
1356613566- /**
1356713567- * Allow users to specify the default settings for allowing cookies, as well as whether all cookies should be created as
1356813568- * non-persistent cookies. This setting's value is of type CookieConfig.
1356913569- */
1357013570- cookieConfig: Browser.Types.Setting;
1357113571- }
1357213572- }
1357313573- }
1357413574- namespace Trial {
1357513575- namespace Ml {
1357613576- interface CreateEngineRequest {
1357713577- [s: string]: unknown;
1357813578- }
1357913579- interface RunEngineRequest {
1358013580- [s: string]: unknown;
1358113581- }
1358213582- /**
1358313583- * Object containing the data, see https://firefox-source-docs.mozilla.org/toolkit/components/ml/notifications.html
1358413584- */
1358513585- interface OnProgressProgressDataType {
1358613586- [s: string]: unknown;
1358713587- }
1358813588- interface Static {
1358913589- /**
1359013590- * Prepare the inference engine
1359113591- */
1359213592- createEngine(CreateEngineRequest: CreateEngineRequest): void;
1359313593- /**
1359413594- * Call the inference engine
1359513595- */
1359613596- runEngine(RunEngineRequest: RunEngineRequest): void;
1359713597- /**
1359813598- * Delete the models the extension downloaded.
1359913599- */
1360013600- deleteCachedModels(): void;
1360113601- /**
1360213602- * Events from the inference engine.
1360313603- *
1360413604- * @param progressData Object containing the data, see https://firefox-source-docs.mozilla.
1360513605- * org/toolkit/components/ml/notifications.html
1360613606- */
1360713607- onProgress: Events.Event<(progressData: OnProgressProgressDataType) => void>;
1360813608- }
1360913609- }
1361013610- }
1361113611- interface Browser {
1361213612- /**
1361313613- * Monitor extension activity
1361413614- *
1361513615- * Permissions: "activityLog"
1361613616- */
1361713617- activityLog: ActivityLog.Static;
1361813618- /**
1361913619- * Permissions: "alarms"
1362013620- */
1362113621- alarms: Alarms.Static;
1362213622- /**
1362313623- * Use the <code>browser.bookmarks</code> API to create, organize, and otherwise manipulate bookmarks.
1362413624- * Also see $(topic:override)[Override Pages], which you can use to create a custom Bookmark Manager page.
1362513625- *
1362613626- * Permissions: "bookmarks"
1362713627- */
1362813628- bookmarks: Bookmarks.Static;
1362913629- /**
1363013630- * Use browser actions to put icons in the main browser toolbar, to the right of the address bar. In addition to its icon,
1363113631- * a browser action can also have a tooltip, a badge, and a popup.
1363213632- *
1363313633- * Permissions: "manifest:action", "manifest:browser_action"
1363413634- */
1363513635- action: Action.Static;
1363613636- /**
1363713637- * Permissions: "manifest:action", "manifest:browser_action"
1363813638- */
1363913639- browserAction: BrowserAction.Static;
1364013640- /**
1364113641- * Use the <code>browser.browserSettings</code> API to control global settings of the browser.
1364213642- *
1364313643- * Permissions: "browserSettings"
1364413644- */
1364513645- browserSettings: BrowserSettings.Static;
1364613646- /**
1364713647- * Use the <code>chrome.browsingData</code> API to remove browsing data from a user's local profile.
1364813648- *
1364913649- * Permissions: "browsingData"
1365013650- */
1365113651- browsingData: BrowsingData.Static;
1365213652- /**
1365313653- * This API provides the ability detect the captive portal state of the users connection.
1365413654- *
1365513655- * Permissions: "captivePortal"
1365613656- */
1365713657- captivePortal: CaptivePortal.Static;
1365813658- /**
1365913659- * Offers the ability to write to the clipboard. Reading is not supported because the clipboard can already be read through
1366013660- * the standard web platform APIs.
1366113661- *
1366213662- * Permissions: "clipboardWrite"
1366313663- */
1366413664- clipboard: Clipboard.Static;
1366513665- /**
1366613666- * Use the commands API to add keyboard shortcuts that trigger actions in your extension, for example,
1366713667- * an action to open the browser action or send a command to the xtension.
1366813668- *
1366913669- * Permissions: "manifest:commands"
1367013670- */
1367113671- commands: Commands.Static;
1367213672- contentScripts: ContentScripts.Static;
1367313673- /**
1367413674- * Use the <code>browser.contextualIdentities</code> API to query and modify contextual identity, also called as containers.
1367513675- *
1367613676- * Permissions: "contextualIdentities"
1367713677- */
1367813678- contextualIdentities: ContextualIdentities.Static;
1367913679- /**
1368013680- * Use the <code>browser.cookies</code> API to query and modify cookies, and to be notified when they change.
1368113681- *
1368213682- * Permissions: "cookies"
1368313683- */
1368413684- cookies: Cookies.Static;
1368513685- /**
1368613686- * Use the <code>chrome.declarativeContent</code> API to take actions depending on the content of a page,
1368713687- * without requiring permission to read the page's content.
1368813688- */
1368913689- declarativeContent: DeclarativeContent.Static;
1369013690- /**
1369113691- * Use the declarativeNetRequest API to block or modify network requests by specifying declarative rules.
1369213692- *
1369313693- * Permissions: "declarativeNetRequest", "declarativeNetRequestWithHostAccess"
1369413694- */
1369513695- declarativeNetRequest: DeclarativeNetRequest.Static;
1369613696- /**
1369713697- * Permissions: "manifest:devtools_page"
1369813698- */
1369913699- devtools: Devtools.Static;
1370013700- /**
1370113701- * Asynchronous DNS API
1370213702- *
1370313703- * Permissions: "dns"
1370413704- */
1370513705- dns: Dns.Static;
1370613706- /**
1370713707- * Permissions: "downloads"
1370813708- */
1370913709- downloads: Downloads.Static;
1371013710- /**
1371113711- * The <code>chrome.events</code> namespace contains common types used by APIs dispatching events to notify you when
1371213712- * something interesting happens.
1371313713- */
1371413714- events: Events.Static;
1371513715- experiments: Experiments.Static;
1371613716- /**
1371713717- * The <code>browser.extensionTypes</code> API contains type declarations for WebExtensions.
1371813718- */
1371913719- extensionTypes: ExtensionTypes.Static;
1372013720- /**
1372113721- * The <code>browser.extension</code> API has utilities that can be used by any extension page.
1372213722- * It includes support for exchanging messages between an extension and its content scripts or between extensions,
1372313723- * as described in detail in $(topic:messaging)[Message Passing].
1372413724- */
1372513725- extension: Extension.Static;
1372613726- /**
1372713727- * Use the <code>browser.find</code> API to interact with the browser's <code>Find</code> interface.
1372813728- *
1372913729- * Permissions: "find"
1373013730- */
1373113731- find: Find.Static;
1373213732- /**
1373313733- * Exposes the browser's profiler.
1373413734- *
1373513735- * Permissions: "geckoProfiler"
1373613736- */
1373713737- geckoProfiler: GeckoProfiler.Static;
1373813738- /**
1373913739- * Use the <code>browser.history</code> API to interact with the browser's record of visited pages. You can add, remove,
1374013740- * and query for URLs in the browser's history. To override the history page with your own version, see $(topic:override)
1374113741- * [Override Pages].
1374213742- *
1374313743- * Permissions: "history"
1374413744- */
1374513745- history: History.Static;
1374613746- /**
1374713747- * Use the <code>browser.i18n</code> infrastructure to implement internationalization across your whole app or extension.
1374813748- */
1374913749- i18n: I18n.Static;
1375013750- /**
1375113751- * Use the chrome.identity API to get OAuth2 access tokens.
1375213752- *
1375313753- * Permissions: "identity"
1375413754- */
1375513755- identity: Identity.Static;
1375613756- /**
1375713757- * Use the <code>browser.idle</code> API to detect when the machine's idle state changes.
1375813758- *
1375913759- * Permissions: "idle"
1376013760- */
1376113761- idle: Idle.Static;
1376213762- /**
1376313763- * The <code>browser.management</code> API provides ways to manage the list of extensions that are installed and running.
1376413764- */
1376513765- management: Management.Static;
1376613766- /**
1376713767- * Permissions: -
1376813768- */
1376913769- manifest: Manifest.Static;
1377013770- /**
1377113771- * Use the browser.contextMenus API to add items to the browser's context menu. You can choose what types of objects your
1377213772- * context menu additions apply to, such as images, hyperlinks, and pages.
1377313773- *
1377413774- * Permissions: "contextMenus"
1377513775- */
1377613776- contextMenus: ContextMenus.Static;
1377713777- /**
1377813778- * Use the browser.menus API to add items to the browser's menus. You can choose what types of objects your context menu
1377913779- * additions apply to, such as images, hyperlinks, and pages.
1378013780- *
1378113781- * Permissions: "menus"
1378213782- */
1378313783- menus: Menus.Static;
1378413784- /**
1378513785- * This API provides the ability to determine the status of and detect changes in the network connection.
1378613786- * This API can only be used in privileged extensions.
1378713787- *
1378813788- * Permissions: "networkStatus"
1378913789- */
1379013790- networkStatus: NetworkStatus.Static;
1379113791- /**
1379213792- * Normandy Study API
1379313793- *
1379413794- * Permissions: "normandyAddonStudy"
1379513795- */
1379613796- normandyAddonStudy: NormandyAddonStudy.Static;
1379713797- /**
1379813798- * Permissions: "notifications"
1379913799- */
1380013800- notifications: Notifications.Static;
1380113801- /**
1380213802- * The omnibox API allows you to register a keyword with Firefox's address bar.
1380313803- *
1380413804- * Permissions: "manifest:omnibox"
1380513805- */
1380613806- omnibox: Omnibox.Static;
1380713807- /**
1380813808- * Use the <code>browser.pageAction</code> API to put icons inside the address bar. Page actions represent actions that can
1380913809- * be taken on the current page, but that aren't applicable to all pages.
1381013810- *
1381113811- * Permissions: "manifest:page_action"
1381213812- */
1381313813- pageAction: PageAction.Static;
1381413814- permissions: Permissions.Static;
1381513815- /**
1381613816- * PKCS#11 module management API
1381713817- *
1381813818- * Permissions: "pkcs11"
1381913819- */
1382013820- pkcs11: Pkcs11.Static;
1382113821- /**
1382213822- * Permissions: "privacy"
1382313823- */
1382413824- privacy: Privacy.Static;
1382513825- /**
1382613826- * Provides access to global proxy settings for Firefox and proxy event listeners to handle dynamic proxy implementations.
1382713827- *
1382813828- * Permissions: "proxy"
1382913829- */
1383013830- proxy: Proxy.Static;
1383113831- /**
1383213832- * Use the <code>browser.runtime</code> API to retrieve the background page, return details about the manifest,
1383313833- * and listen for and respond to events in the app or extension lifecycle. You can also use this API to convert the
1383413834- * relative path of URLs to fully-qualified URLs.
1383513835- */
1383613836- runtime: Runtime.Static;
1383713837- /**
1383813838- * Use the scripting API to execute script in different contexts.
1383913839- *
1384013840- * Permissions: "scripting"
1384113841- */
1384213842- scripting: Scripting.Static;
1384313843- /**
1384413844- * Use browser.search to interact with search engines.
1384513845- *
1384613846- * Permissions: "search"
1384713847- */
1384813848- search: Search.Static;
1384913849- /**
1385013850- * Use the <code>chrome.sessions</code> API to query and restore tabs and windows from a browsing session.
1385113851- *
1385213852- * Permissions: "sessions"
1385313853- */
1385413854- sessions: Sessions.Static;
1385513855- /**
1385613856- * Use sidebar actions to add a sidebar to Firefox.
1385713857- *
1385813858- * Permissions: "manifest:sidebar_action"
1385913859- */
1386013860- sidebarAction: SidebarAction.Static;
1386113861- /**
1386213862- * Use the <code>browser.storage</code> API to store, retrieve, and track changes to user data.
1386313863- *
1386413864- * Permissions: "storage"
1386513865- */
1386613866- storage: Storage.Static;
1386713867- /**
1386813868- * Use the browser.tabGroups API to interact with the browser's tab grouping system. You can use this API to modify,
1386913869- * and rearrange tab groups.
1387013870- *
1387113871- * Permissions: "tabGroups"
1387213872- */
1387313873- tabGroups: TabGroups.Static;
1387413874- /**
1387513875- * Use the <code>browser.tabs</code> API to interact with the browser's tab system. You can use this API to create, modify,
1387613876- * and rearrange tabs in the browser.
1387713877- */
1387813878- tabs: Tabs.Static;
1387913879- /**
1388013880- * The theme API allows customizing of visual elements of the browser.
1388113881- */
1388213882- theme: Theme.Static;
1388313883- /**
1388413884- * Use the chrome.topSites API to access the top sites that are displayed on the new tab page.
1388513885- *
1388613886- * Permissions: "topSites"
1388713887- */
1388813888- topSites: TopSites.Static;
1388913889- /**
1389013890- * Permissions: "trialML"
1389113891- */
1389213892- trial: Trial.Static;
1389313893- /**
1389413894- * Contains types used by other schemas.
1389513895- */
1389613896- types: Types.Static;
1389713897- /**
1389813898- * Permissions: "manifest:user_scripts", "userScripts"
1389913899- */
1390013900- userScripts: UserScripts.Static;
1390113901- /**
1390213902- * Use the <code>browser.webNavigation</code> API to receive notifications about the status of navigation requests
1390313903- * in-flight.
1390413904- *
1390513905- * Permissions: "webNavigation"
1390613906- */
1390713907- webNavigation: WebNavigation.Static;
1390813908- /**
1390913909- * Use the <code>browser.webRequest</code> API to observe and analyze traffic and to intercept, block,
1391013910- * or modify requests in-flight.
1391113911- *
1391213912- * Permissions: "webRequest"
1391313913- */
1391413914- webRequest: WebRequest.Static;
1391513915- /**
1391613916- * Use the <code>browser.windows</code> API to interact with browser windows. You can use this API to create, modify,
1391713917- * and rearrange windows in the browser.
1391813918- */
1391913919- windows: Windows.Static;
1392013920- }
1392113921- }
1392213922-}
1392313923-// This Source Code Form is subject to the terms of the Mozilla Public
1392413924-// License, v. 2.0. If a copy of the MPL was not distributed with this
1392513925-// file, You can obtain one at http://mozilla.org/MPL/2.0/.
1392613926-declare global {
1392713927- interface GlideModes {
1392813928- hint: "hint";
1392913929- }
1393013930-}
1393113931-// This Source Code Form is subject to the terms of the Mozilla Public
1393213932-// License, v. 2.0. If a copy of the MPL was not distributed with this
1393313933-// file, You can obtain one at http://mozilla.org/MPL/2.0/.
1393413934-declare global {
1393513935- interface ExcmdRegistry {
1393613936- jumplist_back: {};
1393713937- jumplist_forward: {};
1393813938- }
1393913939-}
1394013940-// This Source Code Form is subject to the terms of the Mozilla Public
1394113941-// License, v. 2.0. If a copy of the MPL was not distributed with this
1394213942-// file, You can obtain one at http://mozilla.org/MPL/2.0/.
1394313943-declare global {
1394413944- interface ExcmdRegistry {
1394513945- whichkey: {};
1394613946- }
1394713947-}
1394813948-1394913949-export {};
-18
glide/glide.ts
···11-// Config docs:
22-//
33-// https://glide-browser.app/config
44-//
55-// API reference:
66-//
77-// https://glide-browser.app/api
88-//
99-// Default config files can be found here:
1010-//
1111-// https://github.com/glide-browser/glide/tree/main/src/glide/browser/base/content/plugins
1212-//
1313-// Most default keymappings are defined here:
1414-//
1515-// https://github.com/glide-browser/glide/blob/main/src/glide/browser/base/content/plugins/keymaps.mts
1616-//
1717-// Try typing `glide.` and see what you can do!
1818-glide.o.hint_size = "14px";