mirror of
				https://github.com/anticensority/runet-censorship-bypass.git
				synced 2025-10-31 16:07:31 +03:00 
			
		
		
		
	Add import-export via copy-paste
This commit is contained in:
		
							parent
							
								
									89e92c28d2
								
							
						
					
					
						commit
						5d715ce693
					
				|  | @ -2,7 +2,7 @@ | ||||||
| <html style="display: none; will-change: contents, display"> | <html style="display: none; will-change: contents, display"> | ||||||
|   <head> |   <head> | ||||||
|     <meta charset="utf-8"> |     <meta charset="utf-8"> | ||||||
|     <title>Выбор провайдера PAC</title> |     <title>Настройки</title> | ||||||
|     <style> |     <style> | ||||||
|       :root { |       :root { | ||||||
|         --ribbon-color: #4169e1; |         --ribbon-color: #4169e1; | ||||||
|  | @ -316,13 +316,22 @@ | ||||||
|       } |       } | ||||||
| 
 | 
 | ||||||
|       /* TAB_3 EXCEPTIONS */ |       /* TAB_3 EXCEPTIONS */ | ||||||
|  |       #exc-address-container { | ||||||
|  |         display: flex; | ||||||
|  |         align-items: center; | ||||||
|  |         width: 100%; | ||||||
|  |       } | ||||||
|  |       #exc-address-container > a { | ||||||
|  |         border-bottom: 1px solid transparent; | ||||||
|  |         margin-left: 0.2em; | ||||||
|  |       } | ||||||
|       #exc-address { |       #exc-address { | ||||||
|  |         width: 100%; | ||||||
|         display: flex; |         display: flex; | ||||||
|         align-items: baseline; |         align-items: baseline; | ||||||
|         width: 100%; |  | ||||||
|         --exc-hieght: 1.6em; |         --exc-hieght: 1.6em; | ||||||
|         border-bottom: 1px solid var(--ribbon-color) !important; |  | ||||||
|         font-size: 1em; |         font-size: 1em; | ||||||
|  |         border-bottom: 1px solid var(--ribbon-color) !important; | ||||||
|       } |       } | ||||||
|       input#exc-editor { |       input#exc-editor { | ||||||
|         border: none; |         border: none; | ||||||
|  | @ -454,9 +463,15 @@ | ||||||
|       </section> |       </section> | ||||||
|       <section data-for="acc-exc" class="hidden-for-options-page"> |       <section data-for="acc-exc" class="hidden-for-options-page"> | ||||||
| 
 | 
 | ||||||
|         <div>Проксировать указанный сайт? |         <div>Проксировать указанный сайт?</div> | ||||||
|         <div id="exc-address"> |         <div id="exc-address-container"> | ||||||
|           <span>*.</span><input placeholder="navalny.com" list="exc-list" name="browser" id="exc-editor" style=""/><a href="../exceptions/index.html">☰</a></div> |           <div id="exc-address"> | ||||||
|  |             <span>*.</span><input placeholder="navalny.com" list="exc-list" name="browser" id="exc-editor" style=""/> | ||||||
|  |           </div> | ||||||
|  |           <a href="../exceptions/index.html" title="импорт-экспорт"><svg | ||||||
|  |             class="icon" | ||||||
|  |             ><use xlink:href="#icon-import-export"></use></svg> | ||||||
|  |           </a> | ||||||
|         </div> |         </div> | ||||||
|         <datalist id="exc-list"></datalist> |         <datalist id="exc-list"></datalist> | ||||||
|         <ol class="horizontal-list" id="exc-radio"> |         <ol class="horizontal-list" id="exc-radio"> | ||||||
|  | @ -519,6 +534,19 @@ | ||||||
|         <path d="M27.802 5.197c-2.925-3.194-7.13-5.197-11.803-5.197-8.837 0-16 7.163-16 16h3c0-7.18 5.82-13 13-13 3.844 0 7.298 1.669 9.678 4.322l-4.678 4.678h11v-11l-4.198 4.197z"/> |         <path d="M27.802 5.197c-2.925-3.194-7.13-5.197-11.803-5.197-8.837 0-16 7.163-16 16h3c0-7.18 5.82-13 13-13 3.844 0 7.298 1.669 9.678 4.322l-4.678 4.678h11v-11l-4.198 4.197z"/> | ||||||
|         <path d="M29 16c0 7.18-5.82 13-13 13-3.844 0-7.298-1.669-9.678-4.322l4.678-4.678h-11v11l4.197-4.197c2.925 3.194 7.13 5.197 11.803 5.197 8.837 0 16-7.163 16-16h-3z"/> |         <path d="M29 16c0 7.18-5.82 13-13 13-3.844 0-7.298-1.669-9.678-4.322l4.678-4.678h-11v11l4.197-4.197c2.925 3.194 7.13 5.197 11.803 5.197 8.837 0 16-7.163 16-16h-3z"/> | ||||||
|       </symbol> |       </symbol> | ||||||
|  |       <symbol id="icon-import-export" viewBox="0 0 32 32"> | ||||||
|  |         <title>import-export</title> | ||||||
|  |         <g transform="rotate(0 16 16)"> | ||||||
|  |           <path d="M7 22  h 25 v 4 h -25 v  5  l -7-7  7-7 v5 z"/> | ||||||
|  |           <path d="M25 10 h-25 v-4 h 25  v -5  l  7 7 -7 7    z"/> | ||||||
|  |         </g> | ||||||
|  | 
 | ||||||
|  |         <!-- With bars on peaks. | ||||||
|  |         <path d="M30 0h2v16h-2v-16z"></path> | ||||||
|  |         <path d="M0 16h2v16h-2v-16z"></path> | ||||||
|  |         <path d="M10 22 h 22 v 4 h -22 v 5  l -7-7 7-7 v5 z"></path> | ||||||
|  |         <path d="M22 10 h-22 v-4 h 22  v -5 l 7 7 -7 7    z"></path--> | ||||||
|  |       </symbol> | ||||||
|     </svg> |     </svg> | ||||||
|   </body> |   </body> | ||||||
| </html> | </html> | ||||||
|  |  | ||||||
|  | @ -1,9 +1,19 @@ | ||||||
| <!DOCTYPE html> | <!DOCTYPE html> | ||||||
| <html> | <html style="display: none; will-change: contents, display"> | ||||||
|   <head> |   <head> | ||||||
|     <meta charset="utf-8"> |     <meta charset="utf-8"> | ||||||
|     <title>Исключения</title> |     <title>Импорт-экспорт исключений</title> | ||||||
|     <style> |     <style> | ||||||
|  |       @font-face { | ||||||
|  |         font-family: "emoji"; | ||||||
|  |         src:url("../lib/fonts/emoji.woff") format("woff"); | ||||||
|  |         font-weight: normal; | ||||||
|  |         font-style: normal; | ||||||
|  |       } | ||||||
|  |       .emoji { | ||||||
|  |         font-family: "emoji"; | ||||||
|  |       } | ||||||
|  | 
 | ||||||
|       html, body { |       html, body { | ||||||
|         width: 100%; |         width: 100%; | ||||||
|         height: 100%; |         height: 100%; | ||||||
|  | @ -15,7 +25,6 @@ | ||||||
|         flex-direction: column; |         flex-direction: column; | ||||||
|       } |       } | ||||||
|       textarea { |       textarea { | ||||||
|         display: block; |  | ||||||
|         border-width: 1px 0 0 0; |         border-width: 1px 0 0 0; | ||||||
|         padding: 1em; |         padding: 1em; | ||||||
|         height: 100%; |         height: 100%; | ||||||
|  | @ -24,12 +33,16 @@ | ||||||
|       nav { |       nav { | ||||||
|         padding: 0.2em; |         padding: 0.2em; | ||||||
|       } |       } | ||||||
|  |       #status { | ||||||
|  |         padding-left: 1em; | ||||||
|  |       } | ||||||
|     </style> |     </style> | ||||||
|   </head> |   </head> | ||||||
|   <body> |   <body> | ||||||
|     <nav> |     <nav> | ||||||
|       <button>Сохранить в памяти</button> |       <button id="load">Загрузить <span class="emoji">⬇</span></button> | ||||||
|       <button>Считать из памяти</button> |       <button id="save">Сохранить <span class="emoji">⬆</span></button> | ||||||
|  |       <span id="status"></span> | ||||||
|     </nav> |     </nav> | ||||||
|     <textarea id="editor"></textarea> |     <textarea id="editor"></textarea> | ||||||
|     <script src="./index.js"></script> |     <script src="./index.js"></script> | ||||||
|  |  | ||||||
|  | @ -5,20 +5,65 @@ chrome.runtime.getBackgroundPage( (backgroundPage) => | ||||||
|     window, 'EXC', () => { |     window, 'EXC', () => { | ||||||
| 
 | 
 | ||||||
|       const editor = document.getElementById('editor'); |       const editor = document.getElementById('editor'); | ||||||
|       const mods = backgroundPage.apis.pacKitchen.getPacMods(); |       const loadBtn = document.getElementById('load'); | ||||||
|       editor.innerText = `# Комментарии начинаются с # и действуют до конца строки.
 |       const saveBtn = document.getElementById('save'); | ||||||
|  |       const status = document.getElementById('status'); | ||||||
|  | 
 | ||||||
|  |       loadBtn.onclick = function() { | ||||||
|  | 
 | ||||||
|  |         const mods = backgroundPage.apis.pacKitchen.getPacMods(); | ||||||
|  |         editor.value = `# Комментарии начинаются с # и действуют до конца строки.
 | ||||||
|  | # Комментарии НЕ сохраняются! | ||||||
| # Сначала идёт список проксируемых сайтов, | # Сначала идёт список проксируемых сайтов, | ||||||
| # затем ---- на отдельной строке, | # затем ==== на отдельной строке, | ||||||
| # затем исключённые сайты. | # затем исключённые сайты. | ||||||
| 
 | 
 | ||||||
| # ПРОКСИРОВАТЬ: | # ПРОКСИРОВАТЬ: | ||||||
| 
 | 
 | ||||||
| ${mods.included.join('\n')} | ${mods.included.join('\n')} | ||||||
| 
 | 
 | ||||||
| ----------------------------- | =============================== | ||||||
| # НЕ ПРОКСИРОВАТЬ: | # НЕ ПРОКСИРОВАТЬ: | ||||||
| 
 | 
 | ||||||
| ${mods.excluded.join('\n')}`;
 | ${mods.excluded.join('\n')}`;
 | ||||||
| 
 | 
 | ||||||
|  |         status.innerText = 'Успешно загружено!'; | ||||||
|  | 
 | ||||||
|  |       }; | ||||||
|  |       loadBtn.click(); | ||||||
|  | 
 | ||||||
|  |       saveBtn.onclick = function() { | ||||||
|  | 
 | ||||||
|  |         let [proxyList, dontProxyList] = editor.value | ||||||
|  |           .trim() | ||||||
|  |           .replace(/#.*/g, '') | ||||||
|  |           .split(/=+/g) | ||||||
|  |           .map( (listStr) => listStr | ||||||
|  |             .trim() | ||||||
|  |             .split(/(?:\s*\r?\n\s*)+/g) | ||||||
|  |             .filter((host) => host) | ||||||
|  |           ) | ||||||
|  |         dontProxyList = dontProxyList || []; | ||||||
|  | 
 | ||||||
|  |         const exceptions = {}; | ||||||
|  |         proxyList.forEach((host) => (exceptions[host] = true)); | ||||||
|  |         dontProxyList.forEach((host) => (exceptions[host] = false)); | ||||||
|  |         const mods = backgroundPage.apis.pacKitchen.getPacMods(); | ||||||
|  |         mods.exceptions = exceptions; | ||||||
|  |         backgroundPage.apis.pacKitchen.keepCookedNowAsync(mods, (err) => { | ||||||
|  |           if (!err) { | ||||||
|  |             status.innerText = 'Успешно сохранено!'; | ||||||
|  |             loadBtn.click(); | ||||||
|  |           } else { | ||||||
|  |             status.innerText = '<em>ОШИБКА:</em>' + err; | ||||||
|  |           } | ||||||
|  |         }); | ||||||
|  | 
 | ||||||
|  |       }; | ||||||
|  | 
 | ||||||
|  |       editor.oninput = () => (status.innerText = 'Вы держитесь там!'); | ||||||
|  | 
 | ||||||
|  |       document.documentElement.style.display = 'initial'; | ||||||
|  | 
 | ||||||
|     }) |     }) | ||||||
| ); | ); | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user