mirror of
				https://github.com/anticensority/runet-censorship-bypass.git
				synced 2025-10-31 16:07:31 +03:00 
			
		
		
		
	live updates for date
This commit is contained in:
		
							parent
							
								
									a4b83d100c
								
							
						
					
					
						commit
						6c2b2eba30
					
				|  | @ -1,22 +1,30 @@ | ||||||
| function setStatusTo(msg) { | 'use strict'; | ||||||
|  | 
 | ||||||
|  | renderPage(); | ||||||
|  | 
 | ||||||
|  | function renderPage() { | ||||||
|  |   console.log('Rendering started.'); | ||||||
|  | 
 | ||||||
|  |   function setStatusTo(msg) { | ||||||
|     var status = document.querySelector('#status'); |     var status = document.querySelector('#status'); | ||||||
|     if (msg) { |     if (msg) { | ||||||
|       status.classList.remove('off'); |       status.classList.remove('off'); | ||||||
|       status.innerHTML = msg; |       status.innerHTML = msg; | ||||||
|     } else |     } else | ||||||
|       status.classList.add('off'); |       status.classList.add('off'); | ||||||
| } |   } | ||||||
| 
 | 
 | ||||||
| chrome.runtime.getBackgroundPage( backgroundPage => { |   chrome.runtime.getBackgroundPage( backgroundPage => { | ||||||
| 
 | 
 | ||||||
|     var antiCensorRu = backgroundPage.antiCensorRu; |     var antiCensorRu = backgroundPage.antiCensorRu; | ||||||
| 
 | 
 | ||||||
|   // DATE
 |     // SET DATE
 | ||||||
| 
 | 
 | ||||||
|   var dateForUser = 'неизвестно'; |     function setDate() { | ||||||
|  |       var dateForUser = '...'; | ||||||
|       if( antiCensorRu.lastPacUpdateStamp ) { |       if( antiCensorRu.lastPacUpdateStamp ) { | ||||||
|         var diff = Date.now() - antiCensorRu.lastPacUpdateStamp; |         var diff = Date.now() - antiCensorRu.lastPacUpdateStamp; | ||||||
|     var units = ' мс' |         var units = ' мс'; | ||||||
|         var gauges = [ |         var gauges = [ | ||||||
|           [1000, ' с'], |           [1000, ' с'], | ||||||
|           [60, ' мин'], |           [60, ' мин'], | ||||||
|  | @ -39,8 +47,12 @@ chrome.runtime.getBackgroundPage( backgroundPage => { | ||||||
|       var dateElement = document.querySelector('.update-date'); |       var dateElement = document.querySelector('.update-date'); | ||||||
|       dateElement.innerText = dateForUser; |       dateElement.innerText = dateForUser; | ||||||
|       dateElement.title = new Date(antiCensorRu.lastPacUpdateStamp).toLocaleString('ru-RU'); |       dateElement.title = new Date(antiCensorRu.lastPacUpdateStamp).toLocaleString('ru-RU'); | ||||||
|  |     } | ||||||
| 
 | 
 | ||||||
|   // CLOSE
 |     setDate(); | ||||||
|  |     chrome.storage.onChanged.addListener( setDate ); | ||||||
|  | 
 | ||||||
|  |     // CLOSE BUTTON
 | ||||||
| 
 | 
 | ||||||
|     document.querySelector('.close-button').onclick = () => window.close(); |     document.querySelector('.close-button').onclick = () => window.close(); | ||||||
| 
 | 
 | ||||||
|  | @ -94,7 +106,9 @@ chrome.runtime.getBackgroundPage( backgroundPage => { | ||||||
| 
 | 
 | ||||||
|     setStatusTo(''); |     setStatusTo(''); | ||||||
|     checkChosenProvider(); |     checkChosenProvider(); | ||||||
|   if (antiCensorRu.ifNotInstalled) |     if (antiCensorRu.ifFirstInstall) | ||||||
|       triggerChosenProvider(); |       triggerChosenProvider(); | ||||||
| 
 | 
 | ||||||
| }); |   }); | ||||||
|  | 
 | ||||||
|  | } | ||||||
|  |  | ||||||
|  | @ -49,7 +49,10 @@ window.antiCensorRu = { | ||||||
| 
 | 
 | ||||||
|   get pacProvider() { return this.pacProviders[this.currentPacProviderKey] }, |   get pacProvider() { return this.pacProviders[this.currentPacProviderKey] }, | ||||||
| 
 | 
 | ||||||
|   ifNotInstalled: true, |   /* | ||||||
|  |     Offer PAC choice if this is the first time extension was installed. | ||||||
|  |   */ | ||||||
|  |   ifFirstInstall: true, | ||||||
| 
 | 
 | ||||||
|   // PROTECTED
 |   // PROTECTED
 | ||||||
| 
 | 
 | ||||||
|  | @ -60,7 +63,7 @@ window.antiCensorRu = { | ||||||
| 			if (Object.getOwnPropertyDescriptor(this, key).writable && typeof(this[key]) !== 'function') | 			if (Object.getOwnPropertyDescriptor(this, key).writable && typeof(this[key]) !== 'function') | ||||||
| 				onlySettable[key] = this[key] | 				onlySettable[key] = this[key] | ||||||
| 
 | 
 | ||||||
|     return chrome.storage.local.set(onlySettable, () => cb(chrome.runtime.lastError, onlySettable) ); |     return chrome.storage.local.set(onlySettable, () => cb && cb(chrome.runtime.lastError, onlySettable) ); | ||||||
|   }, |   }, | ||||||
| 
 | 
 | ||||||
|   pullFromStorage(cb) { |   pullFromStorage(cb) { | ||||||
|  | @ -85,7 +88,7 @@ window.antiCensorRu = { | ||||||
|         updatePacProxyIps( |         updatePacProxyIps( | ||||||
|           this.pacProvider, |           this.pacProvider, | ||||||
|           () => { |           () => { | ||||||
| 						this.ifNotInstalled = false; | 						this.ifFirstInstall = false; | ||||||
| 						this.pushToStorage(cb) | 						this.pushToStorage(cb) | ||||||
| 					} | 					} | ||||||
|       )} |       )} | ||||||
|  | @ -167,7 +170,7 @@ chrome.runtime.onInstalled.addListener( details => { | ||||||
|           //window.antiCensorRu.installPac();
 |           //window.antiCensorRu.installPac();
 | ||||||
|           break; |           break; | ||||||
|         case 'install': |         case 'install': | ||||||
|           window.antiCensorRu.ifNotInstalled = true; |           window.antiCensorRu.ifFirstInstall = true; | ||||||
|           chrome.runtime.openOptionsPage(); |           chrome.runtime.openOptionsPage(); | ||||||
|       } |       } | ||||||
|     } |     } | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user