diff --git a/extensions/chromium/runet-censorship-bypass-light/assets-sources.txt b/extensions/chromium/runet-censorship-bypass-light/assets-sources.txt new file mode 100644 index 0000000..8d36938 --- /dev/null +++ b/extensions/chromium/runet-censorship-bypass-light/assets-sources.txt @@ -0,0 +1 @@ +Blue Ribbon Icon: http://www.iconsdb.com/icon-sets/cardboard-blue-icons/ribbon-12-icon.html \ No newline at end of file diff --git a/extensions/chromium/runet-censorship-bypass-light/extension/00-init-apis.js b/extensions/chromium/runet-censorship-bypass-light/extension/00-init-apis.js new file mode 100644 index 0000000..deeea8e --- /dev/null +++ b/extensions/chromium/runet-censorship-bypass-light/extension/00-init-apis.js @@ -0,0 +1,33 @@ +'use strict'; + +window.utils = { + + areSettingsNotControlledFor(details) { + + return ['controlled_by_other', 'not_controllable'] + .some( (prefix) => details.levelOfControl.startsWith(prefix) ); + + }, + + messages: { + + searchSettingsForUrl(niddle) { + + return 'chrome://settings/search#' + (chrome.i18n.getMessage(niddle) || niddle); + + }, + + whichExtensionHtml() { + + return chrome.i18n.getMessage('noControl') + + ` + ${ chrome.i18n.getMessage('which') } + `; + + }, + + }, + +}; + +window.apis = {}; diff --git a/extensions/chromium/runet-censorship-bypass-light/extension/12-set-pac-url.js b/extensions/chromium/runet-censorship-bypass-light/extension/12-set-pac-url.js new file mode 100644 index 0000000..42bb04b --- /dev/null +++ b/extensions/chromium/runet-censorship-bypass-light/extension/12-set-pac-url.js @@ -0,0 +1,91 @@ +'use strict'; + +window.state = { + lastError: null, + ifNotControlled: false +}; + +function redBadge(msg) { + + window.chrome.browserAction.setBadgeBackgroundColor({ + color: '#db4b2f', + }); + chrome.browserAction.setBadgeText({ + text: msg, + }); + +} + +let defaultColorPromise = new Promise( function (resolve) { + + chrome.browserAction.getBadgeBackgroundColor({}, resolve); + +}); + +function okBadge(msg) { + + defaultColorPromise.then( function (defaultColor) { + window.chrome.browserAction.setBadgeBackgroundColor({ + color: defaultColor, + }); + chrome.browserAction.setBadgeText({ + text: msg, + }); + }); + +} + +function checkControlFor(details) { + + state.ifNotControlled = utils.areSettingsNotControlledFor(details); + if (state.ifNotControlled) { + console.warn('Failed, other extension is in control.'); + redBadge('xCTRL'); + } else { + console.log('Successfuly set PAC in proxy settings..'); + okBadge('ok'); + } + +} + +chrome.proxy.settings.onChange.addListener( checkControlFor ); + +chrome.proxy.onProxyError.addListener((details) => { + + console.error(details); + //if (window.state.ifNotControlled) { + // return; + //} +}); + +chrome.proxy.settings.set( + { + value: { + mode: 'pac_script', + pacScript: { + /* + Don't use in system configs! Because Win does poor caching. + Url is encoded to counter abuse. + Source: CloudFlare + */ + //url: 'https://anticensorship-russia.tk/generated-pac-scripts/on-switches-0.17.pac', + //url: 'https://antizapret.prostovpn.org/proxy.pac', + url: 'http://localhost:8080/on-switches-0.17.pac', + mandatory: true + //url: '\x68\x74\x74\x70\x73\x3a\x2f\x2f\x61\x6e\x74\x69\x63\x65\x6e\x73\x6f\x72\x73\x68\x69\x70\x2d\x72\x75\x73\x73\x69\x61\x2e\x74\x6b\x2f\x67\x65\x6e\x65\x72\x61\x74\x65\x64\x2d\x70\x61\x63\x2d\x73\x63\x72\x69\x70\x74\x73\x2f\x6f\x6e\x2d\x73\x77\x69\x74\x63\x68\x65\x73\x2d\x30\x2e\x31\x37\x2e\x70\x61\x63', + }, + }, + }, + function() { + + const err = chrome.runtime.lastError || chrome.extension.lastError; + if(err) { + alert(333) + redBadge('ERR'); + } else { + alert(11); + chrome.proxy.settings.get({}, checkControlFor); + } + + } +); diff --git a/extensions/chromium/runet-censorship-bypass-light/extension/40-context-menus.js b/extensions/chromium/runet-censorship-bypass-light/extension/40-context-menus.js new file mode 100644 index 0000000..2db6a12 --- /dev/null +++ b/extensions/chromium/runet-censorship-bypass-light/extension/40-context-menus.js @@ -0,0 +1,49 @@ +'use strict'; + +{ + + 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) => `data:text/html;charset=utf8,