v1.0
This commit is contained in:
		
							
								
								
									
										
											BIN
										
									
								
								icons/128x128.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								icons/128x128.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 5.0 KiB | 
							
								
								
									
										
											BIN
										
									
								
								icons/16x16.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								icons/16x16.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 998 B | 
							
								
								
									
										
											BIN
										
									
								
								icons/48x48.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								icons/48x48.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 524 B | 
							
								
								
									
										27
									
								
								manifest.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								manifest.json
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,27 @@ | |||||||
|  | { | ||||||
|  |   "manifest_version": 3, | ||||||
|  |   "name": "Т-Банк Экспорт", | ||||||
|  |   "version": "1.0", | ||||||
|  |   "description": "", | ||||||
|  |   "icons": { | ||||||
|  |     "16": "/icons/16x16.png", | ||||||
|  |     "48": "/icons/48x48.png", | ||||||
|  |     "128": "/icons/128x128.png" | ||||||
|  |   }, | ||||||
|  |   "action": { | ||||||
|  |     "default_title": "Скачать выписку" | ||||||
|  |   }, | ||||||
|  |   "background": { | ||||||
|  |     "service_worker": "/service_worker.js" | ||||||
|  |   }, | ||||||
|  |   "host_permissions": [ | ||||||
|  |     "*://tbank.ru/*", | ||||||
|  |     "*://www.tbank.ru/*" | ||||||
|  |   ], | ||||||
|  |   "permissions": [ | ||||||
|  |     "cookies", | ||||||
|  |     "activeTab", | ||||||
|  |     "downloads", | ||||||
|  |     "scripting" | ||||||
|  |   ] | ||||||
|  | } | ||||||
							
								
								
									
										42
									
								
								service_worker.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										42
									
								
								service_worker.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,42 @@ | |||||||
|  | const formats = { | ||||||
|  |     csv: 'csv', | ||||||
|  | } | ||||||
|  |  | ||||||
|  | const downloadStatement = (format, sessionId, start, end) => { | ||||||
|  |     const downloadUrl = new URL('https://www.tbank.ru/api/common/v1/export_operations/') | ||||||
|  |  | ||||||
|  |     downloadUrl.searchParams.set('format', format) | ||||||
|  |     downloadUrl.searchParams.set('sessionid', sessionId) | ||||||
|  |     downloadUrl.searchParams.set('start', start) | ||||||
|  |     downloadUrl.searchParams.set('end', end) | ||||||
|  |  | ||||||
|  |     chrome.downloads.download({ | ||||||
|  |         url: downloadUrl.toString(), | ||||||
|  |     }) | ||||||
|  | } | ||||||
|  |  | ||||||
|  | chrome.action.onClicked.addListener(async (tab) => { | ||||||
|  |     chrome.cookies.get( | ||||||
|  |         { | ||||||
|  |             url: tab.url, | ||||||
|  |             name: "psid", | ||||||
|  |         }, | ||||||
|  |         async (cookie) => { | ||||||
|  |             const psId = cookie.value | ||||||
|  |  | ||||||
|  |             const now = new Date() | ||||||
|  |             const year = now.getUTCFullYear() | ||||||
|  |             const month = now.getUTCMonth() | ||||||
|  |  | ||||||
|  |             const start = Date.UTC(year, month, 1) | ||||||
|  |             const end = Date.UTC(year, month + 1, 0, 23, 59, 59, 0) | ||||||
|  |  | ||||||
|  |             downloadStatement( | ||||||
|  |                 formats.csv, | ||||||
|  |                 psId, | ||||||
|  |                 start.toString(), | ||||||
|  |                 end.toString(), | ||||||
|  |             ) | ||||||
|  |         } | ||||||
|  |     ) | ||||||
|  | }) | ||||||
		Reference in New Issue
	
	Block a user