Update style settings on USO without page reload
This commit is contained in:
		
							parent
							
								
									be9cfe072d
								
							
						
					
					
						commit
						2b1d874236
					
				
							
								
								
									
										18
									
								
								install.js
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								install.js
									
									
									
									
									
								
							|  | @ -122,18 +122,32 @@ function saveStyleCode(message, name, addProps) { | |||
|     if (!confirm(chrome.i18n.getMessage(message, [name]))) { | ||||
|       return; | ||||
|     } | ||||
| 
 | ||||
|     enableUpdateButton(false); | ||||
|     getResource(getStyleURL()).then(code => { | ||||
|       chrome.runtime.sendMessage( | ||||
|         Object.assign(JSON.parse(code), addProps, { | ||||
|           method: 'saveStyle', | ||||
|           reason: 'update', | ||||
|         }), | ||||
|         () => sendEvent('styleInstalledChrome') | ||||
|         style => { | ||||
|           if (style.updateUrl.includes('?')) { | ||||
|             enableUpdateButton(true); | ||||
|           } else { | ||||
|             sendEvent('styleInstalledChrome'); | ||||
|           } | ||||
|         } | ||||
|       ); | ||||
|       resolve(); | ||||
|     }); | ||||
|   }); | ||||
| 
 | ||||
|   function enableUpdateButton(state) { | ||||
|     const button = document.getElementById('update_style_button'); | ||||
|     if (button) { | ||||
|       button.style.cssText = state ? '' : | ||||
|         'pointer-events: none !important; opacity: .25 !important;'; | ||||
|     } | ||||
|   } | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user