mirror of
https://github.com/anticensority/runet-censorship-bypass.git
synced 2024-11-24 02:13:43 +03:00
Add popup available on error
This commit is contained in:
parent
f50301febc
commit
b0ab93d921
|
@ -0,0 +1,69 @@
|
|||
'use strict';
|
||||
|
||||
{
|
||||
|
||||
window.apis.menus = {
|
||||
|
||||
getItemsAsObject: () => ({
|
||||
|
||||
hostTracker: {
|
||||
title: 'Сайт доступен из-за границы? Is up?',
|
||||
getUrl: (blockedUrl) => `data:text/html;charset=utf8,<title>Запрашиваю...</title>
|
||||
<form class='tracker-form' method='POST'
|
||||
action='https://www.host-tracker.com/ru/InstantCheck/Create'>
|
||||
<input name='InstantCheckUrl' value='${new URL(blockedUrl).hostname}'
|
||||
type='hidden'>
|
||||
</form>
|
||||
<script>document.querySelector('.tracker-form').submit()<\/script>`,
|
||||
order: 0,
|
||||
},
|
||||
|
||||
antizapretInfo: {
|
||||
title: 'Сайт в реестре блокировок?',
|
||||
getUrl: (blockedUrl) => 'https://antizapret.info/index.php?search=' + new URL(blockedUrl).hostname,
|
||||
order: 1,
|
||||
},
|
||||
|
||||
archiveOrg: {
|
||||
title: 'Из архива archive.org',
|
||||
getUrl: (blockedUrl) => 'https://web.archive.org/web/*/' + blockedUrl,
|
||||
order: 2,
|
||||
},
|
||||
|
||||
googleTranslate: {
|
||||
title: 'Через Google Translate',
|
||||
getUrl: (blockedUrl) => (
|
||||
'https://translate.google.com/translate?hl=&sl=en&tl=ru&anno=2&sandbox=1&u=' + blockedUrl),
|
||||
order: 3,
|
||||
},
|
||||
|
||||
otherUnblock: {
|
||||
title: 'Разблокировать по-другому',
|
||||
getUrl: (blockedUrl) => ('https://rebrand.ly/ac-unblock#' + blockedUrl),
|
||||
order: 4,
|
||||
},
|
||||
|
||||
support: {
|
||||
title: 'Документация / Помощь / Поддержка',
|
||||
getUrl: (blockedUrl) => 'https://rebrand.ly/ac-support',
|
||||
order: 99,
|
||||
},
|
||||
|
||||
}),
|
||||
|
||||
getItemsAsArray: function() {
|
||||
|
||||
const itemsObj = this.getItemsAsObject();
|
||||
return Object.keys(itemsObj).reduce((acc, key) => {
|
||||
|
||||
acc.push(itemsObj[key]);
|
||||
return acc;
|
||||
|
||||
}, [])
|
||||
.sort((a, b) => a.order - b.order);
|
||||
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
'use strict';
|
||||
|
||||
{
|
||||
|
||||
const chromified = window.utils.chromified;
|
||||
|
||||
let seqId = 0;
|
||||
|
||||
const createMenuLinkEntry = (title, tab2url) => {
|
||||
|
||||
const id = (++seqId).toString();
|
||||
|
||||
chrome.contextMenus.create({
|
||||
id: id,
|
||||
title: title,
|
||||
contexts: ['browser_action'],
|
||||
}, chromified((err) => {
|
||||
|
||||
if(err) {
|
||||
console.warn('Context menu error ignored:', err);
|
||||
}
|
||||
|
||||
}));
|
||||
|
||||
chrome.contextMenus.onClicked.addListener((info, tab) => {
|
||||
|
||||
if(info.menuItemId === id) {
|
||||
Promise.resolve( tab2url( tab ) )
|
||||
.then( (url) => chrome.tabs.create({url: url}) );
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
window.apis.menus.getItemsAsArray().forEach((item) => {
|
||||
|
||||
createMenuLinkEntry(
|
||||
item.title,
|
||||
(tab) => item.getUrl(tab.url),
|
||||
);
|
||||
|
||||
});
|
||||
|
||||
}
|
|
@ -1,72 +0,0 @@
|
|||
'use strict';
|
||||
|
||||
{
|
||||
|
||||
const chromified = window.utils.chromified;
|
||||
|
||||
let seqId = 0;
|
||||
|
||||
const createMenuLinkEntry = (title, tab2url) => {
|
||||
|
||||
const id = (++seqId).toString();
|
||||
|
||||
chrome.contextMenus.create({
|
||||
id: id,
|
||||
title: title,
|
||||
contexts: ['browser_action'],
|
||||
}, chromified((err) => {
|
||||
|
||||
if(err) {
|
||||
console.warn('Context menu error ignored:', err);
|
||||
}
|
||||
|
||||
}));
|
||||
|
||||
chrome.contextMenus.onClicked.addListener((info, tab) => {
|
||||
|
||||
if(info.menuItemId === id) {
|
||||
Promise.resolve( tab2url( tab ) )
|
||||
.then( (url) => chrome.tabs.create({url: url}) );
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
createMenuLinkEntry(
|
||||
'Сайт доступен из-за границы? Is up?',
|
||||
(tab) => `data:text/html;charset=utf8,<title>Запрашиваю...</title>
|
||||
<form class='tracker-form' method='POST'
|
||||
action='https://www.host-tracker.com/ru/InstantCheck/Create'>
|
||||
<input name='InstantCheckUrl' value='${new URL(tab.url).hostname}'
|
||||
type='hidden'>
|
||||
</form>
|
||||
<script>document.querySelector('.tracker-form').submit()<\/script>`
|
||||
);
|
||||
|
||||
createMenuLinkEntry(
|
||||
'Сайт в реестре блокировок?',
|
||||
(tab) => 'https://antizapret.info/index.php?search=' + new URL(tab.url).hostname
|
||||
);
|
||||
|
||||
createMenuLinkEntry(
|
||||
'Из архива archive.org',
|
||||
(tab) => 'https://web.archive.org/web/*/' + tab.url
|
||||
);
|
||||
|
||||
createMenuLinkEntry(
|
||||
'Через Google Translate',
|
||||
(tab) => 'https://translate.google.com/translate?hl=&sl=en&tl=ru&anno=2&sandbox=1&u=' + tab.url
|
||||
);
|
||||
|
||||
createMenuLinkEntry(
|
||||
'Разблокировать по-другому',
|
||||
(tab) => 'https://rebrand.ly/ac-unblock#' + tab.url
|
||||
);
|
||||
|
||||
createMenuLinkEntry(
|
||||
'Документация / Помощь / Поддержка',
|
||||
(tab) => 'https://rebrand.ly/ac-support'
|
||||
);
|
||||
|
||||
}
|
|
@ -32,8 +32,9 @@
|
|||
${scripts_2x}
|
||||
, "35-pac-kitchen-api.js"
|
||||
, "37-sync-pac-script-with-pac-provider-api.js"
|
||||
${scripts_7x}
|
||||
, "80-context-menus.js"
|
||||
${scripts_8x}
|
||||
, "70-menu-items.js"
|
||||
, "75-context-menus.js"
|
||||
]
|
||||
},
|
||||
"browser_action": {
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
<!DOCTYPE html>
|
||||
<html style="display: none; will-change: contents, display">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Обход ошибки</title>
|
||||
<style></style>
|
||||
</head>
|
||||
<body>
|
||||
<ol id="menuItems"></ol>
|
||||
<script src="./index.js"></script>
|
||||
<script src="../lib/keep-links-clickable.js"></script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,30 @@
|
|||
'use strict';
|
||||
|
||||
chrome.runtime.getBackgroundPage( (bgWindow) =>
|
||||
bgWindow.apis.errorHandlers.installListenersOn(
|
||||
window, 'ERRM', async() => {
|
||||
|
||||
const [currentTab] = await new Promise((resolve) =>
|
||||
chrome.tabs.query({
|
||||
active: true,
|
||||
currentWindow: true,
|
||||
}, resolve)
|
||||
);
|
||||
|
||||
const itemsRoot = document.getElementById('menuItems');
|
||||
bgWindow.apis.menus.getItemsAsArray().forEach((item) => {
|
||||
|
||||
const li = document.createElement('li');
|
||||
li.innerHTML = `
|
||||
<a href>${item.title}</a>
|
||||
`;
|
||||
li.querySelector('a').href = item.getUrl(currentTab.url);
|
||||
itemsRoot.appendChild(li);
|
||||
|
||||
});
|
||||
|
||||
document.documentElement.style.display = 'initial';
|
||||
|
||||
}
|
||||
)
|
||||
);
|
|
@ -0,0 +1,36 @@
|
|||
'use strict';
|
||||
|
||||
/*
|
||||
window.chrome.browserAction.setBadgeBackgroundColor({
|
||||
color: '#db4b2f',
|
||||
});
|
||||
*/
|
||||
|
||||
chrome.webNavigation.onErrorOccurred.addListener((details) => {
|
||||
|
||||
const tabId = details.tabId;
|
||||
if (!(tabId > 0)) {
|
||||
alert(tabId);
|
||||
return;
|
||||
}
|
||||
|
||||
//console.log('SETTING 2', details.tabId);
|
||||
chrome.browserAction.setPopup({
|
||||
tabId,
|
||||
popup: './pages/on-error-menu/index.html',
|
||||
});
|
||||
|
||||
/*
|
||||
window.chrome.browserAction.setBadgeBackgroundColor({
|
||||
tabId,
|
||||
color: '#09f911',
|
||||
});
|
||||
*/
|
||||
|
||||
chrome.browserAction.setBadgeText({
|
||||
tabId,
|
||||
text: '●●●',
|
||||
});
|
||||
|
||||
});
|
||||
|
|
@ -10,10 +10,10 @@ exports.contexts.full = Object.assign({}, commonContext, {
|
|||
versionSuffix: '',
|
||||
nameSuffixEn: '',
|
||||
nameSuffixRu: '',
|
||||
extra_permissions: ', "webRequest"',
|
||||
extra_permissions: ', "webRequest", "webNavigation"',
|
||||
persistent: '',
|
||||
scripts_2x: ', "20-ip-to-host-api.js"',
|
||||
scripts_7x: ', "70-block-informer.js"',
|
||||
scripts_8x: ', "80-error-menu.js", "85-block-informer.js"',
|
||||
});
|
||||
|
||||
exports.contexts.mini = Object.assign({}, commonContext, {
|
||||
|
@ -23,6 +23,6 @@ exports.contexts.mini = Object.assign({}, commonContext, {
|
|||
extra_permissions: '',
|
||||
persistent: '"persistent": false,',
|
||||
scripts_2x: ', "20-for-mini-only.js"',
|
||||
scripts_7x: '',
|
||||
scripts_8x: '',
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user