2016-03-24 19:11:36 +03:00
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
|
|
+function() {
|
|
|
|
|
|
2016-04-10 12:39:11 +03:00
|
|
|
|
const createMenuLinkEntry = (title, tab2url) => chrome.contextMenus.create({
|
2016-03-24 19:11:36 +03:00
|
|
|
|
title: title,
|
|
|
|
|
contexts: ['browser_action'],
|
|
|
|
|
onclick: (menuInfo, tab) => Promise.resolve( tab2url( tab ) ).then( url => chrome.tabs.create({url: url}) )
|
|
|
|
|
});
|
|
|
|
|
|
2016-04-10 12:39:11 +03:00
|
|
|
|
const removeProtocol = (url) => {
|
2016-05-15 16:08:23 +03:00
|
|
|
|
|
2016-04-10 12:39:11 +03:00
|
|
|
|
const link = createLink(url);
|
|
|
|
|
return link.href.replace( link.protocol + '//', '' );
|
|
|
|
|
};
|
|
|
|
|
|
2016-05-15 16:08:23 +03:00
|
|
|
|
createMenuLinkEntry( 'Сайт доступен из-за границы? Is up?', (tab) => 'http://isup.me/'+ createLink(tab.url).hostname );
|
2016-03-24 19:11:36 +03:00
|
|
|
|
|
|
|
|
|
window.reestrUrl = 'http://reestr.rublacklist.net/search/?q=';
|
|
|
|
|
|
2016-05-15 16:08:23 +03:00
|
|
|
|
createMenuLinkEntry( 'Сайт в реестре блокировок?', (tab) => {
|
|
|
|
|
|
|
|
|
|
const ifHost = confirm('Да — искать по домену\nНет — искать по IP (зависит от местоположения)');
|
2016-04-10 12:39:11 +03:00
|
|
|
|
const hostname = createLink( tab.url ).hostname;
|
2016-05-15 16:08:23 +03:00
|
|
|
|
if (ifHost) {
|
|
|
|
|
return reestrUrl + hostname;
|
2016-04-10 12:39:11 +03:00
|
|
|
|
}
|
2016-05-15 16:08:23 +03:00
|
|
|
|
let 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
|
2016-04-10 12:39:11 +03:00
|
|
|
|
});
|
|
|
|
|
|
2016-05-15 16:08:23 +03:00
|
|
|
|
createMenuLinkEntry( 'Из кэша Google', (tab) => 'https://webcache.googleusercontent.com/search?q=cache:' + removeProtocol(tab.url) );
|
|
|
|
|
|
|
|
|
|
createMenuLinkEntry( 'Из архива archive.org', (tab) => 'https://web.archive.org/web/*/' + removeProtocol(tab.url) );
|
2016-04-10 12:39:11 +03:00
|
|
|
|
|
2016-05-15 16:08:23 +03:00
|
|
|
|
createMenuLinkEntry( 'Открыть веб прокси (не наш)', (tab) => 'https://kproxy.com' );
|
2016-04-10 12:39:11 +03:00
|
|
|
|
|
2016-05-15 16:08:23 +03:00
|
|
|
|
createMenuLinkEntry( 'Другие варианты', (tab) => {
|
|
|
|
|
|
|
|
|
|
const ifPage = confirm('Да — открыть страницу с решениями\nНет — сделать свежий снимок страницы (Screenshot Machine)');
|
|
|
|
|
return ifPage
|
|
|
|
|
? chrome.extension.getURL('./pages/other-unblocks/index.html') + '?' + removeProtocol(tab.url)
|
|
|
|
|
: `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( 'Свежий снимок страницы, Screenshot machine', (tab) => `
|
2016-04-10 12:39:11 +03:00
|
|
|
|
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>`
|
|
|
|
|
);
|
2016-05-15 16:08:23 +03:00
|
|
|
|
*/
|
2016-03-24 19:11:36 +03:00
|
|
|
|
|
2016-04-01 12:06:35 +03:00
|
|
|
|
}();
|