File size: 2,410 Bytes
ae3aee6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// Main application logic
document.addEventListener('DOMContentLoaded', () => {
    // Initialize tooltips
    const tooltips = document.querySelectorAll('.tooltip');
    tooltips.forEach(tooltip => {
        tooltip.addEventListener('mouseenter', () => {
            const tooltipText = tooltip.querySelector('.tooltiptext');
            tooltipText.style.visibility = 'visible';
            tooltipText.style.opacity = '1';
        });
        
        tooltip.addEventListener('mouseleave', () => {
            const tooltipText = tooltip.querySelector('.tooltiptext');
            tooltipText.style.visibility = 'hidden';
            tooltipText.style.opacity = '0';
        });
    });

    // Content generation function
    window.generateContent = async (type) => {
        try {
            // Call Venice API for content generation
            const response = await fetch('https://api.venice.ai/generate', {
                method: 'POST',
                headers: {
                    'Content-Type': 'application/json',
                    'Authorization': `Bearer ${veniceApiKey}`
                },
                body: JSON.stringify({
                    type: type,
                    nsfw: true,
                    length: 'medium',
                    style: 'viral'
                })
            });
            
            const data = await response.json();
            return data.content;
        } catch (error) {
            console.error('Error generating content:', error);
            return null;
        }
    };

    // Affiliate link matching
    window.matchAffiliateLinks = async (content) => {
        try {
            const { data, error } = await supabase
                .from('affiliate_products')
                .select('*')
                .textSearch('keywords', content);
            
            if (error) throw error;
            return data;
        } catch (error) {
            console.error('Error matching affiliate links:', error);
            return [];
        }
    };

    // Trend analysis
    window.analyzeTrends = async () => {
        try {
            const { data, error } = await supabase
                .rpc('get_nsfw_trends');
            
            if (error) throw error;
            return data;
        } catch (error) {
            console.error('Error analyzing trends:', error);
            return null;
        }
    };
});