aboutsummaryrefslogtreecommitdiff
path: root/intimate/index.html
blob: 3c9eb06ef9f84673e49927f9f593426cbaf28aa5 (plain)
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Intimate</title>
    <link href="./bs5/bootstrap.min.css" rel="stylesheet">
    <script src="./bs5/bootstrap.bundle.min.js"></script>
</head>
<body data-bs-theme="dark" style="position: fixed; inset: 0;">
    <div style="position: fixed; top: 0; left: 0; right: 0; height: 257px; -webkit-app-region: drag; z-index: 99999;"></div>
    <div id="bg-cover" class="bg-dark-subtle" style="height: 275px; position: fixed; top: 0; left: 0; right: 0; z-index: 10; transition: opacity 200ms; pointer-events: none; opacity: 1;"></div>
    <div id="bg-img" class="bg-dark-subtle" style="height: 275px; z-index: 0; background-position: center; background-size: cover;"></div>
    <div style="text-align: center;">
        <div class="btn-group">
            <div class="dropdown" style="position: relative; top: -18px; z-index: 999999; -webkit-app-region: no-drag;">
                <button type="button" class="btn btn-primary dropdown-toggle" data-bs-toggle="dropdown" disabled id="main-btn">
                    Get started
                </button>
                <ul class="dropdown-menu" style="z-index: 999999; -webkit-app-region: no-drag;">
                    <li><a class="dropdown-item" href="#" onclick="start(true, true, true);">Ponies · Furries · Local</a></li>
                    <li><a class="dropdown-item" href="#" onclick="start(true, false, true);">Ponies · Local</a></li>
                    <li><a class="dropdown-item" href="#" onclick="start(false, true, true);">Furries · Local</a></li>
                    <li><a class="dropdown-item" href="#" onclick="start(true, true, false);">Ponies · Furries</a></li>
                    <li><a class="dropdown-item" href="#" onclick="start(true, false, false);">Ponies</a></li>
                    <li><a class="dropdown-item" href="#" onclick="start(false, true, false);">Furries</a></li>
                    <li><a class="dropdown-item" href="#" onclick="start(false, false, true);">Local</a></li>
                </ul>
            </div>
        </div>
    </div>
    <div style="text-align: center; margin-top: 15px;">
        <h3 style="margin-bottom: 0;">Spend some time with yourself</h3>
        <h3 id="cta"></h3>
    </div>
    <div style="position: fixed; bottom: 5px; left: 10px; opacity: .5;" class="text-muted small">© Equestria.dev Developers</div>
    <div style="position: fixed; bottom: 5px; right: 10px; opacity: .5; -webkit-app-region: no-drag;" class="text-muted small" id="version"></div>

    <script>
        function start(e621, derpibooru, local) {
            require('electron/renderer').ipcRenderer.send("start", e621, derpibooru, local, config);
        }

        try {
            document.getElementById("version").innerText = "v" + navigator.userAgent.split("intimate/")[1].split(" ")[0];
        } catch (e) {
            document.getElementById("version").innerText = "v" + navigator.userAgent.split("Electron/")[1].split(" ")[0];
        }

        switch (new Date().getHours()) {
            case 0:
            case 1:
            case 2:
            case 3:
            case 4:
            case 5:
                document.getElementById("cta").innerText = "this night";
                break;

            case 6:
            case 7:
            case 8:
            case 9:
            case 10:
            case 11:
                document.getElementById("cta").innerText = "this morning";
                break;

            case 12:
            case 13:
                document.getElementById("cta").innerText = "before or after lunch";
                break;

            case 14:
            case 15:
            case 16:
            case 17:
                document.getElementById("cta").innerText = "this afternoon";
                break;

            case 18:
            case 19:
            case 20:
            case 21:
            case 22:
            case 23:
                document.getElementById("cta").innerText = "tonight";
                break;
        }

        function setBackground(url) {
            console.log(url);
            let img = document.createElement("img");

            img.onload = () => {
                document.getElementById("bg-img").style.backgroundImage = 'url("' + url + '")';
                document.getElementById("bg-cover").style.opacity = "0";
            }

            img.src = url;
        }

        window.onload = () => {
            setTimeout(async () => {
                window.configPath = await require('electron/renderer').ipcRenderer.invoke("config");
                const config = window.config = require('toml').parse(require('fs').readFileSync(configPath).toString());

                if (!config.configured) {
                    alert("Intimate is currently not configured.\n\nThe configuration file will open in your favorite text editor. Please go through it and adjust the settings to your liking, and then restart Intimate.\n\nIf you have already configured Intimate, make sure the \"configured\" options is set to true.");
                    await require('electron/renderer').ipcRenderer.invoke("openConfig");
                    window.close();
                    return;
                }

                let seed = Buffer.from(crypto.getRandomValues(new Uint8Array(32))).toString("hex");
                let derpibooru;
                let e621;

                if (config.modules.derpibooru) derpibooru = (await (await fetch("https://derpibooru.org/api/v1/json/search/images/?q=suggestive,%20faved_by:" + encodeURIComponent(config.modules.derpibooru.source) + ",%20mime_type:image/*,%20-mime_type:image/gif,%20-animated&per_page=1&filter_id=56027&sf=random:" + seed)).json())["images"][0]["view_url"];
                if (config.modules.e621) e621 = (await (await fetch("https://e621.net/posts.json?limit=1&tags=order:random%20fav:" + encodeURIComponent(config.modules.e621.source) + "%20rating:q%20randseed:" + seed)).json())["posts"][0]["file"]["url"];

                console.log(derpibooru, e621);

                setTimeout(() => {
                    if (e621) {
                        if (derpibooru) {
                            setBackground(Math.random() > 0.1 ? derpibooru : e621);
                        } else {
                            setBackground(e621);
                        }
                    } else if (derpibooru) {
                        setBackground(derpibooru);
                    }

                    document.getElementById("main-btn").disabled = false;
                });
            });
        }
    </script>
</body>
</html>