fixed urls in context menus

This commit is contained in:
Ilya Ig. Petrov 2016-04-10 10:39:11 +01:00
parent 004ca19087
commit 04d5dd2346
3 changed files with 46 additions and 41 deletions

View File

@ -22,7 +22,7 @@ window.antiCensorRu = {
pacProviders: {
Антизапрет: {
pacUrl: 'http://antizapret.prostovpn.org/proxy.pac',
pacUrl: 'https://antizapret.prostovpn.org/proxy.pac',
proxyHosts: ['proxy.antizapret.prostovpn.org'],
proxyIps: {
'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-ZCVSvuNWf0WGczNmJzY3gzMWc',
pacUrl: 'https://drive.google.com/uc?export=download&id=0B-ZCVSvuNWf0akpCOURNS2VCTmc',
//pacUrl: 'https://drive.google.com/uc?export=download&id=0B-ZCVSvuNWf0WGczNmJzY3gzMWc', // Beta
proxyHosts: ['proxy.antizapret.prostovpn.org', 'gw2.anticenz.org'],
proxyIps: {
'195.154.110.37': 'proxy.antizapret.prostovpn.org',

View File

@ -14,10 +14,10 @@
window.tabWithError2ip = {}; // For errors only: Error? -> Check this IP!
function getHostname(url) {
var a = document.createElement('a');
function createLink(url) {
const a = document.createElement('a');
a.href = url;
return a.hostname;
return a;
}
+function() {
@ -83,7 +83,7 @@ function getHostname(url) {
var ifTitleSetAlready = /\n/.test(title);
var proxyHost = window.antiCensorRu.pacProvider.proxyIps[ requestDetails.ip ];
var hostname = getHostname( requestDetails.url );
var hostname = createLink( requestDetails.url ).hostname;
var ifShouldUpdateTitle = false;
var indent = ' ';
@ -99,7 +99,7 @@ function getHostname(url) {
});
} else {
var hostsProxiesPair = title.split(proxyTitle);
const hostsProxiesPair = title.split(proxyTitle);
if (hostsProxiesPair[1].indexOf(proxyHost) === -1) {
title = title.replace(hostsProxiesPair[1], hostsProxiesPair[1] +'\n'+ indent + proxyHost);

View File

@ -2,19 +2,24 @@
+function() {
var createMenuLinkEntry = (title, tab2url) => chrome.contextMenus.create({
const createMenuLinkEntry = (title, tab2url) => chrome.contextMenus.create({
title: title,
contexts: ['browser_action'],
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=';
createMenuLinkEntry( 'Сайт в реестре блокировок?', tab => {
const ifIp = confirm('Да = искать по IP.\nНет = искать по домену.');
const hostname = getHostname( tab.url );
const hostname = createLink( tab.url ).hostname;
if (ifIp) {
var ip = window.tabWithError2ip[tab.id];
if ( /^[.\d]+$/.test(hostname) || /^[:\dA-Fa-f]+$/.test(hostname) )
@ -26,20 +31,20 @@
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 => `
data:text/html;charset=utf8,<title>Чиииз...</title>
createMenuLinkEntry( 'Свежий снимок страницы, Screenshot machine', tab => `
data:text/html;charset=utf8,<title>Screenshot machine</title>
<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="cacheLimit" value="0" type="hidden">
</form>
<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) );
}();