From df0c97a8e800c998feb3a86d1a50d746d9b218a7 Mon Sep 17 00:00:00 2001 From: Cheese <33181649+adhesivecheese@users.noreply.github.com> Date: Tue, 27 Feb 2024 22:53:16 +0000 Subject: [PATCH] Change "Reply as subreddit" to switchable reply as --- extension/data/modules/newmodmailpro.js | 43 +++++++++++++++++-------- 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/extension/data/modules/newmodmailpro.js b/extension/data/modules/newmodmailpro.js index a9e381899..7a1a6b3cf 100644 --- a/extension/data/modules/newmodmailpro.js +++ b/extension/data/modules/newmodmailpro.js @@ -48,12 +48,17 @@ export default new Module({ description: 'Open modmail in nightmode', }, { - id: 'noReplyAsSelf', - type: 'boolean', - default: false, + id: 'modmailReplyAs', + type: 'selector', + values: [ + 'Leave Unchanged', + 'Reply as Myself', + 'Reply as the subreddit', + 'Create a Private Moderator Note', + ], + default: 'leave_unchanged', advanced: true, - description: - 'Automatically switch "reply as" selection away from "Reply as myself" to "Reply as subreddit".', + description: 'Automatically switch "reply as" selection', }, { id: 'showModmailPreview', @@ -90,7 +95,7 @@ export default new Module({ }, ({ modmailnightmode: modMailNightmode, lastreplytypecheck: lastReplyTypeCheck, - noReplyAsSelf, + modmailReplyAs, showModmailPreview, clickableReason, sourceButton, @@ -101,11 +106,23 @@ export default new Module({ }) => { const $body = $('body'); - function switchAwayFromReplyAsSelf () { - const current = $('.ThreadViewerReplyForm__replyOptions .FancySelect__valueText').text(); - if (current === 'Reply as myself') { - $body.find('.FancySelect__value').click(); - $body.find('.FancySelect__option:contains("Reply as the subreddit")').click(); + function switchReplyAs () { + // Currently this is only working cosmetically; it'll change the text, but none of the ways I've tried here actually propogate and change + $body.find('#native-select-option').trigger('click'); + switch (modmailReplyAs) { + case 'reply_as_myself': + $body.find('#native-select-option').val('null').trigger('click'); + break; + + case 'reply_as_the_subreddit': + $body.find('#native-select-option').val('isAuthorHidden').trigger('change'); + break; + + case 'create_a_private_moderator_note': + $body.find('#native-select-option').val('isInternal').trigger('change'); + break; + default: + break; } } @@ -248,11 +265,11 @@ export default new Module({ submitReplyForm(); }; - if (noReplyAsSelf) { + if (modmailReplyAs !== 'leave_unchanged') { window.addEventListener('TBNewPage', event => { if (event.detail.pageType === 'modmailConversation') { setTimeout(() => { - switchAwayFromReplyAsSelf(); + switchReplyAs(); }, 1000); } });