MCPcopy
hub / github.com/philc/vimium / init

Function init

content_scripts/hud.js:37–73  ·  view source on GitHub ↗
(focusable)

Source from the content-addressed store, hash-verified

35 },
36
37 async init(focusable) {
38 await Settings.onLoaded();
39 if (focusable == null) {
40 focusable = true;
41 }
42 if (this.hudUI == null) {
43 const queryString = globalThis.vimiumDomTestsAreRunning ? "?dom_tests=true" : "";
44 this.hudUI = new UIComponent();
45 this.hudUI.load(
46 `pages/hud_page.html${queryString}`,
47 "vimium-hud-frame",
48 this.handleUIComponentMessage.bind(this),
49 );
50 }
51 // this[data.name]? data
52 if (this.tween == null) {
53 this.tween = new Tween(
54 "iframe.vimium-hud-frame.vimium-ui-component-visible",
55 this.hudUI.shadowDOM,
56 );
57 }
58 const classList = this.hudUI.iframeElement.classList;
59 if (focusable) {
60 classList.remove("vimium-non-clickable");
61 classList.add("vimium-clickable");
62 // Note(gdh1995): Chrome 74 only acknowledges text selection when a frame has been visible.
63 // See more in #3277.
64 // Note(mrmr1993): Show the HUD frame, so Firefox will actually perform the paste.
65 this.hudUI.setIframeVisible(true);
66 // Force the re-computation of styles, so Chrome sends a visibility change message to the
67 // child frame. See https://github.com/philc/vimium/pull/3277#issuecomment-487363284
68 getComputedStyle(this.hudUI.iframeElement).display;
69 } else {
70 classList.remove("vimium-non-clickable");
71 classList.add("vimium-clickable");
72 }
73 },
74
75 // duration - if omitted, the message will show until dismissed.
76 async show(text, duration) {

Callers

nothing calls this directly

Calls 3

loadMethod · 0.80
removeMethod · 0.80
setIframeVisibleMethod · 0.80

Tested by

no test coverage detected