Editing Talk:1190: Time
Please sign your posts with ~~~~ |
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.
The edit can be undone.
Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 67: | Line 67: | ||
::: No..I checked the random string. They're exactly the same. In fact, now it's gone back to the second image. Again. [[Special:Contributions/220.224.246.97|220.224.246.97]] 08:07, 25 March 2013 (UTC) | ::: No..I checked the random string. They're exactly the same. In fact, now it's gone back to the second image. Again. [[Special:Contributions/220.224.246.97|220.224.246.97]] 08:07, 25 March 2013 (UTC) | ||
− | Just found this JavaScript code embedded in the comic HTML source (Update: Reformatted to prevent eye-bleeding): | + | Just found this JavaScript code embedded in the comic HTML source (Update: Reformatted to prevent eye-bleeding): |
+ | <pre>(function (e) { | ||
+ | "use strict"; | ||
+ | |||
+ | function t() { | ||
+ | this.data = {} | ||
+ | } | ||
+ | function n() { | ||
+ | this.listeners = new t | ||
+ | } | ||
+ | function r(e) { | ||
+ | setTimeout(function () { | ||
+ | throw e | ||
+ | }, 0) | ||
+ | } | ||
+ | function i(e) { | ||
+ | this.type = e | ||
+ | } | ||
+ | function s(e, t) { | ||
+ | i.call(this, e), this.data = t.data, this.lastEventId = t.lastEventId | ||
+ | } | ||
+ | function g(e, t) { | ||
+ | var n = Number(e); | ||
+ | return (n < 1 ? 1 : n > 18e6 ? 18e6 : n) || t | ||
+ | } | ||
+ | function y(e, t, n) { | ||
+ | try { | ||
+ | typeof e[t] == "function" && e[t](n) | ||
+ | } catch (i) { | ||
+ | r(i) | ||
+ | } | ||
+ | } | ||
+ | function b(t, r) { | ||
+ | function B() { | ||
+ | L = d, N !== null && (N.abort(), N = null), C !== 0 && (clearTimeout(C), C = 0), S.readyState = d | ||
+ | } | ||
+ | function j(e) { | ||
+ | var t = L === p || L === h ? N.responseText || "" : "", | ||
+ | n = null; | ||
+ | if (L === h) { | ||
+ | var r = f ? t !== "" ? N.getResponseHeader("Content-Type") : "" : N.contentType; | ||
+ | if (r && v.test(r)) { | ||
+ | L = p, T = !0, x = u, S.readyState = p, n = new i("open"), S.dispatchEvent(n), y(S, "onopen", n); | ||
+ | if (L === d) return | ||
+ | } | ||
+ | } | ||
+ | if (L === p) { | ||
+ | t.length > k && (H = !0, T = !0); | ||
+ | var o = 0, | ||
+ | a = t.indexOf("\r", k), | ||
+ | l = t.indexOf("\n", k); | ||
+ | while (a !== -1 || l !== -1) { | ||
+ | a === -1 || l !== -1 && l < a ? (o = l, l = t.indexOf("\n", o + 1)) : (o = a, a = t.indexOf("\r", o + 1)); | ||
+ | var m = t.slice(k, o), | ||
+ | B = D; | ||
+ | D = t.slice(o, o + 1) === "\r", k = o + 1; | ||
+ | if (!B || m.length !== 0 || D) { | ||
+ | _.push(m); | ||
+ | var j = _.join(""); | ||
+ | _.length = 0; | ||
+ | if (j !== "") { | ||
+ | var I = "", | ||
+ | q = j.indexOf(":", 0); | ||
+ | q !== -1 && (I = j.slice(q + (j.slice(q + 1, q + 2) === " " ? 2 : 1)), j = j.slice(0, q)), j === "data" ? A.push(I) : j === "id" ? O = I : j === "event" ? M = I : j === "retry" ? (u = g(I, u), x = u, b < u && (b = u)) : j === "retryLimit" ? b = g(I, b) : j === "heartbeatTimeout" && (w = g(I, w), C !== 0 && (clearTimeout(C), C = setTimeout(R, w))) | ||
+ | } else { | ||
+ | if (A.length !== 0) { | ||
+ | E = O; | ||
+ | var U = M || "message"; | ||
+ | n = new s(U, { | ||
+ | data: A.join("\n"), | ||
+ | lastEventId: O | ||
+ | }), S.dispatchEvent(n), U === "message" && y(S, "onmessage", n); | ||
+ | if (L === d) return | ||
+ | } | ||
+ | A.length = 0, M = "" | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | k !== t.length && (_.push(t.slice(k)), k = t.length) | ||
+ | } | ||
+ | H && P === 0 && (H = !1, P = setTimeout(F, 80)), L !== p && L !== h || !(e || k > 1048576 || C === 0 && !T) ? C === 0 && (T = !1, C = setTimeout(R, w)) : (L = c, N.abort(), C !== 0 && (clearTimeout(C), C = 0), x > b && (x = b), C = setTimeout(R, x), x = x * 2 + 1, S.readyState = h, n = new i("error"), S.dispatchEvent(n), y(S, "onerror", n)) | ||
+ | } | ||
+ | function F() { | ||
+ | P = 0, j(!1) | ||
+ | } | ||
+ | function I() { | ||
+ | j(!1) | ||
+ | } | ||
+ | function q() { | ||
+ | j(!0) | ||
+ | } | ||
+ | function R() { | ||
+ | C = 0; | ||
+ | if (L !== c) { | ||
+ | j(!1); | ||
+ | return | ||
+ | } | ||
+ | if (navigator.onLine === !1) { | ||
+ | C = setTimeout(R, 500); | ||
+ | return | ||
+ | } | ||
+ | if (m && e.document && (e.document.readyState === "loading" || e.document.readyState === "interactive")) { | ||
+ | C = setTimeout(R, 100); | ||
+ | return | ||
+ | } | ||
+ | N.onload = N.onerror = q, N.mozAnon === undefined ? N.onprogress = I : N.onreadystatechange = I, T = !1, C = setTimeout(R, w), k = 0, L = h, A.length = 0, M = "", O = E, _.length = 0, D = !1, N.open("GET", t + ((t.indexOf("?", 0) === -1 ? "?" : "&") + "lastEventId=" + encodeURIComponent(E) + "&r=" + String(Math.random() + 1).slice(2)), !0), N.withCredentials = o, N.responseType = "text", f && N.setRequestHeader("Accept", "text/event-stream"), N.send(null) | ||
+ | } | ||
+ | t = String(t); | ||
+ | var o = Boolean(a && r && r.withCredentials), | ||
+ | u = g(r ? r.retry : NaN, 1e3), | ||
+ | b = g(r ? r.retryLimit : NaN, 3e5), | ||
+ | w = g(r ? r.heartbeatTimeout : NaN, 45e3), | ||
+ | E = r && r.lastEventId && String(r.lastEventId) || "", | ||
+ | S = this, | ||
+ | x = u, | ||
+ | T = !1, | ||
+ | N = new l, | ||
+ | C = 0, | ||
+ | k = 0, | ||
+ | L = c, | ||
+ | A = [], | ||
+ | O = "", | ||
+ | M = "", | ||
+ | _ = [], | ||
+ | D = !1, | ||
+ | P = 0, | ||
+ | H = !1; | ||
+ | r = null, n.call(this), this.close = B, this.url = t, this.readyState = h, this.withCredentials = o, R() | ||
+ | } | ||
+ | function w() { | ||
+ | this.CONNECTING = h, this.OPEN = p, this.CLOSED = d | ||
+ | } | ||
+ | t.prototype = { | ||
+ | get: function (e) { | ||
+ | return this.data[e + "~"] | ||
+ | }, | ||
+ | set: function (e, t) { | ||
+ | this.data[e + "~"] = t | ||
+ | }, | ||
+ | "delete": function (e) { | ||
+ | delete this.data[e + "~"] | ||
+ | } | ||
+ | }, n.prototype = { | ||
+ | dispatchEvent: function (e) { | ||
+ | var t = String(e.type), | ||
+ | n = this.listeners, | ||
+ | i = n.get(t); | ||
+ | if (!i) return; | ||
+ | var s = i.length, | ||
+ | o = -1; | ||
+ | while (++o < s) { | ||
+ | var u = i[o]; | ||
+ | try { | ||
+ | u.call(this, e) | ||
+ | } catch (a) { | ||
+ | r(a) | ||
+ | } | ||
+ | } | ||
+ | }, | ||
+ | addEventListener: function (e, t) { | ||
+ | e = String(e); | ||
+ | var n = this.listeners, | ||
+ | r = n.get(e); | ||
+ | r || n.set(e, r = []); | ||
+ | var i = r.length; | ||
+ | while (--i >= 0) if (r[i] === t) return; | ||
+ | r.push(t) | ||
+ | }, | ||
+ | removeEventListener: function (e, t) { | ||
+ | e = String(e); | ||
+ | var n = this.listeners, | ||
+ | r = n.get(e); | ||
+ | if (!r) return; | ||
+ | var i = r.length, | ||
+ | s = [], | ||
+ | o = -1; | ||
+ | while (++o < i) r[o] !== t && s.push(r[o]); | ||
+ | s.length === 0 ? n["delete"](e) : n.set(e, s) | ||
+ | } | ||
+ | }, s.prototype = i.prototype; | ||
+ | var o = e.XMLHttpRequest, | ||
+ | u = e.XDomainRequest, | ||
+ | a = Boolean(o && (new o).withCredentials !== undefined), | ||
+ | f = a, | ||
+ | l = a ? o : u, | ||
+ | c = -1, | ||
+ | h = 0, | ||
+ | p = 1, | ||
+ | d = 2, | ||
+ | v = /^text\/event\-stream;?(\s*charset\=utf\-8)?$/i, | ||
+ | m = /AppleWebKit\/5([0-2][0-9]|3[0-4])[^\d]/.test(navigator.userAgent); | ||
+ | w.prototype = n.prototype, b.prototype = new w, w.call(b), l && (e.EventSource = b) | ||
+ | })(this), | ||
+ | function () { | ||
+ | function e(e) { | ||
+ | (new Image).src = "http://xkcd.com/events/" + e | ||
+ | } | ||
+ | function t() { | ||
+ | location.hash == "#verbose" && console.log.apply(console, arguments) | ||
+ | } | ||
+ | try { | ||
+ | var n = "http://c0.xkcd.com/stream/comic/time?method=EventSource", | ||
+ | r = new EventSource(n); | ||
+ | t("connecting to event source:", n), r.addEventListener("open", function (t) { | ||
+ | e("connect_start") | ||
+ | }, !1), r.addEventListener("error", function (t) { | ||
+ | e("connect_error") | ||
+ | }, !1), r.addEventListener("loadtest", t, !1), r.addEventListener("comic/time", t, !1), r.addEventListener("comic/time", function (e) { | ||
+ | var n = JSON.parse(e.data), | ||
+ | r = document.getElementById("comic").getElementsByTagName("img")[0], | ||
+ | i = Math.round(Math.random() * n.spread); | ||
+ | t("waiting", i, "seconds before displaying comic", n.image), setTimeout(function () { | ||
+ | r.src = "http://imgs.xkcd.com/comics/time/" + n.image | ||
+ | }, i * 1e3) | ||
+ | }, !1) | ||
+ | } catch (i) { | ||
+ | e("js_error") | ||
+ | } | ||
+ | }();</pre> | ||
I'm no programmer but this looks important to me... | I'm no programmer but this looks important to me... | ||
− | |||
− | |||
:Doesn't really help. The script basically changes the image when something happens (probably some time passes, although it's possible there is more hidden there). WHAT image then appears is not directed by the script, but by the site. Specifically, the image displayed as first is taken from [http://c0.xkcd.com/redirect/comic/time http://c0.xkcd.com/redirect/comic/time], while the script asks for [http://c0.xkcd.com/stream/comic/time?method=EventSource&r=(somenumber) http://c0.xkcd.com/stream/comic/time?method=EventSource&r=(somenumber)] ... which is, if you get correct "r", probably some json containing the image url. So, even if you hack the script, you will not get all possible urls. -- [[User:Hkmaly|Hkmaly]] ([[User talk:Hkmaly|talk]]) 09:17, 25 March 2013 (UTC) | :Doesn't really help. The script basically changes the image when something happens (probably some time passes, although it's possible there is more hidden there). WHAT image then appears is not directed by the script, but by the site. Specifically, the image displayed as first is taken from [http://c0.xkcd.com/redirect/comic/time http://c0.xkcd.com/redirect/comic/time], while the script asks for [http://c0.xkcd.com/stream/comic/time?method=EventSource&r=(somenumber) http://c0.xkcd.com/stream/comic/time?method=EventSource&r=(somenumber)] ... which is, if you get correct "r", probably some json containing the image url. So, even if you hack the script, you will not get all possible urls. -- [[User:Hkmaly|Hkmaly]] ([[User talk:Hkmaly|talk]]) 09:17, 25 March 2013 (UTC) |