回答編集履歴
3
width/heightがint型になるように
answer
CHANGED
@@ -25,11 +25,11 @@
|
|
25
25
|
let height = 450;// 初期値
|
26
26
|
const gettingWidth = await browser.storage.local.get('width');
|
27
27
|
if(gettingWidth && gettingWidth.width){
|
28
|
-
width = gettingWidth.width
|
28
|
+
width = ~~gettingWidth.width
|
29
29
|
}
|
30
30
|
const gettingHeight = await browser.storage.local.get('height');
|
31
31
|
if(gettingHeight && gettingHeight.height){
|
32
|
-
height = gettingHeight.height;
|
32
|
+
height = ~~gettingHeight.height;
|
33
33
|
}
|
34
34
|
const popupURL = browser.extension.getURL('popup/popup.html');
|
35
35
|
const creating = browser.windows.create({
|
@@ -64,10 +64,10 @@
|
|
64
64
|
const popupURL = browser.extension.getURL('popup/popup.html');
|
65
65
|
Promise.all([gettingWidth, gettingHeight]).then(results => {
|
66
66
|
if (results[0] && results[0].width) {
|
67
|
-
width = results[0].width;
|
67
|
+
width = ~~results[0].width;
|
68
68
|
}
|
69
69
|
if (results[1] && results[1].height) {
|
70
|
-
height = results[1].height;
|
70
|
+
height = ~~results[1].height;
|
71
71
|
}
|
72
72
|
const creating = browser.windows.create({
|
73
73
|
url: popupURL,
|
2
Promise版追加
answer
CHANGED
@@ -45,6 +45,43 @@
|
|
45
45
|
|
46
46
|
width/height の取得を await でまつようにしました。
|
47
47
|
|
48
|
+
|
48
49
|
---
|
49
50
|
|
51
|
+
Promise 版
|
52
|
+
```javascript
|
53
|
+
function onGot(tabInfo) {
|
54
|
+
const tabURL = tabInfo.url;
|
55
|
+
const YouTubewatchURL = 'https://www.youtube.com/watch';
|
56
|
+
if (tabInfo.url.match(YouTubewatchURL)) {
|
57
|
+
browser.windows.onCreated.addListener(() => {
|
58
|
+
newWindow(tabURL);
|
59
|
+
});
|
60
|
+
let width = 800;// 初期値
|
61
|
+
let height = 450;// 初期値
|
62
|
+
const gettingWidth = browser.storage.local.get('width');
|
63
|
+
const gettingHeight = browser.storage.local.get('height');
|
64
|
+
const popupURL = browser.extension.getURL('popup/popup.html');
|
65
|
+
Promise.all([gettingWidth, gettingHeight]).then(results => {
|
66
|
+
if (results[0] && results[0].width) {
|
67
|
+
width = results[0].width;
|
68
|
+
}
|
69
|
+
if (results[1] && results[1].height) {
|
70
|
+
height = results[1].height;
|
71
|
+
}
|
72
|
+
const creating = browser.windows.create({
|
73
|
+
url: popupURL,
|
74
|
+
type: 'panel',
|
75
|
+
width: width,// ここの数値を変えたい
|
76
|
+
height: height,// ここの数値を変えたい
|
77
|
+
});
|
78
|
+
})
|
79
|
+
}
|
80
|
+
}
|
81
|
+
```
|
82
|
+
|
83
|
+
---
|
84
|
+
|
50
|
-
if 文抜けていたのを修正しました
|
85
|
+
if 文抜けていたのを修正しました
|
86
|
+
|
87
|
+
Promise版追加しました
|
1
if文のチェック抜けてたのを修正
answer
CHANGED
@@ -24,9 +24,13 @@
|
|
24
24
|
let width = 800;// 初期値
|
25
25
|
let height = 450;// 初期値
|
26
26
|
const gettingWidth = await browser.storage.local.get('width');
|
27
|
+
if(gettingWidth && gettingWidth.width){
|
27
|
-
|
28
|
+
width = gettingWidth.width
|
29
|
+
}
|
28
30
|
const gettingHeight = await browser.storage.local.get('height');
|
31
|
+
if(gettingHeight && gettingHeight.height){
|
29
|
-
|
32
|
+
height = gettingHeight.height;
|
33
|
+
}
|
30
34
|
const popupURL = browser.extension.getURL('popup/popup.html');
|
31
35
|
const creating = browser.windows.create({
|
32
36
|
url: popupURL,
|
@@ -39,4 +43,8 @@
|
|
39
43
|
}
|
40
44
|
```
|
41
45
|
|
42
|
-
width/height の取得を await でまつようにしました。
|
46
|
+
width/height の取得を await でまつようにしました。
|
47
|
+
|
48
|
+
---
|
49
|
+
|
50
|
+
if 文抜けていたのを修正しました
|