code cosmetics
This commit is contained in:
		
							parent
							
								
									738788f289
								
							
						
					
					
						commit
						e0124f66ba
					
				|  | @ -291,22 +291,20 @@ $('#file-all-styles').onclick = () => { | ||||||
|       return styleDigest ? Object.assign({styleDigest}, style) : style; |       return styleDigest ? Object.assign({styleDigest}, style) : style; | ||||||
|     }); |     }); | ||||||
|     const text = JSON.stringify(styles, null, '\t'); |     const text = JSON.stringify(styles, null, '\t'); | ||||||
|     const fileName = generateFileName(); |  | ||||||
| 
 |  | ||||||
|     const url = 'data:text/plain;charset=utf-8,' + encodeURIComponent(text); |     const url = 'data:text/plain;charset=utf-8,' + encodeURIComponent(text); | ||||||
|  |     return url; | ||||||
|     // for long URLs; https://github.com/schomery/stylish-chrome/issues/13#issuecomment-284582600
 |     // for long URLs; https://github.com/schomery/stylish-chrome/issues/13#issuecomment-284582600
 | ||||||
|     fetch(url) |   }).then(fetch) | ||||||
|     .then(res => res.blob()) |     .then(res => res.blob()) | ||||||
|     .then(blob => { |     .then(blob => { | ||||||
|       const objectURL = URL.createObjectURL(blob); |       const objectURL = URL.createObjectURL(blob); | ||||||
|       Object.assign(document.createElement('a'), { |       Object.assign(document.createElement('a'), { | ||||||
|         download: fileName, |         download: generateFileName(), | ||||||
|         href: objectURL, |         href: objectURL, | ||||||
|         type: 'application/json', |         type: 'application/json', | ||||||
|       }).dispatchEvent(new MouseEvent('click')); |       }).dispatchEvent(new MouseEvent('click')); | ||||||
|       setTimeout(() => URL.revokeObjectURL(objectURL)); |       setTimeout(() => URL.revokeObjectURL(objectURL)); | ||||||
|     }); |     }); | ||||||
|   }); |  | ||||||
| 
 | 
 | ||||||
|   function generateFileName() { |   function generateFileName() { | ||||||
|     const today = new Date(); |     const today = new Date(); | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user