This commit is contained in:
2025-07-18 22:07:22 -03:00
commit d30fd8d30b
25 changed files with 3270 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
import { Wallpaper } from '../../types';
export const baseWallpapers: Wallpaper[] = [
{
name: 'Abstract',
url: 'https://i.imgur.com/C6ynAtX.jpeg'
},
{
name: 'Abstract Red',
url: 'https://i.imgur.com/L89cqyP.jpeg'
},
{
name: 'Beach',
url: 'https://wallpapershome.com/images/pages/pic_h/615.jpg'
},
{
name: 'Mountain',
url: 'https://i.imgur.com/yHfOZUd.jpeg'
},
{
name: 'Waves',
url: 'waves.jpg',
},
];

View File

@@ -0,0 +1,31 @@
async function getWebsiteIcon(url: string): Promise<string> {
try {
const response = await fetch(url);
const html = await response.text();
const doc = new DOMParser().parseFromString(html, 'text/html');
const appleTouchIcon = doc.querySelector('link[rel="apple-touch-icon"]');
if (appleTouchIcon) {
const href = appleTouchIcon.getAttribute('href');
if (href) {
return new URL(href, url).href;
}
}
const iconLink = doc.querySelector('link[rel="icon"][type="image/png"]') || doc.querySelector('link[rel="icon"]');
if (iconLink) {
const href = iconLink.getAttribute('href');
if (href) {
return new URL(href, url).href;
}
}
} catch (error) {
console.error('Error fetching and parsing HTML for icon:', error);
}
return `https://www.google.com/s2/favicons?domain=${new URL(url).hostname}&sz=128`;
}
export { getWebsiteIcon };

View File

@@ -0,0 +1,24 @@
function request_image(url) {
return new Promise(function(resolve, reject) {
var img = new Image();
img.onload = function() { resolve(img); };
img.onerror = function() { reject(url); };
img.src = url + '?random-no-cache=' + Math.floor((1 + Math.random()) * 0x10000).toString(16);
});
}
function ping(url, multiplier) {
return new Promise(function(resolve, reject) {
var start = (new Date()).getTime();
var response = function() {
var delta = ((new Date()).getTime() - start);
delta *= (multiplier || 1);
resolve(delta);
};
request_image(url).then(response).catch(response);
setTimeout(function() { reject(Error('Timeout')); }, 5000);
});
}
export default ping;