-
Notifications
You must be signed in to change notification settings - Fork 3
/
script.js
165 lines (145 loc) · 5.53 KB
/
script.js
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
const createEnterHandle = (element) => (e) => { if ((e.keyCode ? e.keyCode : e.which) == '13' && document.activeElement === element) document.activeElement.click(e); }
const wait = (ms) => new Promise(res => setTimeout(res, ms));
const scrollIntoView = (el) => el["scrollIntoViewIfNeeded" in el ? "scrollIntoViewIfNeeded" : "scrollIntoView"]({ behavior: "smooth", block: "start" });
const setDisabledOfChildButtonsTo = (parent, state) => { for (const child of parent.children) child.disabled = state };
// https://stackoverflow.com/questions/24969383
function absorbEvent(event) {
let e = event || window.event;
e.preventDefault && e.preventDefault();
e.cancelBubble = true;
e.returnValue = false;
return false;
}
// if JS is enabled in the browser replace all of the <a></a> elements with a button that was inside it
document.querySelectorAll(".buttons > a").forEach((anchor) => {
const button = anchor.children[0];
const link = anchor.getAttribute("href");
if (button.nodeName && button.nodeName.toLowerCase() !== 'button') return;
if (link !== "#") button.setAttribute("onclick", `window.open(${JSON.stringify(link)})`);
anchor.replaceWith(button);
})
const bio_elem = document.querySelector("h3#bio"),
uaflag = document.querySelector("span#ua_flag");
function updateAge(element) {
const age = ~~((new Date() - new Date("2007-03-13T08:25:00+0200")) / (1000 * 60 * 60 * 24 * 365.25));
if (element === true) return age; // !!
if (element) return (element.innerText = age);
bio_elem.innerHTML = `a Ukrainian ${uaflag.outerHTML} <span id="age">${age}</span> y.o.`;
uaflag.remove()
}
try { updateAge(); } catch (e) {
console.error(e);
alert(`Age update error:\n${e?.stack ?? e}`);
}
const tg_btn = document.querySelector("button#tg"),
tg_btns = document.querySelector("div.telegram-btns"),
tg_btn_arrow = document.querySelector("button#tg div:last-child"),
[tg_text_1, tg_text_2] = document.querySelectorAll("button#tg h3"),
button_height = "4rem";
tg_btn.onclick = "";
tg_btn_arrow.style.display = ""; // show if js enabled
tg_btns.style.display = ""; // show if js enabled
tg_btn.addEventListener("click", (e) => {
if (!tg_btn_arrow.matches(":hover, :focus")) return window.open(`https://t.me/paketmeqa`);
absorbEvent(e);
if /* close the fold */ (tg_btns.getAttribute("closed") === "false") {
tg_btn_arrow.style.transform = "rotate(0turn)";
tg_btns.setAttribute("closed", "true");
setDisabledOfChildButtonsTo(tg_btns, true);
tg_text_2.style = "width: 0px; opacity: 0; text-align: center; font-size: 0px";
tg_text_1.style = "width: 100%; opacity: 1;";
return
}
/* open the fold */
tg_btn_arrow.style.transform = "rotate(-.25turn)";
tg_btns.setAttribute("closed", "false");
setDisabledOfChildButtonsTo(tg_btns, false);
tg_text_1.style = "width: 0px; opacity: 0; font-size: 0px;";
tg_text_2.style = "width: 100%; opacity: 1; text-align: center;";
setTimeout(() => scrollIntoView(tg_btns), 300);
});
const x_btn = document.querySelector("button#x"),
close_btn = document.querySelector("button#x div:last-child"),
btn_title = document.querySelector("button#x h3");
close_btn.style.display = ""; // show if js enabled
x_btn.appendChild(close_btn);
x_btn.onclick = "";
btn_title.innerHTML = btn_title.innerHTML.slice(0, -2);
x_btn.addEventListener("click", async () => {
if (!close_btn.matches(":hover, :focus")) return window.open(`https://x.com/meqativ`);
x_btn.style.height = "0px";
x_btn.style.opacity = "0";
await wait(275);
x_btn.remove();
});
const lib_text = document.getElementById("lib_text"),
src_btn = document.getElementById("src_btn");
let lib_text_enter_handle = createEnterHandle(lib_text)
function showSourceCodeButton(e) {
absorbEvent(e);
with (src_btn) {
style.opacity = "";
style.position = "";
style.height = "";
setAttribute("tabindex", "0");
focus();
}
with (lib_text) {
innerText = "made with no libraries";
classList.remove("pointer");
removeEventListener("click", showSourceCodeButton);
document.removeEventListener("keyup", lib_text_enter_handle);
setAttribute("tabindex", "");
}
};
with (src_btn) {
style.opacity = "0";
style.position = "absolute";
style.height = "0px";
setAttribute("tabindex", "-1");
}
with (lib_text) {
setAttribute("tabindex", "0");
classList.add("pointer");
innerHTML += "<br/>press me"
addEventListener("click", showSourceCodeButton);
document.addEventListener("keyup", lib_text_enter_handle);
}
const age = document.querySelector("span#age"),
onlyfans_btn = document.querySelector("button#onlyfans"),
btns = document.querySelector(".buttons");
if (age.innerText <= 18) { // nvm
let last, font_size = 2;
onlyfans_btn.style.display = "";// show if js enabled
onlyfans_btn.addEventListener("click", () => {
if (last) clearTimeout(last);
if (age) updateAge(age);
if (!age || age.innerText == 18) return window.open("https://media.tenor.com/iHAv4WoNo2kAAAAC/gotcha-bitch.gif");
scrollIntoView(age);
if (font_size < 8) return (age.style = `font-size: ${(font_size *= 4)}rem;`);
age.style.animation = "look 2s";
age.addEventListener(
"animationend",
() => {
age.style.animation = ""
},
{ once: true }
);
// revert to normal font size
last = setTimeout(() => {
font_size = 1;
age.style = "";
last = undefined;
}, 10 * 1000);
});
}
const usvgs = document.querySelectorAll('usvg');
usvgs.forEach(async (usvg) => {
const source = await fetch(usvg.getAttribute('src'))
.catch(console.error)
.then(res => res.text());
const temp = document.createElement('usvg-pending');
temp.innerHTML = source;
usvg.replaceWith(temp.querySelector('svg'));
temp.remove()
});