From 2b33a3d5c3f2a0dc199c82ac30b1ba97f62a878a Mon Sep 17 00:00:00 2001 From: NovemLinguae <79697282+NovemLinguae@users.noreply.github.com> Date: Mon, 2 Sep 2024 13:19:59 -0700 Subject: [PATCH] addTalkPageBanners: don't write a class if the shell auto detects it (#379) https://en.wikipedia.org/w/index.php?title=Wikipedia_talk:WikiProject_Articles_for_creation&curid=11547670&diff=1243669976&oldid=1243646954 --- src/modules/core.js | 5 +++++ tests/test-core.js | 18 +++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/modules/core.js b/src/modules/core.js index 4d2776a2..e33265c8 100644 --- a/src/modules/core.js +++ b/src/modules/core.js @@ -1710,6 +1710,11 @@ // delete |class= from banners in array banners = banners.map( ( value ) => value.replace( /\s*\|\s*class\s*=\s*[^|}]*([\n|}])/, '$1' ) ); + // The banner shell automatically detects several classes. If it's one of these auto detected classes, write |class= blank instead of writing the class. + if ( [ 'Disambig', 'Template', 'Redirect', 'Portal', 'Project', 'NA' ].indexOf( newAssessment ) !== -1 ) { + newAssessment = ''; + } + // Convert array back to wikitext and append to top of talk page. // Always add a shell even if it's just wrapping one banner, for code simplification reasons. // Add |class= to shell. diff --git a/tests/test-core.js b/tests/test-core.js index 751c1dc0..e6007848 100644 --- a/tests/test-core.js +++ b/tests/test-core.js @@ -382,13 +382,29 @@ I have a question. Can you help answer it? –[[User:Novem Linguae|