回答編集履歴
3
width/heightがint型になるように
test
CHANGED
@@ -52,7 +52,7 @@
|
|
52
52
|
|
53
53
|
if(gettingWidth && gettingWidth.width){
|
54
54
|
|
55
|
-
width = gettingWidth.width
|
55
|
+
width = ~~gettingWidth.width
|
56
56
|
|
57
57
|
}
|
58
58
|
|
@@ -60,7 +60,7 @@
|
|
60
60
|
|
61
61
|
if(gettingHeight && gettingHeight.height){
|
62
62
|
|
63
|
-
height = gettingHeight.height;
|
63
|
+
height = ~~gettingHeight.height;
|
64
64
|
|
65
65
|
}
|
66
66
|
|
@@ -130,13 +130,13 @@
|
|
130
130
|
|
131
131
|
if (results[0] && results[0].width) {
|
132
132
|
|
133
|
-
width = results[0].width;
|
133
|
+
width = ~~results[0].width;
|
134
134
|
|
135
135
|
}
|
136
136
|
|
137
137
|
if (results[1] && results[1].height) {
|
138
138
|
|
139
|
-
height = results[1].height;
|
139
|
+
height = ~~results[1].height;
|
140
140
|
|
141
141
|
}
|
142
142
|
|
2
Promise版追加
test
CHANGED
@@ -92,8 +92,82 @@
|
|
92
92
|
|
93
93
|
|
94
94
|
|
95
|
+
|
96
|
+
|
97
|
+
---
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
Promise 版
|
102
|
+
|
103
|
+
```javascript
|
104
|
+
|
105
|
+
function onGot(tabInfo) {
|
106
|
+
|
107
|
+
const tabURL = tabInfo.url;
|
108
|
+
|
109
|
+
const YouTubewatchURL = 'https://www.youtube.com/watch';
|
110
|
+
|
111
|
+
if (tabInfo.url.match(YouTubewatchURL)) {
|
112
|
+
|
113
|
+
browser.windows.onCreated.addListener(() => {
|
114
|
+
|
115
|
+
newWindow(tabURL);
|
116
|
+
|
117
|
+
});
|
118
|
+
|
119
|
+
let width = 800;// 初期値
|
120
|
+
|
121
|
+
let height = 450;// 初期値
|
122
|
+
|
123
|
+
const gettingWidth = browser.storage.local.get('width');
|
124
|
+
|
125
|
+
const gettingHeight = browser.storage.local.get('height');
|
126
|
+
|
127
|
+
const popupURL = browser.extension.getURL('popup/popup.html');
|
128
|
+
|
129
|
+
Promise.all([gettingWidth, gettingHeight]).then(results => {
|
130
|
+
|
131
|
+
if (results[0] && results[0].width) {
|
132
|
+
|
133
|
+
width = results[0].width;
|
134
|
+
|
135
|
+
}
|
136
|
+
|
137
|
+
if (results[1] && results[1].height) {
|
138
|
+
|
139
|
+
height = results[1].height;
|
140
|
+
|
141
|
+
}
|
142
|
+
|
143
|
+
const creating = browser.windows.create({
|
144
|
+
|
145
|
+
url: popupURL,
|
146
|
+
|
147
|
+
type: 'panel',
|
148
|
+
|
149
|
+
width: width,// ここの数値を変えたい
|
150
|
+
|
151
|
+
height: height,// ここの数値を変えたい
|
152
|
+
|
153
|
+
});
|
154
|
+
|
155
|
+
})
|
156
|
+
|
157
|
+
}
|
158
|
+
|
159
|
+
}
|
160
|
+
|
161
|
+
```
|
162
|
+
|
163
|
+
|
164
|
+
|
95
165
|
---
|
96
166
|
|
97
167
|
|
98
168
|
|
99
169
|
if 文抜けていたのを修正しました
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
Promise版追加しました
|
1
if文のチェック抜けてたのを修正
test
CHANGED
@@ -50,11 +50,19 @@
|
|
50
50
|
|
51
51
|
const gettingWidth = await browser.storage.local.get('width');
|
52
52
|
|
53
|
+
if(gettingWidth && gettingWidth.width){
|
54
|
+
|
53
|
-
width = gettingWidth.width
|
55
|
+
width = gettingWidth.width
|
56
|
+
|
57
|
+
}
|
54
58
|
|
55
59
|
const gettingHeight = await browser.storage.local.get('height');
|
56
60
|
|
61
|
+
if(gettingHeight && gettingHeight.height){
|
62
|
+
|
57
|
-
height = gettingHeight.height;
|
63
|
+
height = gettingHeight.height;
|
64
|
+
|
65
|
+
}
|
58
66
|
|
59
67
|
const popupURL = browser.extension.getURL('popup/popup.html');
|
60
68
|
|
@@ -81,3 +89,11 @@
|
|
81
89
|
|
82
90
|
|
83
91
|
width/height の取得を await でまつようにしました。
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
---
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
if 文抜けていたのを修正しました
|