soiz1 commited on
Commit
d347e38
·
verified ·
1 Parent(s): 69b56b5

Update src/addons/addons/debug-console/userscript.js

Browse files
src/addons/addons/debug-console/userscript.js CHANGED
@@ -1,4 +1,15 @@
1
  export default async ({ addon, console, msg }) => {
 
 
 
 
 
 
 
 
 
 
 
2
  while (true) {
3
  const targetElem = await addon.tab.waitForElement(
4
  'div[class*="menu-bar_file-group"] > div:last-child:not(.sa-record)',
@@ -13,14 +24,7 @@ export default async ({ addon, console, msg }) => {
13
  erudaButton.style.marginLeft = "10px";
14
 
15
  erudaButton.addEventListener("click", () => {
16
- if (!window.eruda) {
17
- const script = document.createElement('script');
18
- script.src = 'https://cdn.jsdelivr.net/npm/eruda';
19
- script.onload = () => {
20
- eruda.init();
21
- };
22
- document.body.appendChild(script);
23
- } else {
24
  eruda.show();
25
  }
26
  });
@@ -28,4 +32,4 @@ export default async ({ addon, console, msg }) => {
28
  targetElem.parentElement.appendChild(erudaButton);
29
  }
30
  }
31
- };
 
1
  export default async ({ addon, console, msg }) => {
2
+ // ページ読み込み直後にerudaを読み込む
3
+ if (!window.eruda) {
4
+ const script = document.createElement('script');
5
+ script.src = 'https://cdn.jsdelivr.net/npm/eruda';
6
+ script.onload = () => {
7
+ eruda.init();
8
+ };
9
+ document.body.appendChild(script);
10
+ }
11
+
12
+ // ボタン挿入処理をループで監視
13
  while (true) {
14
  const targetElem = await addon.tab.waitForElement(
15
  'div[class*="menu-bar_file-group"] > div:last-child:not(.sa-record)',
 
24
  erudaButton.style.marginLeft = "10px";
25
 
26
  erudaButton.addEventListener("click", () => {
27
+ if (window.eruda) {
 
 
 
 
 
 
 
28
  eruda.show();
29
  }
30
  });
 
32
  targetElem.parentElement.appendChild(erudaButton);
33
  }
34
  }
35
+ };