From ca8d75337273ded07d66c003995e406132af10b0 Mon Sep 17 00:00:00 2001 From: "Ilya Ig. Petrov" Date: Wed, 1 Feb 2017 18:41:10 +0000 Subject: [PATCH] Grey icon if turned off, change exception editor ui/behavior --- .../extension/00-init-apis.js | 23 +++- .../extension/11-error-handlers-api.js | 29 ++-- .../extension/15-pac-kitchen-api.js | 2 +- ...7-sync-pac-script-with-pac-provider-api.js | 2 +- .../extension/manifest.json | 6 +- .../pages/choose-pac-provider/index.html | 129 +++++++++++------- .../pages/choose-pac-provider/index.js | 108 ++++++++++----- 7 files changed, 192 insertions(+), 107 deletions(-) diff --git a/extensions/chromium/runet-censorship-bypass/extension/00-init-apis.js b/extensions/chromium/runet-censorship-bypass/extension/00-init-apis.js index 630d3aa..b3d1dde 100644 --- a/extensions/chromium/runet-censorship-bypass/extension/00-init-apis.js +++ b/extensions/chromium/runet-censorship-bypass/extension/00-init-apis.js @@ -106,10 +106,27 @@ }, - areSettingsNotControlledFor(details) { + /* + * Possible values for levelOfControl: + * + * 1. "not_controllable" + * 2. "controlled_by_other_extensions" + * 3. "controllable_by_this_extension" + * 4. "controlled_by_this_extension" + * + * See: https://developer.chrome.com/extensions/proxy + * */ - return ['controlled_by_other', 'not_controllable'] - .some( (prefix) => details.levelOfControl.startsWith(prefix) ); + + areSettingsControllableFor(details) { + + return details.levelOfControl.endsWith('this_extension'); + + }, + + areSettingsControlledFor(details) { + + return details.levelOfControl.startsWith('controlled_by_this'); }, diff --git a/extensions/chromium/runet-censorship-bypass/extension/11-error-handlers-api.js b/extensions/chromium/runet-censorship-bypass/extension/11-error-handlers-api.js index 1fbc973..c8075c8 100644 --- a/extensions/chromium/runet-censorship-bypass/extension/11-error-handlers-api.js +++ b/extensions/chromium/runet-censorship-bypass/extension/11-error-handlers-api.js @@ -109,19 +109,28 @@ }, - ifNotControlled: null, + ifControlled: null, + ifControllable: null, - isNotControlled(details) { + isControllable(details) { - this.ifNotControlled = window.utils.areSettingsNotControlledFor(details); - if (this.ifNotControlled) { + this.ifControllable = window.utils.areSettingsControllableFor(details); + + if (this.ifControllable) { + this.ifControlled = window.utils.areSettingsControlledFor(details); + } else { + this.ifControlled = false; + } + + if (this.ifControlled) { + chrome.browserAction.setIcon( {path: './icons/default-128.png'} ); + } else { chrome.browserAction.setIcon({ path: './icons/default-grayscale-128.png', }); - } else { - chrome.browserAction.setIcon( {path: './icons/default-128.png'} ); } - return this.ifNotControlled; + + return this.ifControllable; }, @@ -192,7 +201,7 @@ chrome.proxy.settings.get( {}, - (details) => handlers.isNotControlled(details) + (details) => handlers.isControllable(details) ); chrome.notifications.onClicked.addListener( function(notId) { @@ -211,7 +220,7 @@ chrome.proxy.onProxyError.addListener((details) => { - if (handlers.ifNotControlled) { + if (!handlers.ifControlled) { return; } /* @@ -233,7 +242,7 @@ console.log('Proxy settings changed.', details); const noCon = 'no-control'; - if ( handlers.isNotControlled(details) ) { + if ( !handlers.isControllable(details) ) { handlers.mayNotifyVoid( noCon, chrome.i18n.getMessage('noControl'), diff --git a/extensions/chromium/runet-censorship-bypass/extension/15-pac-kitchen-api.js b/extensions/chromium/runet-censorship-bypass/extension/15-pac-kitchen-api.js index 2c0ecfe..e629260 100644 --- a/extensions/chromium/runet-censorship-bypass/extension/15-pac-kitchen-api.js +++ b/extensions/chromium/runet-censorship-bypass/extension/15-pac-kitchen-api.js @@ -296,7 +296,7 @@ keepCookedNowAsync(pacMods = mandatory(), cb = throwIfError) { - console.log('Keep cooked now...'); + console.log('Keep cooked now...', cb); if (typeof(pacMods) === 'function') { cb = pacMods; pacMods = this.getCurrentConfigs(); diff --git a/extensions/chromium/runet-censorship-bypass/extension/17-sync-pac-script-with-pac-provider-api.js b/extensions/chromium/runet-censorship-bypass/extension/17-sync-pac-script-with-pac-provider-api.js index 91c2b00..b379258 100644 --- a/extensions/chromium/runet-censorship-bypass/extension/17-sync-pac-script-with-pac-provider-api.js +++ b/extensions/chromium/runet-censorship-bypass/extension/17-sync-pac-script-with-pac-provider-api.js @@ -69,7 +69,7 @@ } chrome.proxy.settings.get({}, (details) => { - if ( window.utils.areSettingsNotControlledFor( details ) ) { + if ( !window.utils.areSettingsControlledFor( details ) ) { console.warn('Failed, other extension is in control.'); return cb( diff --git a/extensions/chromium/runet-censorship-bypass/extension/manifest.json b/extensions/chromium/runet-censorship-bypass/extension/manifest.json index 044a7bb..0e4ba90 100755 --- a/extensions/chromium/runet-censorship-bypass/extension/manifest.json +++ b/extensions/chromium/runet-censorship-bypass/extension/manifest.json @@ -1,10 +1,10 @@ { "manifest_version": 2, - "name": "__MSG_extName__ 0.18", + "name": "__MSG_extName__ 0.19", "default_locale": "ru", "description": "__MSG_extDesc__", - "version": "0.0.0.18", + "version": "0.0.0.19", "icons": { "128": "/icons/default-128.png" }, @@ -37,7 +37,7 @@ ] }, "browser_action": { - "default_title": "Этот сайт благословлён 0.18", + "default_title": "Этот сайт благословлён 0.19", "default_popup": "/pages/choose-pac-provider/index.html" }, "options_ui": { diff --git a/extensions/chromium/runet-censorship-bypass/extension/pages/choose-pac-provider/index.html b/extensions/chromium/runet-censorship-bypass/extension/pages/choose-pac-provider/index.html index a3346ec..bf39ff2 100755 --- a/extensions/chromium/runet-censorship-bypass/extension/pages/choose-pac-provider/index.html +++ b/extensions/chromium/runet-censorship-bypass/extension/pages/choose-pac-provider/index.html @@ -6,6 +6,7 @@ :root { --ribbon-color: #4169e1; --default-grey: #bfbfbf; + max-width: 27em; } body { margin: 0; @@ -64,35 +65,52 @@ color: white; } + :root:not(.if-options-page) .only-for-options-page { + display: none; + } + :root.if-options-page .hidden-for-options-page { + display: none; + } + /* ACCORDION (OR TABBED STATEFUL UI) */ .off { display: none; } - .acc-padded { + + section[data-for] { padding: 0.6em 0.5em 1em; } + :root.if-options-page section[data-for] { + padding-bottom: 0.6em; + } + :root.if-options-page section[data-for]:not(:last-child) { + border-bottom: 1px solid var(--default-grey); + } /* HIDE */ - #acc-pac:not(:checked) ~ .main-nav section[data-for="acc-pac"].hideable, - #acc-exc:not(:checked) ~ .main-nav section[data-for="acc-exc"].hideable, - #acc-mods:not(:checked) ~ .main-nav section[data-for="acc-mods"].hideable, - #acc-ntf:not(:checked) ~ .main-nav section[data-for="acc-ntf"].hideable + :root:not(.if-options-page) #acc-pac:not(:checked) ~ .main-nav section[data-for="acc-pac"], + :root:not(.if-options-page) #acc-exc:not(:checked) ~ .main-nav section[data-for="acc-exc"], + :root:not(.if-options-page) #acc-mods:not(:checked) ~ .main-nav section[data-for="acc-mods"], + :root:not(.if-options-page) #acc-ntf:not(:checked) ~ .main-nav section[data-for="acc-ntf"] { /* Hide, but preclude width resizes. */ height: 0px !important; line-height: 0px !important; - padding: 0; - margin: 0; + padding-top: 0 !important; + padding-bottom: 0 !important; + margin-top: 0 !important; + margin-bottom: 0 !important; + border: none !important; display: block; visibility: hidden; - transform: scaleY(0); + transform: scaleY(0) !important; } - #acc-pac:not(:checked) ~ .main-nav section[data-for="acc-pac"].hideable *, - #acc-exc:not(:checked) ~ .main-nav section[data-for="acc-exc"].hideable *, - #acc-mods:not(:checked) ~ .main-nav section[data-for="acc-mods"].hideable *, - #acc-ntf:not(:checked) ~ .main-nav section[data-for="acc-ntf"].hideable * + :root:not(.if-options-page) #acc-pac:not(:checked) ~ .main-nav section[data-for="acc-pac"] *, + :root:not(.if-options-page) #acc-exc:not(:checked) ~ .main-nav section[data-for="acc-exc"] *, + :root:not(.if-options-page) #acc-mods:not(:checked) ~ .main-nav section[data-for="acc-mods"] *, + :root:not(.if-options-page) #acc-ntf:not(:checked) ~ .main-nav section[data-for="acc-ntf"] * { margin-top: 0 !important; margin-bottom: 0 !important; @@ -258,27 +276,34 @@ } /* TAB_3 EXCEPTIONS */ - - #exc-editor { - border-radius: 0 !important; - border: none !important; + #exc-address { + display: flex; + align-items: baseline; + width: 100%; + --exc-hieght: 1.6em; border-bottom: 1px solid var(--ribbon-color) !important; - // I don't understand this three, but they have effect. - max-height: 1.6em !important; - min-height: 1.6em !important; - height: 1em !important; + font-size: 1em; + } + input#exc-editor { + border: none; + width: 100%; + background: inherit; + // The two below align '.' (dot) vertically. + max-height: var(--exc-hieght) !important; + min-height: var(--exc-hieght) !important; } #exc-radio { display: flex; justify-content: space-around; + margin-top: 0.5em; } [name="if-proxy-this-site"]:checked + label { font-weight: bold; } - #exc-editor.if-yes { + #exc-address.if-yes { background-color: lightgreen; } - #exc-editor.if-no { + #exc-address.if-no { background-color: pink; } @@ -332,53 +357,51 @@