Readme

interpret your dream

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
export default async function(interval) {
// Sample phrases and words that are likely to appear in dream descriptions
const introPhrases = [
"I was flying over",
"I found myself in a",
"suddenly appeared",
"I was chased by",
"I met a mysterious",
"I was lost in a",
"I discovered a hidden",
"I was trapped in a",
"I transformed into a",
"I was surrounded by",
"I encountered a",
"I was given a",
"I was searching for",
"I was haunted by",
"I was attending a",
"I was exploring a",
"I was climbing a",
"I was falling into",
"I was running away from",
"I was walking through",
];
const objects = ["castle", "forest", "stranger", "monster", "friend", "cave", "party", "mountain", "abyss", "garden"];
const actions = [
"and found a treasure",
"but got lost",
"and met a talking animal",
"but it was a dream within a dream",
"and discovered a new world",
"but realized I could not move",
"and escaped from danger",
"but it started to vanish",
"and found a secret passage",
"but then I woke up",
];
// Generate a random dream-like sentence
let randomSentence = introPhrases[Math.floor(Math.random() * introPhrases.length)] + " "
+ objects[Math.floor(Math.random() * objects.length)] + " "
+ actions[Math.floor(Math.random() * actions.length)];
// If the sentence is shorter than 250 characters, repeat the process to extend it
while (randomSentence.length < 250) {
randomSentence += ", " + introPhrases[Math.floor(Math.random() * introPhrases.length)] + " "
+ objects[Math.floor(Math.random() * objects.length)] + " "
+ actions[Math.floor(Math.random() * actions.length)];
}
// Generate a random UUID
const randomUuid = () => {
let uuid = "";
for (let i = 0; i < 32; i++) {
const random = Math.random() * 16 | 0;
if (i === 8 || i === 12 || i === 16 || i === 20) {
uuid += "-";
}
uuid += (i === 12 ? 4 : (i === 16 ? (random & 3 | 8) : random)).toString(16);
}
return uuid;
};
console.log(randomSentence.trim());
// Create the request payload
const payload = {
dream: randomSentence.trim(),
lat: null,
long: null,
};
// Send the POST request
const response = await fetch("https://dreaminterpreteraibackend.com/dream", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Accept": "*/*",
"Accept-Encoding": "gzip, deflate, br, zstd",
"Accept-Language": "en-US,en;q=0.9",
"Country": "US",
"Language": "en",
"Origin": "https://www.dreaminterpreter.ai",
"Referer": "https://www.dreaminterpreter.ai/",
"Sec-Ch-Ua": "\"Google Chrome\";v=\"123\", \"Not:A-Brand\";v=\"8\", \"Chromium\";v=\"123\"",
"Sec-Ch-Ua-Mobile": "?0",
"Sec-Ch-Ua-Platform": "\"macOS\"",
"Sec-Fetch-Dest": "empty",
"Sec-Fetch-Mode": "cors",
"Sec-Fetch-Site": "cross-site",
"Uid": randomUuid(),
"User-Agent":
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36",
},
body: JSON.stringify(payload),
});
// Handle the response
const data = await response.json();
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
2
v3
March 24, 2024