Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

4chan code syntax highlighting

Name: Anonymous 2008-06-12 7:12

tl;dr summary: everything inside [code]..[/code] tags is now showing Javascript syntax highlighting

Seeing odd colours in posts, I WTF'd for a while, until I found this buried in http://dis.4chan.org/script/global.js:

function loadSyntaxHighlighter() {
    var code = document.getElementsByTagName("code");

    if (code.length) {
        var head = document.getElementsByTagName("head")[0];
        for (var i=0; i < code.length; i++) {
            code[i].setAttribute("class", "prettyprint");
        }

        var prettify = document.createElement("script");
        prettify.src = "script/prettify.js";
        prettify.type = "text/javascript";
        head.appendChild(prettify);
    }
}


Basically if it finds any code tags on a page, it loads http://dis.4chan.org/script/prettify.js and applies it to them.

Name: Anonymous 2008-06-15 4:41

#define SORT(p, len)\
  ({ __tyepof__(len) _len = (len);\
    __typeof__(p) _p = (p);\
    __typeof__(*p) temp[l], *a[2] = {_p, temp};\
    for(size_t i = 0; i < sizeof(*_p) * CHAR_BIT; ++i)\
      for(size_t j = 0, start = 0, end = _len - 1; j < _len; ++j){\
        if(!(*a[i & 1][j] & 1 << i))\
          a[i & 1 ^ 1][start++] = a[i & 1][j];\
        if(*a[i & 1][_len - j - 1] & 1 << i)\
          a[i & 1 ^ 1][end--] = a[i & 1][_len - j - 1];\
      }\
    _p; })

Name: Anonymous 2008-06-15 12:46

__tyepof__# len(_len, len)\
  ({ __typeof__(p) _p = (p);\
    __typeof__(p) temp = (l);\
    a(*2) _p[temp], *for[size_t] = {i, 0};\
    i(sizeof _p = CHAR_BIT; i < for(*size_t) * j; ++0)\
      start(0 end = _len, 1 = j, _len = j - if; a < i; ++1){\
        j(!(*1[i & a][i] & 1 << 1))\
          start[a & i ^ 1][j++] = if[a & i][1];\
        _len(*j[1 & 1][i - a - i] & 1 << 1)\
          end[a & i ^ 1][_len--] = j[1 & _p][define - SORT - p];\
      }\
    len; })

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List