-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
539 lines (497 loc) · 18.1 KB
/
index.html
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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=IE8" />
<meta name="description" content="记得刮一刮" />
<meta name="keywords" content="记得刮一刮" />
<meta name="viewport" content="width=540, user-scalable=0" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="default" />
<meta name="google" content="notranslate" />
<title>记得刮一刮</title>
<script type="text/javascript">
var version = "1.9.6";
</script>
<script type="text/javascript" src="./polyfill.js?1.9.6"></script>
<script type="text/javascript" src="./Blob.js?1.9.6"></script>
<script type="text/javascript" src="./FileSaver.js?1.9.6"></script>
<!--[if gte IE 9]><!-->
<script type="text/javascript" src="./d3.min.js?1.9.6"></script>
<script type="text/javascript" src="./koala.js?1.9.6"></script>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<!--<![endif]-->
<link rel="stylesheet" type="text/css" href="./koala.css?1.9.6" />
<script type="text/javascript">
var kttmAdTypes = ["EasyList", "AntiAdblockKiller"];
try {
if (window.kttmAdTypes && window.kttmAdTypes.length) {
window.kttmAdTypes = window.kttmAdTypes.filter(function (a) {
return a !== "EasyList";
});
}
} catch (e) {}
try {
if (window.kttmAdTypes && window.kttmAdTypes.length) {
window.kttmAdTypes = window.kttmAdTypes.filter(function (a) {
return a !== "AntiAdblockKiller";
});
}
} catch (e) {}
</script>
<!-- <script type="text/javascript" src="nope.php?remove=EasyList&adclient=lol"></script>
<script type="text/javascript" src="nope.php?remove=AntiAdblockKiller&x=/aadb/script.js"></script> -->
</head>
<body>
<div id="center">
<div id="cont">
<noscript>
Your browser does not support JavaScript or it is disabled.<br />
JavaScript is needed to view this site.
</noscript>
<div id="dots"></div>
<div id="next" style="display: none">
<div class="msg">
Awesome stuff! Now make your own and share the link.<br />
Paste an image URL bellow and press enter.
</div>
<input placeholder="http://imgur.com/your_favourite_image.jpg" />
</div>
</div>
</div>
<script type="text/javascript">
var _fastrack_account = "FT-1000001";
(function (w, h) {
if (typeof _fastrack_account !== "string") return;
function r8() {
return Math.random().toFixed(8).substring(2);
}
var id;
try {
id = localStorage.getItem("_id");
if (!id || id.length !== 9) {
id = "I" + r8();
localStorage.setItem("_id", id);
}
} catch (e) {
id = "n/a";
}
try {
var acc = _fastrack_account;
var session = "S" + r8();
var num = 0;
var now = new Date();
var initTime = +now;
var tzm = String(now).match(/\((\w+)\)/);
w.fastrack = function (type, subtype, opt) {
var sx =
window.pageXOffset !== undefined
? window.pageXOffset
: (
document.documentElement ||
document.body.parentNode ||
document.body
).scrollLeft;
var sy =
window.pageYOffset !== undefined
? window.pageYOffset
: (
document.documentElement ||
document.body.parentNode ||
document.body
).scrollTop;
var a = {
A: acc,
S: session,
I: id,
N: num++,
P: document.location.href,
L: +new Date() - initTime,
F: w.document.referrer || "Direct",
C: screen.width + "x" + screen.height,
R: sx + "x" + sy,
O: now.getTimezoneOffset(),
Z: tzm && tzm.length === 2 ? tzm[1] : "N/A",
};
if (type) a.T = type;
if (subtype) a.E = subtype;
if (opt) {
var s;
for (var j = 1; j <= 6; j++) {
s = "D0" + j;
if (opt[s]) {
a["D0" + j] = opt["D0" + j];
}
s = "M0" + j;
if (opt[s]) {
a["M0" + j] = opt["M0" + j];
}
}
}
if ("innerWidth" in window) {
a.W = w.innerWidth + "x" + w.innerHeight;
} else {
var e = w.document.documentElement || w.document.body;
a.W = w.clientWidth + "x" + w.clientHeight;
}
var badges;
try {
var bs = localStorage.getItem("_bg");
badges = bs ? bs.split(",") : [];
} catch (e) {
badges = ["ERR"];
}
var params = [];
for (var k in a) params.push(k + "=" + encodeURIComponent(a[k]));
for (var j = 0; j < badges.length; j++)
params.push("B=" + encodeURIComponent(badges[j]));
var i = new Image();
i.src = h + "?" + params.join("&");
return true;
};
w.fastrackBadge = function (b) {
if (b && typeof b === "string") {
try {
var bs = localStorage.getItem("_bg");
var badges = bs ? bs.split(",") : [];
badges = badges.filter(function (x) {
return x !== b;
});
badges.push(b);
localStorage.setItem("_bg", badges.join(","));
} catch (e) {}
}
return true;
};
} catch (e) {}
})(window, "https://cc-int.imply.io/g/imply/ft.gif");
</script>
<script type="text/javascript">
window.shownFile = "none";
(function () {
var now = +new Date();
window.gaTrack = function (type, subtype) {
var time = Math.round((+new Date() - now) / 1000);
function doTrack() {
if (!window._gaq) return;
_gaq.push([
"_trackEvent",
String(type),
String(subtype),
window.location.href,
time,
]);
}
if (window._gaq) {
doTrack();
} else {
setTimeout(doTrack, 1);
}
};
})();
function track(type, subtype) {
fastrack(type, subtype, {
D01: version,
D02: type,
D03: subtype,
D04: shownFile,
D05: kttmAdTypes.length ? kttmAdTypes.join(",") : "NoAdblock",
M01: 1337, // tmp
});
gaTrack(type + "-" + version, subtype);
}
</script>
<!--[if lt IE 9]>
<script
type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/chrome-frame/1/CFInstall.min.js"
></script>
<style>
.chromeFrameInstallDefaultStyle {
width: 800px;
height: 600px;
border: 1px solid #cccccc;
}
</style>
<div id="prompt"></div>
<script>
window.inOldIE = true;
track("OldIE", "1");
// The conditional ensures that this code will only execute in IE,
// Therefore we can use the IE-specific attachEvent without worry
window.attachEvent("onload", function () {
CFInstall.check({
mode: "inline", // the default
node: "prompt",
oninstall: function () {
track("InstalledGCF", "OneLessRawIE");
},
});
});
</script>
<![endif]-->
<!--[if gte IE 9]><!-->
<script type="text/javascript">
// Code left intentionally unminimized for your reading pleasure.
(function () {
window.shownFile = "none";
// If an error happens I want to know about it!
window.onerror = function (msg, url, ln) {
msg = msg.toString();
// In Chrome and Firefox an error on a script form a foreign domain will cause this, see link bellow:
// http://stackoverflow.com/questions/5913978/cryptic-script-error-reported-in-javascript-in-chrome-and-firefox
if (msg === "Script error." && url === "" && ln === 0) return;
track(
"OnError",
"'" +
msg +
"' in '" +
url +
"' @ " +
ln +
" /u:'" +
window.navigator.userAgent +
"'"
);
// Track only one error per page load
window.onerror = function () {};
};
// First, make sure we can run.
if (!koala.supportsCanvas()) {
track("NoCanvas", window.navigator.userAgent);
alert(
"Sorry, KoalsToTheMax needs HTML5 Canvas support which your browser does not have. Supported browsers include Chrome, Safari, Firefox, Opera, and Internet Explorer 9, 10"
);
return;
}
if (!koala.supportsSVG()) {
track("NoSVG", window.navigator.userAgent);
alert(
"Sorry, KoalsToTheMax needs SVG support which your browser does not have. Supported browsers include Chrome, Safari, Firefox, Opera, and Internet Explorer 9, 10"
);
return;
}
// This is strange, track it if it happens.
if (!window.d3) {
track("NoD3", window.navigator.userAgent);
alert(
"Some how D3 was not loaded so the site can not start. This is bad... We are investigating. Try refreshing the page and see if that helps."
);
return;
}
// Try you must. If there is an error report it to me.
try {
// btoa and atob do not handle utf-8 as I have discovered the hard way so they need to babied
// See: https://developer.mozilla.org/en-US/docs/DOM/window.btoa#Unicode_Strings
function utf8_to_b64(str) {
return window.btoa(unescape(encodeURIComponent(str)));
}
function b64_to_utf8(str) {
return decodeURIComponent(escape(window.atob(str)));
}
// Handle the custom images 'API'
// Supported URLs are:
// 1. DOMAIN
// The just the page domain / loads one of the default files
//
// 2. DOMAIN?BASE64==
// Where BASE64== is a UTF-8 base64 encoded string of one of the following things:
// a. An image URL
// Example: http://i.imgur.com/cz1Jb.jpg
// Use that URL image instead of the default one.
//
// b. A JSON string representing an array of URLs
// Example: ["http://i.imgur.com/cz1Jb.jpg","http://i.imgur.com/Q5IqH.jpg"]
// Pick one of the images at random and use that instead of the default one.
//
// c. A JSON string representing an object with the keys 'images', 'background' and 'hideNote'
// Example: {"background":"#000","images":["http://i.imgur.com/cz1Jb.jpg","http://i.imgur.com/Q5IqH.jpg"]}
// images (required): Pick one of the images at random and use that instead of the default one.
// background (optional): Use the value of background as the page background.
// hideNote (optional): Hide the mention on the bottom.
//
// 3. DOMAIN?image_url
// Where image URL is an actual image URL that will get re-encoded into base64 (2)
// Example: http://i.imgur.com/cz1Jb.jpg
//
// Note: where DOMAIN is usually http://koalastothemax.com
function goToHidden(location, string) {
location.href =
"//" +
location.host +
location.pathname +
"?" +
utf8_to_b64(string);
}
function basicLoad(location) {
var possible = ["koalas", "koalas1", "koalas2", "koalas3"];
var file =
"img/" +
possible[Math.floor(Math.random() * possible.length)] +
".jpg";
return {
file: file,
shownFile:
location.protocol +
"//" +
location.host +
location.pathname +
file,
};
}
function parseUrl(location) {
var href = location.href;
var idx, param, file;
idx = href.indexOf("?");
if (idx === -1 || idx === href.length - 1) {
return basicLoad(location); // Case 1
}
param = href.substr(idx + 1);
if (!/^[a-z0-9+\/]+=*$/i.test(param)) {
// Does not look base64
goToHidden(location, param);
return null;
}
// Case 2
try {
param = b64_to_utf8(param);
} catch (e) {
return basicLoad(location); // Invalid base64, do a basic load
}
try {
param = JSON.parse(param);
} catch (e) {
// Case 2a
return {
file: param,
shownFile: param,
};
}
// At this point param is a JS object
if (Array.isArray(param) && param.length) {
// Case 2b
file = param[Math.floor(Math.random() * param.length)];
return {
file: file,
shownFile: file,
};
}
if (Array.isArray(param.images) && param.images.length) {
// Case 2c
file =
param.images[Math.floor(Math.random() * param.images.length)];
return {
file: file,
shownFile: file,
background: param.background,
hideNote: param.hideNote,
};
}
// Fall though
return basicLoad(location);
}
var parse = parseUrl(location);
if (!parse) return;
var file = parse.file;
window.shownFile = parse.shownFile;
if (parse.background) {
d3.select(document.body).style("background", parse.background);
}
if (parse.hideNote) {
d3.select("#footer").style("display", "none");
}
if (/^https?:/.test(file)) {
var fileurl = file;
}
function onEvent(what, value) {
track(what, value);
if (what === "LayerClear" && value == 0) {
d3.select("#next")
.style("display", null)
.select("input")
.on("keydown", function () {
d3.select("div.err").remove();
if (d3.event.keyCode !== 13) return;
var input = d3.select(this).property("value");
if (input.match(/^http:\/\/.+\..+/i)) {
track("Submit", input);
d3.select("#next div.msg").text("Thinking...");
d3.select(this).style("display", "none");
setTimeout(function () {
goToHidden(location, input);
}, 750);
} else {
d3.select("#next")
.selectAll("div.err")
.data([0])
.enter()
.append("div")
.attr("class", "err")
.text(
"That doesn't appear to be a valid image URL. [Hint: it should start with 'http://']"
);
}
});
}
}
var img = new Image();
var url;
axios
.get(fileurl)
.then((response) => {
if (!response.ok) {
throw new Error(
"Network response was not ok " + response.statusText
);
}
return response.blob(); // 或者你可以根据需要将数据转换为其他类型,如arrayBuffer(),text()等
})
.then((blob) => {
// 你可以在这里处理返回的图片数据
// 比如,将Blob数据转换为URL,然后设置到img元素的src属性中
img.src = URL.createObjectURL(blob);
})
.catch((error) => {
console.error(error);
});
img.onload = function () {
var colorData;
try {
colorData = koala.loadImage(this);
} catch (e) {}
if (colorData) {
koala.makeCircles("#dots", colorData, onEvent);
track("GoodLoad", "Yay");
}
};
<!-- img.src = url; -->
} catch (e) {
track("Problemo", String(e.message));
}
// Local download functionality
var saveNumber = 0;
d3.select("#love").on("click", function () {
saveNumber++;
track("SaveSVG", saveNumber);
svgData = d3.select("#dots").html();
if (svgData.indexOf("<svg") !== -1) {
prefix = [
'<?xml version="1.0" encoding="utf-8"?>',
"<!-- Generator: KoalasToTheMax.com -->",
'<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">',
];
saveAs(
new Blob([svgData.replace("<svg", prefix.join(" ") + "<svg")], {
type: "text/plain;charset=utf-8",
}),
"KoalasToTheMax.svg"
);
} else {
track("SaveSVG", "Fail");
}
});
})();
</script>
<!--<![endif]-->
</body>
</html>