diff --git a/extensions/chromium/runet-censorship-bypass/src/extension-common/70-menu-items.js b/extensions/chromium/runet-censorship-bypass/src/extension-common/70-menu-items.js new file mode 100644 index 0000000..aa6590b --- /dev/null +++ b/extensions/chromium/runet-censorship-bypass/src/extension-common/70-menu-items.js @@ -0,0 +1,69 @@ +'use strict'; + +{ + + window.apis.menus = { + + getItemsAsObject: () => ({ + + hostTracker: { + title: 'Сайт доступен из-за границы? Is up?', + getUrl: (blockedUrl) => `data:text/html;charset=utf8,Запрашиваю... +
+ +
+ + + + diff --git a/extensions/chromium/runet-censorship-bypass/src/extension-common/pages/on-error-menu/index.js b/extensions/chromium/runet-censorship-bypass/src/extension-common/pages/on-error-menu/index.js new file mode 100644 index 0000000..3da2309 --- /dev/null +++ b/extensions/chromium/runet-censorship-bypass/src/extension-common/pages/on-error-menu/index.js @@ -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 = ` + ${item.title} + `; + li.querySelector('a').href = item.getUrl(currentTab.url); + itemsRoot.appendChild(li); + + }); + + document.documentElement.style.display = 'initial'; + + } + ) +); diff --git a/extensions/chromium/runet-censorship-bypass/src/extension-full/80-error-menu.js b/extensions/chromium/runet-censorship-bypass/src/extension-full/80-error-menu.js new file mode 100644 index 0000000..aacff5d --- /dev/null +++ b/extensions/chromium/runet-censorship-bypass/src/extension-full/80-error-menu.js @@ -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: '●●●', + }); + +}); + diff --git a/extensions/chromium/runet-censorship-bypass/src/extension-full/70-block-informer.js b/extensions/chromium/runet-censorship-bypass/src/extension-full/85-block-informer.js similarity index 100% rename from extensions/chromium/runet-censorship-bypass/src/extension-full/70-block-informer.js rename to extensions/chromium/runet-censorship-bypass/src/extension-full/85-block-informer.js diff --git a/extensions/chromium/runet-censorship-bypass/src/templates-data.js b/extensions/chromium/runet-censorship-bypass/src/templates-data.js index 78f75ec..7d9d533 100644 --- a/extensions/chromium/runet-censorship-bypass/src/templates-data.js +++ b/extensions/chromium/runet-censorship-bypass/src/templates-data.js @@ -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: '', });