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

@ -17,12 +17,12 @@
window.antiCensorRu = {
// PUBLIC
version: chrome.runtime.getManifest().version,
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',
@ -109,7 +109,7 @@ window.antiCensorRu = {
(err, res) => {
if (err)
return reject(err);
this.lastPacUpdateStamp = Date.now();
this.ifFirstInstall = false;
this.setAlarms();

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() {
@ -38,7 +38,7 @@ function getHostname(url) {
}
chrome.tabs.onUpdated.addListener( onTabUpdate );
function isInsideTabWithIp(requestDetails) {
return requestDetails.tabId !== -1 && requestDetails.ip
}
@ -72,7 +72,7 @@ function getHostname(url) {
}
)
);
return true;
function updateTitle(requestDetails, cb) {
@ -82,8 +82,8 @@ function getHostname(url) {
title => {
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);
@ -109,7 +109,7 @@ function getHostname(url) {
if (hostsProxiesPair[0].indexOf(hostname) === -1) {
title = title.replace(proxyTitle, indent + hostname +'\n'+ proxyTitle);
ifShouldUpdateTitle = true;
var _cb = cb;
cb = () => chrome.browserAction.getBadgeText(
{tabId: requestDetails.tabId},
@ -144,4 +144,4 @@ function getHostname(url) {
{ urls: ['<all_urls>'] }
);
}();
}();

View File

@ -2,44 +2,49 @@
+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 );
if (ifIp) {
var ip = window.tabWithError2ip[tab.id];
if ( /^[.\d]+$/.test(hostname) || /^[:\dA-Fa-f]+$/.test(hostname) )
ip = hostname;
return ip
? reestrUrl + ip
: chrome.extension.getURL('./pages/is-ip-blocked/index.html') +'?'+ hostname
}
return reestrUrl + hostname
});
const ifIp = confirm('Да = искать по IP.\nНет = искать по домену.');
const hostname = createLink( tab.url ).hostname;
if (ifIp) {
var ip = window.tabWithError2ip[tab.id];
if ( /^[.\d]+$/.test(hostname) || /^[:\dA-Fa-f]+$/.test(hostname) )
ip = hostname;
return ip
? reestrUrl + ip
: chrome.extension.getURL('./pages/is-ip-blocked/index.html') +'?'+ 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 => `
data:text/html;charset=utf8,<title>Чиииз...</title>
<form method="POST" action="https://screenshotmachine.com/processor.php">
<input name="urlparam" value="${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( 'Свежий снимок страницы, 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="${ 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) );
}();