diff --git a/ElectronMainApp/config/default.json b/ElectronMainApp/config/default.json index fc7f1b17..0a89a0d2 100644 --- a/ElectronMainApp/config/default.json +++ b/ElectronMainApp/config/default.json @@ -24,6 +24,16 @@ "LANGUAGE_SPECIFIC_ID": 7, "CUSTOM_FILTERS_GROUP_ID": 0 }, + "SafariExtensionBundles": { + "GENERAL": "com.adguard.safari.AdGuard.BlockerExtension", + "PRIVACY": "com.adguard.safari.AdGuard.BlockerPrivacy", + "SOCIAL_WIDGETS_AND_ANNOYANCES": "com.adguard.safari.AdGuard.BlockerSocial", + "SECURITY": "com.adguard.safari.AdGuard.BlockerSecurity", + "OTHER": "com.adguard.safari.AdGuard.BlockerOther", + "CUSTOM": "com.adguard.safari.AdGuard.BlockerCustom", + "ADVANCED_BLOCKING": "com.adguard.safari.AdGuard.AdvancedBlocking", + "ICON": "com.adguard.safari.AdGuard.Extension" + }, "backendUrl": "https://chrome.adtidy.org", "backendApiKey": "4DDBE80A3DA94D819A00523252FB6380", "filtersUrl": "https://filters.adtidy.org/extension/safari", diff --git a/ElectronMainApp/locales/en.json b/ElectronMainApp/locales/en.json index 9a24062c..868156b2 100644 --- a/ElectronMainApp/locales/en.json +++ b/ElectronMainApp/locales/en.json @@ -284,6 +284,9 @@ "options_about": { "message": "About" }, + "options_content_blockers": { + "message": "Content blockers" + }, "options_compare_btn": { "message": "How they compare" }, @@ -303,7 +306,7 @@ "message": "Github" }, "onboarding_safari_desc": { - "message": "Check the box next to \"AdGuard Safari Icon\", \"AdGuard Advanced Blocking\" and \"AdGuard\" in Safari preferences" + "message": "Check the boxes next to AdGuard extensions in Safari preferences" }, "onboarding_safari_btn": { "message": "Open preferences" @@ -344,16 +347,52 @@ "options_verbose_logging_desc": { "message": "If Verbose logging is enabled, AdGuard Safari extensions will print additional information to the browser console" }, - "settings_notification_title": { - "message": "Attention! AdGuard extensions are disabled" - }, - "settings_notification_text": { - "message": "You can use these extensions to manage AdGuard for Safari. For instance, pause blocking on a website, or block an ad manually. You can enable AdGuard Icon and Advanced Blocking here<\/a>." - }, "settings_notification_protection_title": { "message": "Attention! Protection was disabled" }, "settings_notification_protection_text": { - "message": "AdGuard protection is paused. Enable AdGuard<\/a>." + "message": "AdGuard protection is paused." + }, + "settings_notification_protection_button_text": { + "message": "Fix it" + }, + "settings_notification_extensions_button_text": { + "message": "Fix it" + }, + "settings_notification_extensions_title": { + "message": "Some AdGuard extensions are disabled!" + }, + "settings_notification_extensions_text": { + "message": "You should enable all AdGuard extensions for correctly ad blocking in Safari" + }, + "settings_notification_cb_extensions_title": { + "message": "Some AdGuard content blocker extensions are disabled!" + }, + "settings_notification_cb_extensions_text": { + "message": "You should enable all AdGuard content blocker extensions for correctly ad blocking in Safari" + }, + "options_cb_general_title": { + "message": "AdGuard General" + }, + "options_cb_privacy_title": { + "message": "AdGuard Privacy" + }, + "options_cb_social_title": { + "message": "AdGuard Social" + }, + "options_cb_security_title": { + "message": "AdGuard Security" + }, + "options_cb_other_title": { + "message": "AdGuard Other" + }, + "options_cb_custom_title": { + "message": "AdGuard Custom" + }, + "options_cb_rules_info": { + "message": "%s rules used" + }, + "options_cb_disabled_warning": { + "message": "Disabled in Safari" } } \ No newline at end of file diff --git a/ElectronMainApp/safari-ext/index.js b/ElectronMainApp/safari-ext/index.js index 96f5358a..a55f2d4d 100644 --- a/ElectronMainApp/safari-ext/index.js +++ b/ElectronMainApp/safari-ext/index.js @@ -9,6 +9,9 @@ const addon = require('bindings')('safari_ext_addon'); */ module.exports = (() => { + const ADVANCED_BLOCKING_BUNDLE_ID = "com.adguard.safari.AdGuard.AdvancedBlocking"; + const ICON_EXTENSION_BUNDLE_ID = "com.adguard.safari.AdGuard.Extension"; + /** * Initializes toolbar * @@ -134,30 +137,18 @@ module.exports = (() => { }; /** - * Getting state of the content blocker extension. - * Returns true in callback if extension enabled, else returns false. - * @param callback = (enabled as bool) => {} - */ - const extensionContentBlockerState = (callback) => { - addon.extensionContentBlockerState(callback); - }; - - /** - * Getting state of the icon of Safari app extension. - * Returns true in callback if extension enabled, else returns false. - * @param callback = (enabled as bool) => {} - */ - const extensionSafariIconState = (callback) => { - addon.extensionSafariIconState(callback); - }; - - /** - * Getting state of Advanced Blocking Safari extension. - * Returns true in callback if extension enabled, else returns false. - * @param callback = (enabled as bool) => {} + * Get safari extensions states info + * @param bundleId extension bundle identifier + * @param callback {*} */ - const extensionAdvancedBlockingState = (callback) => { - addon.extensionAdvancedBlockingState(callback); + const getExtensionState = (bundleId, callback) => { + if (bundleId === ADVANCED_BLOCKING_BUNDLE_ID) { + addon.extensionAdvancedBlockingState(callback); + } else if (bundleId === ICON_EXTENSION_BUNDLE_ID) { + addon.extensionSafariIconState(callback); + } else { + addon.getExtensionContentBlockerState(bundleId, callback); + } }; /** @@ -192,9 +183,7 @@ module.exports = (() => { whitelistDomains: whitelistDomains, setUserFilter: setUserFilter, userFilter: userFilter, - extensionContentBlockerState: extensionContentBlockerState, - extensionSafariIconState: extensionSafariIconState, - extensionAdvancedBlockingState: extensionAdvancedBlockingState, + getExtensionState: getExtensionState, openExtensionsPreferenses: openExtensionsPreferenses, debugLog: debugLog, setVerboseLogging: setVerboseLogging diff --git a/ElectronMainApp/safari-ext/src.mm b/ElectronMainApp/safari-ext/src.mm index 0ba9348e..e1d73e45 100644 --- a/ElectronMainApp/safari-ext/src.mm +++ b/ElectronMainApp/safari-ext/src.mm @@ -399,19 +399,22 @@ static void AsyncSendHandler(uv_async_t *handle) { }]; } -NAN_METHOD(extensionContentBlockerState){ +NAN_METHOD(getExtensionContentBlockerState){ - if (info.Length() < 1) { - ThrowTypeError("Wrong number of arguments"); - return; - } + if (info.Length() < 2) { + ThrowTypeError("Wrong number of arguments"); + return; + } - if (!info[0]->IsFunction()) { - ThrowTypeError("Wrong arguments"); - return; - } + if (!info[0]->IsString() || !info[1]->IsFunction()) { + ThrowTypeError("Wrong arguments"); + return; + } - Nan::Callback *cb = new Nan::Callback(info[0].As()); + Nan::Utf8String message (info[0]); + NSString *bundleId = [NSString stringWithCString:*message encoding:NSUTF8StringEncoding]; + + Nan::Callback *cb = new Nan::Callback(info[1].As()); void (^resultBlock)(BOOL result) = ^void(BOOL result) { @@ -425,7 +428,7 @@ static void AsyncSendHandler(uv_async_t *handle) { }); }; - [SFContentBlockerManager getStateOfContentBlockerWithIdentifier:AESharedResources.blockerBundleId + [SFContentBlockerManager getStateOfContentBlockerWithIdentifier:bundleId completionHandler:^(SFContentBlockerState * _Nullable state, NSError * _Nullable error) { resultBlock(error == nil && state.enabled); }]; @@ -732,8 +735,8 @@ static void AsyncSendHandler(uv_async_t *handle) { Nan::Set(target, New("whitelistDomains").ToLocalChecked(), GetFunction(New(whitelistDomains)).ToLocalChecked()); - Nan::Set(target, New("extensionContentBlockerState").ToLocalChecked(), - GetFunction(New(extensionContentBlockerState)).ToLocalChecked()); + Nan::Set(target, New("getExtensionContentBlockerState").ToLocalChecked(), + GetFunction(New(getExtensionContentBlockerState)).ToLocalChecked()); Nan::Set(target, New("extensionSafariIconState").ToLocalChecked(), GetFunction(New(extensionSafariIconState)).ToLocalChecked()); diff --git a/ElectronMainApp/src/main/app/content-blocker/content-blocker-adapter.js b/ElectronMainApp/src/main/app/content-blocker/content-blocker-adapter.js index e5b9e945..f5910bd7 100644 --- a/ElectronMainApp/src/main/app/content-blocker/content-blocker-adapter.js +++ b/ElectronMainApp/src/main/app/content-blocker/content-blocker-adapter.js @@ -1,3 +1,4 @@ +const config = require('config'); const listeners = require('../../notifier'); const events = require('../../events'); const settings = require('../settings-manager'); @@ -6,7 +7,7 @@ const {jsonFromFilters} = require('../libs/JSConverter'); const whitelist = require('../whitelist'); const log = require('../utils/log'); const concurrent = require('../utils/concurrent'); -const {groupRules} = require('./rule-groups'); +const {groupRules, rulesGroupsBundles} = require('./rule-groups'); /** * Safari Content Blocker Adapter @@ -29,19 +30,6 @@ module.exports = (function () { } ]; - /** - * Rules groups to extension bundle identifiers dictionary - */ - const rulesGroupsBundles = { - general: "com.adguard.safari.AdGuard.BlockerExtension", - privacy: "com.adguard.safari.AdGuard.BlockerPrivacy", - socialWidgetsAndAnnoyances: "com.adguard.safari.AdGuard.BlockerSocial", - security: "com.adguard.safari.AdGuard.BlockerSecurity", - other: "com.adguard.safari.AdGuard.BlockerOther", - custom: "com.adguard.safari.AdGuard.BlockerCustom", - advancedBlocking: "com.adguard.safari.AdGuard.AdvancedBlocking" - }; - /** * Load content blocker */ @@ -64,6 +52,13 @@ module.exports = (function () { } setSafariContentBlocker(rulesGroupsBundles[group.key], json); + + listeners.notifyListeners(events.CONTENT_BLOCKER_EXTENSION_UPDATED, { + rulesCount: group.rules.length, + bundleId: rulesGroupsBundles[group.key], + overlimit: result && result.overLimit, + filterGroups: group.filterGroups + }); } const advancedBlocking = setAdvancedBlocking(rules.map(x => x.ruleText)); diff --git a/ElectronMainApp/src/main/app/content-blocker/rule-groups.js b/ElectronMainApp/src/main/app/content-blocker/rule-groups.js index 444a87af..7caad8d0 100644 --- a/ElectronMainApp/src/main/app/content-blocker/rule-groups.js +++ b/ElectronMainApp/src/main/app/content-blocker/rule-groups.js @@ -15,6 +15,8 @@ module.exports = (function () { const AntiBannerFilterGroupsId = config.get('AntiBannerFilterGroupsId'); const AntiBannerFiltersId = config.get('AntiBannerFiltersId'); + const SafariExtensionBundles = config.get('SafariExtensionBundles'); + /** * Rules groups * @@ -62,6 +64,19 @@ module.exports = (function () { all: [groups.general, groups.privacy, groups.security, groups.socialWidgetsAndAnnoyances, groups.other, groups.custom] }; + /** + * Rules groups to extension bundle identifiers dictionary + */ + const rulesGroupsBundles = { + general: SafariExtensionBundles.GENERAL, + privacy: SafariExtensionBundles.PRIVACY, + socialWidgetsAndAnnoyances: SafariExtensionBundles.SOCIAL_WIDGETS_AND_ANNOYANCES, + security: SafariExtensionBundles.SECURITY, + other: SafariExtensionBundles.OTHER, + custom: SafariExtensionBundles.CUSTOM, + advancedBlocking: SafariExtensionBundles.ADVANCED_BLOCKING + }; + /** * Groups provided rules * @@ -103,6 +118,7 @@ module.exports = (function () { const result = []; for (let groupName in groups) { const key = groups[groupName].key; + const filterGroups = groups[groupName].filterGroups; if (rulesByAffinityBlocks[key]) { rulesByGroup[key] = rulesByGroup[key].concat(rulesByAffinityBlocks[key]); @@ -110,7 +126,8 @@ module.exports = (function () { result.push({ key: key, - rules: rulesByGroup[key] + rules: rulesByGroup[key], + filterGroups: filterGroups }); log.info(`Affinity block ${key}: rules length: ${rulesByGroup[key].length}`); @@ -180,9 +197,32 @@ module.exports = (function () { return result; }; + let bundleGroups; + const filterGroupsBundles = () => { + if (bundleGroups) { + return bundleGroups; + } + + const result = []; + + for (let key in rulesGroupsBundles) { + if (groups[key]) { + result.push({ + bundleId: rulesGroupsBundles[key], + groupIds: groups[key].filterGroups + }); + } + } + + bundleGroups = result; + return result; + }; + return { groupRules, - groups + groups, + rulesGroupsBundles, + filterGroupsBundles }; })(); diff --git a/ElectronMainApp/src/main/events.js b/ElectronMainApp/src/main/events.js index 66b34158..8215c66c 100644 --- a/ElectronMainApp/src/main/events.js +++ b/ElectronMainApp/src/main/events.js @@ -27,6 +27,7 @@ const EventNotifierTypes = module.exports = { NOTIFY_UPDATE_USER_FILTER_RULES: "event.notify.update.user.filter.rules", UPDATE_WHITELIST_FILTER_RULES: "event.update.whitelist.filter.rules", CONTENT_BLOCKER_UPDATED: "event.content.blocker.updated", + CONTENT_BLOCKER_EXTENSION_UPDATED: "event.content.blocker.extension.updated", CONTENT_BLOCKER_UPDATE_REQUIRED: "event.content.blocker.update.required", SHOW_OPTIONS_FILTERS_TAB: "event.show.options.filters", SHOW_OPTIONS_USER_FILTER_TAB: "event.show.options.user.filter", diff --git a/ElectronMainApp/src/main/startup.js b/ElectronMainApp/src/main/startup.js index f5c0616a..74850957 100644 --- a/ElectronMainApp/src/main/startup.js +++ b/ElectronMainApp/src/main/startup.js @@ -6,6 +6,7 @@ const log = require('./app/utils/log'); const contentBlockerListener = require('./app/content-blocker/content-blocker-listener'); const notificationController = require('./notification-controller'); const safariToolbar = require('safari-ext'); +const toolbarController = require('./toolbar-controller'); /** * Application startup @@ -45,9 +46,9 @@ module.exports = (() => { safariToolbar.sendReady(); // Check safari extensions - safariToolbar.extensionContentBlockerState((result) => { - if (!result) { - log.warn('Safari extension content blocker is turned off!'); + toolbarController.getExtensionsState((result) => { + if (!result || !result.contentBlockersEnabled) { + log.warn('Safari content blockers are turned off!'); showWindow(); } diff --git a/ElectronMainApp/src/main/toolbar-controller.js b/ElectronMainApp/src/main/toolbar-controller.js index 9f3b0319..e6be320f 100644 --- a/ElectronMainApp/src/main/toolbar-controller.js +++ b/ElectronMainApp/src/main/toolbar-controller.js @@ -1,3 +1,4 @@ +const config = require('config'); const safariToolbar = require('safari-ext'); const applicationApi = require('./api'); const listeners = require('./notifier'); @@ -13,6 +14,16 @@ const { shell } = require('electron'); */ module.exports = (() => { + const SafariExtensionBundles = config.get('SafariExtensionBundles'); + const ContentBlockerExtensions = [ + SafariExtensionBundles.GENERAL, + SafariExtensionBundles.PRIVACY, + SafariExtensionBundles.SOCIAL_WIDGETS_AND_ANNOYANCES, + SafariExtensionBundles.SECURITY, + SafariExtensionBundles.OTHER, + SafariExtensionBundles.CUSTOM + ]; + /** * Protection status has been changed from toolbar * @@ -162,6 +173,55 @@ module.exports = (() => { }); }; + /** + * Get safari extensions states info + * @param callback {*} + */ + const getExtensionsState = (callback) => { + const dfds = []; + const extensions = {}; + + for (let bundle in SafariExtensionBundles) { + const bundleId = SafariExtensionBundles[bundle]; + dfds.push(new Promise((resolve) => { + safariToolbar.getExtensionState(bundleId, (info) => { + extensions[bundleId] = info; + resolve(); + }); + })); + } + + Promise.all(dfds).then(function () { + let allContentBlockersDisabled = true; + let contentBlockersEnabled = true; + let minorExtensionsEnabled = true; + + for (let extension in extensions) { + const extensionEnabled = extensions[extension]; + if (!extensionEnabled) { + if (ContentBlockerExtensions.indexOf(extension) >= 0) { + contentBlockersEnabled = false; + } else { + minorExtensionsEnabled = false; + } + } else { + if (ContentBlockerExtensions.indexOf(extension) >= 0) { + allContentBlockersDisabled = false; + } + } + } + + const result = { + extensions, + contentBlockersEnabled, + minorExtensionsEnabled, + allContentBlockersDisabled + }; + + callback(result); + }); + }; + /** * Sets verbose logging * @@ -172,7 +232,8 @@ module.exports = (() => { }; return { - initToolbarController + initToolbarController, + getExtensionsState }; })(); \ No newline at end of file diff --git a/ElectronMainApp/src/main/ui-event-handler.js b/ElectronMainApp/src/main/ui-event-handler.js index ff84de99..55be2d07 100644 --- a/ElectronMainApp/src/main/ui-event-handler.js +++ b/ElectronMainApp/src/main/ui-event-handler.js @@ -12,6 +12,8 @@ const safariToolbar = require('safari-ext'); const applicationApi = require('./api'); const updater = require('./updater'); const log = require('./app/utils/log'); +const toolbarController = require('./toolbar-controller'); +const {filterGroupsBundles} = require('./app/content-blocker/rule-groups'); /** @@ -84,22 +86,13 @@ module.exports.init = function () { filters.addAndEnableFilters([filter.filterId]); }); break; - case 'checkContentBlockerExtension': - safariToolbar.extensionContentBlockerState((result) => { - sendResponse(event, 'checkContentBlockerExtensionResponse', result); + case 'getSafariExtensionsState': + toolbarController.getExtensionsState((result) => { + sendResponse(event, 'getSafariExtensionsStateResponse', result); }); break; - case 'checkSafariExtensions': - safariToolbar.extensionSafariIconState((result) => { - if (!result) { - sendResponse(event, 'checkSafariExtensionsResponse', result); - return; - } - - safariToolbar.extensionAdvancedBlockingState((result) => { - sendResponse(event, 'checkSafariExtensionsResponse', result); - }); - }); + case 'getContentBlockersMetadata': + sendResponse(event, 'getContentBlockersMetadataResponse', filterGroupsBundles()); break; case 'openSafariExtensionsPrefs': safariToolbar.openExtensionsPreferenses(()=> { diff --git a/ElectronMainApp/src/main/ui/css/style.css b/ElectronMainApp/src/main/ui/css/style.css index c6393555..6b715946 100644 --- a/ElectronMainApp/src/main/ui/css/style.css +++ b/ElectronMainApp/src/main/ui/css/style.css @@ -6,6 +6,57 @@ margin-top: 140px; height: 100%; } +.button { + cursor: pointer; + border: 0; + height: 40px; + border-radius: 4px; + font-size: 13px; + line-height: 42px; + transition: 0.3s ease background-color; + font-weight: 600; + outline: none; +} +.button--green { + padding: 0 30px; + background-color: #68bc86; + color: #ffffff; +} +.button--orange { + background-color: #eb9300; + color: #fff; +} +.button--green:hover { + background-color: #5ba575; +} +.button--transparent { + padding: 0 20px; + box-shadow: 0 0 0 1px rgba(216, 216, 216, .7); + background-color: transparent; +} +.button--transparent:hover { + background-color: rgba(0, 0, 0, .05); +} +.button--link { + padding: 0 40px; + color: #fff; + display: inline-block; + text-decoration: none; + min-width: 175px; + text-align: center; +} +.button--green-bd { + padding: 0 40px; + color: #66b574; + box-shadow: inset 0 0 0 1px #66b574; + display: inline-block; + text-decoration: none; + min-width: 175px; + transition: 0.3s ease background-color; +} +.button--green-bd:hover { + background-color: rgba(239, 239, 239, 0.5); +} /* st */ .tab-pane { display: none; @@ -345,28 +396,44 @@ padding-right: 70px; opacity: 0.5; } +.opts-list--content-blocker .block-type { + cursor: default; +} .opts-list li.active .block-type { opacity: 1; } .settings-notification { margin-top: auto; padding: 24px; - background: rgba(245, 166, 35, 0.2); + background: #fff3df; border-radius: 8px 8px 8px 8px; margin-bottom: 15px; } +.settings-notification--cols { + display: none; + justify-content: space-between; + align-items: center; +} .settings-notification__title { font-size: 16px; - color: #4d4d4d; width: 470px; - line-height: 17px; - margin-bottom: 8px; + line-height: 20px; + margin-bottom: 4px; + color: #4d4d4d; } .settings-notification__text { color: #888888; - font-size: 14px; + line-height: 14px; + font-size: 12px; max-width: 553px; - line-height: 17px; +} +.settings-notification__btn { + font-size: 16px; + min-width: 200px; + text-transform: uppercase; + height: 48px; + border-radius: 8px; + outline: none; } .block-type__desc { display: flex; @@ -416,6 +483,27 @@ .block-type__ico--0 { background-image: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48c3ZnIHdpZHRoPSI2MXB4IiBoZWlnaHQ9IjYwcHgiIHZpZXdCb3g9IjAgMCA2MSA2MCIgdmVyc2lvbj0iMS4xI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LDM5LjE5NjE0NyAzMi42OTg2MDQ2LDM4LjY3MTg4NjggTDMyLjY5ODYwNDYsMzEuMzc0NjY3OSBDMzIuNjk4NjA0NiwzMC45NzM0Mjc5IDMyLjg1MjM0MTEsMzAuNTg1NTYyNSAzMy4xMjQ3NTE1LDMwLjI4ODYxODIgTDQyLjY2NzE3ODIsMjAuMDE5NTc0OSBDNDMuMzgxOTE4MywxOS4yNDkxOTQgNDIuODMxNzMwMywxOCA0MS43NzQ0Mjc1LDE4IEwxOC4yMjg0NjMzLDE4IEMxNy4xNzExODc1LDE4IDE2LjYxODI3NTQsMTkuMjQ2NTE5MSAxNy4zMzU3MTI2LDIwLjAxOTU3NDkgTDI2Ljg3ODE5MzMsMzAuMjg1OTcgWiIgaWQ9IlNoYXBlIiBzdHJva2U9IiNGRkZGRkYiIHN0cm9rZS13aWR0aD0iMiI+PC9wYXRoPiAgICAgICAgICAgICAgICA8cGF0aCBkPSJNMjQuNSwyMS41IEwzMi41NjIyNTc3LDIxLjUiIGlkPSJMaW5lIiBzdHJva2U9IiNGRkZGRkYiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIj48L3BhdGg+ICAgICAgICAgICAgPC9nPiAgICAgICAgPC9nPiAgICA8L2c+PC9zdmc+); } +.block-type__ico-info { + width: 32px; + height: 32px; + margin-right: 25px; + background-repeat: no-repeat; + display: inline-block; + flex-shrink: 0; + background-position: 50%; +} +.block-type__ico-info--warning { + background-image: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48c3ZnIHdpZHRoPSIzMHB4IiBoZWlnaHQ9IjMwcHgiIHZpZXdCb3g9IjAgMCAzMCAzMCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIj4gICAgICAgI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yb3VwIiB0cmFuc2Zvcm09InRyYW5zbGF0ZSgxNi4wMDAwMDAsIDE2LjY2NjY2Nykgc2NhbGUoMSwgLTEpIHRyYW5zbGF0ZSgtMTYuMDAwMDAwLCAtMTYuNjY2NjY3KSB0cmFuc2xhdGUoMTAuNjY2NjY3LCA5LjMzMzMzMykiPiAgICAgICAgICAgICAgICAgICAgICAgICAgICA8ZyBpZD0iR3JvdXAtMiI+ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA8cGF0aCBkPSJNMi4wMzM1MDE2OSwxMy4yOTk4MzE2IEw4LjYzMzE2NDk4LDYuNzAwMTY4MzUiIGlkPSJMaW5lIiBzdHJva2U9IiNERjM4MTIiIHN0cm9rZS13aWR0aD0iMS41IiBzdHJva2UtbGluZWNhcD0icm91bmQiIHRyYW5zZm9ybT0idHJhbnNsYXRlKDUuMzMzMzMzLCAxMC4wMDAwMDApIHJvdGF0ZSgtMjI1LjAwMDAwMCkgdHJhbnNsYXRlKC01LjMzMzMzMywgLTEwLjAwMDAwMCkgIj48L3BhdGg+ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA8Y2lyY2xlIGlkPSJPdmFsIiBmaWxsPSIjREYzODEyIiBjeD0iNS4zMzMzMzMzMyIgY3k9IjEuMzMzMzMzMzMiIHI9IjEuMzMzMzMzMzMiPjwvY2lyY2xlPiAgICAgICAgICAgICAgICAgICAgICAgICAgICA8L2c+ICAgICAgICAgICAgICAgICAgICAgICAgPC9nPiAgICAgICAgICAgICAgICAgICAgPC9nPiAgICAgICAgICAgICAgICA8L2c+ICAgICAgICAgICAgPC9nPiAgICAgICAgPC9nPiAgICA8L2c+PC9zdmc+); +} + +.block-type__ico-info--check { + background-image: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48c3ZnIHdpZHRoPSIyMnB4IiBoZWlnaHQ9IjE1cHgiIHZpZXdCb3g9IjAgMCAyMiAxNSIgdmVyc2lvb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2MjAzMzQgMi42NjY2NjY2NywxNiIgaWQ9Ik92YWwiPjwvcGF0aD4gICAgICAgICAgICAgICAgICAgIDxwYXRoIGQ9Ik04LjY2NjY2NjY3LDM1LjMzMzMzMzMgQzE2Ljc2Njg0MywzNS4zMzMzMzMzIDIzLjMzMzMzMzMsMjkuMzYzNzk2NyAyMy4zMzMzMzMzLDIyIEMyMy4zMzMzMzMzLDE0LjYzNjIwMzMgMTYuNzY2ODQzLDguNjY2NjY2NjcgOC42NjY2NjY2Nyw4LjY2NjY2NjY3IiBpZD0iT3ZhbCIgb3BhY2l0eT0iMC4yIiB0cmFuc2Zvcm09InRyYW5zbGF0ZSgxNi4wMDAwMDAsIDIyLjAwMDAwMCkgcm90YXRlKC0yNzAuMDAwMDAwKSB0cmFuc2xhdGUoLTE2LjAwMDAwMCwgLTIyLjAwMDAwMCkgIj48L3BhdGg+ICAgICAgICAgICAgICAgIDwvZz4gICAgICAgICAgICA8L2c+ICAgICAgICA8L2c+ICAgIDwvZz48L3N2Zz4=); + animation: clockwise 2s linear infinite; +} .block-type__desc-title { color: #66b574; @@ -424,6 +512,24 @@ .block-type:hover .block-type__desc-title { text-decoration: underline; } +.block-type__info-title { + font-size: 16px; + line-height: 20px; + color: #4d4d4d; + margin-bottom: 4px; +} +.block-type__info-desc { + font-size: 12px; + line-height: 14px; + color: #888; + margin-bottom: 10px; +} +.cb_disabled_warning { + color: #9C1D00; +} +.block-type__info-desc:last-child { + margin-bottom: 0; +} .desc--filters { color: rgba(77, 77, 77, 0.5); } @@ -688,58 +794,13 @@ li.active .toggler:before { background-size: contain; background-image: url(../images/arrow-down.svg); } -.button { - cursor: pointer; - border: 0; - height: 40px; - border-radius: 4px; - font-size: 13px; - line-height: 42px; - transition: 0.3s ease background-color; - font-weight: 600; -} -.button--green { - padding: 0 30px; - background-color: #68bc86; - color: #ffffff; -} -.button--green:hover { - background-color: #5ba575; -} -.button--transparent { - padding: 0 20px; - box-shadow: 0 0 0 1px rgba(216, 216, 216, .7); - background-color: transparent; -} -.button--transparent:hover { - background-color: rgba(0, 0, 0, .05); -} -.button--link { - padding: 0 40px; - color: #fff; - display: inline-block; - text-decoration: none; - min-width: 175px; - text-align: center; -} + .wlimit .settings-actions .button--link { padding: 0 35px; } .settings-actions .button--link { color: #fff; } -.button--green-bd { - padding: 0 40px; - color: #66b574; - box-shadow: inset 0 0 0 1px #66b574; - display: inline-block; - text-decoration: none; - min-width: 175px; - transition: 0.3s ease background-color; -} -.button--green-bd:hover { - background-color: rgba(239, 239, 239, 0.5); -} .settings-actions .button--green-bd { color: #66b574; margin-left: 20px; @@ -1467,6 +1528,10 @@ li.active .toggler:before { display: none; } +body { + overflow: auto; +} + .onboarding { position: absolute; display: none; diff --git a/ElectronMainApp/src/main/ui/js/options.js b/ElectronMainApp/src/main/ui/js/options.js index b0f4bcd8..6fe3f25a 100644 --- a/ElectronMainApp/src/main/ui/js/options.js +++ b/ElectronMainApp/src/main/ui/js/options.js @@ -956,6 +956,10 @@ const AntiBannerFilters = function (options) { if (hash && hash.indexOf('#antibanner') === 0) { TopMenu.toggleTab(); } + + ipcRenderer.send('renderer-to-main', JSON.stringify({ + 'type': 'getContentBlockersMetadata' + })); }); ipcRenderer.send('renderer-to-main', JSON.stringify({ @@ -1305,13 +1309,39 @@ const AntiBannerFilters = function (options) { } } + /** + * Creates filters info string + * + * @param groupIds [] array of enabled groups + */ + const getFiltersInfo = (groupIds) => { + if (!groupIds || groupIds.length === 0) { + return null; + } + + if (loadedFiltersInfo.filters.length === 0) { + return null; + } + + let filters = []; + for (let groupId of groupIds) { + if (loadedFiltersInfo.isCategoryEnabled(groupId)) { + const groupFilters = getFiltersByGroupId(groupId, loadedFiltersInfo.filters); + filters = filters.concat(groupFilters); + } + } + + return generateFiltersNamesDescription(filters); + }; + return { render: renderCategoriesAndFilters, updateRulesCountInfo: updateRulesCountInfo, onFilterStateChanged: onFilterStateChanged, onCategoryStateChanged: onCategoryStateChanged, onFilterDownloadStarted: onFilterDownloadStarted, - onFilterDownloadFinished: onFilterDownloadFinished + onFilterDownloadFinished: onFilterDownloadFinished, + getFiltersInfo: getFiltersInfo }; }; @@ -1475,7 +1505,7 @@ const Settings = function () { if (protectionEnabled) { enableProtectionNotification.style.display = 'none'; } else { - enableProtectionNotification.style.display = 'block'; + enableProtectionNotification.style.display = 'flex'; } }; @@ -1511,6 +1541,127 @@ const Settings = function () { }; }; +/** + * Content blockers tab + * + * @returns {*} + * @constructor + */ +const ContentBlockersScreen = function (antiBannerFilters) { + 'use strict'; + + /** + * Elements to extension bundles dictionary + * + * @type {{*}} + */ + const extensionElements = { + "com.adguard.safari.AdGuard.BlockerExtension": "cb_general", + "com.adguard.safari.AdGuard.BlockerPrivacy": "cb_privacy", + "com.adguard.safari.AdGuard.BlockerSocial": "cb_social", + "com.adguard.safari.AdGuard.BlockerSecurity": "cb_security", + "com.adguard.safari.AdGuard.BlockerOther": "cb_other", + "com.adguard.safari.AdGuard.BlockerCustom": "cb_custom" + }; + + /** + * Extension element for bundle identifier + * + * @param bundleId + * @return {*} + */ + const getExtensionElement = (bundleId) => { + const elementId = extensionElements[bundleId]; + if (elementId) { + return document.getElementById(elementId); + } + + return null; + }; + + /** + * Updates content blockers info + * + * @param info + */ + const updateContentBlockers = (info) => { + for (let extensionId in info.extensions) { + const state = info.extensions[extensionId]; + + const element = getExtensionElement(extensionId); + if (element) { + const icon = element.querySelector('.extension-block-ico'); + const warning = element.querySelector('.cb_disabled_warning'); + const rulesCount = element.querySelector('.cb_rules_count'); + + icon.classList.remove("block-type__ico-info--load"); + + icon.classList.add(state ? "block-type__ico-info--check" : "block-type__ico-info--warning"); + warning.style.display = state ? 'none' : 'flex'; + + rulesCount.style.display = state ? 'flex' : 'none'; + } + } + }; + + /** + * Updates extension rules count + * + * @param bundleId + * @param info + * @param filtersInfo + */ + const updateExtensionState = (bundleId, info, filtersInfo) => { + const element = getExtensionElement(bundleId); + if (element) { + if (info) { + const rulesInfoElement = element.querySelector('.cb_rules_count'); + rulesInfoElement.textContent = i18n.__("options_cb_rules_info.message", info.rulesCount); + + //TODO: We might show rules overlimit here + } + + if (filtersInfo) { + const filtersInfoElement = element.querySelector('.cb_filters_info'); + filtersInfoElement.textContent = filtersInfo; + } + } + }; + + /** + * Sets loading state for extensions + */ + const setLoading = () => { + const extensionsIcons = document.querySelectorAll('.extension-block-ico'); + extensionsIcons.forEach((ext) => { + ext.classList.remove("block-type__ico-info--warning"); + ext.classList.remove("block-type__ico-info--check"); + + ext.classList.add("block-type__ico-info--load"); + }); + }; + + /** + * Initialize + * + */ + const init = () => { + ipcRenderer.on('getContentBlockersMetadataResponse', (e, response) => { + for (let extension of response) { + const filtersInfo = antiBannerFilters.getFiltersInfo(extension.groupIds); + updateExtensionState(extension.bundleId, null, filtersInfo); + } + }); + }; + + return { + updateContentBlockers, + setLoading, + updateExtensionState, + init + }; +}; + /** * Page controller * @@ -1542,7 +1693,6 @@ PageController.prototype = { this.aboutUpdatesRelaunch = document.getElementById('about-updates-relaunch'); this._initBoardingScreen(); - this._initSafariExtensionsMessage(); this._initUpdatesBlock(); }, @@ -1571,46 +1721,41 @@ PageController.prototype = { _initBoardingScreen: function () { let body = document.querySelector('body'); let onBoardingScreenEl = body.querySelector('#boarding-screen-placeholder'); - ipcRenderer.on('checkContentBlockerExtensionResponse', (e, arg) => { - body.style.overflow = arg ? 'auto' : 'hidden'; - onBoardingScreenEl.style.display = arg ? 'none' : 'flex'; - }); + const enableExtensionsNotification = document.getElementById('enableExtensionsNotification'); + const enableCbExtensionsNotification = document.getElementById('enableCbExtensionsNotification'); - let openSafariSettingsButton = document.querySelector('#open-safari-extensions-settings-btn'); - openSafariSettingsButton && openSafariSettingsButton.addEventListener('click', (e) => { - e.preventDefault(); - this._openSafariExtensionsPrefs(); - }); + let self = this; + ipcRenderer.on('getSafariExtensionsStateResponse', (e, arg) => { + const allContentBlockersDisabled = arg.allContentBlockersDisabled; + const contentBlockersEnabled = arg.contentBlockersEnabled; + const minorExtensionsEnabled = arg.minorExtensionsEnabled; - this._checkContentBlockerExtension(); - window.addEventListener("focus", () => this._checkContentBlockerExtension()); - }, + body.style.overflow = !allContentBlockersDisabled ? 'auto' : 'hidden'; + onBoardingScreenEl.style.display = !allContentBlockersDisabled ? 'none' : 'flex'; - _initSafariExtensionsMessage: function() { - const enableExtensionsNotification = document.getElementById('enableExtensionsNotification'); - ipcRenderer.on('checkSafariExtensionsResponse', (e, arg) => { - enableExtensionsNotification.style.display = arg ? 'none' : 'block'; + enableExtensionsNotification.style.display = (contentBlockersEnabled && minorExtensionsEnabled) ? 'none' : 'flex'; + enableCbExtensionsNotification.style.display = contentBlockersEnabled ? 'none' : 'flex'; + + self.contentBlockers.updateContentBlockers(arg); }); - this._checkSafariExtensions(); - window.addEventListener("focus", () => this._checkSafariExtensions()); + const openSafariSettingsButtons = document.querySelectorAll('.open-safari-extensions-settings-btn'); + openSafariSettingsButtons.forEach((but) => { + but.addEventListener('click', (e) => { + e.preventDefault(); + this._openSafariExtensionsPrefs(); + }); + }); - const notificationEnableExtensionsLink = document.getElementById('notificationEnableIconLink'); - notificationEnableExtensionsLink && notificationEnableExtensionsLink.addEventListener('click', (e) => { - e.preventDefault(); - this._openSafariExtensionsPrefs(); - }) + this.checkSafariExtensions(); + window.addEventListener("focus", () => this.checkSafariExtensions()); }, - _checkContentBlockerExtension: function () { - ipcRenderer.send('renderer-to-main', JSON.stringify({ - 'type': 'checkContentBlockerExtension' - })); - }, + checkSafariExtensions: function() { + this.contentBlockers.setLoading(); - _checkSafariExtensions: function() { ipcRenderer.send('renderer-to-main', JSON.stringify({ - 'type': 'checkSafariExtensions' + 'type': 'getSafariExtensionsState' })); }, @@ -1659,6 +1804,10 @@ PageController.prototype = { this.antiBannerFilters = new AntiBannerFilters({ rulesInfo: contentBlockerInfo }); this.antiBannerFilters.render(); + // Initialize Content blockers + this.contentBlockers = new ContentBlockersScreen(this.antiBannerFilters); + this.contentBlockers.init(); + document.querySelector('#about-version-placeholder').textContent = i18n.__("options_about_version.message", environmentOptions.appVersion); }, @@ -1726,12 +1875,14 @@ const initPage = function (response) { case EventNotifierTypes.FILTER_ENABLE_DISABLE: controller.antiBannerFilters.onFilterStateChanged(options); controller.settings.updateAcceptableAdsCheckbox(options); + controller.contentBlockers.setLoading(); break; case EventNotifierTypes.FILTER_ADD_REMOVE: controller.antiBannerFilters.render(); break; case EventNotifierTypes.FILTER_GROUP_ENABLE_DISABLE: controller.antiBannerFilters.onCategoryStateChanged(options); + controller.contentBlockers.setLoading(); break; case EventNotifierTypes.START_DOWNLOAD_FILTER: controller.antiBannerFilters.onFilterDownloadStarted(options); @@ -1742,12 +1893,19 @@ const initPage = function (response) { break; case EventNotifierTypes.UPDATE_USER_FILTER_RULES: controller.userFilter.updateUserFilterRules(); + controller.contentBlockers.setLoading(); break; case EventNotifierTypes.UPDATE_WHITELIST_FILTER_RULES: controller.whiteListFilter.updateWhiteListDomains(); + controller.contentBlockers.setLoading(); break; case EventNotifierTypes.CONTENT_BLOCKER_UPDATED: controller.antiBannerFilters.updateRulesCountInfo(options); + controller.checkSafariExtensions(); + break; + case EventNotifierTypes.CONTENT_BLOCKER_EXTENSION_UPDATED: + const filtersInfo = controller.antiBannerFilters.getFiltersInfo(options.filterGroups); + controller.contentBlockers.updateExtensionState(options.bundleId, options, filtersInfo); break; case EventNotifierTypes.SHOW_OPTIONS_FILTERS_TAB: window.location.hash = 'antibanner'; diff --git a/ElectronMainApp/src/main/ui/options.html b/ElectronMainApp/src/main/ui/options.html index 15f15a7c..5f66ade7 100644 --- a/ElectronMainApp/src/main/ui/options.html +++ b/ElectronMainApp/src/main/ui/options.html @@ -44,6 +44,11 @@ +
  • + + + +
  • @@ -57,11 +62,35 @@
    +
    +
    +
    +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    +
    +
    + +
    • @@ -145,14 +174,6 @@ -
      -

      -

      -
      -
      -

      -

      -
      @@ -328,6 +349,115 @@

      +
      +
      +
      +
      +
      +
      +
      +
      + +
      +
        +
      • +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
      • +
      • +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
      • +
      • +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
      • +
      • +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
      • +
      • +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
      • +
      • +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
      • +
      +

    +