diff --git a/src/_locales/en/adnauseam.json b/src/_locales/en/adnauseam.json index 9e8dca5ed7d3d..6a94b76ed5cb2 100755 --- a/src/_locales/en/adnauseam.json +++ b/src/_locales/en/adnauseam.json @@ -187,6 +187,10 @@ "message": "No Ads collected on this page (showing recent)", "description": "shown in menu when only 'recent' Ads are shown" }, + "adnThisPageStrictBlocked": { + "message": "{{domain}} is currently strict blocked.", + "description": "shown in menu when the current page is strict blocked" + }, "adnExportedAdsFilename": { "message": "AdNauseam_Export_{{datetime}}.json", "description": "English: AdNauseam file export" @@ -249,7 +253,27 @@ }, "adnMenuResume": { "message": "Resume", - "description": "appears in ADN popup menu" + "description": "appears in ADN popup menu three state button" + }, + "adnMenuDisable": { + "message": "Disable", + "description": "Disabled Adnauseam -> appears in ADN popup menu three state button" + }, + "adnMenuActive": { + "message": "Active", + "description": "Make Adnauseam Active -> appears in ADN popup menu three state button" + }, + "adnMenuStrict": { + "message": "Strict", + "description": "Activate Strict Block -> appears in ADN popup menu three state button" + }, + "adnMenuDisableScopeDomain": { + "message": "on domain.com", + "description": "Disable AdNaueam Block On this Domain -> Popup option that appears inside ADN menu" + }, + "adnMenuDisableScopePage": { + "message": "on this page", + "description": "Disable AdNaueam Block On This Page -> Popup option that appears inside ADN menu" }, "adnMenuSettings": { "message": "Settings", @@ -439,6 +463,10 @@ "message": "Whitelists", "description": "appears as tab name in dashboard" }, + "strictBlockListPageName": { + "message": "Strict Block List", + "description": "appears as tab name in dashboard" + }, "eventLoggingPrompt": { "message": "Activate debugging mode", "description": "prompt for toggle" diff --git a/src/css/menu.css b/src/css/menu.css index 5422b48ad3d65..368d965b4e24f 100755 --- a/src/css/menu.css +++ b/src/css/menu.css @@ -1114,4 +1114,10 @@ select { opacity: 0; margin-bottom: 0; } - } \ No newline at end of file + } + +.fa-icon.info { + color: white; + fill: white; + opacity: 0.8; +} \ No newline at end of file diff --git a/src/dashboard.html b/src/dashboard.html index d30287cb314db..717cb8d8d9bcd 100644 --- a/src/dashboard.html +++ b/src/dashboard.html @@ -23,7 +23,7 @@ - STRICT BLOCK LIST + diff --git a/src/js/adn/menu.js b/src/js/adn/menu.js index aef4d673862ea..4fec699e7ad90 100644 --- a/src/js/adn/menu.js +++ b/src/js/adn/menu.js @@ -24,7 +24,7 @@ (function () { 'use strict'; - let ads, page, settings; // remove? only if we can find an updated ad already in the DOM + let ads, page, settings, recent; // remove? only if we can find an updated ad already in the DOM const ad_list_height = 360; @@ -66,6 +66,7 @@ const renderPage = function (json) { page = json && json.pageUrl; settings = json && json.prefs; + recent = json && json.recent if (page) { // disable pause & resume buttons for options, vault, about/chrome @@ -76,24 +77,10 @@ } } - uDom("#alert-noads").addClass('hide'); // reset state + uDom("#alert-noads").addClass('hide'); // reset state of no ads showned + uDom("#alert-strictblock").addClass('hide'); // reset state of no ads showned uDom('#main').toggleClass('disabled', getIsDisabled()); - // set button state - if (getIsDisabled()) { - // disabled - uDom('#disable').prop('checked', true); - } else if (getIsStrictBlocked()) { - // strict blocked - uDom('#strict').prop('checked', true); - toggleStrictAlert(page, true) - } else { - // active - uDom('#active').prop('checked', true); - } - - - // disable 3 state toggle button if (typeof json !== 'undefined' && json !== null) { ads = json.data; @@ -122,6 +109,20 @@ }).then((data) => { renderNotifications(data.notifications) adjustBlockHeight(data.disableWarnings) + + // set button state + if (getIsDisabled()) { + // disabled + uDom('#disable').prop('checked', true); + } else if (getIsStrictBlocked()) { + // strict blocked + uDom('#strict').prop('checked', true); + toggleStrictAlert(page, true) + } else { + // active + uDom('#active').prop('checked', true); + } + }); }); } @@ -151,7 +152,7 @@ const $items = uDom('#ad-list-items'); $items.removeClass().empty(); - let ads = json.data; + ads = json.data; if (ads) { if (json.recent) doRecent(); for (let i = 0, j = ads.length; i < j; i++) { @@ -372,11 +373,20 @@ } const toggleStrictAlert = function (pageUrl, state) { - console.log("toggleStrictAlert", pageUrl) + console.log("toggleStrictAlert", pageUrl, state, ads) + let hostname = (new URL(pageUrl)).hostname; + uDom("#alert-strictblock .text").text(uDom("#alert-strictblock .text").text().replace("{{domain}}", hostname)) if (state) { - uDom("#alert-noads").removeClass('hide'); - } else { + uDom("#alert-strictblock").removeClass('hide'); uDom("#alert-noads").addClass('hide'); + uDom('#ad-list-items').addClass('recent-ads'); + } else { + if (recent) { + uDom("#alert-noads").removeClass('hide'); + } else { + uDom('#ad-list-items').removeClass('recent-ads'); + } + uDom("#alert-strictblock").addClass('hide'); } } @@ -561,11 +571,13 @@ onClickStrict(); break; case 'disable': + toggleStrictAlert(popupData.pageURL, false) toggleEnabled(evt, false) // open dropdown menu onClickDisableArrow() break; case 'active': + toggleStrictAlert(popupData.pageURL, false) toggleEnabled(evt, true) break; default: @@ -574,21 +586,31 @@ } const onChangeDisabledScope = function (evt) { - console.log("onChangeDisabledScope", evt) var scope = uDom(".disable_type_radio:checked") ? uDom(".disable_type_radio:checked").val() : '' + // first remove previous whichever previous scope from whitelist vAPI.messaging.send( 'adnauseam', { what: 'toggleEnabled', url: popupData.pageURL, scope: scope, - state: false, + state: true, tabId: popupData.tabId + }).then(() => { + // then re-add it with current scope + vAPI.messaging.send( + 'adnauseam', { + what: 'toggleEnabled', + url: popupData.pageURL, + scope: scope, + state: false, + tabId: popupData.tabId + }); + setTimeout(function () { + closePopup() + }, 500) }); - setTimeout(function () { - closePopup() - }, 500) } - + // keep in mind: // state == false -> disabled // state == true -> active @@ -679,6 +701,8 @@ 'behind-the-scene' && !popupData.advancedUserEnabled)) { return; } + // enable alert + toggleStrictAlert(popupData.pageURL, true) uDom('#main').removeClass('disabled') vAPI.messaging.send( 'adnauseam', { diff --git a/src/js/ublock.js b/src/js/ublock.js index 5af3eee830fb5..118534fe40ae2 100644 --- a/src/js/ublock.js +++ b/src/js/ublock.js @@ -129,11 +129,9 @@ const matchBucket = function(url, hostname, bucket, start) { if ( newState === undefined ) { newState = !currentState; } - /* if ( newState === currentState ) { return currentState; } - */ const netWhitelist = this.netWhitelist; const pos = url.indexOf('#'); @@ -142,10 +140,6 @@ const matchBucket = function(url, hostname, bucket, start) { let key = targetHostname; let directive = scope === 'page' ? targetURL : targetHostname; - // if the button is "active" or "disable", remove page from strictBlock - // this.removePageFromStrictBlockList(this.netStrictBlockList, targetURL, targetHostname) - // end ADN - // Add to directive list if ( newState === false ) { let bucket = netWhitelist.get(key); diff --git a/src/menu.html b/src/menu.html index 93fdd565ee2f6..3483ff07fbb7a 100644 --- a/src/menu.html +++ b/src/menu.html @@ -9,6 +9,8 @@ + + @@ -53,7 +55,7 @@

alert -

+

question-circle

@@ -71,17 +73,17 @@

- + - + - @@ -93,19 +95,13 @@

+