Notes
Notes - notes.io |
const teleSearch = "post";
const trans_lang = [];
const bulk_search_array = [];
const nested_channel_regex = false;
const highlight_message = (messages, searchTerm) => {
let words = "";
let isHtml = false;
try {
words = messages.replace(/s+/g, " ").trim();
// Check if content appears to be HTML
isHtml = /<[^>]+>/g.test(words);
} catch {
words = messages;
}
// Helper: Strip HTML tags for text matching
const stripHtml = (html) => {
return html.replace(/<[^>]*>/g, ' ')
.replace(/ /g, ' ')
.replace(/</g, '<')
.replace(/>/g, '>')
.replace(/&/g, '&')
.replace(/"/g, '"')
.replace(/'/g, "'")
.replace(/s+/g, ' ')
.trim();
};
// Helper: Normalize text for comparison (remove extra spaces, normalize case)
const normalizeText = (text) => {
return text.toLowerCase()
.replace(/s+/g, " ")
.trim()
// Normalize common separators
.replace(/[s]*:[s]*/g, ":")
.replace(/[s]*-[s]*/g, "-")
.replace(/[s]*|[s]*/g, "|")
.replace(/[s]*=[s]*/g, "=");
};
// Helper: Create search variations
const createSearchVariations = (term) => {
const normalized = normalizeText(term);
const variations = new Set();
// Original term
variations.add(term.toLowerCase());
variations.add(normalized);
// If the term contains separators, create variations
const separators = [':', '-', '|', '=', ' '];
separators.forEach(sep => {
if (normalized.includes(sep)) {
const parts = normalized.split(sep);
if (parts.length === 2) {
const [key, value] = parts;
// Different spacing variations
variations.add(`${key}${sep}${value}`);
variations.add(`${key} ${sep} ${value}`);
variations.add(`${key}${sep} ${value}`);
variations.add(`${key} ${sep}${value}`);
variations.add(`${key} ${sep} ${value}`);
// Just the key-value without separator
variations.add(`${key} ${value}`);
// With other separators
separators.forEach(altSep => {
if (altSep !== sep) {
variations.add(`${key}${altSep}${value}`);
variations.add(`${key} ${altSep} ${value}`);
variations.add(`${key}${altSep} ${value}`);
variations.add(`${key} ${altSep}${value}`);
}
});
}
}
});
return Array.from(variations);
};
// Helper: Find best match index and length in both HTML and plain text
const findBestMatch = (originalText, searchVariations) => {
const plainText = isHtml ? stripHtml(originalText) : originalText;
const normalizedText = normalizeText(plainText);
let bestMatch = { index: -1, length: 0, variation: "", plainTextIndex: -1 };
// First try normalized matching
for (const variation of searchVariations) {
const index = normalizedText.indexOf(variation);
if (index >= 0) {
if (bestMatch.index === -1 || variation.length > bestMatch.length) {
bestMatch = {
index,
length: variation.length,
variation,
plainTextIndex: plainText.toLowerCase().indexOf(variation)
};
}
}
}
// If no normalized match, try fuzzy matching on plain text
if (bestMatch.index === -1) {
const lowerText = plainText.toLowerCase();
for (const variation of searchVariations) {
const index = lowerText.indexOf(variation);
if (index >= 0) {
if (bestMatch.index === -1 || variation.length > bestMatch.length) {
bestMatch = {
index,
length: variation.length,
variation,
plainTextIndex: index
};
}
}
}
}
return bestMatch;
};
// Helper: Map plain text position to HTML position
const mapPlainTextToHtml = (htmlText, plainTextIndex) => {
if (!isHtml) return plainTextIndex;
let htmlIndex = 0;
let plainIndex = 0;
let inTag = false;
for (let i = 0; i < htmlText.length; i++) {
const char = htmlText[i];
if (char === '<') {
inTag = true;
} else if (char === '>') {
inTag = false;
htmlIndex = i + 1;
continue;
}
if (!inTag) {
if (plainIndex === plainTextIndex) {
return htmlIndex;
}
plainIndex++;
}
htmlIndex = i + 1;
}
return htmlIndex;
};
// Helper: Extract snippet around match (HTML-aware)
const extractSnippet = (text, index, matchLength, pre = 30, post = 120) => {
if (isHtml) {
// For HTML, work with the original text but be mindful of tags
const start = Math.max(0, index - pre);
const end = Math.min(text.length, index + matchLength + post);
return text.slice(start, end) + " ";
} else {
// For plain text, work normally
const start = Math.max(0, index - pre);
const end = Math.min(text.length, index + matchLength + post);
return text.slice(start, end) + " ";
}
};
// Helper: URL matching and extraction (HTML-aware)
const extractMatchingUrls = (text, searchVariations) => {
const urlRegex = /https?://[^s<>"]+/gi;
const textToSearch = isHtml ? stripHtml(text) : text;
const urls = textToSearch.match(urlRegex) || [];
return urls
.filter((url) => {
const lowerUrl = url.toLowerCase();
return searchVariations.some(variation => lowerUrl.includes(variation));
})
.map((url) => url + " ")
.join("");
};
try {
if (!searchTerm) return words;
const searchVariations = createSearchVariations(searchTerm);
const match = findBestMatch(words, searchVariations);
if (match.index < 0) return words;
// For HTML content, try to map back to HTML positions
let extractIndex = match.index;
if (isHtml && match.plainTextIndex >= 0) {
extractIndex = mapPlainTextToHtml(words, match.plainTextIndex);
}
const snippet = extractSnippet(words, extractIndex, match.length);
const matchingUrls = extractMatchingUrls(words, searchVariations);
// Split URLs and filter out duplicates
const urls = matchingUrls
.split(" ")
.filter((url) => url.trim() && !snippet.includes(url));
const result = snippet + urls.join(" ");
return result.trim();
} catch {
return words;
}
};
// Test cases
const message = "**n**`417738<blr> **********</blr>|12|2025|962`**n**`417738<blr> **********</blr>|07|2025|978`**n**`417738<blr> **********</blr>|10|2024|476`**n**`417738<blr> **********</blr>|04|2032|169`**n**`417738<blr> **********</blr>|03|2032|842`**n**`417738<blr> **********</blr>|03|2024|321`**n**`417738<blr> **********</blr>|02|2033|461`**n**`417738<blr> **********</blr>|01|2028|616`**n**`417738<blr> **********</blr>|11|2028|539`**n**`417738<blr> **********</blr>|12|2028|189`**nnInformation : Business - Debit - VisanBank : HYPO ALPE-ADRIA-BANK A.D. BEOGRADnCountry : Serbia 🇷🇸nnUser : ****@soFaLKK**** [free user]nBot : ****@savagecheckbot****nChannel : **[**Pagina Oficial**](https://savagebot.ngrok.io/informacion)";
console.log("=== Testing various search patterns ===");
console.log("1. 'country : serbia':");
console.log(highlight_message(message, "country : serbia"));
console.log();
console.log("2. 'country: serbia':");
console.log(highlight_message(message, "country: serbia"));
console.log();
console.log("3. 'country :serbia':");
console.log(highlight_message(message, "country :serbia"));
console.log();
console.log("4. 'country:Serbia':");
console.log(highlight_message(message, "country:Serbia"));
console.log();
console.log("5. 'country Serbia':");
console.log(highlight_message(message, "country Serbia"));
console.log();
console.log("6. 'country - Serbia':");
console.log(highlight_message(message, "country - Serbia"));
console.log();
console.log("7. 'Country=Serbia' (alternative separator):");
console.log(highlight_message(message, "Country=Serbia"));
console.log();
console.log("8. 'serbia' (value only):");
console.log(highlight_message(message, "serbia"));
console.log();
console.log("9. 'Country|Serbia' (pipe separator):");
console.log(highlight_message(message, "Country|Serbia"));
console.log();
console.log("10. 'brand code: visa':");
console.log(highlight_message(message, "brand code: visa"));
console.log();
console.log("11. 'status approved':");
console.log(highlight_message(message, "status approved"));
console.log();
console.log("12. 'card type credit':");
console.log(highlight_message(message, "card type credit"));
console.log();
// Test HTML content
console.log("=== Testing HTML content ===");
const htmlMessage = `
<div class="message-card">
<p><strong>Status:</strong> <span class="approved">Approved!</span> ✅</p>
<p><strong>Brand Code:</strong> <span class="brand">VISA</span></p>
<p><strong>Category:</strong> <span class="category">CLASSIC</span></p>
<p><strong>Card Type:</strong> <span class="type">CREDIT</span></p>
<p><strong>Country:</strong> <span class="country">Serbia</span> 🇷🇸</p>
<p><strong>Bank:</strong> HYPO ALPE-ADRIA-BANK A.D. BEOGRAD</p>
<a href="https://example.com/serbia-banks">More info about Serbia banks</a>
</div>
`;
console.log("13. HTML: 'country: serbia':");
console.log(highlight_message(htmlMessage, "country: serbia"));
console.log();
console.log("14. HTML: 'status approved':");
console.log(highlight_message(htmlMessage, "status approved"));
console.log();
console.log("15. HTML: 'brand code visa':");
console.log(highlight_message(htmlMessage, "brand code visa"));
console.log();
console.log("16. HTML: 'card type credit':");
console.log(highlight_message(htmlMessage, "card type credit"));
console.log();
// Test with HTML entities
const htmlWithEntities = `
<div>
<p>Card Info: <VISA> - Country: "Serbia"</p>
<p>Status: & Approved & Ready</p>
<p>Bank: HYPO ALPE-ADRIA-BANK</p>
</div>
`;
console.log("17. HTML with entities: 'country serbia':");
console.log(highlight_message(htmlWithEntities, "country serbia"));
console.log();
console.log("18. HTML with entities: 'status approved':");
console.log(highlight_message(htmlWithEntities, "status approved"));
console.log();
// Test mixed content
const mixedContent = `
<div class="notification">
⇻ <strong>CC:</strong> 428250 **********|10|2032|931
⇻ <em>Status:</em> <span class="success">Approved!</span> ✅
⇻ <strong>Country:</strong> <span class="flag">Serbia[🇷🇸]</span>
<br/>
<small>Checked by: @username</small>
</div>
`;
console.log("19. Mixed HTML: 'country serbia':");
console.log(highlight_message(mixedContent, "country serbia"));
console.log();
console.log("20. Mixed HTML: 'status approved':");
console.log(highlight_message(mixedContent, "status approved"));
console.log();
// Test cases specific to the new message format
console.log("=== Testing with Credit Card Data Format ===");
console.log("21. 'bank: hypo':");
console.log(highlight_message(message, "bank: hypo"));
console.log();
console.log("22. 'information business':");
console.log(highlight_message(message, "information business"));
console.log();
console.log("23. 'debit visa':");
console.log(highlight_message(message, "debit visa"));
console.log();
console.log("24. 'user free':");
console.log(highlight_message(message, "user free"));
console.log();
console.log("25. 'bot savagecheckbot':");
console.log(highlight_message(message, "bot savagecheckbot"));
console.log();
console.log("26. 'channel pagina':");
console.log(highlight_message(message, "channel pagina"));
console.log();
console.log("27. '417738' (BIN number):");
console.log(highlight_message(message, "417738"));
console.log();
console.log("28. '2025' (expiry year):");
console.log(highlight_message(message, "2025"));
console.log();
console.log("29. 'beograd' (city):");
console.log(highlight_message(message, "beograd"));
console.log();
console.log("30. 'alpe-adria-bank':");
console.log(highlight_message(message, "alpe-adria-bank"));
console.log();
![]() |
Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 14 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team
