Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ShlomoCode/7fa6580c2ec81bf0bcd5b7864ba2de54 to your computer and use it in GitHub Desktop.
Save ShlomoCode/7fa6580c2ec81bf0bcd5b7864ba2de54 to your computer and use it in GitHub Desktop.
סקריפט להסרת סימני שאלה וקריאה מוגזמים בשליחת פוסט/נושא בפורומי NodeBB
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);
@ShlomoCode
Copy link
Author

מבחן לרג'קס - https://regex101.com/r/tVFxN7/1

@MusiCode1
Copy link

מגניב!!!!!!!! לגמרי!!!!!!!

@ShlomoCode
Copy link
Author

עדכון: בכותרת מותר רק סימן שאלה/קריאה אחד ברצף, בגוף הפוסט מותר עד 2.

@davidlip123
Copy link

וואוו יעיל מאוד.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment