mirror of
				https://github.com/anticensority/runet-censorship-bypass.git
				synced 2025-10-30 23:47:56 +03:00 
			
		
		
		
	fixed urls in context menus
This commit is contained in:
		
							parent
							
								
									004ca19087
								
							
						
					
					
						commit
						04d5dd2346
					
				|  | @ -17,12 +17,12 @@ | ||||||
| window.antiCensorRu = { | window.antiCensorRu = { | ||||||
| 
 | 
 | ||||||
|   // PUBLIC
 |   // PUBLIC
 | ||||||
|    | 
 | ||||||
|   version: chrome.runtime.getManifest().version, |   version: chrome.runtime.getManifest().version, | ||||||
| 
 | 
 | ||||||
|   pacProviders: { |   pacProviders: { | ||||||
|     Антизапрет: { |     Антизапрет: { | ||||||
|       pacUrl: 'http://antizapret.prostovpn.org/proxy.pac', |       pacUrl: 'https://antizapret.prostovpn.org/proxy.pac', | ||||||
|       proxyHosts: ['proxy.antizapret.prostovpn.org'], |       proxyHosts: ['proxy.antizapret.prostovpn.org'], | ||||||
|       proxyIps: { |       proxyIps: { | ||||||
|         '195.154.110.37': 'proxy.antizapret.prostovpn.org', |         '195.154.110.37': 'proxy.antizapret.prostovpn.org', | ||||||
|  | @ -37,8 +37,8 @@ window.antiCensorRu = { | ||||||
|       } |       } | ||||||
|     }, |     }, | ||||||
|     Оба_и_на_свитчах: { |     Оба_и_на_свитчах: { | ||||||
|       //pacUrl: 'https://drive.google.com/uc?export=download&id=0B-ZCVSvuNWf0akpCOURNS2VCTmc',
 |       pacUrl: 'https://drive.google.com/uc?export=download&id=0B-ZCVSvuNWf0akpCOURNS2VCTmc', | ||||||
|       pacUrl: 'https://drive.google.com/uc?export=download&id=0B-ZCVSvuNWf0WGczNmJzY3gzMWc', |       //pacUrl: 'https://drive.google.com/uc?export=download&id=0B-ZCVSvuNWf0WGczNmJzY3gzMWc', // Beta
 | ||||||
|       proxyHosts: ['proxy.antizapret.prostovpn.org', 'gw2.anticenz.org'], |       proxyHosts: ['proxy.antizapret.prostovpn.org', 'gw2.anticenz.org'], | ||||||
|       proxyIps: { |       proxyIps: { | ||||||
|         '195.154.110.37': 'proxy.antizapret.prostovpn.org', |         '195.154.110.37': 'proxy.antizapret.prostovpn.org', | ||||||
|  | @ -109,7 +109,7 @@ window.antiCensorRu = { | ||||||
|         (err, res) => { |         (err, res) => { | ||||||
|           if (err) |           if (err) | ||||||
|             return reject(err); |             return reject(err); | ||||||
|   | 
 | ||||||
|           this.lastPacUpdateStamp = Date.now(); |           this.lastPacUpdateStamp = Date.now(); | ||||||
|           this.ifFirstInstall = false; |           this.ifFirstInstall = false; | ||||||
|           this.setAlarms(); |           this.setAlarms(); | ||||||
|  |  | ||||||
|  | @ -14,10 +14,10 @@ | ||||||
| 
 | 
 | ||||||
| window.tabWithError2ip = {}; // For errors only: Error? -> Check this IP!
 | window.tabWithError2ip = {}; // For errors only: Error? -> Check this IP!
 | ||||||
| 
 | 
 | ||||||
| function getHostname(url) { | function createLink(url) { | ||||||
|   var a = document.createElement('a'); |   const a = document.createElement('a'); | ||||||
|   a.href = url; |   a.href = url; | ||||||
|   return a.hostname; |   return a; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| +function() { | +function() { | ||||||
|  | @ -38,7 +38,7 @@ function getHostname(url) { | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   chrome.tabs.onUpdated.addListener( onTabUpdate ); |   chrome.tabs.onUpdated.addListener( onTabUpdate ); | ||||||
|    | 
 | ||||||
|   function isInsideTabWithIp(requestDetails) { |   function isInsideTabWithIp(requestDetails) { | ||||||
|     return requestDetails.tabId !== -1 && requestDetails.ip |     return requestDetails.tabId !== -1 && requestDetails.ip | ||||||
|   } |   } | ||||||
|  | @ -72,7 +72,7 @@ function getHostname(url) { | ||||||
|         } |         } | ||||||
|       ) |       ) | ||||||
|     ); |     ); | ||||||
|      | 
 | ||||||
|     return true; |     return true; | ||||||
| 
 | 
 | ||||||
|     function updateTitle(requestDetails, cb) { |     function updateTitle(requestDetails, cb) { | ||||||
|  | @ -82,8 +82,8 @@ function getHostname(url) { | ||||||
|         title => { |         title => { | ||||||
|           var ifTitleSetAlready = /\n/.test(title); |           var ifTitleSetAlready = /\n/.test(title); | ||||||
|           var proxyHost = window.antiCensorRu.pacProvider.proxyIps[ requestDetails.ip ]; |           var proxyHost = window.antiCensorRu.pacProvider.proxyIps[ requestDetails.ip ]; | ||||||
|            | 
 | ||||||
|           var hostname = getHostname( requestDetails.url ); |           var hostname = createLink( requestDetails.url ).hostname; | ||||||
| 
 | 
 | ||||||
|           var ifShouldUpdateTitle = false; |           var ifShouldUpdateTitle = false; | ||||||
|           var indent = '  '; |           var indent = '  '; | ||||||
|  | @ -99,7 +99,7 @@ function getHostname(url) { | ||||||
|             }); |             }); | ||||||
| 
 | 
 | ||||||
|           } else { |           } else { | ||||||
|             var hostsProxiesPair = title.split(proxyTitle); |             const hostsProxiesPair = title.split(proxyTitle); | ||||||
| 
 | 
 | ||||||
|             if (hostsProxiesPair[1].indexOf(proxyHost) === -1) { |             if (hostsProxiesPair[1].indexOf(proxyHost) === -1) { | ||||||
|               title = title.replace(hostsProxiesPair[1], hostsProxiesPair[1] +'\n'+ indent + proxyHost); |               title = title.replace(hostsProxiesPair[1], hostsProxiesPair[1] +'\n'+ indent + proxyHost); | ||||||
|  | @ -109,7 +109,7 @@ function getHostname(url) { | ||||||
|             if (hostsProxiesPair[0].indexOf(hostname) === -1) { |             if (hostsProxiesPair[0].indexOf(hostname) === -1) { | ||||||
|               title = title.replace(proxyTitle, indent + hostname +'\n'+ proxyTitle); |               title = title.replace(proxyTitle, indent + hostname +'\n'+ proxyTitle); | ||||||
|               ifShouldUpdateTitle = true; |               ifShouldUpdateTitle = true; | ||||||
|                | 
 | ||||||
|               var _cb = cb; |               var _cb = cb; | ||||||
|               cb = () => chrome.browserAction.getBadgeText( |               cb = () => chrome.browserAction.getBadgeText( | ||||||
|                 {tabId: requestDetails.tabId}, |                 {tabId: requestDetails.tabId}, | ||||||
|  | @ -144,4 +144,4 @@ function getHostname(url) { | ||||||
|     { urls: ['<all_urls>'] } |     { urls: ['<all_urls>'] } | ||||||
|   ); |   ); | ||||||
| 
 | 
 | ||||||
| }(); | }(); | ||||||
|  |  | ||||||
|  | @ -2,44 +2,49 @@ | ||||||
| 
 | 
 | ||||||
| +function() { | +function() { | ||||||
| 
 | 
 | ||||||
|   var createMenuLinkEntry = (title, tab2url) => chrome.contextMenus.create({ |   const createMenuLinkEntry = (title, tab2url) => chrome.contextMenus.create({ | ||||||
|     title: title, |     title: title, | ||||||
|     contexts: ['browser_action'], |     contexts: ['browser_action'], | ||||||
|     onclick: (menuInfo, tab) => Promise.resolve( tab2url( tab ) ).then( url => chrome.tabs.create({url: url}) ) |     onclick: (menuInfo, tab) => Promise.resolve( tab2url( tab ) ).then( url => chrome.tabs.create({url: url}) ) | ||||||
|   }); |   }); | ||||||
| 
 | 
 | ||||||
|   createMenuLinkEntry( 'Сайт доступен из-за границы? Is up?', tab => 'http://isup.me/'+ getHostname(tab.url) ); |   const removeProtocol = (url) => { | ||||||
|  |     const link = createLink(url); | ||||||
|  |     return link.href.replace( link.protocol + '//', '' ); | ||||||
|  |   }; | ||||||
|  | 
 | ||||||
|  |   createMenuLinkEntry( 'Сайт доступен из-за границы? Is up?', tab => 'http://isup.me/'+ createLink(tab.url).hostname ); | ||||||
| 
 | 
 | ||||||
|   window.reestrUrl = 'http://reestr.rublacklist.net/search/?q='; |   window.reestrUrl = 'http://reestr.rublacklist.net/search/?q='; | ||||||
| 
 | 
 | ||||||
|   createMenuLinkEntry( 'Сайт в реестре блокировок?', tab => { |   createMenuLinkEntry( 'Сайт в реестре блокировок?', tab => { | ||||||
| 		const ifIp = confirm('Да = искать по IP.\nНет = искать по домену.'); |     const ifIp = confirm('Да = искать по IP.\nНет = искать по домену.'); | ||||||
| 		const hostname = getHostname( tab.url ); |     const hostname = createLink( tab.url ).hostname; | ||||||
| 		if (ifIp) { |     if (ifIp) { | ||||||
| 			var ip = window.tabWithError2ip[tab.id]; |       var ip = window.tabWithError2ip[tab.id]; | ||||||
| 			if ( /^[.\d]+$/.test(hostname) || /^[:\dA-Fa-f]+$/.test(hostname) ) |       if ( /^[.\d]+$/.test(hostname) || /^[:\dA-Fa-f]+$/.test(hostname) ) | ||||||
| 				ip = hostname; |         ip = hostname; | ||||||
| 			return ip |       return ip | ||||||
| 				? reestrUrl + ip |         ? reestrUrl + ip | ||||||
| 				: chrome.extension.getURL('./pages/is-ip-blocked/index.html') +'?'+ hostname |         : chrome.extension.getURL('./pages/is-ip-blocked/index.html') +'?'+ hostname | ||||||
| 		} |     } | ||||||
| 		return reestrUrl + hostname |     return reestrUrl + hostname | ||||||
| 	}); |   }); | ||||||
| 
 | 
 | ||||||
|   createMenuLinkEntry( 'Из кэша Google', tab => 'https://webcache.googleusercontent.com/search?q=cache:'+ tab.url ); |   createMenuLinkEntry( 'Из кэша Google', tab => 'https://webcache.googleusercontent.com/search?q=cache:' + removeProtocol(tab.url) ); | ||||||
| 
 | 
 | ||||||
|   createMenuLinkEntry( 'Из архива archive.org', tab => 'https://web-beta.archive.org/web/submit?url='+ tab.url ); |   createMenuLinkEntry( 'Из архива archive.org', tab => 'https://web.archive.org/web/*/' + removeProtocol(tab.url) ); | ||||||
| 
 | 
 | ||||||
| 	createMenuLinkEntry( 'Свежий снимок страницы', tab => ` |   createMenuLinkEntry( 'Свежий снимок страницы, Screenshot machine', tab => ` | ||||||
| 		data:text/html;charset=utf8,<title>Чиииз...</title> |     data:text/html;charset=utf8,<title>Screenshot machine</title> | ||||||
| 			<form method="POST" action="https://screenshotmachine.com/processor.php"> |         <form method="POST" action="https://screenshotmachine.com/processor.php"> | ||||||
| 				<input name="urlparam" value="${tab.url}" type="hidden"> |             <input name="urlparam" value="${ removeProtocol(tab.url) }" type="hidden"> | ||||||
| 				<input name="size" value="F" type="hidden"> |             <input name="size" value="F" type="hidden"> | ||||||
| 				<input name="cacheLimit" value="0" type="hidden"> |             <input name="cacheLimit" value="0" type="hidden"> | ||||||
| 			</form> |         </form> | ||||||
| 			<script>document.forms[0].submit()</script>` |         <script>document.forms[0].submit()</script>` | ||||||
| 	); |   ); | ||||||
| 
 | 
 | ||||||
|   createMenuLinkEntry( 'Разблокировать страницу по-другому', tab => chrome.extension.getURL('./pages/other-unblocks/index.html') +'?'+ tab.url ); |   createMenuLinkEntry( 'Разблокировать страницу по-другому', tab => chrome.extension.getURL('./pages/other-unblocks/index.html') +'?'+ removeProtocol(tab.url) ); | ||||||
| 
 | 
 | ||||||
| }(); | }(); | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user