-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathpptp.js
147 lines (136 loc) · 6.1 KB
/
pptp.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
/**
* Copyright (c) 2018. トリナー(@toliner_), みやゆー(@yuu1111main), そるてぃ(@salty_7), Keitan(@0505Keitan). All rights reserved.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
let count = 0;
let popu = 0;
let popute = 0;
let poputepi = 0;
let poputepi2 = 0;
let poputepi2ltu = 0;
let start = new Date();
let hour = 0;
let min = 0;
let sec = 0;
let now = 0;
let datet = 0;
let time;
const team = ['ポ', 'プ', 'テ', 'ピ', 'ッ', 'ク'];
const team2 = ['ポ', 'プ', 'テ', 'ピ', 'ク'];
//よく分からんのでとりあえず即時関数
const take = (() => {
const aa = [
' ------- 、 rへ------、',
' ___、+\'\'"~ 八 ~\'\'< つ \',
' _、+\'\'"~ ./ ,: ^ 丶 ヽく__ ∧',
' , -r- / / / -、 \'´ ̄!\‘, ‘:, | \/',
' / .∧ \..゙|/_,,.。*\'/ /|,/\__/^ヽ /,,_ `! \', |',
' / ∧ \ 〈〉. , .| y\'\'"ヽ______ 7´⌒ヽ _| ト;′',
' 〈 ∧ (竹) .∨... || ,r ヽ 三三/ ‘:, Y! .|,′',
' ∨ ∧ ∨... | .|八 °,!三三{. ° ノ 八 /---、',
'. ∨ ∧ ∨....∨(.^ 、_,、_, ` ,.ィ^!./_ \',',
' ∨ /三ミメ、 ∨ 冫≧=‐------‐ァ=≦/ .|/ } !',
'. ∨三三三三圦__.\\/ \|イ `\'\'<:\/:::::/ | (___)',
' 〈〉 ノ ゞ三シ. \ \; { / `¨ヘ⌒こフ .∨ 〔、、、_)',
' ) \八 `^i、_ __ \\ .∨ `¨´',
' <ヘ_/三\_/|\、.\ /::/ ) \`\'´ _ ,∨、',
' |\三三三三:/ |. \/^ゞク≦---‐=≦::::::「:::::::::|::::/',
' /:::::::/:::::::/:::::::::;′:::::::::|::::::::::|:人',
'happy end!! '
];
let take_temp = ''
aa.forEach((value) => {
take_temp += value;
take_temp += '<br>'
})
return take_temp;
})()
function pptp() {
const pipimi = document.getElementById('pipimi');
pipimi.textContent = '';
const popuko = document.getElementById('popuko');
popuko.textContent = '';
const result = document.getElementById('kekka');
const button = document.getElementById('bkb');
button.style.visibility = 'hidden';
button.disabled = true;
xor.seed(Date.now())
const pop = () => {
now = new Date();
datet = parseInt((now.getTime() - start.getTime()) / 1000);
hour = parseInt(datet / 3600);
min = parseInt((datet / 60) % 60);
sec = datet % 60;
const time = `${toZeroPadString(hour, 2)}時間${toZeroPadString(min, 2)}分${toZeroPadString(sec, 2)}秒`; // パターン2
count++;
if (pipimi.textContent.endsWith('ッ')) {
pipimi.textContent += team2[getRandomInt(5)];;
} else {
pipimi.textContent += team[getRandomInt(6)];;
}
result.innerHTML = `ポプが出来た回数:${popu}<br>
ポプテが出来た回数:${popute}<br>
ポプテピが出来た回数:${poputepi}<br>
ポプテピピが出来た回数:${poputepi2}<br>
ポプテピピッが出来た回数:${poputepi2ltu}<br>
経過時間:${time}<br>
`;
if (pipimi.textContent.endsWith('ポプ')) {
popu++;
}
if (pipimi.textContent.endsWith('ポプテ')) {
popute++;
}
if (pipimi.textContent.endsWith('ポプテピ')) {
poputepi++;
}
if (pipimi.textContent.endsWith('ポプテピピ')) {
poputepi2++;
}
if (pipimi.textContent.endsWith('ポプテピピッ')) {
poputepi2ltu++;
}
if (pipimi.textContent.endsWith('ポプテピピック')) {
button.disabled = false;
button.style.visibility = 'visible';
clearInterval(pop);
const text = pipimi.textContent;
const count = document.getElementById('count');
count.innerHTML = team.reduce((prev, x) => `${prev ? `${prev}` : ''}'${x}'の文字数:${countChar(text, x)} <br>`);
popuko.innerHTML = `${take}<br>${count.textContent}文字目だよ <br>
<a href="https://twitter.com/share?text=「ポ・プ・テ・ピ・ッ・ク」をランダムに出力して「ポプテピピック」が完成したら竹●房を破壊するやつを、${count.textContent}文字目、${time}で完成させました!(ポプテピピッまで完成した回数:${poputepi2ltu}%20https://toliner.github.io/gen_pptp/&hashtags=ポプテの破壊するJS" target="_blank">Twitterでシェアする</a>`.replace('\n', '<br>');
} else {
requestAnimationFrame(pop);
}
// 最下部にスクロールする
document.documentElement.scrollTop = document.body.scrollHeight;
};
requestAnimationFrame(pop);
}
function toZeroPadString(num, padCount) {
return String(num).padStart(padCount, '0');
}
const getRandomInt = (max) => {
const val = xor.rand() % max
return val < 0 ? -val : val;
}
const countChar = (str, seq) => str.split(seq).length - 1;
xor = {
x: 123456789,
y: 362436069,
z: 521288629,
w: 88675123
};
xor.seed = function (s) {
xor.w = s;
}
xor.rand = function () {
let t = xor.x ^ (xor.x << 11);
xor.x = xor.y;
xor.y = xor.z;
xor.z = xor.w;
return xor.w = (xor.w ^ (xor.w >>> 19)) ^ (t ^ (t >>> 8));
}