Last active
July 8, 2022 13:41
-
-
Save ShlomoCode/7fa6580c2ec81bf0bcd5b7864ba2de54 to your computer and use it in GitHub Desktop.
סקריפט להסרת סימני שאלה וקריאה מוגזמים בשליחת פוסט/נושא בפורומי NodeBB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function RemovesBullshits() { | |
const inputs = [$('[class="title form-control"]'), $('.write')]; | |
let isRemoved; | |
for (let i = 0; i < inputs.length; i++) { | |
const regex = new RegExp(`([\?!]{${i === 0 ? '1' : '2'}})([\?!]+)`, 'gm'); | |
if (regex.test(inputs[i].val())) { | |
const inputOld = inputs[i].val(); | |
const inputNew = inputOld.replaceAll(regex, '$1'); | |
inputs[i].val(inputNew); | |
isRemoved = true; | |
} | |
} | |
if (isRemoved) { | |
app.alert({ | |
title: 'שים לב!', | |
message: 'ההודעה שלך הכילה סימני שאלה/קריאה מוגזמים, והם הוסרו בהתאם לחוקי הפורום.', | |
timeout: 4500, | |
type: 'warning', | |
}); | |
} | |
} | |
$('.composer-submit').click(RemovesBullshits); |
מגניב!!!!!!!! לגמרי!!!!!!!
עדכון: בכותרת מותר רק סימן שאלה/קריאה אחד ברצף, בגוף הפוסט מותר עד 2.
וואוו יעיל מאוד.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
מבחן לרג'קס - https://regex101.com/r/tVFxN7/1