@@ -40,6 +40,7 @@ const generateWithTitleEle = document.getElementById("generate-with-title");
4040const titleWordLimitLabelEle = document . getElementById ( "title-word-limit-label" ) ;
4141const titleWordLimitEle = document . getElementById ( "title-word-limit" ) ;
4242const message2Ele = document . getElementById ( "message2" ) ;
43+ const autoInsertPopupEle = document . getElementById ( "auto-insert-popup" ) ;
4344
4445// Get the browser storage
4546const browserStorage = browser . storage . local ;
@@ -164,7 +165,21 @@ titleWordLimitEle.oninput = (event) => {
164165 } ;
165166}
166167
167- function setCurrentChoice ( { chhotoHost, chhotoKey, allowedProtocols, generateWithTitle, titleWordLimit } ) {
168+ // Automatically insert long URL into popup
169+ autoInsertPopupEle . onclick = ( ) => {
170+ // Get browser storage
171+ browserStorage . get ( "autoInsertPopup" ) . then ( ( { autoInsertPopup } ) => {
172+ // Get value
173+ autoInsertPopup = autoInsertPopupEle . checked ;
174+
175+ // Save value
176+ browserStorage . set ( { autoInsertPopup } ) ;
177+ } ) ;
178+ } ;
179+
180+
181+
182+ function setCurrentChoice ( { chhotoHost, chhotoKey, allowedProtocols, generateWithTitle, titleWordLimit, autoInsertPopup } ) {
168183 hostKeyEle . value = chhotoHost || "" ;
169184 apiKeyEle . value = chhotoKey || "" ;
170185
@@ -191,16 +206,25 @@ function setCurrentChoice({ chhotoHost, chhotoKey, allowedProtocols, generateWit
191206 browserStorage . set ( { titleWordLimit : titleWordLimit } ) ;
192207 }
193208
209+ // If autoInsertPopup is undefined, set the default value
210+ if ( autoInsertPopup === undefined ) {
211+ autoInsertPopup = false ;
212+ browserStorage . set ( { autoInsertPopup : autoInsertPopup } ) ;
213+ }
214+
194215 // Initialize a list of protocols that are allowed if unset. This needs
195216 // to be synced with the initialization code in background.js#validateURL.
196217 allowedProtocols = new Set ( allowedProtocols ) ;
197218
219+
220+ // Update the checkboxes to display the correct value
198221 AllowHttpEle . checked = allowedProtocols . has ( "http:" ) ;
199222 AllowHttpsEle . checked = allowedProtocols . has ( "https:" ) ;
200223 AllowFileEle . checked = allowedProtocols . has ( "file:" ) ;
201224 AllowFtpEle . checked = allowedProtocols . has ( "ftp:" ) ;
202225
203226 generateWithTitleEle . checked = generateWithTitle ;
227+ autoInsertPopupEle . checked = autoInsertPopup ;
204228
205229 // Set default display
206230 let display = "none" ;
0 commit comments