nolimit-x 1.0.16 → 1.0.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/placeholders.js +2 -3
- package/src/utils.js +59 -14
package/package.json
CHANGED
package/src/placeholders.js
CHANGED
|
@@ -101,10 +101,9 @@ const dynamicPlaceholders = [
|
|
|
101
101
|
if (customUrl) {
|
|
102
102
|
return customUrl.trim();
|
|
103
103
|
}
|
|
104
|
-
|
|
105
|
-
// Otherwise fetch favicon for the domain
|
|
104
|
+
// Otherwise fetch favicon for the domain as base64
|
|
106
105
|
const domain = utils.getDomainFromEmail(email);
|
|
107
|
-
return await utils.
|
|
106
|
+
return await utils.fetchFaviconBase64(domain);
|
|
108
107
|
}
|
|
109
108
|
},
|
|
110
109
|
|
package/src/utils.js
CHANGED
|
@@ -2,6 +2,7 @@ const fs = require('fs');
|
|
|
2
2
|
const path = require('path');
|
|
3
3
|
const natural = require('natural');
|
|
4
4
|
const { Buffer } = require('buffer');
|
|
5
|
+
const https = require('https');
|
|
5
6
|
|
|
6
7
|
// Date and Time Functions
|
|
7
8
|
function formatDate(date, format) {
|
|
@@ -162,6 +163,25 @@ const faviconCache = {};
|
|
|
162
163
|
const CACHE_FILE = 'favicons-cache.json';
|
|
163
164
|
const FAVICON_TIMEOUT = 3000; // 3 seconds
|
|
164
165
|
|
|
166
|
+
// Special favicon mapping for major providers
|
|
167
|
+
const specialFavicons = {
|
|
168
|
+
'gmail.com': 'https://ssl.gstatic.com/ui/v1/icons/mail/rfr/gmail.ico',
|
|
169
|
+
'googlemail.com': 'https://ssl.gstatic.com/ui/v1/icons/mail/rfr/gmail.ico',
|
|
170
|
+
'yahoo.com': 'https://s.yimg.com/rz/l/yahoo_en-US_f_p_142x37.png',
|
|
171
|
+
'outlook.com': 'https://outlook-1.cdn.office.net/assets/mail/pwa/v1/pngs/favicon-32x32.png',
|
|
172
|
+
'hotmail.com': 'https://outlook-1.cdn.office.net/assets/mail/pwa/v1/pngs/favicon-32x32.png',
|
|
173
|
+
'aol.com': 'https://www.aol.com/favicon.ico',
|
|
174
|
+
'icloud.com': 'https://www.apple.com/favicon.ico',
|
|
175
|
+
'protonmail.com': 'https://proton.me/favicon.ico',
|
|
176
|
+
'zoho.com': 'https://www.zoho.com/favicon.ico',
|
|
177
|
+
'mail.com': 'https://www.mail.com/favicon.ico',
|
|
178
|
+
'gmx.com': 'https://www.gmx.com/favicon.ico',
|
|
179
|
+
'yandex.com': 'https://mail.yandex.com/favicon.ico',
|
|
180
|
+
'fastmail.com': 'https://www.fastmail.com/favicon.ico',
|
|
181
|
+
'kolabnow.com': 'https://kolabnow.com/sites/default/files/favicon.ico',
|
|
182
|
+
// Add more as needed
|
|
183
|
+
};
|
|
184
|
+
|
|
165
185
|
// Load persistent favicon cache from disk
|
|
166
186
|
function loadFaviconCache() {
|
|
167
187
|
try {
|
|
@@ -248,20 +268,26 @@ async function fetchFavicon(domain) {
|
|
|
248
268
|
if (faviconCache[domain]) return faviconCache[domain];
|
|
249
269
|
}
|
|
250
270
|
let faviconUrl = '';
|
|
251
|
-
//
|
|
252
|
-
|
|
253
|
-
faviconUrl =
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
271
|
+
// Use special mapping if available
|
|
272
|
+
if (specialFavicons[domain]) {
|
|
273
|
+
faviconUrl = specialFavicons[domain];
|
|
274
|
+
console.log(`Using special favicon for ${domain}: ${faviconUrl}`);
|
|
275
|
+
} else {
|
|
276
|
+
// Try fallback sources directly (skip localhost fetch)
|
|
277
|
+
try {
|
|
278
|
+
faviconUrl = await fetchFaviconFallback(domain);
|
|
279
|
+
if (faviconUrl) {
|
|
280
|
+
console.log(`Fetched favicon for ${domain}: ${faviconUrl}`);
|
|
281
|
+
} else {
|
|
282
|
+
console.warn(`No favicon found for ${domain}, using default.`);
|
|
283
|
+
}
|
|
284
|
+
} catch (error) {
|
|
285
|
+
console.warn(`Fallback favicon fetch failed for ${domain}:`, error.message);
|
|
286
|
+
}
|
|
287
|
+
// Use a default favicon if all else fails
|
|
288
|
+
if (!faviconUrl) {
|
|
289
|
+
faviconUrl = 'https://www.google.com/s2/favicons?sz=32&domain_url=' + encodeURIComponent(domain);
|
|
258
290
|
}
|
|
259
|
-
} catch (error) {
|
|
260
|
-
console.warn(`Fallback favicon fetch failed for ${domain}:`, error.message);
|
|
261
|
-
}
|
|
262
|
-
// Use a default favicon if all else fails
|
|
263
|
-
if (!faviconUrl) {
|
|
264
|
-
faviconUrl = 'https://www.google.com/s2/favicons?sz=32&domain_url=' + encodeURIComponent(domain);
|
|
265
291
|
}
|
|
266
292
|
// Cache the result
|
|
267
293
|
faviconCache[domain] = faviconUrl;
|
|
@@ -320,6 +346,24 @@ async function batchFetchFavicons(domains) {
|
|
|
320
346
|
// Initialize cache on module load
|
|
321
347
|
loadFaviconCache();
|
|
322
348
|
|
|
349
|
+
// Fetch favicon as base64 data URI
|
|
350
|
+
async function fetchFaviconBase64(domain) {
|
|
351
|
+
const faviconUrl = await fetchFavicon(domain);
|
|
352
|
+
if (!faviconUrl) return '';
|
|
353
|
+
return new Promise((resolve) => {
|
|
354
|
+
https.get(faviconUrl, (res) => {
|
|
355
|
+
const data = [];
|
|
356
|
+
res.on('data', chunk => data.push(chunk));
|
|
357
|
+
res.on('end', () => {
|
|
358
|
+
const buffer = Buffer.concat(data);
|
|
359
|
+
const base64 = buffer.toString('base64');
|
|
360
|
+
const mime = res.headers['content-type'] || 'image/png';
|
|
361
|
+
resolve(`data:${mime};base64,${base64}`);
|
|
362
|
+
});
|
|
363
|
+
}).on('error', () => resolve(''));
|
|
364
|
+
});
|
|
365
|
+
}
|
|
366
|
+
|
|
323
367
|
// Export all functions
|
|
324
368
|
module.exports = {
|
|
325
369
|
// Date and Time
|
|
@@ -365,5 +409,6 @@ module.exports = {
|
|
|
365
409
|
fetchFavicon,
|
|
366
410
|
batchFetchFavicons,
|
|
367
411
|
loadFaviconCache,
|
|
368
|
-
saveFaviconCache
|
|
412
|
+
saveFaviconCache,
|
|
413
|
+
fetchFaviconBase64
|
|
369
414
|
};
|