added an option to hide the spam filter info in the message. see #506

This commit is contained in:
mic 2026-02-08 22:30:07 +01:00
parent 0550077567
commit b4ae956b82
4 changed files with 31 additions and 6 deletions

View file

@ -1347,6 +1347,14 @@
"message": "If the value returned by the AI is above this threshold, the email will be moved to the spam folder.",
"description": ""
},
"prefs_OptionText_spamfilter_show_msg_panel": {
"message": "Show spam report panel",
"description": ""
},
"prefs_OptionText_spamfilter_show_msg_panel_Info": {
"message": "If checked, a panel with the spam report will be shown on top of the message.",
"description": ""
},
"spamfilter_threshold_too_low": {
"message": "The spam threshold is too low! You will likely mark too much mails as spam!",
"description": ""

View file

@ -359,6 +359,10 @@ messenger.runtime.onMessage.addListener((message, sender, sendResponse) => {
browser.tabs.sendMessage(message.tabId, { command: "api_send_custom_text", custom_text: message.custom_text });
break;
case 'checkSpamReport':
if(!prefs_init.spamfilter_show_msg_panel){
return;
}
async function _checkSpamReport(tabId) {
try {
if (sender.tab.type !== 'messageDisplay' && sender.tab.type !== 'mail') return;
@ -834,6 +838,7 @@ async function reload_pref_init(){
spamfilter: prefs_default.spamfilter,
summarize: prefs_default.summarize,
spamfilter_threshold: prefs_default.spamfilter_threshold,
spamfilter_show_msg_panel: prefs_default.spamfilter_show_msg_panel,
dynamic_menu_force_enter: prefs_default.dynamic_menu_force_enter,
...getDynamicSettingsDefaults(['use_specific_integration', 'connection_type'])
});
@ -1288,12 +1293,14 @@ async function processEmails(messages, addTagsAuto, spamFilter) {
taSpamReport.saveReportData(report_data, message.headerMessageId);
// Check if the message is currently displayed and update the banner
let tabs = await browser.tabs.query({ active: true, currentWindow: true });
if (tabs.length > 0) {
let activeTab = tabs[0];
let displayedMessage = await browser.messageDisplay.getDisplayedMessage(activeTab.id);
if (displayedMessage && displayedMessage.id === message.id) {
browser.tabs.sendMessage(activeTab.id, { command: "showSpamReport", data: report_data });
if (prefs_init.spamfilter_show_msg_panel) {
let tabs = await browser.tabs.query({ active: true, currentWindow: true });
if (tabs.length > 0) {
let activeTab = tabs[0];
let displayedMessage = await browser.messageDisplay.getDisplayedMessage(activeTab.id);
if (displayedMessage && displayedMessage.id === message.id) {
browser.tabs.sendMessage(activeTab.id, { command: "showSpamReport", data: report_data });
}
}
}
}

View file

@ -133,6 +133,7 @@ export const prefs_default = {
spamfilter: false,
spamfilter_threshold: 70,
spamfilter_enabled_accounts: [],
spamfilter_show_msg_panel: true,
summarize: false,
...generated_prefs
}

View file

@ -35,6 +35,15 @@
</label>
</td>
</tr>
<tr class="spamfilter_tr">
<td><span class="opt_title">__MSG_prefs_OptionText_spamfilter_show_msg_panel__</span></td>
<td>
<label>
<input type="checkbox" id="spamfilter_show_msg_panel" name="spamfilter_show_msg_panel" class="option-input" />
__MSG_prefs_OptionText_spamfilter_show_msg_panel_Info__
</label>
</td>
</tr>
</table>
<div id="spamfilter_container">