Skip to content

Commit

Permalink
Merge pull request dhowe#1950 from mneunomne/dhowe#1910
Browse files Browse the repository at this point in the history
  • Loading branch information
dhowe authored Oct 25, 2021
2 parents eabe6e5 + d3aa562 commit 4fd765a
Show file tree
Hide file tree
Showing 9 changed files with 115 additions and 10 deletions.
4 changes: 4 additions & 0 deletions src/_locales/en/adnauseam.json
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,10 @@
"message": "Activate debugging mode",
"description": "prompt for toggle"
},
"disableWarnings": {
"message": "Disable warnings",
"description": "English:Disable warnings"
},
"removeAdsInPrivate": {
"message": "Remove ads collected in private mode",
"description": "English:Remove ads collected in private mode - settings page"
Expand Down
15 changes: 15 additions & 0 deletions src/js/adn/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -2190,6 +2190,21 @@
};
};

// check if "disable warning" optnion is enabled or not
exports.getWarningDisabled = function () {
return µb.userSettings.disableWarnings;
};

// ADN broadcast change of "disable warning" to all tabs
exports.setWarningDisabled = function () {
vAPI.messaging.broadcast({
what: µb.userSettings.disableWarnings ? 'hideNotifications' : 'showNotifications',
});
return µb.userSettings.disableWarnings;
};



exports.getNotifications = function () {
return notifications;
};
Expand Down
14 changes: 11 additions & 3 deletions src/js/adn/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,28 @@
case 'adVisited':
updateAd(request.ad);
break;

case 'notifications':
renderNotifications(request.notifications);
adjustBlockHeight();
break;
// disable warnings option #1910
case 'hideNotifications':
uDom('#notifications').addClass("hide");
adjustBlockHeight();
break;
case 'showNotifications':
uDom('#notifications').removeClass("hide");
adjustBlockHeight();
break;
}
});

/******************************************************************************/

const renderPage = function (json) {

page = json && json.pageUrl;
settings = json && json.prefs;
settings =json && json.prefs;

function disableMenu() {
uDom.nodeFromId('pause-button').disabled = true;
Expand Down
20 changes: 20 additions & 0 deletions src/js/adn/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,22 @@
changeUserSettings(name, value);
};
/******************************************************************************/

/******************************************************************************/
// ADN disable warnings option #1910
const onDisableWarningChanged = function (ev) {
const input = ev.target;
let value = input.checked;
// send to messaging so that the change is broadcasted to all tabs
vAPI.messaging.send(
'adnauseam', {
what: 'setWarningDisabled',
value, value
}
)

}


// Workaround for:
// https://github.com/gorhill/uBlock/issues/1448
Expand Down Expand Up @@ -224,6 +240,10 @@
.on('click', onPreventDefault);
});

// disable warning
uDom('[data-setting-name="disableWarnings"]')
.on('change', onDisableWarningChanged)

// Minor text fixes
if (uDom('#exportDialog').text() === "Back up to file") {
uDom('#exportDialog').text("Backup to file");
Expand Down
13 changes: 13 additions & 0 deletions src/js/adn/shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,19 @@ const removeNotification = function (notes, note) {
};

const renderNotifications = function (visibleNotes, thePage) {
// disable warnings option #1910
vAPI.messaging.send(
'adnauseam', {
what: 'getWarningDisabled'
}
).then(isDisabled => {
if (isDisabled) {
uDom("#notifications").addClass('hide');
} else {
uDom("#notifications").removeClass('hide');
}
})

const page = thePage || 'menu';
let notifications = Notifications;

Expand Down
27 changes: 24 additions & 3 deletions src/js/adn/vault.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,14 @@
adjustHeight();
createSlider();
break;
case 'hideNotifications':
uDom('#notifications').addClass("hide");
adjustHeight();
break;
case 'showNotifications':
uDom('#notifications').removeClass("hide");
adjustHeight();
break;
}
});

Expand Down Expand Up @@ -134,8 +142,20 @@
adjustHeight();
})
})


// disable warnings #1910
// Notifications need to be hidden right away for the correct height to be calculated
vAPI.messaging.send(
'adnauseam', {
what: 'getWarningDisabled'
}
).then(isDisabled => {
if (isDisabled) {
uDom("#notifications").addClass('hide');
} else {
uDom("#notifications").removeClass('hide');
}
adjustHeight();
})
};

const autoUpdateVault = function(){
Expand Down Expand Up @@ -2155,7 +2175,8 @@
}

function adjustHeight(){
$("#stage").css('height', String($(window).height() - $("#notifications").height()) + "px" );
let notificationsHeight = $("#notifications").hasClass("hide") ? 0 : $("#notifications").height();
$("#stage").css('height', String($(window).height() - notificationsHeight) + "px" );
}

// @cqx931 use the existing $(document).keyup function
Expand Down
1 change: 1 addition & 0 deletions src/js/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ const µBlock = (( ) => { // jshint ignore:line
clickProbability: 1.0,
removeAdsInPrivate: true,
strictBlockingMode: false,
disableWarnings: false,

clickOnlyWhenIdleFor: 0,
noIncomingCookies: true,
Expand Down
30 changes: 26 additions & 4 deletions src/js/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,17 @@ if ( self.location.hash.slice(1) === 'no-dashboard.html' ) {
/// ADN notification to appear on dashboard
vAPI.broadcastListener.add(request => {
switch (request.what) {
case 'notifications':
renderNotifications(request.notifications, "dashboard");
resizeFrame();
break;
case 'notifications':
renderNotifications(request.notifications, "dashboard");
resizeFrame();
break;
// ADN when "disable notifications" option is changed, hide or show notifications
case 'hideNotifications':
uDom('#notifications').addClass("hide");
break;
case 'showNotifications':
uDom('#notifications').removeClass("hide");
break;
}
});

Expand Down Expand Up @@ -187,6 +194,21 @@ vAPI.messaging.send(
})
});

// disable warnings #1910
vAPI.messaging.send(
'adnauseam', {
what: 'getWarningDisabled'
}
).then(isDisabled => {
if (isDisabled) {
uDom("#notifications").addClass('hide');
} else {
uDom("#notifications").removeClass('hide');
}
adjustHeight();
})


/******************************************************************************/

// <<<<< end of local scope
Expand Down
1 change: 1 addition & 0 deletions src/options.html
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ <h2 data-i18n="settingsInterfacePrompt"></h2>
<li><input id="color-blind-friendly" type="checkbox" data-setting-name="colorBlindFriendly" data-setting-type="bool"><label data-i18n="settingsColorBlindPrompt" for="color-blind-friendly"></label></li>
<!--li><input id="cloud-storage-enabled" type="checkbox" data-setting-name="cloudStorageEnabled" data-setting-type="bool"><label data-i18n="settingsCloudStorageEnabledPrompt" for="cloud-storage-enabled"></label> <a class="fa-icon info" href="https://github.com/gorhill/uBlock/wiki/Cloud-storage" target="_blank">info-circle</a-->
<li><input id="event-logging" type="checkbox" data-setting-name="eventLogging" data-setting-type="bool"> <label data-i18n="eventLoggingPrompt" for="event-logging"></label></li>
<li><input id="disable-warnings" type="checkbox" data-setting-name="disableWarnings" data-setting-type="bool"> <label data-i18n="disableWarnings" for="disable-warnings"></label></li>
</ul>
</li>
<li class="subgroup">
Expand Down

0 comments on commit 4fd765a

Please sign in to comment.