@@ -46,7 +46,9 @@ export class UIManager {
4646 const editLink = document . createElement ( "a" ) ;
4747 editLink . className = "btn-text icon-btn" ;
4848 editLink . title = "Open in editor" ;
49- editLink . href = chrome . runtime . getURL ( "editor/editor.html" ) ;
49+ editLink . href = `${ chrome . runtime . getURL (
50+ "editor/editor.html"
51+ ) } ?id=${ this . editor . currentScript . id } `;
5052 editLink . target = "_blank" ;
5153 editLink . innerHTML = `<i data-feather="edit-2" width="16" height="16"></i>` ;
5254 // Insert before the action button
@@ -148,7 +150,8 @@ export class UIManager {
148150 const codePreview = this . createCodePreview (
149151 data . code ,
150152 data . actions ,
151- data . isScript
153+ data . isScript ,
154+ data . name
152155 ) ;
153156 content . appendChild ( codePreview ) ;
154157 }
@@ -157,7 +160,7 @@ export class UIManager {
157160 return messageEl ;
158161 }
159162
160- createCodePreview ( code , actions , isScript ) {
163+ createCodePreview ( code , actions , isScript , name ) {
161164 const preview = document . createElement ( "div" ) ;
162165 preview . className = "code-preview" ;
163166
@@ -193,7 +196,9 @@ export class UIManager {
193196 const editLink = document . createElement ( "a" ) ;
194197 editLink . className = "btn-text icon-btn" ;
195198 editLink . title = "Open in editor" ;
196- editLink . href = chrome . runtime . getURL ( "editor/editor.html" ) ;
199+ editLink . href = `${ chrome . runtime . getURL ( "editor/editor.html" ) } ?id=${
200+ this . editor . currentScript . id
201+ } `;
197202 editLink . target = "_blank" ;
198203 editLink . innerHTML = `<i data-feather="edit-2" width="16" height="16"></i>` ;
199204 actionsDiv . appendChild ( editLink ) ;
@@ -222,7 +227,7 @@ export class UIManager {
222227 code
223228 ) ;
224229 } else {
225- this . editor . userscriptHandler . createUserscript ( code ) ;
230+ this . editor . userscriptHandler . createUserscript ( code , name ) ;
226231 }
227232 } ) ;
228233
@@ -331,13 +336,13 @@ export class UIManager {
331336 const selector = document . createElement ( "div" ) ;
332337 selector . className = "script-selector" ;
333338
334- scripts . forEach ( ( scriptName ) => {
339+ scripts . forEach ( ( script ) => {
335340 const item = document . createElement ( "div" ) ;
336341 item . className = "script-item" ;
337- item . textContent = scriptName ;
342+ item . textContent = script . name ;
338343 item . addEventListener ( "click" , ( ) => {
339344 const atIndex = input . value . lastIndexOf ( "@" ) ;
340- input . value = input . value . substring ( 0 , atIndex + 1 ) + scriptName + " " ;
345+ input . value = input . value . substring ( 0 , atIndex + 1 ) + script . name + " " ;
341346 this . hideScriptSelector ( ) ;
342347 input . focus ( ) ;
343348 } ) ;
0 commit comments