runet-censorship-bypass/extensions/chromium/minimalistic-pac-setter/extension/3-context-menus.js

46 lines
1.9 KiB
JavaScript
Raw Normal View History

2016-03-24 19:11:36 +03:00
'use strict';
+function() {
var 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}) )
});
2016-04-01 12:06:35 +03:00
createMenuLinkEntry( 'Сайт доступен из-за границы? Is up?', tab => 'http://isup.me/'+ getHostname(tab.url) );
2016-03-24 19:11:36 +03:00
window.reestrUrl = 'http://reestr.rublacklist.net/search/?q=';
2016-04-01 12:06:35 +03:00
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
});
createMenuLinkEntry( 'Из кэша Google', tab => 'https://webcache.googleusercontent.com/search?q=cache:'+ tab.url );
createMenuLinkEntry( 'Из архива archive.org', tab => 'https://web-beta.archive.org/web/submit?url='+ 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>`
);
2016-03-24 19:11:36 +03:00
createMenuLinkEntry( 'Разблокировать страницу по-другому', tab => chrome.extension.getURL('./pages/other-unblocks/index.html') +'?'+ tab.url );
2016-04-01 12:06:35 +03:00
}();