עזרה | עזרה להוספת תוספים לפורום
-
@טופ-שבמתמחים כן אם אני לא טועה זה צול גאה והשגתי את הפורמט!
// ==UserScript==
// @name בני ברק - אימוג'י בהקלדה
// @namespace https://github.com/tsoolgee/BNAI-BRAK-IMOGI
// @version 0.0.9
// @description מחליף מילים לאימוג'ים בזמן הקלדה בצ'אטים של NodeBB
// @author You
// @match https://bnebrak.com/*
// @match http://mitmachim.top/*
// @match https://mitmachim.top/*
// @grant none
// @updateURL https://raw.githubusercontent.com/tsoolgee/BNAI-BRAK-IMOGI/main/script.user.js
// @downloadURL https://raw.githubusercontent.com/tsoolgee/BNAI-BRAK-IMOGI/main/script.user.js
// ==/UserScript==(function () {
'use strict';const map = [ ['חחחח', '😂'], ['חחח', '😄'], ['חח', '😊'], ['קריצה', '😉'], ['עצוב', '😞'], ['שמח', '🙂'], ['מגניב', '😎'], ['גרר', '😡'], ['אני כועס', '😠'], ['חושב', '🤔'], ['מתלבט', '🤔'], ['שוקל', '⚖️'], ['אני ישן', '😴'], ['אני עייף', '🥱'], ['ששש', '🤫'], ['תודה', '👍'], ['כוכב', '⭐'], ['לב', '❤️'], ['רעיון', '💡'], ['אש', '🔥'], ['חריף', '🌶️'], ]; let lastKey = ''; function replaceInTextarea(textarea) { // בודקים אם המקש האחרון היה רווח או אנטר if (lastKey !== ' ' && lastKey !== 'Enter') return; const val = textarea.value; const cursor = textarea.selectionStart; const textBefore = val.slice(0, cursor); for (const [from, to] of map) { // שולפים את התו האחרון שהוקלד בפועל מתוך תיבת הטקסט (רווח או ירידת שורה) const triggerChar = textBefore.slice(-1); // מוודאים שהתו האחרון הוא אכן רווח או ירידת שורה if (triggerChar !== ' ' && triggerChar !== '\n') continue; const target = from + triggerChar; // בודקים אם הטקסט לפני הסמן מסתיים במילת המפתח כולל הרווח if (!textBefore.endsWith(target)) continue; const matchEnd = cursor - 1; const wordStart = matchEnd - from.length; // מוודאים שמדובר במילה שלמה ואין אותיות שצמודות אליה מאחור const charBefore = val[wordStart - 1]; if (charBefore !== undefined && charBefore !== ' ' && charBefore !== '\n') continue; // מרכיבים מחדש את הטקסט: מחליפים את מילת המפתח באימוג'י ומחזירים את הרווח const newVal = val.slice(0, wordStart) + to + triggerChar + val.slice(cursor); textarea.value = newVal; // חישוב מיקום הסמן מחדש const newCursor = wordStart + to.length + triggerChar.length; textarea.setSelectionRange(newCursor, newCursor); textarea.dispatchEvent(new Event('input', { bubbles: true })); return; } } function attachToTextarea(textarea) { if (textarea.dataset.emojiAttached) return; textarea.dataset.emojiAttached = 'true'; textarea.addEventListener('keydown', function (e) { lastKey = e.key; }, true); textarea.addEventListener('input', function () { replaceInTextarea(this); }); } function findAndAttach() { document.querySelectorAll('textarea[component="chat/input"], textarea.mousetrap') .forEach(attachToTextarea); } findAndAttach(); new MutationObserver(findAndAttach).observe(document.body, { childList: true, subtree: true });})();
@חייא-שיאומי מה שהבאת זה לא תוסף להתקנה בנודביבי, זה רק תוסף שמשתמשים יכולים להתקין. אני מחפש את התוסף שמותקן כבר כאן על הפורום עצמו.
שלום! נראה שהשיחה הזו מעניינת אותך, אבל עדיין אין לך חשבון.
נמאס לכם לגלול בין אותם הפוסטים בכל ביקור? כשנרשמים לחשבון, תמיד תחזרו בדיוק למקום שבו הייתם קודם, ותוכלו לבחור לקבל התראות על תגובות חדשות (בין אם במייל, ובין אם בהתראת פוש). תוכלו גם לשמור סימניות ולפרגן ב-upvote לפוסטים כדי להביע הערכה לחברי קהילה אחרים.
בעזרת התרומה שלך, הפוסט הזה יכול להיות אפילו טוב יותר 💗
הרשמה התחברות