summaryrefslogtreecommitdiffstats
path: root/typescript/src/setContentEditable.ts
blob: ebfe4230e91eb4565c95ea72d41fa0ea237ac771 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/* SPDX-License-Identifier: AGPL-3.0-or-later */

import podsClassName from "./podsClassName.js";
import typescriptNever from "./typescriptNever.js";

export default (): void => {
  try {
    Array.from(
      document.querySelectorAll(
        `html > body > div#__next > div > main > main > div.${podsClassName} > div > div > section > section > div > div > div > details > div`
      )
    )
      .filter((element: Element): boolean => {
        if (element instanceof HTMLDivElement) {
          return true;
        } else if (element instanceof Element) {
          console.warn({ element });
        } else {
          typescriptNever(element);
        }

        return false;
      })
      .map((element: Element): void => {
        if (element instanceof Element) {
          element.setAttribute("contenteditable", "");
        } else {
          typescriptNever(element);
        }
      });
  } catch (error) {
    console.warn({ error });
  }
};