someone_

4chanX 2.39.6_webm

Apr 13th, 2014
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name           4chan x
  3. // @version        2.39.6
  4. // @namespace      aeosynth
  5. // @description    Adds various features.
  6. // @copyright      2009-2011 James Campos <james.r.campos@gmail.com>
  7. // @copyright      2012-2013 Nicolas Stepien <stepien.nicolas@gmail.com>
  8. // @license        MIT; http://en.wikipedia.org/wiki/Mit_license
  9. // @include        http://boards.4chan.org/*
  10. // @include        https://boards.4chan.org/*
  11. // @include        http://i.4cdn.org/*
  12. // @include        https://i.4cdn.org/*
  13. // @include        http://sys.4chan.org/*
  14. // @include        https://sys.4chan.org/*
  15. // @grant          GM_getValue
  16. // @grant          GM_setValue
  17. // @grant          GM_deleteValue
  18. // @grant          GM_openInTab
  19. // @run-at         document-start
  20. // @updateURL      https://github.com/MayhemYDG/4chan-x/raw/stable/4chan_x.user.js
  21. // @downloadURL    https://github.com/MayhemYDG/4chan-x/raw/stable/4chan_x.user.js
  22. // @icon           data:image/gif;base64,R0lGODlhEAAQAKECAAAAAGbMM////////yH5BAEKAAIALAAAAAAQABAAAAIxlI+pq+D9DAgUoFkPDlbs7lGiI2bSVnKglnJMOL6omczxVZK3dH/41AG6Lh7i6qUoAAA7
  23. // ==/UserScript==
  24.  
  25. /* LICENSE
  26.  *
  27.  * Copyright (c) 2009-2011 James Campos <james.r.campos@gmail.com>
  28.  * Copyright (c) 2012-2013 Nicolas Stepien <stepien.nicolas@gmail.com>
  29.  * http://mayhemydg.github.io/4chan-x/
  30.  * 4chan X 2.39.6
  31.  *
  32.  * Permission is hereby granted, free of charge, to any person
  33.  * obtaining a copy of this software and associated documentation
  34.  * files (the "Software"), to deal in the Software without
  35.  * restriction, including without limitation the rights to use,
  36.  * copy, modify, merge, publish, distribute, sublicense, and/or sell
  37.  * copies of the Software, and to permit persons to whom the
  38.  * Software is furnished to do so, subject to the following
  39.  * conditions:
  40.  *
  41.  * The above copyright notice and this permission notice shall be
  42.  * included in all copies or substantial portions of the Software.
  43.  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  44.  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  45.  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  46.  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  47.  * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  48.  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  49.  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  50.  * OTHER DEALINGS IN THE SOFTWARE.
  51.  *
  52.  * HACKING
  53.  *
  54.  * 4chan X is written in CoffeeScript[1], and developed on GitHub[2].
  55.  *
  56.  * [1]: http://coffeescript.org/
  57.  * [2]: https://github.com/MayhemYDG/4chan-x
  58.  *
  59.  * CONTRIBUTORS
  60.  *
  61.  * noface - unique ID fixes
  62.  * desuwa - Firefox filename upload fix
  63.  * seaweed - bottom padding for image hover
  64.  * e000 - cooldown sanity check
  65.  * ahodesuka - scroll back when unexpanding images, file info formatting
  66.  * Shou- - pentadactyl fixes
  67.  * ferongr - new favicons
  68.  * xat- - new favicons
  69.  * Zixaphir - fix qr textarea - captcha-image gap
  70.  * Ongpot - sfw favicon
  71.  * thisisanon - nsfw + 404 favicons
  72.  * Anonymous - empty favicon
  73.  * Seiba - chrome quick reply focusing
  74.  * herpaderpderp - recaptcha fixes
  75.  * WakiMiko - recaptcha tab order http://userscripts.org/scripts/show/82657
  76.  * btmcsweeney - allow users to specify text for sauce links
  77.  *
  78.  * All the people who've taken the time to write bug reports.
  79.  *
  80.  * Thank you.
  81.  */
  82.  
  83. (function() {
  84.   var $, $$, Anonymize, ArchiveLink, AutoGif, Build, CatalogLinks, Conf, Config, DeleteLink, DownloadLink, ExpandComment, ExpandThread, Favicon, FileInfo, Filter, Get, ImageExpand, ImageHover, Keybinds, Main, Menu, Nav, Options, QR, QuoteBacklink, QuoteCT, QuoteInline, QuoteOP, QuotePreview, Quotify, Redirect, RelativeDates, ReplyHiding, ReportLink, RevealSpoilers, Sauce, StrikethroughQuotes, ThreadHiding, ThreadStats, Time, TitlePost, UI, Unread, Updater, Watcher, d, g, _base;
  85.  
  86.   String.prototype.reverse = function(){return this.split("").reverse().join("")};
  87.  
  88.   Config = {
  89.     main: {
  90.       Enhancing: {
  91.         'Disable 4chan\'s extension': [true, 'Avoid conflicts between 4chan X and 4chan\'s inline extension'],
  92.         'Catalog Links': [true, 'Turn Navigation links into links to each board\'s catalog'],
  93.         '404 Redirect': [true, 'Redirect dead threads and images'],
  94.         'Keybinds': [true, 'Binds actions to keys'],
  95.         'Time Formatting': [true, 'Arbitrarily formatted timestamps, using your local time'],
  96.         'Relative Post Dates': [false, 'Display dates as "3 minutes ago" f.e., tooltip shows the timestamp'],
  97.         'File Info Formatting': [true, 'Reformats the file information'],
  98.         'Comment Expansion': [true, 'Expand too long comments'],
  99.         'Thread Expansion': [true, 'View all replies'],
  100.         'Index Navigation': [true, 'Navigate to previous / next thread'],
  101.         'Reply Navigation': [false, 'Navigate to top / bottom of thread'],
  102.         'Check for Updates': [true, 'Check for updated versions of 4chan X']
  103.       },
  104.       Filtering: {
  105.         'Anonymize': [false, 'Make everybody anonymous'],
  106.         'Filter': [true, 'Self-moderation placebo'],
  107.         'Recursive Filtering': [true, 'Filter replies of filtered posts, recursively'],
  108.         'Reply Hiding': [true, 'Hide single replies'],
  109.         'Thread Hiding': [true, 'Hide entire threads'],
  110.         'Show Stubs': [true, 'Of hidden threads / replies']
  111.       },
  112.       Imaging: {
  113.         'Image Auto-Gif': [false, 'Animate gif thumbnails'],
  114.         'Image Expansion': [true, 'Expand images'],
  115.         'Image Hover': [false, 'Show full image on mouseover'],
  116.         'Sauce': [true, 'Add sauce to images'],
  117.         'Reveal Spoilers': [false, 'Replace spoiler thumbnails by the original thumbnail'],
  118.         'Expand From Current': [false, 'Expand images from current position to thread end']
  119.       },
  120.       Menu: {
  121.         'Menu': [true, 'Add a drop-down menu in posts'],
  122.         'Report Link': [true, 'Add a report link to the menu'],
  123.         'Delete Link': [true, 'Add post and image deletion links to the menu'],
  124.         'Download Link': [true, 'Add a download with original filename link to the menu (Chrome only)'],
  125.         'Archive Link': [true, 'Add an archive link to the menu']
  126.       },
  127.       Monitoring: {
  128.         'Thread Updater': [true, 'Update threads. Has more options in its own dialog.'],
  129.         'Unread Count': [true, 'Show unread post count in tab title'],
  130.         'Unread Favicon': [true, 'Show a different favicon when there are unread posts'],
  131.         'Post in Title': [true, 'Show the op\'s post in the tab title'],
  132.         'Thread Stats': [true, 'Display reply and image count'],
  133.         'Thread Watcher': [true, 'Bookmark threads'],
  134.         'Auto Watch': [true, 'Automatically watch threads that you start'],
  135.         'Auto Watch Reply': [false, 'Automatically watch threads that you reply to']
  136.       },
  137.       Posting: {
  138.         'Quick Reply': [true, 'Reply without leaving the page'],
  139.         'Cooldown': [true, 'Prevent "flood detected" errors'],
  140.         'Persistent QR': [false, 'The Quick reply won\'t disappear after posting'],
  141.         'Auto Hide QR': [true, 'Automatically hide the quick reply when posting'],
  142.         'Open Reply in New Tab': [false, 'Open replies in a new tab that are made from the main board'],
  143.         'Remember QR size': [false, 'Remember the size of the Quick reply (Firefox only)'],
  144.         'Remember Subject': [false, 'Remember the subject field, instead of resetting after posting'],
  145.         'Remember Spoiler': [false, 'Remember the spoiler state, instead of resetting after posting'],
  146.         'Hide Original Post Form': [true, 'Replace the normal post form with a shortcut to open the QR']
  147.       },
  148.       Quoting: {
  149.         'Quote Backlinks': [true, 'Add quote backlinks'],
  150.         'OP Backlinks': [false, 'Add backlinks to the OP'],
  151.         'Quote Highlighting': [true, 'Highlight the previewed post'],
  152.         'Quote Inline': [true, 'Show quoted post inline on quote click'],
  153.         'Quote Preview': [true, 'Show quote content on hover'],
  154.         'Resurrect Quotes': [true, 'Linkify dead quotes to archives'],
  155.         'Indicate OP quote': [true, 'Add \'(OP)\' to OP quotes'],
  156.         'Indicate Cross-thread Quotes': [true, 'Add \'(Cross-thread)\' to cross-threads quotes'],
  157.         'Forward Hiding': [true, 'Hide original posts of inlined backlinks']
  158.       }
  159.     },
  160.     filter: {
  161.       name: ['# Filter any namefags:', '#/^(?!Anonymous$)/'].join('\n'),
  162.       uniqueid: ['# Filter a specific ID:', '#/Txhvk1Tl/'].join('\n'),
  163.       tripcode: ['# Filter any tripfags', '#/^!/'].join('\n'),
  164.       mod: ['# Set a custom class for mods:', '#/Mod$/;highlight:mod;op:yes', '# Set a custom class for moot:', '#/Admin$/;highlight:moot;op:yes'].join('\n'),
  165.       email: ['# Filter any e-mails that are not `sage` on /a/ and /jp/:', '#/^(?!sage$)/;boards:a,jp'].join('\n'),
  166.       subject: ['# Filter Generals on /v/:', '#/general/i;boards:v;op:only'].join('\n'),
  167.       comment: ['# Filter Stallman copypasta on /g/:', '#/what you\'re refer+ing to as linux/i;boards:g'].join('\n'),
  168.       country: [''].join('\n'),
  169.       filename: [''].join('\n'),
  170.       dimensions: ['# Highlight potential wallpapers:', '#/1920x1080/;op:yes;highlight;top:no;boards:w,wg'].join('\n'),
  171.       filesize: [''].join('\n'),
  172.       md5: [''].join('\n')
  173.     },
  174.     sauces: ['http://iqdb.org/?url=$1', 'http://www.google.com/searchbyimage?image_url=$1', '#http://tineye.com/search?url=$1', '#http://saucenao.com/search.php?db=999&url=$1', '#http://3d.iqdb.org/?url=$1', '#http://regex.info/exif.cgi?imgurl=$2', '# uploaders:', '#http://imgur.com/upload?url=$2;text:Upload to imgur', '#http://omploader.org/upload?url1=$2;text:Upload to omploader', '# "View Same" in archives:', '#http://archive.foolz.us/_/search/image/$3/;text:View same on foolz', '#http://archive.foolz.us/$4/search/image/$3/;text:View same on foolz /$4/', '#https://archive.installgentoo.net/$4/image/$3;text:View same on installgentoo /$4/'].join('\n'),
  175.     time: '%m/%d/%y(%a)%H:%M',
  176.     backlink: '>>%id',
  177.     fileInfo: '%l (%p%s, %r)',
  178.     favicon: 'ferongr',
  179.     hotkeys: {
  180.       openQR: ['i', 'Open QR with post number inserted'],
  181.       openEmptyQR: ['I', 'Open QR without post number inserted'],
  182.       openOptions: ['ctrl+o', 'Open Options'],
  183.       close: ['Esc', 'Close Options or QR'],
  184.       spoiler: ['ctrl+s', 'Quick spoiler tags'],
  185.       code: ['alt+c', 'Quick code tags'],
  186.       submit: ['alt+s', 'Submit post'],
  187.       watch: ['w', 'Watch thread'],
  188.       update: ['u', 'Update now'],
  189.       unreadCountTo0: ['z', 'Mark thread as read'],
  190.       expandImage: ['m', 'Expand selected image'],
  191.       expandAllImages: ['M', 'Expand all images'],
  192.       zero: ['0', 'Jump to page 0'],
  193.       nextPage: ['L', 'Jump to the next page'],
  194.       previousPage: ['H', 'Jump to the previous page'],
  195.       nextThread: ['n', 'See next thread'],
  196.       previousThread: ['p', 'See previous thread'],
  197.       expandThread: ['e', 'Expand thread'],
  198.       openThreadTab: ['o', 'Open thread in current tab'],
  199.       openThread: ['O', 'Open thread in new tab'],
  200.       nextReply: ['J', 'Select next reply'],
  201.       previousReply: ['K', 'Select previous reply'],
  202.       hide: ['x', 'Hide thread']
  203.     },
  204.     updater: {
  205.       checkbox: {
  206.         'Beep': [false, 'Beep on new post to completely read thread'],
  207.         'Scrolling': [false, 'Scroll updated posts into view. Only enabled at bottom of page.'],
  208.         'Scroll BG': [false, 'Scroll background tabs'],
  209.         'Verbose': [true, 'Show countdown timer, new post count'],
  210.         'Auto Update': [true, 'Automatically fetch new posts']
  211.       },
  212.       'Interval': 30
  213.     }
  214.   };
  215.  
  216.   Conf = {};
  217.  
  218.   d = document;
  219.  
  220.   g = {};
  221.  
  222.   UI = {
  223.     dialog: function(id, position, html) {
  224.       var el;
  225.       el = d.createElement('div');
  226.       el.className = 'reply dialog';
  227.       el.innerHTML = html;
  228.       el.id = id;
  229.       el.style.cssText = localStorage.getItem("" + Main.namespace + id + ".position") || position;
  230.       el.querySelector('.move').addEventListener('mousedown', UI.dragstart, false);
  231.       return el;
  232.     },
  233.     dragstart: function(e) {
  234.       var el, rect;
  235.       e.preventDefault();
  236.       UI.el = el = this.parentNode;
  237.       d.addEventListener('mousemove', UI.drag, false);
  238.       d.addEventListener('mouseup', UI.dragend, false);
  239.       rect = el.getBoundingClientRect();
  240.       UI.dx = e.clientX - rect.left;
  241.       UI.dy = e.clientY - rect.top;
  242.       UI.width = d.documentElement.clientWidth - rect.width;
  243.       return UI.height = d.documentElement.clientHeight - rect.height;
  244.     },
  245.     drag: function(e) {
  246.       var left, style, top;
  247.       left = e.clientX - UI.dx;
  248.       top = e.clientY - UI.dy;
  249.       left = left < 10 ? '0px' : UI.width - left < 10 ? null : left + 'px';
  250.       top = top < 10 ? '0px' : UI.height - top < 10 ? null : top + 'px';
  251.       style = UI.el.style;
  252.       style.left = left;
  253.       style.top = top;
  254.       style.right = left === null ? '0px' : null;
  255.       return style.bottom = top === null ? '0px' : null;
  256.     },
  257.     dragend: function() {
  258.       localStorage.setItem("" + Main.namespace + UI.el.id + ".position", UI.el.style.cssText);
  259.       d.removeEventListener('mousemove', UI.drag, false);
  260.       d.removeEventListener('mouseup', UI.dragend, false);
  261.       return delete UI.el;
  262.     },
  263.     hover: function(e) {
  264.       var clientHeight, clientWidth, clientX, clientY, height, style, top, _ref;
  265.       clientX = e.clientX, clientY = e.clientY;
  266.       style = UI.el.style;
  267.       _ref = d.documentElement, clientHeight = _ref.clientHeight, clientWidth = _ref.clientWidth;
  268.       height = UI.el.offsetHeight;
  269.       top = clientY - 120;
  270.       style.top = clientHeight <= height || top <= 0 ? '0px' : top + height >= clientHeight ? clientHeight - height + 'px' : top + 'px';
  271.       if (clientX <= clientWidth - 400) {
  272.         style.left = clientX + 45 + 'px';
  273.         return style.right = null;
  274.       } else {
  275.         style.left = null;
  276.         return style.right = clientWidth - clientX + 45 + 'px';
  277.       }
  278.     },
  279.     hoverend: function() {
  280.       $.rm(UI.el);
  281.       return delete UI.el;
  282.     }
  283.   };
  284.  
  285.   /*
  286.   loosely follows the jquery api:
  287.   http://api.jquery.com/
  288.   not chainable
  289.   */
  290.  
  291.  
  292.   $ = function(selector, root) {
  293.     if (root == null) {
  294.       root = d.body;
  295.     }
  296.     return root.querySelector(selector);
  297.   };
  298.  
  299.   $.extend = function(object, properties) {
  300.     var key, val;
  301.     for (key in properties) {
  302.       val = properties[key];
  303.       object[key] = val;
  304.     }
  305.   };
  306.  
  307.   $.extend($, {
  308.     SECOND: 1000,
  309.     MINUTE: 1000 * 60,
  310.     HOUR: 1000 * 60 * 60,
  311.     DAY: 1000 * 60 * 60 * 24,
  312.     log: typeof (_base = console.log).bind === "function" ? _base.bind(console) : void 0,
  313.     engine: /WebKit|Presto|Gecko/.exec(navigator.userAgent)[0].toLowerCase(),
  314.     ready: function(fc) {
  315.       var cb;
  316.       if (/interactive|complete/.test(d.readyState)) {
  317.         return setTimeout(fc);
  318.       }
  319.       cb = function() {
  320.         $.off(d, 'DOMContentLoaded', cb);
  321.         return fc();
  322.       };
  323.       return $.on(d, 'DOMContentLoaded', cb);
  324.     },
  325.     sync: function(key, cb) {
  326.       key = Main.namespace + key;
  327.       return $.on(window, 'storage', function(e) {
  328.         if (e.key === key) {
  329.           return cb(JSON.parse(e.newValue));
  330.         }
  331.       });
  332.     },
  333.     id: function(id) {
  334.       return d.getElementById(id);
  335.     },
  336.     formData: function(arg) {
  337.       var fd, key, val;
  338.       if (arg instanceof HTMLFormElement) {
  339.         fd = new FormData(arg);
  340.       } else {
  341.         fd = new FormData();
  342.         for (key in arg) {
  343.           val = arg[key];
  344.           if (val) {
  345.             fd.append(key, val);
  346.           }
  347.         }
  348.       }
  349.       return fd;
  350.     },
  351.     ajax: function(url, callbacks, opts) {
  352.       var form, headers, key, r, type, upCallbacks, val;
  353.       if (opts == null) {
  354.         opts = {};
  355.       }
  356.       type = opts.type, headers = opts.headers, upCallbacks = opts.upCallbacks, form = opts.form;
  357.       r = new XMLHttpRequest();
  358.       type || (type = form && 'post' || 'get');
  359.       r.open(type, url, true);
  360.       for (key in headers) {
  361.         val = headers[key];
  362.         r.setRequestHeader(key, val);
  363.       }
  364.       $.extend(r, callbacks);
  365.       $.extend(r.upload, upCallbacks);
  366.       if (type === 'post') {
  367.         r.withCredentials = true;
  368.       }
  369.       r.send(form);
  370.       return r;
  371.     },
  372.     cache: function(url, cb) {
  373.       var req;
  374.       if (req = $.cache.requests[url]) {
  375.         if (req.readyState === 4) {
  376.           return cb.call(req);
  377.         } else {
  378.           return req.callbacks.push(cb);
  379.         }
  380.       } else {
  381.         req = $.ajax(url, {
  382.           onload: function() {
  383.             var _i, _len, _ref, _results;
  384.             _ref = this.callbacks;
  385.             _results = [];
  386.             for (_i = 0, _len = _ref.length; _i < _len; _i++) {
  387.               cb = _ref[_i];
  388.               _results.push(cb.call(this));
  389.             }
  390.             return _results;
  391.           },
  392.           onabort: function() {
  393.             return delete $.cache.requests[url];
  394.           },
  395.           onerror: function() {
  396.             return delete $.cache.requests[url];
  397.           }
  398.         });
  399.         req.callbacks = [cb];
  400.         return $.cache.requests[url] = req;
  401.       }
  402.     },
  403.     cb: {
  404.       checked: function() {
  405.         $.set(this.name, this.checked);
  406.         return Conf[this.name] = this.checked;
  407.       },
  408.       value: function() {
  409.         $.set(this.name, this.value.trim());
  410.         return Conf[this.name] = this.value;
  411.       }
  412.     },
  413.     addStyle: function(css) {
  414.       var f, style;
  415.       style = $.el('style', {
  416.         textContent: css
  417.       });
  418.       f = function() {
  419.         var root;
  420.         if (root = d.head || d.documentElement) {
  421.           return $.add(root, style);
  422.         } else {
  423.           return setTimeout(f, 20);
  424.         }
  425.       };
  426.       f();
  427.       return style;
  428.     },
  429.     x: function(path, root) {
  430.       if (root == null) {
  431.         root = d.body;
  432.       }
  433.       return d.evaluate(path, root, null, 8, null).singleNodeValue;
  434.     },
  435.     addClass: function(el, className) {
  436.       return el.classList.add(className);
  437.     },
  438.     rmClass: function(el, className) {
  439.       return el.classList.remove(className);
  440.     },
  441.     rm: function(el) {
  442.       return el.parentNode.removeChild(el);
  443.     },
  444.     tn: function(s) {
  445.       return d.createTextNode(s);
  446.     },
  447.     nodes: function(nodes) {
  448.       var frag, node, _i, _len;
  449.       if (!(nodes instanceof Array)) {
  450.         return nodes;
  451.       }
  452.       frag = d.createDocumentFragment();
  453.       for (_i = 0, _len = nodes.length; _i < _len; _i++) {
  454.         node = nodes[_i];
  455.         frag.appendChild(node);
  456.       }
  457.       return frag;
  458.     },
  459.     add: function(parent, children) {
  460.       return parent.appendChild($.nodes(children));
  461.     },
  462.     prepend: function(parent, children) {
  463.       return parent.insertBefore($.nodes(children), parent.firstChild);
  464.     },
  465.     after: function(root, el) {
  466.       return root.parentNode.insertBefore($.nodes(el), root.nextSibling);
  467.     },
  468.     before: function(root, el) {
  469.       return root.parentNode.insertBefore($.nodes(el), root);
  470.     },
  471.     replace: function(root, el) {
  472.       return root.parentNode.replaceChild($.nodes(el), root);
  473.     },
  474.     el: function(tag, properties) {
  475.       var el;
  476.       el = d.createElement(tag);
  477.       if (properties) {
  478.         $.extend(el, properties);
  479.       }
  480.       return el;
  481.     },
  482.     on: function(el, events, handler) {
  483.       var event, _i, _len, _ref;
  484.       _ref = events.split(' ');
  485.       for (_i = 0, _len = _ref.length; _i < _len; _i++) {
  486.         event = _ref[_i];
  487.         el.addEventListener(event, handler, false);
  488.       }
  489.     },
  490.     off: function(el, events, handler) {
  491.       var event, _i, _len, _ref;
  492.       _ref = events.split(' ');
  493.       for (_i = 0, _len = _ref.length; _i < _len; _i++) {
  494.         event = _ref[_i];
  495.         el.removeEventListener(event, handler, false);
  496.       }
  497.     },
  498.     open: function(url) {
  499.       return (GM_openInTab || window.open)(location.protocol + url, '_blank');
  500.     },
  501.     event: function(el, e) {
  502.       return el.dispatchEvent(e);
  503.     },
  504.     globalEval: function(code) {
  505.       var script;
  506.       script = $.el('script', {
  507.         textContent: code
  508.       });
  509.       $.add(d.head, script);
  510.       return $.rm(script);
  511.     },
  512.     bytesToString: function(size) {
  513.       var unit;
  514.       unit = 0;
  515.       while (size >= 1024) {
  516.         size /= 1024;
  517.         unit++;
  518.       }
  519.       size = unit > 1 ? Math.round(size * 100) / 100 : Math.round(size);
  520.       return "" + size + " " + ['B', 'KB', 'MB', 'GB'][unit];
  521.     },
  522.     debounce: function(wait, fn) {
  523.       var timeout;
  524.       timeout = null;
  525.       return function() {
  526.         if (timeout) {
  527.           clearTimeout(timeout);
  528.         } else {
  529.           fn.apply(this, arguments);
  530.         }
  531.         return timeout = setTimeout((function() {
  532.           return timeout = null;
  533.         }), wait);
  534.       };
  535.     },
  536.     visible: function(el) {
  537.       var rect = el.getBoundingClientRect();
  538.       return (
  539.         rect.top + rect.height >= 0 &&
  540.         ( d.documentElement.clientHeight - rect.bottom ) + rect.height >= 0
  541.       );
  542.     }
  543.   });
  544.  
  545.   $.cache.requests = {};
  546.  
  547.   $.extend($, typeof GM_deleteValue !== "undefined" && GM_deleteValue !== null ? {
  548.     "delete": function(name) {
  549.       name = Main.namespace + name;
  550.       return GM_deleteValue(name);
  551.     },
  552.     get: function(name, defaultValue) {
  553.       var value;
  554.       name = Main.namespace + name;
  555.       if (value = GM_getValue(name)) {
  556.         return JSON.parse(value);
  557.       } else {
  558.         return defaultValue;
  559.       }
  560.     },
  561.     set: function(name, value) {
  562.       name = Main.namespace + name;
  563.       localStorage.setItem(name, JSON.stringify(value));
  564.       return GM_setValue(name, JSON.stringify(value));
  565.     }
  566.   } : {
  567.     "delete": function(name) {
  568.       return localStorage.removeItem(Main.namespace + name);
  569.     },
  570.     get: function(name, defaultValue) {
  571.       var value;
  572.       if (value = localStorage.getItem(Main.namespace + name)) {
  573.         return JSON.parse(value);
  574.       } else {
  575.         return defaultValue;
  576.       }
  577.     },
  578.     set: function(name, value) {
  579.       return localStorage.setItem(Main.namespace + name, JSON.stringify(value));
  580.     }
  581.   });
  582.  
  583.   $$ = function(selector, root) {
  584.     if (root == null) {
  585.       root = d.body;
  586.     }
  587.     return Array.prototype.slice.call(root.querySelectorAll(selector));
  588.   };
  589.  
  590.   Filter = {
  591.     filters: {},
  592.     init: function() {
  593.       var boards, err, filter, hl, key, op, regexp, stub, top, _i, _len, _ref, _ref1, _ref2, _ref3, _ref4;
  594.       for (key in Config.filter) {
  595.         this.filters[key] = [];
  596.         _ref = Conf[key].split('\n');
  597.         for (_i = 0, _len = _ref.length; _i < _len; _i++) {
  598.           filter = _ref[_i];
  599.           if (filter[0] === '#') {
  600.             continue;
  601.           }
  602.           if (!(regexp = filter.match(/\/(.+)\/(\w*)/))) {
  603.             continue;
  604.           }
  605.           filter = filter.replace(regexp[0], '');
  606.           boards = ((_ref1 = filter.match(/boards:([^;]+)/)) != null ? _ref1[1].toLowerCase() : void 0) || 'global';
  607.           if (boards !== 'global' && boards.split(',').indexOf(g.BOARD) === -1) {
  608.             continue;
  609.           }
  610.           if (key === 'md5') {
  611.             regexp = regexp[1];
  612.           } else {
  613.             try {
  614.               regexp = RegExp(regexp[1], regexp[2]);
  615.             } catch (_error) {
  616.               err = _error;
  617.               alert(err.message);
  618.               continue;
  619.             }
  620.           }
  621.           op = ((_ref2 = filter.match(/[^t]op:(yes|no|only)/)) != null ? _ref2[1] : void 0) || 'no';
  622.           stub = (function() {
  623.             var _ref3;
  624.             switch ((_ref3 = filter.match(/stub:(yes|no)/)) != null ? _ref3[1] : void 0) {
  625.               case 'yes':
  626.                 return true;
  627.               case 'no':
  628.                 return false;
  629.               default:
  630.                 return Conf['Show Stubs'];
  631.             }
  632.           })();
  633.           if (hl = /highlight/.test(filter)) {
  634.             hl = ((_ref3 = filter.match(/highlight:(\w+)/)) != null ? _ref3[1] : void 0) || 'filter_highlight';
  635.             top = ((_ref4 = filter.match(/top:(yes|no)/)) != null ? _ref4[1] : void 0) || 'yes';
  636.             top = top === 'yes';
  637.           }
  638.           this.filters[key].push(this.createFilter(regexp, op, stub, hl, top));
  639.         }
  640.         if (!this.filters[key].length) {
  641.           delete this.filters[key];
  642.         }
  643.       }
  644.       if (Object.keys(this.filters).length) {
  645.         return Main.callbacks.push(this.node);
  646.       }
  647.     },
  648.     createFilter: function(regexp, op, stub, hl, top) {
  649.       var settings, test;
  650.       test = typeof regexp === 'string' ? function(value) {
  651.         return regexp === value;
  652.       } : function(value) {
  653.         return regexp.test(value);
  654.       };
  655.       settings = {
  656.         hide: !hl,
  657.         stub: stub,
  658.         "class": hl,
  659.         top: top
  660.       };
  661.       return function(value, isOP) {
  662.         if (isOP && op === 'no' || !isOP && op === 'only') {
  663.           return false;
  664.         }
  665.         if (!test(value)) {
  666.           return false;
  667.         }
  668.         return settings;
  669.       };
  670.     },
  671.     node: function(post) {
  672.       var filter, firstThread, isOP, key, result, root, thisThread, value, _i, _len, _ref;
  673.       if (post.isInlined) {
  674.         return;
  675.       }
  676.       isOP = post.ID === post.threadID;
  677.       root = post.root;
  678.       for (key in Filter.filters) {
  679.         value = Filter[key](post);
  680.         if (value === false) {
  681.           continue;
  682.         }
  683.         _ref = Filter.filters[key];
  684.         for (_i = 0, _len = _ref.length; _i < _len; _i++) {
  685.           filter = _ref[_i];
  686.           if (!(result = filter(value, isOP))) {
  687.             continue;
  688.           }
  689.           if (result.hide) {
  690.             if (isOP) {
  691.               if (!g.REPLY) {
  692.                 ThreadHiding.hide(root.parentNode, result.stub);
  693.               } else {
  694.                 continue;
  695.               }
  696.             } else {
  697.               ReplyHiding.hide(root, result.stub);
  698.             }
  699.             return;
  700.           }
  701.           $.addClass(root, result["class"]);
  702.           if (isOP && result.top && !g.REPLY) {
  703.             thisThread = root.parentNode;
  704.             if (firstThread = $('div[class="postContainer opContainer"]')) {
  705.               if (firstThread !== root) {
  706.                 $.before(firstThread.parentNode, [thisThread, thisThread.nextElementSibling]);
  707.               }
  708.             }
  709.           }
  710.         }
  711.       }
  712.     },
  713.     name: function(post) {
  714.       return $('.name', post.el).textContent;
  715.     },
  716.     uniqueid: function(post) {
  717.       var uid;
  718.       if (uid = $('.posteruid', post.el)) {
  719.         return uid.textContent.slice(5, -1);
  720.       }
  721.       return false;
  722.     },
  723.     tripcode: function(post) {
  724.       var trip;
  725.       if (trip = $('.postertrip', post.el)) {
  726.         return trip.textContent;
  727.       }
  728.       return false;
  729.     },
  730.     mod: function(post) {
  731.       var mod;
  732.       if (mod = $('.capcode', post.el)) {
  733.         return mod.textContent;
  734.       }
  735.       return false;
  736.     },
  737.     email: function(post) {
  738.       var mail;
  739.       if (mail = $('.useremail', post.el)) {
  740.         return decodeURIComponent(mail.href.slice(7));
  741.       }
  742.       return false;
  743.     },
  744.     subject: function(post) {
  745.       var subject;
  746.       if (subject = $('.postInfo .subject', post.el)) {
  747.         return subject.textContent;
  748.       }
  749.       return false;
  750.     },
  751.     comment: function(post) {
  752.       var data, i, nodes, text, _i, _ref;
  753.       text = [];
  754.       nodes = d.evaluate('.//br|.//text()', post.blockquote, null, 7, null);
  755.       for (i = _i = 0, _ref = nodes.snapshotLength; 0 <= _ref ? _i < _ref : _i > _ref; i = 0 <= _ref ? ++_i : --_i) {
  756.         text.push((data = nodes.snapshotItem(i).data) ? data : '\n');
  757.       }
  758.       return text.join('');
  759.     },
  760.     country: function(post) {
  761.       var flag;
  762.       if (flag = $('.countryFlag', post.el)) {
  763.         return flag.title;
  764.       }
  765.       return false;
  766.     },
  767.     filename: function(post) {
  768.       var file, fileInfo;
  769.       fileInfo = post.fileInfo;
  770.       if (fileInfo) {
  771.         if (file = $('.fileText > span', fileInfo)) {
  772.           return file.title || file.innerHTML;
  773.         } else {
  774.           return fileInfo.firstElementChild.dataset.filename;
  775.         }
  776.       }
  777.       return false;
  778.     },
  779.     dimensions: function(post) {
  780.       var fileInfo, match;
  781.       fileInfo = post.fileInfo;
  782.       if (fileInfo && (match = fileInfo.textContent.match(/\d+x\d+/))) {
  783.         return match[0];
  784.       }
  785.       return false;
  786.     },
  787.     filesize: function(post) {
  788.       var img;
  789.       img = post.img;
  790.       if (img) {
  791.         return img.alt.replace('Spoiler Image, ', '');
  792.       }
  793.       return false;
  794.     },
  795.     md5: function(post) {
  796.       var img;
  797.       img = post.img;
  798.       if (img) {
  799.         return img.dataset.md5;
  800.       }
  801.       return false;
  802.     },
  803.     menuInit: function() {
  804.       var div, entry, type, _i, _len, _ref;
  805.       div = $.el('div', {
  806.         textContent: 'Filter'
  807.       });
  808.       entry = {
  809.         el: div,
  810.         open: function() {
  811.           return true;
  812.         },
  813.         children: []
  814.       };
  815.       _ref = [['Name', 'name'], ['Unique ID', 'uniqueid'], ['Tripcode', 'tripcode'], ['Admin/Mod', 'mod'], ['E-mail', 'email'], ['Subject', 'subject'], ['Comment', 'comment'], ['Country', 'country'], ['Filename', 'filename'], ['Image dimensions', 'dimensions'], ['Filesize', 'filesize'], ['Image MD5', 'md5']];
  816.       for (_i = 0, _len = _ref.length; _i < _len; _i++) {
  817.         type = _ref[_i];
  818.         entry.children.push(Filter.createSubEntry(type[0], type[1]));
  819.       }
  820.       return Menu.addEntry(entry);
  821.     },
  822.     createSubEntry: function(text, type) {
  823.       var el, onclick, open;
  824.       el = $.el('a', {
  825.         href: 'javascript:;',
  826.         textContent: text
  827.       });
  828.       onclick = null;
  829.       open = function(post) {
  830.         var value;
  831.         value = Filter[type](post);
  832.         if (value === false) {
  833.           return false;
  834.         }
  835.         $.off(el, 'click', onclick);
  836.         onclick = function() {
  837.           var re, save, select, ta, tl;
  838.           re = type === 'md5' ? value : value.replace(/\/|\\|\^|\$|\n|\.|\(|\)|\{|\}|\[|\]|\?|\*|\+|\|/g, function(c) {
  839.             if (c === '\n') {
  840.               return '\\n';
  841.             } else if (c === '\\') {
  842.               return '\\\\';
  843.             } else {
  844.               return "\\" + c;
  845.             }
  846.           });
  847.           re = type === 'md5' ? "/" + value + "/" : "/^" + re + "$/";
  848.           if (/\bop\b/.test(post["class"])) {
  849.             re += ';op:yes';
  850.           }
  851.           save = (save = $.get(type, '')) ? "" + save + "\n" + re : re;
  852.           $.set(type, save);
  853.           Options.dialog();
  854.           select = $('select[name=filter]', $.id('options'));
  855.           select.value = type;
  856.           $.event(select, new Event('change'));
  857.           $.id('filter_tab').checked = true;
  858.           ta = select.nextElementSibling;
  859.           tl = ta.textLength;
  860.           ta.setSelectionRange(tl, tl);
  861.           return ta.focus();
  862.         };
  863.         $.on(el, 'click', onclick);
  864.         return true;
  865.       };
  866.       return {
  867.         el: el,
  868.         open: open
  869.       };
  870.     }
  871.   };
  872.  
  873.   StrikethroughQuotes = {
  874.     init: function() {
  875.       return Main.callbacks.push(this.node);
  876.     },
  877.     node: function(post) {
  878.       var el, quote, show_stub, _i, _len, _ref;
  879.       if (post.isInlined) {
  880.         return;
  881.       }
  882.       _ref = post.quotes;
  883.       for (_i = 0, _len = _ref.length; _i < _len; _i++) {
  884.         quote = _ref[_i];
  885.         if (!((el = $.id(quote.hash.slice(1))) && quote.hostname === 'boards.4chan.org' && !/catalog$/.test(quote.pathname) && el.hidden)) {
  886.           continue;
  887.         }
  888.         $.addClass(quote, 'filtered');
  889.         if (Conf['Recursive Filtering'] && post.ID !== post.threadID) {
  890.           show_stub = !!$.x('preceding-sibling::div[contains(@class,"stub")]', el);
  891.           ReplyHiding.hide(post.root, show_stub);
  892.         }
  893.       }
  894.     }
  895.   };
  896.  
  897.   ExpandComment = {
  898.     init: function() {
  899.       var a, _i, _len, _ref;
  900.       _ref = $$('.abbr');
  901.       for (_i = 0, _len = _ref.length; _i < _len; _i++) {
  902.         a = _ref[_i];
  903.         $.on(a.firstElementChild, 'click', ExpandComment.expand);
  904.       }
  905.     },
  906.     expand: function(e) {
  907.       var a, replyID, threadID, _, _ref;
  908.       e.preventDefault();
  909.       _ref = this.href.match(/(\d+)#p(\d+)/), _ = _ref[0], threadID = _ref[1], replyID = _ref[2];
  910.       this.textContent = "Loading No." + replyID + "...";
  911.       a = this;
  912.       return $.cache("//api.4chan.org" + this.pathname + ".json", function() {
  913.         return ExpandComment.parse(this, a, threadID, replyID);
  914.       });
  915.     },
  916.     parse: function(req, a, threadID, replyID) {
  917.       var bq, clone, href, post, posts, quote, quotes, spoilerRange, _i, _j, _len, _len1;
  918.       if (req.status !== 200) {
  919.         a.textContent = "" + req.status + " " + req.statusText;
  920.         return;
  921.       }
  922.       posts = JSON.parse(req.response).posts;
  923.       if (spoilerRange = posts[0].custom_spoiler) {
  924.         Build.spoilerRange[g.BOARD] = spoilerRange;
  925.       }
  926.       replyID = +replyID;
  927.       for (_i = 0, _len = posts.length; _i < _len; _i++) {
  928.         post = posts[_i];
  929.         if (post.no === replyID) {
  930.           break;
  931.         }
  932.       }
  933.       if (post.no !== replyID) {
  934.         a.textContent = 'No.#{replyID} not found.';
  935.         return;
  936.       }
  937.       bq = $.id("m" + replyID);
  938.       clone = bq.cloneNode(false);
  939. //      clone.innerHTML = post.com.replace(/\b(\&gt;\s*)?([A-Za-z]+)-\2/ig, "$1$2");
  940.       quotes = clone.getElementsByClassName('quotelink');
  941.       for (_j = 0, _len1 = quotes.length; _j < _len1; _j++) {
  942.         quote = quotes[_j];
  943.         href = quote.getAttribute('href');
  944.         if (href[0] === '/') {
  945.           continue;
  946.         }
  947.         quote.href = "res/" + href;
  948.       }
  949.       post = {
  950.         blockquote: clone,
  951.         threadID: threadID,
  952.         quotes: quotes,
  953.         backlinks: []
  954.       };
  955.       if (Conf['Resurrect Quotes']) {
  956.         Quotify.node(post);
  957.       }
  958.       if (Conf['Quote Preview']) {
  959.         QuotePreview.node(post);
  960.       }
  961.       if (Conf['Quote Inline']) {
  962.         QuoteInline.node(post);
  963.       }
  964.       if (Conf['Indicate OP quote']) {
  965.         QuoteOP.node(post);
  966.       }
  967.       if (Conf['Indicate Cross-thread Quotes']) {
  968.         QuoteCT.node(post);
  969.       }
  970.       $.replace(bq, clone);
  971.       return Main.prettify(clone);
  972.     }
  973.   };
  974.  
  975.   ExpandThread = {
  976.     init: function() {
  977.       var a, span, _i, _len, _ref, _results;
  978.       _ref = $$('.summary');
  979.       _results = [];
  980.       for (_i = 0, _len = _ref.length; _i < _len; _i++) {
  981.         span = _ref[_i];
  982.         a = $.el('a', {
  983.           textContent: "+ " + span.textContent,
  984.           className: 'summary desktop',
  985.           href: 'javascript:;'
  986.         });
  987.         $.on(a, 'click', function() {
  988.           return ExpandThread.toggle(this.parentNode);
  989.         });
  990.         _results.push($.replace(span, a));
  991.       }
  992.       return _results;
  993.     },
  994.     toggle: function(thread) {
  995.       var a, num, replies, reply, url, _i, _len;
  996.       url = "//api.4chan.org/" + g.BOARD + "/res/" + thread.id.slice(1) + ".json";
  997.       a = $('.summary', thread);
  998.       switch (a.textContent[0]) {
  999.         case '+':
  1000.           a.textContent = a.textContent.replace('+', '× Loading...');
  1001.           $.cache(url, function() {
  1002.             return ExpandThread.parse(this, thread, a);
  1003.           });
  1004.           break;
  1005.         case '×':
  1006.           a.textContent = a.textContent.replace('× Loading...', '+');
  1007.           $.cache.requests[url].abort();
  1008.           break;
  1009.         case '-':
  1010.           a.textContent = a.textContent.replace('-', '+');
  1011.           num = (function() {
  1012.             switch (g.BOARD) {
  1013.               case 'b':
  1014.               case 'vg':
  1015.               case 'q':
  1016.                 return 3;
  1017.               case 't':
  1018.                 return 1;
  1019.               default:
  1020.                 return 5;
  1021.             }
  1022.           })();
  1023.           replies = $$('.replyContainer', thread);
  1024.           replies.splice(replies.length - num, num);
  1025.           for (_i = 0, _len = replies.length; _i < _len; _i++) {
  1026.             reply = replies[_i];
  1027.             $.rm(reply);
  1028.           }
  1029.       }
  1030.     },
  1031.     parse: function(req, thread, a) {
  1032.       var backlink, id, link, nodes, post, posts, replies, reply, spoilerRange, threadID, _i, _j, _k, _len, _len1, _len2, _ref, _ref1;
  1033.       if (req.status !== 200) {
  1034.         a.textContent = "" + req.status + " " + req.statusText;
  1035.         $.off(a, 'click', ExpandThread.cb.toggle);
  1036.         return;
  1037.       }
  1038.       a.textContent = a.textContent.replace('× Loading...', '-');
  1039.       posts = JSON.parse(req.response).posts;
  1040.       if (spoilerRange = posts[0].custom_spoiler) {
  1041.         Build.spoilerRange[g.BOARD] = spoilerRange;
  1042.       }
  1043.       replies = posts.slice(1);
  1044.       threadID = thread.id.slice(1);
  1045.       nodes = [];
  1046.       for (_i = 0, _len = replies.length; _i < _len; _i++) {
  1047.         reply = replies[_i];
  1048.         post = Build.postFromObject(reply, g.BOARD);
  1049.         id = reply.no;
  1050.         link = $('a[title="Highlight this post"]', post);
  1051.         link.href = "res/" + threadID + "#p" + id;
  1052.         link.nextSibling.href = "res/" + threadID + "#q" + id;
  1053.         nodes.push(post);
  1054.       }
  1055.       _ref = $$('.summary ~ .replyContainer', a.parentNode);
  1056.       for (_j = 0, _len1 = _ref.length; _j < _len1; _j++) {
  1057.         post = _ref[_j];
  1058.         $.rm(post);
  1059.       }
  1060.       _ref1 = $$('.backlink', a.previousElementSibling);
  1061.       for (_k = 0, _len2 = _ref1.length; _k < _len2; _k++) {
  1062.         backlink = _ref1[_k];
  1063.         if (!$.id(backlink.hash.slice(1))) {
  1064.           $.rm(backlink);
  1065.         }
  1066.       }
  1067.       return $.after(a, nodes);
  1068.     }
  1069.   };
  1070.  
  1071.   ThreadHiding = {
  1072.     init: function() {
  1073.       var a, hiddenThreads, thread, _i, _len, _ref;
  1074.       hiddenThreads = ThreadHiding.sync();
  1075.       if (g.CATALOG) {
  1076.         return;
  1077.       }
  1078.       _ref = $$('.thread');
  1079.       for (_i = 0, _len = _ref.length; _i < _len; _i++) {
  1080.         thread = _ref[_i];
  1081.         a = $.el('a', {
  1082.           className: 'hide_thread_button',
  1083.           innerHTML: '<span>[ - ]</span>',
  1084.           href: 'javascript:;'
  1085.         });
  1086.         $.on(a, 'click', ThreadHiding.cb);
  1087.         $.prepend(thread, a);
  1088.         if (thread.id.slice(1) in hiddenThreads) {
  1089.           ThreadHiding.hide(thread);
  1090.         }
  1091.       }
  1092.     },
  1093.     sync: function() {
  1094.       var hiddenThreads, hiddenThreadsCatalog, id;
  1095.       hiddenThreads = $.get("hiddenThreads/" + g.BOARD + "/", {});
  1096.       hiddenThreadsCatalog = JSON.parse(localStorage.getItem("4chan-hide-t-" + g.BOARD)) || {};
  1097.       if (g.CATALOG) {
  1098.         for (id in hiddenThreads) {
  1099.           hiddenThreadsCatalog[id] = true;
  1100.         }
  1101.         localStorage.setItem("4chan-hide-t-" + g.BOARD, JSON.stringify(hiddenThreadsCatalog));
  1102.       } else {
  1103.         for (id in hiddenThreadsCatalog) {
  1104.           if (!(id in hiddenThreads)) {
  1105.             hiddenThreads[id] = Date.now();
  1106.           }
  1107.         }
  1108.         $.set("hiddenThreads/" + g.BOARD + "/", hiddenThreads);
  1109.       }
  1110.       return hiddenThreads;
  1111.     },
  1112.     cb: function() {
  1113.       return ThreadHiding.toggle($.x('ancestor::div[parent::div[@class="board"]]', this));
  1114.     },
  1115.     toggle: function(thread) {
  1116.       var hiddenThreads, id;
  1117.       hiddenThreads = $.get("hiddenThreads/" + g.BOARD + "/", {});
  1118.       id = thread.id.slice(1);
  1119.       if (thread.hidden || /\bhidden_thread\b/.test(thread.firstChild.className)) {
  1120.         ThreadHiding.show(thread);
  1121.         delete hiddenThreads[id];
  1122.       } else {
  1123.         ThreadHiding.hide(thread);
  1124.         hiddenThreads[id] = Date.now();
  1125.       }
  1126.       return $.set("hiddenThreads/" + g.BOARD + "/", hiddenThreads);
  1127.     },
  1128.     hide: function(thread, show_stub) {
  1129.       var a, menuButton, num, opInfo, span, stub, text;
  1130.       if (show_stub == null) {
  1131.         show_stub = Conf['Show Stubs'];
  1132.       }
  1133.       if (!show_stub) {
  1134.         thread.hidden = true;
  1135.         thread.nextElementSibling.hidden = true;
  1136.         return;
  1137.       }
  1138.       if (/\bhidden_thread\b/.test(thread.firstChild.className)) {
  1139.         return;
  1140.       }
  1141.       num = 0;
  1142.       if (span = $('.summary', thread)) {
  1143.         num = Number(span.textContent.match(/\d+/));
  1144.       }
  1145.       num += $$('.opContainer ~ .replyContainer', thread).length;
  1146.       text = num === 1 ? '1 reply' : "" + num + " replies";
  1147.       opInfo = $('.desktop > .nameBlock', thread).textContent;
  1148.       stub = $.el('div', {
  1149.         className: 'hide_thread_button hidden_thread',
  1150.         innerHTML: '<a href="javascript:;"><span>[ + ]</span> </a>'
  1151.       });
  1152.       a = stub.firstChild;
  1153.       $.on(a, 'click', ThreadHiding.cb);
  1154.       $.add(a, $.tn("" + opInfo + " (" + text + ")"));
  1155.       if (Conf['Menu']) {
  1156.         menuButton = Menu.a.cloneNode(true);
  1157.         $.on(menuButton, 'click', Menu.toggle);
  1158.         $.add(stub, [$.tn(' '), menuButton]);
  1159.       }
  1160.       return $.prepend(thread, stub);
  1161.     },
  1162.     show: function(thread) {
  1163.       var stub;
  1164.       if (stub = $('.hidden_thread', thread)) {
  1165.         $.rm(stub);
  1166.       }
  1167.       thread.hidden = false;
  1168.       return thread.nextElementSibling.hidden = false;
  1169.     }
  1170.   };
  1171.  
  1172.   ReplyHiding = {
  1173.     init: function() {
  1174.       return Main.callbacks.push(this.node);
  1175.     },
  1176.     node: function(post) {
  1177.       var side;
  1178.       if (post.isInlined || post.ID === post.threadID) {
  1179.         return;
  1180.       }
  1181.       side = $('.sideArrows', post.root);
  1182.       $.addClass(side, 'hide_reply_button');
  1183.       side.innerHTML = '<a href="javascript:;"><span>[ - ]</span></a>';
  1184.       $.on(side.firstChild, 'click', ReplyHiding.toggle);
  1185.       if (post.ID in g.hiddenReplies) {
  1186.         return ReplyHiding.hide(post.root);
  1187.       }
  1188.     },
  1189.     toggle: function() {
  1190.       var button, id, quote, quotes, root, _i, _j, _len, _len1;
  1191.       button = this.parentNode;
  1192.       root = button.parentNode;
  1193.       id = root.id.slice(2);
  1194.       quotes = $$(".quotelink[href$='#p" + id + "'], .backlink[href$='#p" + id + "']");
  1195.       if (/\bstub\b/.test(button.className)) {
  1196.         ReplyHiding.show(root);
  1197.         for (_i = 0, _len = quotes.length; _i < _len; _i++) {
  1198.           quote = quotes[_i];
  1199.           $.rmClass(quote, 'filtered');
  1200.         }
  1201.         delete g.hiddenReplies[id];
  1202.       } else {
  1203.         ReplyHiding.hide(root);
  1204.         for (_j = 0, _len1 = quotes.length; _j < _len1; _j++) {
  1205.           quote = quotes[_j];
  1206.           $.addClass(quote, 'filtered');
  1207.         }
  1208.         g.hiddenReplies[id] = Date.now();
  1209.       }
  1210.       return $.set("hiddenReplies/" + g.BOARD + "/", g.hiddenReplies);
  1211.     },
  1212.     hide: function(root, show_stub) {
  1213.       var a, el, menuButton, side, stub;
  1214.       if (show_stub == null) {
  1215.         show_stub = Conf['Show Stubs'];
  1216.       }
  1217.       side = $('.sideArrows', root);
  1218.       if (side.hidden) {
  1219.         return;
  1220.       }
  1221.       side.hidden = true;
  1222.       el = side.nextElementSibling;
  1223.       el.hidden = true;
  1224.       if (!show_stub) {
  1225.         return;
  1226.       }
  1227.       stub = $.el('div', {
  1228.         className: 'hide_reply_button stub',
  1229.         innerHTML: '<a href="javascript:;"><span>[ + ]</span> </a>'
  1230.       });
  1231.       a = stub.firstChild;
  1232.       $.on(a, 'click', ReplyHiding.toggle);
  1233.       $.add(a, $.tn(Conf['Anonymize'] ? 'Anonymous' : $('.desktop > .nameBlock', el).textContent));
  1234.       if (Conf['Menu']) {
  1235.         menuButton = Menu.a.cloneNode(true);
  1236.         $.on(menuButton, 'click', Menu.toggle);
  1237.         $.add(stub, [$.tn(' '), menuButton]);
  1238.       }
  1239.       return $.prepend(root, stub);
  1240.     },
  1241.     show: function(root) {
  1242.       var stub;
  1243.       if (stub = $('.stub', root)) {
  1244.         $.rm(stub);
  1245.       }
  1246.       $('.sideArrows', root).hidden = false;
  1247.       return $('.post', root).hidden = false;
  1248.     }
  1249.   };
  1250.  
  1251.   Menu = {
  1252.     entries: [],
  1253.     init: function() {
  1254.       this.a = $.el('a', {
  1255.         className: 'menu_button',
  1256.         href: 'javascript:;',
  1257.         innerHTML: '[<span></span>]'
  1258.       });
  1259.       this.el = $.el('div', {
  1260.         className: 'reply dialog',
  1261.         id: 'menu',
  1262.         tabIndex: 0
  1263.       });
  1264.       $.on(this.el, 'click', function(e) {
  1265.         return e.stopPropagation();
  1266.       });
  1267.       $.on(this.el, 'keydown', this.keybinds);
  1268.       $.on(d, 'AddMenuEntry', function(e) {
  1269.         return Menu.addEntry(e.detail);
  1270.       });
  1271.       return Main.callbacks.push(this.node);
  1272.     },
  1273.     node: function(post) {
  1274.       var a;
  1275.       if (post.isInlined && !post.isCrosspost) {
  1276.         a = $('.menu_button', post.el);
  1277.       } else {
  1278.         a = Menu.a.cloneNode(true);
  1279.         $.add($('.postInfo', post.el), [$.tn('\u00A0'), a]);
  1280.       }
  1281.       return $.on(a, 'click', Menu.toggle);
  1282.     },
  1283.     toggle: function(e) {
  1284.       var lastOpener, post;
  1285.       e.preventDefault();
  1286.       e.stopPropagation();
  1287.       if (Menu.el.parentNode) {
  1288.         lastOpener = Menu.lastOpener;
  1289.         Menu.close();
  1290.         if (lastOpener === this) {
  1291.           return;
  1292.         }
  1293.       }
  1294.       Menu.lastOpener = this;
  1295.       post = /\bhidden_thread\b/.test(this.parentNode.className) ? $.x('ancestor::div[parent::div[@class="board"]]/child::div[contains(@class,"opContainer")]', this) : $.x('ancestor::div[contains(@class,"postContainer")][1]', this);
  1296.       return Menu.open(this, Main.preParse(post));
  1297.     },
  1298.     open: function(button, post) {
  1299.       var bLeft, bRect, bTop, el, entry, funk, mRect, _i, _len, _ref;
  1300.       el = Menu.el;
  1301.       el.setAttribute('data-id', post.ID);
  1302.       el.setAttribute('data-rootid', post.root.id);
  1303.       funk = function(entry, parent) {
  1304.         var child, children, subMenu, _i, _len;
  1305.         children = entry.children;
  1306.         if (!entry.open(post)) {
  1307.           return;
  1308.         }
  1309.         $.add(parent, entry.el);
  1310.         if (!children) {
  1311.           return;
  1312.         }
  1313.         if (subMenu = $('.subMenu', entry.el)) {
  1314.           $.rm(subMenu);
  1315.         }
  1316.         subMenu = $.el('div', {
  1317.           className: 'reply dialog subMenu'
  1318.         });
  1319.         $.add(entry.el, subMenu);
  1320.         for (_i = 0, _len = children.length; _i < _len; _i++) {
  1321.           child = children[_i];
  1322.           funk(child, subMenu);
  1323.         }
  1324.       };
  1325.       _ref = Menu.entries;
  1326.       for (_i = 0, _len = _ref.length; _i < _len; _i++) {
  1327.         entry = _ref[_i];
  1328.         funk(entry, el);
  1329.       }
  1330.       Menu.focus($('.entry', Menu.el));
  1331.       $.on(d, 'click', Menu.close);
  1332.       $.add(d.body, el);
  1333.       mRect = el.getBoundingClientRect();
  1334.       bRect = button.getBoundingClientRect();
  1335.       bTop = d.documentElement.scrollTop + d.body.scrollTop + bRect.top;
  1336.       bLeft = d.documentElement.scrollLeft + d.body.scrollLeft + bRect.left;
  1337.       el.style.top = bRect.top + bRect.height + mRect.height < d.documentElement.clientHeight ? bTop + bRect.height + 2 + 'px' : bTop - mRect.height - 2 + 'px';
  1338.       el.style.left = bRect.left + mRect.width < d.documentElement.clientWidth ? bLeft + 'px' : bLeft + bRect.width - mRect.width + 'px';
  1339.       return el.focus();
  1340.     },
  1341.     close: function() {
  1342.       var el, focused, _i, _len, _ref;
  1343.       el = Menu.el;
  1344.       $.rm(el);
  1345.       _ref = $$('.focused.entry', el);
  1346.       for (_i = 0, _len = _ref.length; _i < _len; _i++) {
  1347.         focused = _ref[_i];
  1348.         $.rmClass(focused, 'focused');
  1349.       }
  1350.       el.innerHTML = null;
  1351.       el.removeAttribute('style');
  1352.       delete Menu.lastOpener;
  1353.       delete Menu.focusedEntry;
  1354.       return $.off(d, 'click', Menu.close);
  1355.     },
  1356.     keybinds: function(e) {
  1357.       var el, next, subMenu;
  1358.       el = Menu.focusedEntry;
  1359.       switch (Keybinds.keyCode(e) || e.keyCode) {
  1360.         case 'Esc':
  1361.           Menu.lastOpener.focus();
  1362.           Menu.close();
  1363.           break;
  1364.         case 13:
  1365.         case 32:
  1366.           el.click();
  1367.           break;
  1368.         case 'Up':
  1369.           if (next = el.previousElementSibling) {
  1370.             Menu.focus(next);
  1371.           }
  1372.           break;
  1373.         case 'Down':
  1374.           if (next = el.nextElementSibling) {
  1375.             Menu.focus(next);
  1376.           }
  1377.           break;
  1378.         case 'Right':
  1379.           if ((subMenu = $('.subMenu', el)) && (next = subMenu.firstElementChild)) {
  1380.             Menu.focus(next);
  1381.           }
  1382.           break;
  1383.         case 'Left':
  1384.           if (next = $.x('parent::*[contains(@class,"subMenu")]/parent::*', el)) {
  1385.             Menu.focus(next);
  1386.           }
  1387.           break;
  1388.         default:
  1389.           return;
  1390.       }
  1391.       e.preventDefault();
  1392.       return e.stopPropagation();
  1393.     },
  1394.     focus: function(el) {
  1395.       var focused, _i, _len, _ref;
  1396.       if (focused = $.x('parent::*/child::*[contains(@class,"focused")]', el)) {
  1397.         $.rmClass(focused, 'focused');
  1398.       }
  1399.       _ref = $$('.focused', el);
  1400.       for (_i = 0, _len = _ref.length; _i < _len; _i++) {
  1401.         focused = _ref[_i];
  1402.         $.rmClass(focused, 'focused');
  1403.       }
  1404.       Menu.focusedEntry = el;
  1405.       return $.addClass(el, 'focused');
  1406.     },
  1407.     addEntry: function(entry) {
  1408.       var funk;
  1409.       funk = function(entry) {
  1410.         var child, children, el, _i, _len;
  1411.         el = entry.el, children = entry.children;
  1412.         $.addClass(el, 'entry');
  1413.         $.on(el, 'focus mouseover', function(e) {
  1414.           e.stopPropagation();
  1415.           return Menu.focus(this);
  1416.         });
  1417.         if (!children) {
  1418.           return;
  1419.         }
  1420.         $.addClass(el, 'hasSubMenu');
  1421.         for (_i = 0, _len = children.length; _i < _len; _i++) {
  1422.           child = children[_i];
  1423.           funk(child);
  1424.         }
  1425.       };
  1426.       funk(entry);
  1427.       return Menu.entries.push(entry);
  1428.     }
  1429.   };
  1430.  
  1431.   Keybinds = {
  1432.     init: function() {
  1433.       var node, _i, _len, _ref;
  1434.       _ref = $$('[accesskey]');
  1435.       for (_i = 0, _len = _ref.length; _i < _len; _i++) {
  1436.         node = _ref[_i];
  1437.         node.removeAttribute('accesskey');
  1438.       }
  1439.       return $.on(d, 'keydown', Keybinds.keydown);
  1440.     },
  1441.     keydown: function(e) {
  1442.       var form, key, o, target, thread;
  1443.       if (!(key = Keybinds.keyCode(e))) {
  1444.         return;
  1445.       }
  1446.       target = e.target;
  1447.       if (/TEXTAREA|INPUT/.test(target.nodeName)) {
  1448.         if (!((key === 'Esc') || (/\+/.test(key)))) {
  1449.           return;
  1450.         }
  1451.       }
  1452.       thread = Nav.getThread();
  1453.       switch (key) {
  1454.         case Conf.openQR:
  1455.           Keybinds.qr(thread, true);
  1456.           break;
  1457.         case Conf.openEmptyQR:
  1458.           Keybinds.qr(thread);
  1459.           break;
  1460.         case Conf.openOptions:
  1461.           if (!$.id('overlay')) {
  1462.             Options.dialog();
  1463.           }
  1464.           break;
  1465.         case Conf.close:
  1466.           if (o = $.id('overlay')) {
  1467.             Options.close.call(o);
  1468.           } else if (QR.el) {
  1469.             QR.close();
  1470.           }
  1471.           break;
  1472.         case Conf.submit:
  1473.           if (QR.el && !QR.status()) {
  1474.             QR.submit();
  1475.           }
  1476.           break;
  1477.         case Conf.spoiler:
  1478.           if (target.nodeName !== 'TEXTAREA') {
  1479.             return;
  1480.           }
  1481.           Keybinds.tags('spoiler', target);
  1482.           break;
  1483.         case Conf.code:
  1484.           if (target.nodeName !== 'TEXTAREA') {
  1485.             return;
  1486.           }
  1487.           Keybinds.tags('code', target);
  1488.           break;
  1489.         case Conf.watch:
  1490.           Watcher.toggle(thread);
  1491.           break;
  1492.         case Conf.update:
  1493.           Updater.update();
  1494.           break;
  1495.         case Conf.unreadCountTo0:
  1496.           Unread.replies = [];
  1497.           Unread.update(true);
  1498.           break;
  1499.         case Conf.expandImage:
  1500.           Keybinds.img(thread);
  1501.           break;
  1502.         case Conf.expandAllImages:
  1503.           Keybinds.img(thread, true);
  1504.           break;
  1505.         case Conf.zero:
  1506.           window.location = "/" + g.BOARD + "/0#delform";
  1507.           break;
  1508.         case Conf.nextPage:
  1509.           if (form = $('.next form')) {
  1510.             window.location = form.action;
  1511.           }
  1512.           break;
  1513.         case Conf.previousPage:
  1514.           if (form = $('.prev form')) {
  1515.             window.location = form.action;
  1516.           }
  1517.           break;
  1518.         case Conf.nextThread:
  1519.           if (g.REPLY) {
  1520.             return;
  1521.           }
  1522.           Nav.scroll(+1);
  1523.           break;
  1524.         case Conf.previousThread:
  1525.           if (g.REPLY) {
  1526.             return;
  1527.           }
  1528.           Nav.scroll(-1);
  1529.           break;
  1530.         case Conf.expandThread:
  1531.           ExpandThread.toggle(thread);
  1532.           break;
  1533.         case Conf.openThread:
  1534.           Keybinds.open(thread);
  1535.           break;
  1536.         case Conf.openThreadTab:
  1537.           Keybinds.open(thread, true);
  1538.           break;
  1539.         case Conf.nextReply:
  1540.           Keybinds.hl(+1, thread);
  1541.           break;
  1542.         case Conf.previousReply:
  1543.           Keybinds.hl(-1, thread);
  1544.           break;
  1545.         case Conf.hide:
  1546.           if (/\bthread\b/.test(thread.className)) {
  1547.             ThreadHiding.toggle(thread);
  1548.           }
  1549.           break;
  1550.         default:
  1551.           return;
  1552.       }
  1553.       return e.preventDefault();
  1554.     },
  1555.     keyCode: function(e) {
  1556.       var c, kc, key;
  1557.       key = (function() {
  1558.         switch (kc = e.keyCode) {
  1559.           case 8:
  1560.             return '';
  1561.           case 13:
  1562.             return 'Enter';
  1563.           case 27:
  1564.             return 'Esc';
  1565.           case 37:
  1566.             return 'Left';
  1567.           case 38:
  1568.             return 'Up';
  1569.           case 39:
  1570.             return 'Right';
  1571.           case 40:
  1572.             return 'Down';
  1573.           case 48:
  1574.           case 49:
  1575.           case 50:
  1576.           case 51:
  1577.           case 52:
  1578.           case 53:
  1579.           case 54:
  1580.           case 55:
  1581.           case 56:
  1582.           case 57:
  1583.           case 65:
  1584.           case 66:
  1585.           case 67:
  1586.           case 68:
  1587.           case 69:
  1588.           case 70:
  1589.           case 71:
  1590.           case 72:
  1591.           case 73:
  1592.           case 74:
  1593.           case 75:
  1594.           case 76:
  1595.           case 77:
  1596.           case 78:
  1597.           case 79:
  1598.           case 80:
  1599.           case 81:
  1600.           case 82:
  1601.           case 83:
  1602.           case 84:
  1603.           case 85:
  1604.           case 86:
  1605.           case 87:
  1606.           case 88:
  1607.           case 89:
  1608.           case 90:
  1609.             c = String.fromCharCode(kc);
  1610.             if (e.shiftKey) {
  1611.               return c;
  1612.             } else {
  1613.               return c.toLowerCase();
  1614.             }
  1615.             break;
  1616.           default:
  1617.             return null;
  1618.         }
  1619.       })();
  1620.       if (key) {
  1621.         if (e.altKey) {
  1622.           key = 'alt+' + key;
  1623.         }
  1624.         if (e.ctrlKey) {
  1625.           key = 'ctrl+' + key;
  1626.         }
  1627.         if (e.metaKey) {
  1628.           key = 'meta+' + key;
  1629.         }
  1630.       }
  1631.       return key;
  1632.     },
  1633.     tags: function(tag, ta) {
  1634.       var range, selEnd, selStart, value;
  1635.       value = ta.value;
  1636.       selStart = ta.selectionStart;
  1637.       selEnd = ta.selectionEnd;
  1638.       ta.value = value.slice(0, selStart) + ("[" + tag + "]") + value.slice(selStart, selEnd) + ("[/" + tag + "]") + value.slice(selEnd);
  1639.       range = ("[" + tag + "]").length + selEnd;
  1640.       ta.setSelectionRange(range, range);
  1641.       return $.event(ta, new Event('input'));
  1642.     },
  1643.     img: function(thread, all) {
  1644.       var thumb;
  1645.       if (all) {
  1646.         return $.id('imageExpand').click();
  1647.       } else {
  1648.         thumb = $('img[data-md5]', $('.post.highlight', thread) || thread);
  1649.         return ImageExpand.toggle(thumb.parentNode);
  1650.       }
  1651.     },
  1652.     qr: function(thread, quote) {
  1653.       if (quote) {
  1654.         QR.quote.call($('a[title="Quote this post"]', $('.post.highlight', thread) || thread));
  1655.       } else {
  1656.         QR.open();
  1657.       }
  1658.       return $('textarea', QR.el).focus();
  1659.     },
  1660.     open: function(thread, tab) {
  1661.       var id, url;
  1662.       if (g.REPLY) {
  1663.         return;
  1664.       }
  1665.       id = thread.id.slice(1);
  1666.       url = "//boards.4chan.org/" + g.BOARD + "/res/" + id;
  1667.       if (tab) {
  1668.         return $.open(url);
  1669.       } else {
  1670.         return location.href = url;
  1671.       }
  1672.     },
  1673.     hl: function(delta, thread) {
  1674.       var next, post, rect, replies, reply, _i, _len;
  1675.       if (post = $('.reply.highlight', thread)) {
  1676.         $.rmClass(post, 'highlight');
  1677.         post.removeAttribute('tabindex');
  1678.         rect = post.getBoundingClientRect();
  1679.         if (rect.bottom >= 0 && rect.top <= d.documentElement.clientHeight) {
  1680.           next = $.x('child::div[contains(@class,"post reply")]', delta === +1 ? post.parentNode.nextElementSibling : post.parentNode.previousElementSibling);
  1681.           if (!next) {
  1682.             this.focus(post);
  1683.             return;
  1684.           }
  1685.           if (!(g.REPLY || $.x('ancestor::div[parent::div[@class="board"]]', next) === thread)) {
  1686.             return;
  1687.           }
  1688.           rect = next.getBoundingClientRect();
  1689.           if (rect.top < 0 || rect.bottom > d.documentElement.clientHeight) {
  1690.             next.scrollIntoView(delta === -1);
  1691.           }
  1692.           this.focus(next);
  1693.           return;
  1694.         }
  1695.       }
  1696.       replies = $$('.reply', thread);
  1697.       if (delta === -1) {
  1698.         replies.reverse();
  1699.       }
  1700.       for (_i = 0, _len = replies.length; _i < _len; _i++) {
  1701.         reply = replies[_i];
  1702.         rect = reply.getBoundingClientRect();
  1703.         if (delta === +1 && rect.top >= 0 || delta === -1 && rect.bottom <= d.documentElement.clientHeight) {
  1704.           this.focus(reply);
  1705.           return;
  1706.         }
  1707.       }
  1708.     },
  1709.     focus: function(post) {
  1710.       $.addClass(post, 'highlight');
  1711.       post.tabIndex = 0;
  1712.       return post.focus();
  1713.     }
  1714.   };
  1715.  
  1716.   Nav = {
  1717.     init: function() {
  1718.       var next, prev, span;
  1719.       span = $.el('span', {
  1720.         id: 'navlinks'
  1721.       });
  1722.       prev = $.el('a', {
  1723.         textContent: '▲',
  1724.         href: 'javascript:;'
  1725.       });
  1726.       next = $.el('a', {
  1727.         textContent: '▼',
  1728.         href: 'javascript:;'
  1729.       });
  1730.       $.on(prev, 'click', this.prev);
  1731.       $.on(next, 'click', this.next);
  1732.       $.add(span, [prev, $.tn(' '), next]);
  1733.       return $.add(d.body, span);
  1734.     },
  1735.     prev: function() {
  1736.       if (g.REPLY) {
  1737.         return window.scrollTo(0, 0);
  1738.       } else {
  1739.         return Nav.scroll(-1);
  1740.       }
  1741.     },
  1742.     next: function() {
  1743.       if (g.REPLY) {
  1744.         return window.scrollTo(0, d.body.scrollHeight);
  1745.       } else {
  1746.         return Nav.scroll(+1);
  1747.       }
  1748.     },
  1749.     getThread: function(full) {
  1750.       var bottom, i, rect, thread, _i, _len, _ref;
  1751.       Nav.threads = $$('.thread:not([hidden])');
  1752.       _ref = Nav.threads;
  1753.       for (i = _i = 0, _len = _ref.length; _i < _len; i = ++_i) {
  1754.         thread = _ref[i];
  1755.         rect = thread.getBoundingClientRect();
  1756.         bottom = rect.bottom;
  1757.         if (bottom > 0) {
  1758.           if (full) {
  1759.             return [thread, i, rect];
  1760.           }
  1761.           return thread;
  1762.         }
  1763.       }
  1764.       return $('.board');
  1765.     },
  1766.     scroll: function(delta) {
  1767.       var i, rect, thread, top, _ref, _ref1;
  1768.       _ref = Nav.getThread(true), thread = _ref[0], i = _ref[1], rect = _ref[2];
  1769.       top = rect.top;
  1770.       if (!((delta === -1 && Math.ceil(top) < 0) || (delta === +1 && top > 1))) {
  1771.         i += delta;
  1772.       }
  1773.       top = (_ref1 = Nav.threads[i]) != null ? _ref1.getBoundingClientRect().top : void 0;
  1774.       return window.scrollBy(0, top);
  1775.     }
  1776.   };
  1777.  
  1778.   QR = {
  1779.     init: function() {
  1780.       if (!$.id('postForm')) {
  1781.         return;
  1782.       }
  1783.       Main.callbacks.push(this.node);
  1784.       return setTimeout(this.asyncInit);
  1785.     },
  1786.     asyncInit: function() {
  1787.       var link;
  1788.       if (Conf['Hide Original Post Form']) {
  1789.         link = $.el('h1', {
  1790.           innerHTML: "<a href=javascript:;>" + (g.REPLY ? 'Reply to Thread' : 'Start a Thread') + "</a>"
  1791.         });
  1792.         $.on(link.firstChild, 'click', function() {
  1793.           QR.open();
  1794.           if (!g.REPLY) {
  1795.             QR.threadSelector.value = g.BOARD === 'f' ? '9999' : 'new';
  1796.           }
  1797.           return $('textarea', QR.el).focus();
  1798.         });
  1799.         $.before($.id('postForm'), link);
  1800.       }
  1801.       if (Conf['Persistent QR']) {
  1802.         QR.dialog();
  1803.         if (Conf['Auto Hide QR']) {
  1804.           QR.hide();
  1805.         }
  1806.       }
  1807.       $.on(d, 'dragover', QR.dragOver);
  1808.       $.on(d, 'drop', QR.dropFile);
  1809.       return $.on(d, 'dragstart dragend', QR.drag);
  1810.     },
  1811.     node: function(post) {
  1812.       return $.on($('a[title="Quote this post"]', $('.postInfo', post.el)), 'click', QR.quote);
  1813.     },
  1814.     open: function() {
  1815.       if (QR.el) {
  1816.         QR.el.hidden = false;
  1817.         return QR.unhide();
  1818.       } else {
  1819.         return QR.dialog();
  1820.       }
  1821.     },
  1822.     close: function() {
  1823.       var i, spoiler, _i, _len, _ref;
  1824.       QR.el.hidden = true;
  1825.       QR.abort();
  1826.       d.activeElement.blur();
  1827.       $.rmClass(QR.el, 'dump');
  1828.       _ref = QR.replies;
  1829.       for (_i = 0, _len = _ref.length; _i < _len; _i++) {
  1830.         i = _ref[_i];
  1831.         QR.replies[0].rm();
  1832.       }
  1833.       QR.cooldown.auto = false;
  1834.       QR.status();
  1835.       QR.resetFileInput();
  1836.       if (!Conf['Remember Spoiler'] && (spoiler = $.id('spoiler')).checked) {
  1837.         spoiler.click();
  1838.       }
  1839.       return QR.cleanError();
  1840.     },
  1841.     hide: function() {
  1842.       d.activeElement.blur();
  1843.       $.addClass(QR.el, 'autohide');
  1844.       return $.id('autohide').checked = true;
  1845.     },
  1846.     unhide: function() {
  1847.       $.rmClass(QR.el, 'autohide');
  1848.       return $.id('autohide').checked = false;
  1849.     },
  1850.     toggleHide: function() {
  1851.       return this.checked && QR.hide() || QR.unhide();
  1852.     },
  1853.     error: function(err) {
  1854.       var el;
  1855.       el = $('.warning', QR.el);
  1856.       if (typeof err === 'string') {
  1857.         el.textContent = err;
  1858.       } else {
  1859.         el.innerHTML = null;
  1860.         $.add(el, err);
  1861.       }
  1862.       QR.open();
  1863.       if (QR.captcha.isEnabled && /captcha|verification/i.test(el.textContent)) {
  1864.         $('[autocomplete]', QR.el).focus();
  1865.       }
  1866.       if (d.hidden) {
  1867.         return alert(el.textContent);
  1868.       }
  1869.     },
  1870.     cleanError: function() {
  1871.       return $('.warning', QR.el).textContent = null;
  1872.     },
  1873.     status: function(data) {
  1874.       var disabled, input, value;
  1875.       if (data == null) {
  1876.         data = {};
  1877.       }
  1878.       if (!QR.el) {
  1879.         return;
  1880.       }
  1881.       if (g.dead) {
  1882.         value = 404;
  1883.         disabled = true;
  1884.         QR.cooldown.auto = false;
  1885.       }
  1886.       value = data.progress || QR.cooldown.seconds || value;
  1887.       input = QR.status.input;
  1888.       input.value = QR.cooldown.auto && Conf['Cooldown'] ? value ? "Auto " + value : 'Auto' : value || 'Submit';
  1889.       return input.disabled = disabled || false;
  1890.     },
  1891.     cooldown: {
  1892.       init: function() {
  1893.         if (!Conf['Cooldown']) {
  1894.           return;
  1895.         }
  1896.         QR.cooldown.types = {
  1897.           thread: (function() {
  1898.             switch (g.BOARD) {
  1899.               case 'q':
  1900.                 return 86400;
  1901.               case 'b':
  1902.               case 'soc':
  1903.               case 'r9k':
  1904.                 return 600;
  1905.               default:
  1906.                 return 300;
  1907.             }
  1908.           })(),
  1909.           sage: g.BOARD === 'q' ? 600 : 60,
  1910.           file: g.BOARD === 'q' ? 300 : 30,
  1911.           post: g.BOARD === 'q' ? 60 : 30
  1912.         };
  1913.         QR.cooldown.cooldowns = $.get("" + g.BOARD + ".cooldown", {});
  1914.         QR.cooldown.start();
  1915.         return $.sync("" + g.BOARD + ".cooldown", QR.cooldown.sync);
  1916.       },
  1917.       start: function() {
  1918.         if (QR.cooldown.isCounting) {
  1919.           return;
  1920.         }
  1921.         QR.cooldown.isCounting = true;
  1922.         return QR.cooldown.count();
  1923.       },
  1924.       sync: function(cooldowns) {
  1925.         var id;
  1926.         for (id in cooldowns) {
  1927.           QR.cooldown.cooldowns[id] = cooldowns[id];
  1928.         }
  1929.         return QR.cooldown.start();
  1930.       },
  1931.       set: function(data) {
  1932.         var cooldown, hasFile, isReply, isSage, start, type;
  1933.         if (!Conf['Cooldown']) {
  1934.           return;
  1935.         }
  1936.         start = Date.now();
  1937.         if (data.delay) {
  1938.           cooldown = {
  1939.             delay: data.delay
  1940.           };
  1941.         } else {
  1942.           isSage = /sage/i.test(data.post.email);
  1943.           hasFile = !!data.post.file;
  1944.           isReply = data.isReply;
  1945.           type = !isReply ? 'thread' : isSage ? 'sage' : hasFile ? 'file' : 'post';
  1946.           cooldown = {
  1947.             isReply: isReply,
  1948.             isSage: isSage,
  1949.             hasFile: hasFile,
  1950.             timeout: start + QR.cooldown.types[type] * $.SECOND
  1951.           };
  1952.         }
  1953.         QR.cooldown.cooldowns[start] = cooldown;
  1954.         $.set("" + g.BOARD + ".cooldown", QR.cooldown.cooldowns);
  1955.         return QR.cooldown.start();
  1956.       },
  1957.       unset: function(id) {
  1958.         delete QR.cooldown.cooldowns[id];
  1959.         return $.set("" + g.BOARD + ".cooldown", QR.cooldown.cooldowns);
  1960.       },
  1961.       count: function() {
  1962.         var cooldown, cooldowns, elapsed, hasFile, isReply, isSage, now, post, seconds, start, type, types, update, _ref;
  1963.         if (Object.keys(QR.cooldown.cooldowns).length) {
  1964.           setTimeout(QR.cooldown.count, 1000);
  1965.         } else {
  1966.           $["delete"]("" + g.BOARD + ".cooldown");
  1967.           delete QR.cooldown.isCounting;
  1968.           delete QR.cooldown.seconds;
  1969.           QR.status();
  1970.           return;
  1971.         }
  1972.         if ((isReply = g.REPLY ? true : QR.threadSelector.value !== 'new')) {
  1973.           post = QR.replies[0];
  1974.           isSage = /sage/i.test(post.email);
  1975.           hasFile = !!post.file;
  1976.         }
  1977.         now = Date.now();
  1978.         seconds = null;
  1979.         _ref = QR.cooldown, types = _ref.types, cooldowns = _ref.cooldowns;
  1980.         for (start in cooldowns) {
  1981.           cooldown = cooldowns[start];
  1982.           if ('delay' in cooldown) {
  1983.             if (cooldown.delay) {
  1984.               seconds = Math.max(seconds, cooldown.delay--);
  1985.             } else {
  1986.               seconds = Math.max(seconds, 0);
  1987.               QR.cooldown.unset(start);
  1988.             }
  1989.             continue;
  1990.           }
  1991.           if (isReply === cooldown.isReply) {
  1992.             type = !isReply ? 'thread' : isSage && cooldown.isSage ? 'sage' : hasFile && cooldown.hasFile ? 'file' : 'post';
  1993.             elapsed = Math.floor((now - start) / 1000);
  1994.             if (elapsed >= 0) {
  1995.               seconds = Math.max(seconds, types[type] - elapsed);
  1996.             }
  1997.           }
  1998.           if (!((start <= now && now <= cooldown.timeout))) {
  1999.             QR.cooldown.unset(start);
  2000.           }
  2001.         }
  2002.         update = seconds !== null || !!QR.cooldown.seconds;
  2003.         QR.cooldown.seconds = seconds;
  2004.         if (update) {
  2005.           QR.status();
  2006.         }
  2007.         if (seconds === 0 && QR.cooldown.auto) {
  2008.           return QR.submit();
  2009.         }
  2010.       }
  2011.     },
  2012.     quote: function(e) {
  2013.       var caretPos, id, range, s, sel, ta, text, _ref;
  2014.       if (e != null) {
  2015.         e.preventDefault();
  2016.       }
  2017.       QR.open();
  2018.       ta = $('textarea', QR.el);
  2019.       if (!(g.REPLY || ta.value)) {
  2020.         QR.threadSelector.value = $.x('ancestor::div[parent::div[@class="board"]]', this).id.slice(1);
  2021.       }
  2022.       id = this.previousSibling.hash.slice(2);
  2023.       text = ">>" + id + "\n";
  2024.       sel = d.getSelection();
  2025.       if ((s = sel.toString().trim()) && id === ((_ref = $.x('ancestor-or-self::blockquote', sel.anchorNode)) != null ? _ref.id.match(/\d+$/)[0] : void 0)) {
  2026.         s = s.replace(/\n/g, '\n>');
  2027.         text += ">" + s + "\n";
  2028.       }
  2029.       caretPos = ta.selectionStart;
  2030.       ta.value = ta.value.slice(0, caretPos) + text + ta.value.slice(ta.selectionEnd);
  2031.       range = caretPos + text.length;
  2032.       ta.setSelectionRange(range, range);
  2033.       ta.focus();
  2034.       return $.event(ta, new Event('input'));
  2035.     },
  2036.     characterCount: function() {
  2037.       var count, counter;
  2038.       counter = QR.charaCounter;
  2039.       count = this.textLength;
  2040.       counter.textContent = count;
  2041.       counter.hidden = count < 1000;
  2042.       return (count > 1500 ? $.addClass : $.rmClass)(counter, 'warning');
  2043.     },
  2044.     drag: function(e) {
  2045.       var toggle;
  2046.       toggle = e.type === 'dragstart' ? $.off : $.on;
  2047.       toggle(d, 'dragover', QR.dragOver);
  2048.       return toggle(d, 'drop', QR.dropFile);
  2049.     },
  2050.     dragOver: function(e) {
  2051.       e.preventDefault();
  2052.       return e.dataTransfer.dropEffect = 'copy';
  2053.     },
  2054.     dropFile: function(e) {
  2055.       if (!e.dataTransfer.files.length) {
  2056.         return;
  2057.       }
  2058.       e.preventDefault();
  2059.       QR.open();
  2060.       QR.fileInput.call(e.dataTransfer);
  2061.       return $.addClass(QR.el, 'dump');
  2062.     },
  2063.     fileInput: function() {
  2064.       var file, _i, _len, _ref;
  2065.       QR.cleanError();
  2066.       if (this.files.length === 1) {
  2067.         file = this.files[0];
  2068.         if (file.size > this.max) {
  2069.           QR.error('File too large.');
  2070.           QR.resetFileInput();
  2071.         } else if (-1 === QR.mimeTypes.indexOf(file.type)) {
  2072.           QR.error('Unsupported file type.');
  2073.           QR.resetFileInput();
  2074.         } else {
  2075.           QR.selected.setFile(file);
  2076.         }
  2077.         return;
  2078.       }
  2079.       _ref = this.files;
  2080.       for (_i = 0, _len = _ref.length; _i < _len; _i++) {
  2081.         file = _ref[_i];
  2082.         if (file.size > this.max) {
  2083.           QR.error("File " + file.name + " is too large.");
  2084.           break;
  2085.         } else if (-1 === QR.mimeTypes.indexOf(file.type)) {
  2086.           QR.error("" + file.name + ": Unsupported file type.");
  2087.           break;
  2088.         }
  2089.         if (!QR.replies[QR.replies.length - 1].file) {
  2090.           QR.replies[QR.replies.length - 1].setFile(file);
  2091.         } else {
  2092.           new QR.reply().setFile(file);
  2093.         }
  2094.       }
  2095.       $.addClass(QR.el, 'dump');
  2096.       return QR.resetFileInput();
  2097.     },
  2098.     resetFileInput: function() {
  2099.       return $('[type=file]', QR.el).value = null;
  2100.     },
  2101.     replies: [],
  2102.     reply: (function() {
  2103.       function _Class() {
  2104.         var persona, prev,
  2105.           _this = this;
  2106.         prev = QR.replies[QR.replies.length - 1];
  2107.         persona = $.get('QR.persona', {});
  2108.         this.name = prev ? prev.name : persona.name || null;
  2109.         this.email = prev && !/^sage$/.test(prev.email) ? prev.email : persona.email || null;
  2110.         this.sub = prev && Conf['Remember Subject'] ? prev.sub : Conf['Remember Subject'] ? persona.sub : null;
  2111.         this.spoiler = prev && Conf['Remember Spoiler'] ? prev.spoiler : false;
  2112.         this.com = null;
  2113.         this.el = $.el('a', {
  2114.           className: 'thumbnail',
  2115.           draggable: true,
  2116.           href: 'javascript:;',
  2117.           innerHTML: '<a class=remove>×</a><label hidden><input type=checkbox> Spoiler</label><span></span>'
  2118.         });
  2119.         $('input', this.el).checked = this.spoiler;
  2120.         $.on(this.el, 'click', function() {
  2121.           return _this.select();
  2122.         });
  2123.         $.on($('.remove', this.el), 'click', function(e) {
  2124.           e.stopPropagation();
  2125.           return _this.rm();
  2126.         });
  2127.         $.on($('label', this.el), 'click', function(e) {
  2128.           return e.stopPropagation();
  2129.         });
  2130.         $.on($('input', this.el), 'change', function(e) {
  2131.           _this.spoiler = e.target.checked;
  2132.           if (_this.el.id === 'selected') {
  2133.             return $.id('spoiler').checked = _this.spoiler;
  2134.           }
  2135.         });
  2136.         $.before($('#addReply', QR.el), this.el);
  2137.         $.on(this.el, 'dragstart', this.dragStart);
  2138.         $.on(this.el, 'dragenter', this.dragEnter);
  2139.         $.on(this.el, 'dragleave', this.dragLeave);
  2140.         $.on(this.el, 'dragover', this.dragOver);
  2141.         $.on(this.el, 'dragend', this.dragEnd);
  2142.         $.on(this.el, 'drop', this.drop);
  2143.         QR.replies.push(this);
  2144.       }
  2145.  
  2146.       _Class.prototype.setFile = function(file) {
  2147.         var fileUrl, img, url,
  2148.           _this = this;
  2149.         this.file = file;
  2150.         this.el.title = "" + file.name + " (" + ($.bytesToString(file.size)) + ")";
  2151.         if (QR.spoiler) {
  2152.           $('label', this.el).hidden = false;
  2153.         }
  2154.         if (!/^image/.test(file.type)) {
  2155.           this.el.style.backgroundImage = null;
  2156.           return;
  2157.         }
  2158.         if (!(url = window.URL || window.webkitURL)) {
  2159.           return;
  2160.         }
  2161.         url.revokeObjectURL(this.url);
  2162.         fileUrl = url.createObjectURL(file);
  2163.         img = $.el('img');
  2164.         $.on(img, 'load', function() {
  2165.           var c, data, i, l, s, ui8a, _i;
  2166.           s = 90 * 3;
  2167.           if (img.height < s || img.width < s) {
  2168.             _this.url = fileUrl;
  2169.             _this.el.style.backgroundImage = "url(" + _this.url + ")";
  2170.             return;
  2171.           }
  2172.           if (img.height <= img.width) {
  2173.             img.width = s / img.height * img.width;
  2174.             img.height = s;
  2175.           } else {
  2176.             img.height = s / img.width * img.height;
  2177.             img.width = s;
  2178.           }
  2179.           c = $.el('canvas');
  2180.           c.height = img.height;
  2181.           c.width = img.width;
  2182.           c.getContext('2d').drawImage(img, 0, 0, img.width, img.height);
  2183.           data = atob(c.toDataURL().split(',')[1]);
  2184.           l = data.length;
  2185.           ui8a = new Uint8Array(l);
  2186.           for (i = _i = 0; 0 <= l ? _i < l : _i > l; i = 0 <= l ? ++_i : --_i) {
  2187.             ui8a[i] = data.charCodeAt(i);
  2188.           }
  2189.           _this.url = url.createObjectURL(new Blob([ui8a], {
  2190.             type: 'image/png'
  2191.           }));
  2192.           _this.el.style.backgroundImage = "url(" + _this.url + ")";
  2193.           return typeof url.revokeObjectURL === "function" ? url.revokeObjectURL(fileUrl) : void 0;
  2194.         });
  2195.         return img.src = fileUrl;
  2196.       };
  2197.  
  2198.       _Class.prototype.rmFile = function() {
  2199.         var _base1;
  2200.         QR.resetFileInput();
  2201.         delete this.file;
  2202.         this.el.title = null;
  2203.         this.el.style.backgroundImage = null;
  2204.         if (QR.spoiler) {
  2205.           $('label', this.el).hidden = true;
  2206.         }
  2207.         return typeof (_base1 = window.URL || window.webkitURL).revokeObjectURL === "function" ? _base1.revokeObjectURL(this.url) : void 0;
  2208.       };
  2209.  
  2210.       _Class.prototype.select = function() {
  2211.         var data, rectEl, rectList, _i, _len, _ref, _ref1;
  2212.         if ((_ref = QR.selected) != null) {
  2213.           _ref.el.id = null;
  2214.         }
  2215.         QR.selected = this;
  2216.         this.el.id = 'selected';
  2217.         rectEl = this.el.getBoundingClientRect();
  2218.         rectList = this.el.parentNode.getBoundingClientRect();
  2219.         this.el.parentNode.scrollLeft += rectEl.left + rectEl.width / 2 - rectList.left - rectList.width / 2;
  2220.         _ref1 = ['name', 'email', 'sub', 'com'];
  2221.         for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
  2222.           data = _ref1[_i];
  2223.           $("[name=" + data + "]", QR.el).value = this[data];
  2224.         }
  2225.         QR.characterCount.call($('textarea', QR.el));
  2226.         return $('#spoiler', QR.el).checked = this.spoiler;
  2227.       };
  2228.  
  2229.       _Class.prototype.dragStart = function() {
  2230.         return $.addClass(this, 'drag');
  2231.       };
  2232.  
  2233.       _Class.prototype.dragEnter = function() {
  2234.         return $.addClass(this, 'over');
  2235.       };
  2236.  
  2237.       _Class.prototype.dragLeave = function() {
  2238.         return $.rmClass(this, 'over');
  2239.       };
  2240.  
  2241.       _Class.prototype.dragOver = function(e) {
  2242.         e.preventDefault();
  2243.         return e.dataTransfer.dropEffect = 'move';
  2244.       };
  2245.  
  2246.       _Class.prototype.drop = function() {
  2247.         var el, index, newIndex, oldIndex, reply;
  2248.         el = $('.drag', this.parentNode);
  2249.         index = function(el) {
  2250.           return Array.prototype.slice.call(el.parentNode.children).indexOf(el);
  2251.         };
  2252.         oldIndex = index(el);
  2253.         newIndex = index(this);
  2254.         if (oldIndex < newIndex) {
  2255.           $.after(this, el);
  2256.         } else {
  2257.           $.before(this, el);
  2258.         }
  2259.         reply = QR.replies.splice(oldIndex, 1)[0];
  2260.         return QR.replies.splice(newIndex, 0, reply);
  2261.       };
  2262.  
  2263.       _Class.prototype.dragEnd = function() {
  2264.         var el;
  2265.         $.rmClass(this, 'drag');
  2266.         if (el = $('.over', this.parentNode)) {
  2267.           return $.rmClass(el, 'over');
  2268.         }
  2269.       };
  2270.  
  2271.       _Class.prototype.rm = function() {
  2272.         var index, _base1;
  2273.         QR.resetFileInput();
  2274.         $.rm(this.el);
  2275.         index = QR.replies.indexOf(this);
  2276.         if (QR.replies.length === 1) {
  2277.           new QR.reply().select();
  2278.         } else if (this.el.id === 'selected') {
  2279.           (QR.replies[index - 1] || QR.replies[index + 1]).select();
  2280.         }
  2281.         QR.replies.splice(index, 1);
  2282.         return typeof (_base1 = window.URL || window.webkitURL).revokeObjectURL === "function" ? _base1.revokeObjectURL(this.url) : void 0;
  2283.       };
  2284.  
  2285.       return _Class;
  2286.  
  2287.     })(),
  2288.     captcha: {
  2289.       init: function() {
  2290.         var _this = this;
  2291.         if (-1 !== d.cookie.indexOf('pass_enabled=')) {
  2292.           return;
  2293.         }
  2294.         if (!(this.isEnabled = !!$.id('captchaFormPart'))) {
  2295.           return;
  2296.         }
  2297.         if ($.id('recaptcha_challenge_field_holder')) {
  2298.           return this.ready();
  2299.         } else {
  2300.           this.onready = function() {
  2301.             return _this.ready();
  2302.           };
  2303.           return $.on($.id('captchaContainer'), 'DOMNodeInserted', this.onready);
  2304.         }
  2305.       },
  2306.       ready: function() {
  2307.         var _this = this, challenge;
  2308.         if (this.challenge = challenge = $.id('recaptcha_challenge_field_holder')) {
  2309.           $.off($.id('captchaContainer'), 'DOMNodeInserted', this.onready);
  2310.           delete this.onready;
  2311.         } else {
  2312.           return;
  2313.         }
  2314.         $.addClass(QR.el, 'captcha');
  2315.         $.after($('.textarea', QR.el), $.el('div', {
  2316.           className: 'captchaimg',
  2317.           title: 'Reload',
  2318.           innerHTML: '<img>'
  2319.         }));
  2320.         $.after($('.captchaimg', QR.el), $.el('div', {
  2321.           className: 'captchainput',
  2322.           innerHTML: '<input title=Verification class=field autocomplete=off size=1>'
  2323.         }));
  2324.         this.img = $('.captchaimg > img', QR.el);
  2325.         this.input = $('.captchainput > input', QR.el);
  2326.         $.on(this.img.parentNode, 'click', this.reload);
  2327.         $.on(this.input, 'keydown', this.keydown);
  2328.         (new MutationObserver(_this.load.bind(_this))).observe(challenge, {
  2329.           childList: true,
  2330.           subtree: true,
  2331.           attributes: true
  2332.         });
  2333.         $.sync('captchas', function(arr) {
  2334.           return _this.count(arr.length);
  2335.         });
  2336.         this.count($.get('captchas', []).length);
  2337.         return this.reload();
  2338.       },
  2339.       save: function() {
  2340.         var captcha, captchas, response;
  2341.         if (!(response = this.input.value)) {
  2342.           return;
  2343.         }
  2344.         captchas = $.get('captchas', []);
  2345.         while ((captcha = captchas[0]) && captcha.time < Date.now()) {
  2346.           captchas.shift();
  2347.         }
  2348.         captchas.push({
  2349.           challenge: this.challenge.firstChild.value,
  2350.           response: response,
  2351.           time: this.timeout
  2352.         });
  2353.         $.set('captchas', captchas);
  2354.         this.count(captchas.length);
  2355.         return this.reload();
  2356.       },
  2357.       load: function() {
  2358.         var challenge;
  2359.         this.timeout = Date.now() + 4 * $.MINUTE;
  2360.         console.log(this.challenge);
  2361.         challenge = this.challenge.firstChild.value;
  2362.         this.img.alt = challenge;
  2363.         this.img.src = "//www.google.com/recaptcha/api/image?c=" + challenge;
  2364.         return this.input.value = null;
  2365.       },
  2366.       count: function(count) {
  2367.         this.input.placeholder = (function() {
  2368.           switch (count) {
  2369.             case 0:
  2370.               return 'Verification (Shift + Enter to cache)';
  2371.             case 1:
  2372.               return 'Verification (1 cached captcha)';
  2373.             default:
  2374.               return "Verification (" + count + " cached captchas)";
  2375.           }
  2376.         })();
  2377.         return this.input.alt = count;
  2378.       },
  2379.       reload: function(focus) {
  2380.         $.globalEval('javascript:Recaptcha.reload("t")');
  2381.         if (focus) {
  2382.           return QR.captcha.input.focus();
  2383.         }
  2384.       },
  2385.       keydown: function(e) {
  2386.         var c;
  2387.         c = QR.captcha;
  2388.         if (e.keyCode === 8 && !c.input.value) {
  2389.           c.reload();
  2390.         } else if (e.keyCode === 13 && e.shiftKey) {
  2391.           c.save();
  2392.         } else {
  2393.           return;
  2394.         }
  2395.         return e.preventDefault();
  2396.       }
  2397.     },
  2398.     dialog: function() {
  2399.       var fileInput, id, mimeTypes, name, spoiler, ta, thread, threads, _i, _j, _len, _len1, _ref, _ref1;
  2400.       QR.el = UI.dialog('qr', 'top:0;right:0;', '\
  2401. <div class=move>\
  2402.  Quick Reply <input type=checkbox id=autohide title=Auto-hide>\
  2403.  <span> <a class=close title=Close>×</a></span>\
  2404. </div>\
  2405. <form>\
  2406.  <div><input id=dump type=button title="Dump list" value=+ class=field><input name=name title=Name placeholder=Name class=field size=1><input name=email title=E-mail placeholder=E-mail class=field size=1><input name=sub title=Subject placeholder=Subject class=field size=1></div>\
  2407.  <div id=replies><div><a id=addReply href=javascript:; title="Add a reply">+</a></div></div>\
  2408.  <div class=textarea><textarea name=com title=Comment placeholder=Comment class=field></textarea><span id=charCount></span></div>\
  2409.  <div><input type=file title="Shift+Click to remove the selected file." multiple size=16><input type=submit></div>\
  2410.  <label id=spoilerLabel><input type=checkbox id=spoiler> Spoiler Image</label>\
  2411.  <div class=warning></div>\
  2412. </form>');
  2413.       if (Conf['Remember QR size'] && $.engine === 'gecko') {
  2414.         $.on(ta = $('textarea', QR.el), 'mouseup', function() {
  2415.           return $.set('QR.size', this.style.cssText);
  2416.         });
  2417.         ta.style.cssText = $.get('QR.size', '');
  2418.       }
  2419.       QR.mimeTypes = ['image/jpeg', 'image/png', 'image/gif', 'application/pdf', 'application/x-shockwave-flash', 'video/webm', ''];
  2420.       fileInput = $('input[type=file]', QR.el);
  2421.       fileInput.max = $('input[name=MAX_FILE_SIZE]').value;
  2422.       if ($.engine !== 'presto') {
  2423.         fileInput.accept = mimeTypes;
  2424.       }
  2425.       QR.spoiler = !!$('input[name=spoiler]');
  2426.       spoiler = $('#spoilerLabel', QR.el);
  2427.       spoiler.hidden = !QR.spoiler;
  2428.       QR.charaCounter = $('#charCount', QR.el);
  2429.       ta = $('textarea', QR.el);
  2430.       if (!g.REPLY) {
  2431.         threads = '<option value=new>New thread</option>';
  2432.         _ref = $$('.thread');
  2433.         for (_i = 0, _len = _ref.length; _i < _len; _i++) {
  2434.           thread = _ref[_i];
  2435.           id = thread.id.slice(1);
  2436.           threads += "<option value=" + id + ">Thread " + id + "</option>";
  2437.         }
  2438.         QR.threadSelector = g.BOARD === 'f' ? $('select[name=filetag]').cloneNode(true) : $.el('select', {
  2439.           innerHTML: threads,
  2440.           title: 'Create a new thread / Reply to a thread'
  2441.         });
  2442.         $.prepend($('.move > span', QR.el), QR.threadSelector);
  2443.         $.on(QR.threadSelector, 'mousedown', function(e) {
  2444.           return e.stopPropagation();
  2445.         });
  2446.       }
  2447.       $.on($('#autohide', QR.el), 'change', QR.toggleHide);
  2448.       $.on($('.close', QR.el), 'click', QR.close);
  2449.       $.on($('#dump', QR.el), 'click', function() {
  2450.         return QR.el.classList.toggle('dump');
  2451.       });
  2452.       $.on($('#addReply', QR.el), 'click', function() {
  2453.         return new QR.reply().select();
  2454.       });
  2455.       $.on($('form', QR.el), 'submit', QR.submit);
  2456.       $.on(ta, 'input', function() {
  2457.         return QR.selected.el.lastChild.textContent = this.value;
  2458.       });
  2459.       $.on(ta, 'input', QR.characterCount);
  2460.       $.on(fileInput, 'change', QR.fileInput);
  2461.       $.on(fileInput, 'click', function(e) {
  2462.         if (e.shiftKey) {
  2463.           return QR.selected.rmFile() || e.preventDefault();
  2464.         }
  2465.       });
  2466.       $.on(spoiler.firstChild, 'change', function() {
  2467.         return $('input', QR.selected.el).click();
  2468.       });
  2469.       $.on($('.warning', QR.el), 'click', QR.cleanError);
  2470.       new QR.reply().select();
  2471.       _ref1 = ['name', 'email', 'sub', 'com'];
  2472.       for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
  2473.         name = _ref1[_j];
  2474.         $.on($("[name=" + name + "]", QR.el), 'input', function() {
  2475.           var _ref2;
  2476.           QR.selected[this.name] = this.value;
  2477.           if (QR.cooldown.auto && QR.selected === QR.replies[0] && (0 < (_ref2 = QR.cooldown.seconds) && _ref2 <= 5)) {
  2478.             return QR.cooldown.auto = false;
  2479.           }
  2480.         });
  2481.       }
  2482.       QR.status.input = $('input[type=submit]', QR.el);
  2483.       QR.status();
  2484.       QR.cooldown.init();
  2485.       QR.captcha.init();
  2486.       $.add(d.body, QR.el);
  2487.       return $.event(QR.el, new CustomEvent('QRDialogCreation', {
  2488.         bubbles: true
  2489.       }));
  2490.     },
  2491.     submit: function(e) {
  2492.       var callbacks, captcha, captchas, challenge, err, filetag, m, opts, post, reply, response, textOnly, threadID, _ref;
  2493.       if (e != null) {
  2494.         e.preventDefault();
  2495.       }
  2496.       if (QR.cooldown.seconds) {
  2497.         QR.cooldown.auto = !QR.cooldown.auto;
  2498.         QR.status();
  2499.         return;
  2500.       }
  2501.       QR.abort();
  2502.       reply = QR.replies[0];
  2503.       if (g.BOARD === 'f' && !g.REPLY) {
  2504.         filetag = QR.threadSelector.value;
  2505.         threadID = 'new';
  2506.       } else {
  2507.         threadID = g.THREAD_ID || QR.threadSelector.value;
  2508.       }
  2509.       if (threadID === 'new') {
  2510.         threadID = null;
  2511.         if (((_ref = g.BOARD) === 'vg' || _ref === 'q') && !reply.sub) {
  2512.           err = 'New threads require a subject.';
  2513.         } else if (!(reply.file || (textOnly = !!$('input[name=textonly]', $.id('postForm'))))) {
  2514.           err = 'No file selected.';
  2515.         } else if (g.BOARD === 'f' && filetag === '9999') {
  2516.           err = 'Invalid tag specified.';
  2517.         }
  2518.       } else if (!(reply.com || reply.file)) {
  2519.         err = 'No file selected.';
  2520.       }
  2521.       if (QR.captcha.isEnabled && !err) {
  2522.         captchas = $.get('captchas', []);
  2523.         while ((captcha = captchas[0]) && captcha.time < Date.now()) {
  2524.           captchas.shift();
  2525.         }
  2526.         if (captcha = captchas.shift()) {
  2527.           challenge = captcha.challenge;
  2528.           response = captcha.response;
  2529.         } else {
  2530.           challenge = QR.captcha.img.alt;
  2531.           if (response = QR.captcha.input.value) {
  2532.             QR.captcha.reload();
  2533.           }
  2534.         }
  2535.         $.set('captchas', captchas);
  2536.         QR.captcha.count(captchas.length);
  2537.         if (!response) {
  2538.           err = 'No valid captcha.';
  2539.         } else {
  2540.           response = response.trim();
  2541.           if (!/\s/.test(response)) {
  2542.             response = "" + response + " " + response;
  2543.           }
  2544.         }
  2545.       }
  2546.       if (err) {
  2547.         QR.cooldown.auto = false;
  2548.         QR.status();
  2549.         QR.error(err);
  2550.         return;
  2551.       }
  2552.       QR.cleanError();
  2553.       QR.cooldown.auto = QR.replies.length > 1;
  2554.       if (Conf['Auto Hide QR'] && !QR.cooldown.auto) {
  2555.         QR.hide();
  2556.       }
  2557.       if (!QR.cooldown.auto && $.x('ancestor::div[@id="qr"]', d.activeElement)) {
  2558.         d.activeElement.blur();
  2559.       }
  2560.       QR.status({
  2561.         progress: '...'
  2562.       });
  2563.       post = {
  2564.         resto: threadID,
  2565.         name: reply.name,
  2566.         email: reply.email,
  2567.         sub: reply.sub,
  2568.         com: reply.com,
  2569.         upfile: reply.file,
  2570.         filetag: filetag,
  2571.         spoiler: reply.spoiler,
  2572.         textonly: textOnly,
  2573.         mode: 'regist',
  2574.         pwd: (m = d.cookie.match(/4chan_pass=([^;]+)/)) ? decodeURIComponent(m[1]) : $('input[name=pwd]').value,
  2575.         recaptcha_challenge_field: challenge,
  2576.         recaptcha_response_field: response
  2577.       };
  2578.       callbacks = {
  2579.         onload: function() {
  2580.           return QR.response(this.response);
  2581.         },
  2582.         onerror: function() {
  2583.           QR.cooldown.auto = false;
  2584.           QR.status();
  2585.           return QR.error($.el('a', {
  2586.             href: '//www.4chan.org/banned',
  2587.             target: '_blank',
  2588.             textContent: 'Connection error, or you are banned.'
  2589.           }));
  2590.         }
  2591.       };
  2592.       opts = {
  2593.         form: $.formData(post),
  2594.         upCallbacks: {
  2595.           onload: function() {
  2596.             return QR.status({
  2597.               progress: '...'
  2598.             });
  2599.           },
  2600.           onprogress: function(e) {
  2601.             return QR.status({
  2602.               progress: "" + (Math.round(e.loaded / e.total * 100)) + "%"
  2603.             });
  2604.           }
  2605.         }
  2606.       };
  2607.       return QR.ajax = $.ajax($.id('postForm').parentNode.action, callbacks, opts);
  2608.     },
  2609.     response: function(html) {
  2610.       var ban, board, doc, err, persona, postID, reply, threadID, _, _ref, _ref1;
  2611.       doc = d.implementation.createHTMLDocument('');
  2612.       doc.documentElement.innerHTML = html;
  2613.       if (ban = $('.banType', doc)) {
  2614.         board = $('.board', doc).innerHTML;
  2615.         err = $.el('span', {
  2616.           innerHTML: ban.textContent.toLowerCase() === 'banned' ? ("You are banned on " + board + "! ;_;<br>") + "Click <a href=//www.4chan.org/banned target=_blank>here</a> to see the reason." : ("You were issued a warning on " + board + " as " + ($('.nameBlock', doc).innerHTML) + ".<br>") + ("Reason: " + ($('.reason', doc).innerHTML))
  2617.         });
  2618.       } else if (err = doc.getElementById('errmsg')) {
  2619.         if ((_ref = $('a', err)) != null) {
  2620.           _ref.target = '_blank';
  2621.         }
  2622.       } else if (doc.title !== 'Post successful!') {
  2623.         err = 'Connection error with sys.4chan.org.';
  2624.       }
  2625.       if (err) {
  2626.         if (/captcha|verification/i.test(err.textContent) || err === 'Connection error with sys.4chan.org.') {
  2627.           if (/mistyped/i.test(err.textContent)) {
  2628.             err = 'Error: You seem to have mistyped the CAPTCHA.';
  2629.           }
  2630.           QR.cooldown.auto = QR.captcha.isEnabled ? !!$.get('captchas', []).length : err === 'Connection error with sys.4chan.org.' ? true : false;
  2631.           QR.cooldown.set({
  2632.             delay: 2
  2633.           });
  2634.         } else {
  2635.           QR.cooldown.auto = false;
  2636.         }
  2637.         QR.status();
  2638.         QR.error(err);
  2639.         return;
  2640.       }
  2641.       reply = QR.replies[0];
  2642.       persona = $.get('QR.persona', {});
  2643.       persona = {
  2644.         name: reply.name,
  2645.         email: /^sage$/.test(reply.email) ? persona.email : reply.email,
  2646.         sub: Conf['Remember Subject'] ? reply.sub : null
  2647.       };
  2648.       $.set('QR.persona', persona);
  2649.       _ref1 = doc.body.lastChild.textContent.match(/thread:(\d+),no:(\d+)/), _ = _ref1[0], threadID = _ref1[1], postID = _ref1[2];
  2650.       $.event(QR.el, new CustomEvent('QRPostSuccessful', {
  2651.         bubbles: true,
  2652.         detail: {
  2653.           threadID: threadID,
  2654.           postID: postID
  2655.         }
  2656.       }));
  2657.       QR.cooldown.set({
  2658.         post: reply,
  2659.         isReply: threadID !== '0'
  2660.       });
  2661.       if (threadID === '0') {
  2662.         location.pathname = "/" + g.BOARD + "/res/" + postID;
  2663.       } else {
  2664.         QR.cooldown.auto = QR.replies.length > 1;
  2665.         if (Conf['Open Reply in New Tab'] && !g.REPLY && !QR.cooldown.auto) {
  2666.           $.open("//boards.4chan.org/" + g.BOARD + "/res/" + threadID + "#p" + postID);
  2667.         }
  2668.       }
  2669.       if (Conf['Persistent QR'] || QR.cooldown.auto) {
  2670.         reply.rm();
  2671.       } else {
  2672.         QR.close();
  2673.       }
  2674.       QR.status();
  2675.       return QR.resetFileInput();
  2676.     },
  2677.     abort: function() {
  2678.       var _ref;
  2679.       if ((_ref = QR.ajax) != null) {
  2680.         _ref.abort();
  2681.       }
  2682.       delete QR.ajax;
  2683.       return QR.status();
  2684.     }
  2685.   };
  2686.  
  2687.   Options = {
  2688.     init: function() {
  2689.       return $.ready(Options.initReady);
  2690.     },
  2691.     initReady: function() {
  2692.       var a, setting, settings, _i, _len, _ref;
  2693.       _ref = ['navtopright', 'navbotright'];
  2694.       for (_i = 0, _len = _ref.length; _i < _len; _i++) {
  2695.         settings = _ref[_i];
  2696.         a = $.el('a', {
  2697.           href: 'javascript:;',
  2698.           className: 'settingsWindowLink',
  2699.           textContent: '4chan X Settings'
  2700.         });
  2701.         $.on(a, 'click', Options.dialog);
  2702.         setting = $.id(settings);
  2703.         if (Conf['Disable 4chan\'s extension']) {
  2704.           $.replace(setting.firstElementChild, a);
  2705.         } else {
  2706.           $.prepend(setting, [$.tn('['), a, $.tn('] ')]);
  2707.         }
  2708.       }
  2709.       if (!$.get('firstrun')) {
  2710.         $.set('firstrun', true);
  2711.         if (!Favicon.el) {
  2712.           Favicon.init();
  2713.         }
  2714.         return Options.dialog();
  2715.       }
  2716.     },
  2717.     dialog: function() {
  2718.       var arr, back, checked, description, dialog, favicon, fileInfo, filter, hiddenNum, hiddenThreads, indicator, indicators, input, key, li, obj, overlay, sauce, time, tr, ul, _i, _len, _ref, _ref1, _ref2;
  2719.       dialog = $.el('div', {
  2720.         id: 'options',
  2721.         className: 'reply dialog',
  2722.         innerHTML: '<div id=optionsbar>\
  2723.  <div id=credits>\
  2724.    <a target=_blank href=http://mayhemydg.github.io/4chan-x/>4chan X</a>\
  2725.    | <a target=_blank href=https://raw.github.com/mayhemydg/4chan-x/master/changelog>' + Main.version + '</a>\
  2726.    | <a target=_blank href=http://mayhemydg.github.io/4chan-x/#bug-report>Issues</a>\
  2727.  </div>\
  2728.  <div>\
  2729.    <label for=main_tab>Main</label>\
  2730.    | <label for=filter_tab>Filter</label>\
  2731.    | <label for=sauces_tab>Sauce</label>\
  2732.    | <label for=rice_tab>Rice</label>\
  2733.    | <label for=keybinds_tab>Keybinds</label>\
  2734.  </div>\
  2735. </div>\
  2736. <hr>\
  2737. <div id=content>\
  2738.  <input type=radio name=tab hidden id=main_tab checked>\
  2739.  <div>\
  2740.    <div class=imp-exp>\
  2741.      <button class=export>Export settings</button>\
  2742.      <button class=import>Import settings</button>\
  2743.      <input type=file style="visibility:hidden">\
  2744.    </div>\
  2745.    <p class=imp-exp-result></p>\
  2746.  </div>\
  2747.  <input type=radio name=tab hidden id=sauces_tab>\
  2748.  <div>\
  2749.    <div class=warning><code>Sauce</code> is disabled.</div>\
  2750.    Lines starting with a <code>#</code> will be ignored.<br>\
  2751.    You can specify a certain display text by appending <code>;text:[text]</code> to the url.\
  2752.    <ul>These parameters will be replaced by their corresponding values:\
  2753.      <li>$1: Thumbnail url.</li>\
  2754.      <li>$2: Full image url.</li>\
  2755.      <li>$3: MD5 hash.</li>\
  2756.      <li>$4: Current board.</li>\
  2757.    </ul>\
  2758.    <textarea name=sauces id=sauces class=field></textarea>\
  2759.  </div>\
  2760.  <input type=radio name=tab hidden id=filter_tab>\
  2761.  <div>\
  2762.    <div class=warning><code>Filter</code> is disabled.</div>\
  2763.    <select name=filter>\
  2764.      <option value=guide>Guide</option>\
  2765.      <option value=name>Name</option>\
  2766.      <option value=uniqueid>Unique ID</option>\
  2767.      <option value=tripcode>Tripcode</option>\
  2768.      <option value=mod>Admin/Mod</option>\
  2769.      <option value=email>E-mail</option>\
  2770.      <option value=subject>Subject</option>\
  2771.      <option value=comment>Comment</option>\
  2772.      <option value=country>Country</option>\
  2773.      <option value=filename>Filename</option>\
  2774.      <option value=dimensions>Image dimensions</option>\
  2775.      <option value=filesize>Filesize</option>\
  2776.      <option value=md5>Image MD5 (uses exact string matching, not regular expressions)</option>\
  2777.    </select>\
  2778.  </div>\
  2779.  <input type=radio name=tab hidden id=rice_tab>\
  2780.  <div>\
  2781.    <div class=warning><code>Quote Backlinks</code> are disabled.</div>\
  2782.    <ul>\
  2783.      Backlink formatting\
  2784.      <li><input name=backlink class=field> : <span id=backlinkPreview></span></li>\
  2785.    </ul>\
  2786.    <div class=warning><code>Time Formatting</code> is disabled.</div>\
  2787.    <ul>\
  2788.      Time formatting\
  2789.      <li><input name=time class=field> : <span id=timePreview></span></li>\
  2790.      <li>Supported <a href=http://en.wikipedia.org/wiki/Date_%28Unix%29#Formatting>format specifiers</a>:</li>\
  2791.      <li>Day: %a, %A, %d, %e</li>\
  2792.      <li>Month: %m, %b, %B</li>\
  2793.      <li>Year: %y</li>\
  2794.      <li>Hour: %k, %H, %l (lowercase L), %I (uppercase i), %p, %P</li>\
  2795.      <li>Minutes: %M</li>\
  2796.      <li>Seconds: %S</li>\
  2797.    </ul>\
  2798.    <div class=warning><code>File Info Formatting</code> is disabled.</div>\
  2799.    <ul>\
  2800.      File Info Formatting\
  2801.      <li><input name=fileInfo class=field> : <span id=fileInfoPreview class=fileText></span></li>\
  2802.      <li>Link: %l (lowercase L, truncated), %L (untruncated), %t (Unix timestamp)</li>\
  2803.      <li>Original file name: %n (truncated), %N (untruncated), %T (Unix timestamp)</li>\
  2804.      <li>Spoiler indicator: %p</li>\
  2805.      <li>Size: %B (Bytes), %K (KB), %M (MB), %s (4chan default)</li>\
  2806.      <li>Resolution: %r (Displays PDF on /po/, for PDFs)</li>\
  2807.    </ul>\
  2808.    <div class=warning><code>Unread Favicon</code> is disabled.</div>\
  2809.    Unread favicons<br>\
  2810.    <select name=favicon>\
  2811.      <option value=ferongr>ferongr</option>\
  2812.      <option value=xat->xat-</option>\
  2813.      <option value=Mayhem>Mayhem</option>\
  2814.      <option value=Original>Original</option>\
  2815.    </select>\
  2816.    <span></span>\
  2817.  </div>\
  2818.  <input type=radio name=tab hidden id=keybinds_tab>\
  2819.  <div>\
  2820.    <div class=warning><code>Keybinds</code> are disabled.</div>\
  2821.    <div>Allowed keys: Ctrl, Alt, Meta, a-z, A-Z, 0-9, Up, Down, Right, Left.</div>\
  2822.    <table><tbody>\
  2823.      <tr><th>Actions</th><th>Keybinds</th></tr>\
  2824.    </tbody></table>\
  2825.  </div>\
  2826. </div>'
  2827.       });
  2828.       $.on($('#main_tab + div .export', dialog), 'click', Options["export"]);
  2829.       $.on($('#main_tab + div .import', dialog), 'click', Options["import"]);
  2830.       $.on($('#main_tab + div input', dialog), 'change', Options.onImport);
  2831.       _ref = Config.main;
  2832.       for (key in _ref) {
  2833.         obj = _ref[key];
  2834.         ul = $.el('ul', {
  2835.           textContent: key
  2836.         });
  2837.         for (key in obj) {
  2838.           arr = obj[key];
  2839.           checked = $.get(key, Conf[key]) ? 'checked' : '';
  2840.           description = arr[1];
  2841.           li = $.el('li', {
  2842.             innerHTML: "<label><input type=checkbox name=\"" + key + "\" " + checked + ">" + key + "</label><span class=description>: " + description + "</span>"
  2843.           });
  2844.           $.on($('input', li), 'click', $.cb.checked);
  2845.           $.add(ul, li);
  2846.         }
  2847.         $.add($('#main_tab + div', dialog), ul);
  2848.       }
  2849.       hiddenThreads = $.get("hiddenThreads/" + g.BOARD + "/", {});
  2850.       hiddenNum = Object.keys(g.hiddenReplies).length + Object.keys(hiddenThreads).length;
  2851.       li = $.el('li', {
  2852.         innerHTML: "<button>hidden: " + hiddenNum + "</button> <span class=description>: Forget all hidden posts. Useful if you accidentally hide a post and have \"Show Stubs\" disabled."
  2853.       });
  2854.       $.on($('button', li), 'click', Options.clearHidden);
  2855.       $.add($('ul:nth-child(2)', dialog), li);
  2856.       filter = $('select[name=filter]', dialog);
  2857.       $.on(filter, 'change', Options.filter);
  2858.       sauce = $('#sauces', dialog);
  2859.       sauce.value = $.get(sauce.name, Conf[sauce.name]);
  2860.       $.on(sauce, 'change', $.cb.value);
  2861.       (back = $('[name=backlink]', dialog)).value = $.get('backlink', Conf['backlink']);
  2862.       (time = $('[name=time]', dialog)).value = $.get('time', Conf['time']);
  2863.       (fileInfo = $('[name=fileInfo]', dialog)).value = $.get('fileInfo', Conf['fileInfo']);
  2864.       $.on(back, 'input', $.cb.value);
  2865.       $.on(back, 'input', Options.backlink);
  2866.       $.on(time, 'input', $.cb.value);
  2867.       $.on(time, 'input', Options.time);
  2868.       $.on(fileInfo, 'input', $.cb.value);
  2869.       $.on(fileInfo, 'input', Options.fileInfo);
  2870.       favicon = $('select[name=favicon]', dialog);
  2871.       favicon.value = $.get('favicon', Conf['favicon']);
  2872.       $.on(favicon, 'change', $.cb.value);
  2873.       $.on(favicon, 'change', Options.favicon);
  2874.       _ref1 = Config.hotkeys;
  2875.       for (key in _ref1) {
  2876.         arr = _ref1[key];
  2877.         tr = $.el('tr', {
  2878.           innerHTML: "<td>" + arr[1] + "</td><td><input name=" + key + " class=field></td>"
  2879.         });
  2880.         input = $('input', tr);
  2881.         input.value = $.get(key, Conf[key]);
  2882.         $.on(input, 'keydown', Options.keybind);
  2883.         $.add($('#keybinds_tab + div tbody', dialog), tr);
  2884.       }
  2885.       indicators = {};
  2886.       _ref2 = $$('.warning', dialog);
  2887.       for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
  2888.         indicator = _ref2[_i];
  2889.         key = indicator.firstChild.textContent;
  2890.         indicator.hidden = $.get(key, Conf[key]);
  2891.         indicators[key] = indicator;
  2892.         $.on($("[name='" + key + "']", dialog), 'click', function() {
  2893.           return indicators[this.name].hidden = this.checked;
  2894.         });
  2895.       }
  2896.       overlay = $.el('div', {
  2897.         id: 'overlay'
  2898.       });
  2899.       $.on(overlay, 'click', Options.close);
  2900.       $.on(dialog, 'click', function(e) {
  2901.         return e.stopPropagation();
  2902.       });
  2903.       $.add(overlay, dialog);
  2904.       $.add(d.body, overlay);
  2905.       d.body.style.setProperty('width', "" + d.body.clientWidth + "px", null);
  2906.       $.addClass(d.body, 'unscroll');
  2907.       Options.filter.call(filter);
  2908.       Options.backlink.call(back);
  2909.       Options.time.call(time);
  2910.       Options.fileInfo.call(fileInfo);
  2911.       return Options.favicon.call(favicon);
  2912.     },
  2913.     close: function() {
  2914.       $.rm(this);
  2915.       d.body.style.removeProperty('width');
  2916.       return $.rmClass(d.body, 'unscroll');
  2917.     },
  2918.     clearHidden: function() {
  2919.       $["delete"]("hiddenReplies/" + g.BOARD + "/");
  2920.       $["delete"]("hiddenThreads/" + g.BOARD + "/");
  2921.       this.textContent = "hidden: 0";
  2922.       return g.hiddenReplies = {};
  2923.     },
  2924.     keybind: function(e) {
  2925.       var key;
  2926.       if (e.keyCode === 9) {
  2927.         return;
  2928.       }
  2929.       e.preventDefault();
  2930.       e.stopPropagation();
  2931.       if ((key = Keybinds.keyCode(e)) == null) {
  2932.         return;
  2933.       }
  2934.       this.value = key;
  2935.       return $.cb.value.call(this);
  2936.     },
  2937.     filter: function() {
  2938.       var el, name, ta;
  2939.       el = this.nextSibling;
  2940.       if ((name = this.value) !== 'guide') {
  2941.         ta = $.el('textarea', {
  2942.           name: name,
  2943.           className: 'field',
  2944.           value: $.get(name, Conf[name])
  2945.         });
  2946.         $.on(ta, 'change', $.cb.value);
  2947.         $.replace(el, ta);
  2948.         return;
  2949.       }
  2950.       if (el) {
  2951.         $.rm(el);
  2952.       }
  2953.       return $.after(this, $.el('article', {
  2954.         innerHTML: '<p>Use <a href=https://developer.mozilla.org/en/JavaScript/Guide/Regular_Expressions>regular expressions</a>, one per line.<br>\
  2955.  Lines starting with a <code>#</code> will be ignored.<br>\
  2956.  For example, <code>/weeaboo/i</code> will filter posts containing the string `<code>weeaboo</code>`, case-insensitive.</p>\
  2957.  <ul>You can use these settings with each regular expression, separate them with semicolons:\
  2958.    <li>\
  2959.      Per boards, separate them with commas. It is global if not specified.<br>\
  2960.      For example: <code>boards:a,jp;</code>.\
  2961.    </li>\
  2962.    <li>\
  2963.      Filter OPs only along with their threads (`only`), replies only (`no`, this is default), or both (`yes`).<br>\
  2964.      For example: <code>op:only;</code>, <code>op:no;</code> or <code>op:yes;</code>.\
  2965.    </li>\
  2966.    <li>\
  2967.      Overrule the `Show Stubs` setting if specified: create a stub (`yes`) or not (`no`).<br>\
  2968.      For example: <code>stub:yes;</code> or <code>stub:no;</code>.\
  2969.    </li>\
  2970.    <li>\
  2971.      Highlight instead of hiding. You can specify a class name to use with a userstyle.<br>\
  2972.      For example: <code>highlight;</code> or <code>highlight:wallpaper;</code>.\
  2973.    </li>\
  2974.    <li>\
  2975.      Highlighted OPs will have their threads put on top of board pages by default.<br>\
  2976.      For example: <code>top:yes;</code> or <code>top:no;</code>.\
  2977.    </li>\
  2978.  </ul>'
  2979.       }));
  2980.     },
  2981.     time: function() {
  2982.       Time.foo();
  2983.       Time.date = new Date();
  2984.       return $.id('timePreview').textContent = Time.funk(Time);
  2985.     },
  2986.     backlink: function() {
  2987.       return $.id('backlinkPreview').textContent = Conf['backlink'].replace(/%id/, '123456789');
  2988.     },
  2989.     fileInfo: function() {
  2990.       FileInfo.data = {
  2991.         link: '//i.4cdn.org/g/src/1334437723720.jpg',
  2992.         spoiler: true,
  2993.         size: '276',
  2994.         unit: 'KB',
  2995.         resolution: '1280x720',
  2996.         fullname: 'd9bb2efc98dd0df141a94399ff5880b7.jpg',
  2997.         shortname: 'd9bb2efc98dd0df141a94399ff5880(...).jpg'
  2998.       };
  2999.       FileInfo.setFormats();
  3000.       return $.id('fileInfoPreview').innerHTML = FileInfo.funk(FileInfo);
  3001.     },
  3002.     favicon: function() {
  3003.       Favicon["switch"]();
  3004.       Unread.update(true);
  3005.       return this.nextElementSibling.innerHTML = "<img src=" + Favicon.unreadSFW + "> <img src=" + Favicon.unreadNSFW + "> <img src=" + Favicon.unreadDead + ">";
  3006.     },
  3007.     "export": function() {
  3008.       var a, data, now, output;
  3009.       now = Date.now();
  3010.       data = {
  3011.         version: Main.version,
  3012.         date: now,
  3013.         Conf: Conf,
  3014.         WatchedThreads: $.get('watched', {})
  3015.       };
  3016.       a = $.el('a', {
  3017.         className: 'warning',
  3018.         textContent: 'Save me!',
  3019.         download: "4chan X v" + Main.version + "-" + now + ".json",
  3020.         href: "data:application/json;base64," + (btoa(unescape(encodeURIComponent(JSON.stringify(data))))),
  3021.         target: '_blank'
  3022.       });
  3023.       if ($.engine !== 'gecko') {
  3024.         a.click();
  3025.         return;
  3026.       }
  3027.       output = this.parentNode.nextElementSibling;
  3028.       output.innerHTML = null;
  3029.       return $.add(output, a);
  3030.     },
  3031.     "import": function() {
  3032.       return this.nextElementSibling.click();
  3033.     },
  3034.     onImport: function() {
  3035.       var file, output, reader;
  3036.       if (!(file = this.files[0])) {
  3037.         return;
  3038.       }
  3039.       output = this.parentNode.nextElementSibling;
  3040.       if (!confirm('Your current settings will be entirely overwritten, are you sure?')) {
  3041.         output.textContent = 'Import aborted.';
  3042.         return;
  3043.       }
  3044.       reader = new FileReader();
  3045.       reader.onload = function(e) {
  3046.         var data, err;
  3047.         try {
  3048.           data = JSON.parse(e.target.result);
  3049.           Options.loadSettings(data);
  3050.           if (confirm('Import successful. Refresh now?')) {
  3051.             return window.location.reload();
  3052.           }
  3053.         } catch (_error) {
  3054.           err = _error;
  3055.           return output.textContent = 'Import failed due to an error.';
  3056.         }
  3057.       };
  3058.       return reader.readAsText(file);
  3059.     },
  3060.     loadSettings: function(data) {
  3061.       var key, val, _ref;
  3062.       _ref = data.Conf;
  3063.       for (key in _ref) {
  3064.         val = _ref[key];
  3065.         $.set(key, val);
  3066.       }
  3067.       return $.set('watched', data.WatchedThreads);
  3068.     }
  3069.   };
  3070.  
  3071.   Updater = {
  3072.     init: function() {
  3073.       var checkbox, checked, dialog, html, input, name, title, _i, _len, _ref;
  3074.       html = '<div class=move><span id=count></span> <span id=timer></span></div>';
  3075.       checkbox = Config.updater.checkbox;
  3076.       for (name in checkbox) {
  3077.         title = checkbox[name][1];
  3078.         checked = Conf[name] ? 'checked' : '';
  3079.         html += "<div><label title='" + title + "'>" + name + "<input name='" + name + "' type=checkbox " + checked + "></label></div>";
  3080.       }
  3081.       checked = Conf['Auto Update'] ? 'checked' : '';
  3082.       html += "      <div><label title='Controls whether *this* thread automatically updates or not'>Auto Update This<input name='Auto Update This' type=checkbox " + checked + "></label></div>      <div><label>Interval (s)<input type=number name=Interval class=field min=5></label></div>      <div><input value='Update Now' type=button name='Update Now'></div>";
  3083.       dialog = UI.dialog('updater', 'bottom: 0; right: 0;', html);
  3084.       this.count = $('#count', dialog);
  3085.       this.timer = $('#timer', dialog);
  3086.       this.thread = $.id("t" + g.THREAD_ID);
  3087.       this.unsuccessfulFetchCount = 0;
  3088.       this.lastModified = '0';
  3089.       _ref = $$('input', dialog);
  3090.       for (_i = 0, _len = _ref.length; _i < _len; _i++) {
  3091.         input = _ref[_i];
  3092.         if (input.type === 'checkbox') {
  3093.           $.on(input, 'click', $.cb.checked);
  3094.         }
  3095.         switch (input.name) {
  3096.           case 'Scroll BG':
  3097.             $.on(input, 'click', this.cb.scrollBG);
  3098.             this.cb.scrollBG.call(input);
  3099.             break;
  3100.           case 'Verbose':
  3101.             $.on(input, 'click', this.cb.verbose);
  3102.             this.cb.verbose.call(input);
  3103.             break;
  3104.           case 'Auto Update This':
  3105.             $.on(input, 'click', this.cb.autoUpdate);
  3106.             this.cb.autoUpdate.call(input);
  3107.             break;
  3108.           case 'Interval':
  3109.             input.value = Conf['Interval'];
  3110.             $.on(input, 'change', this.cb.interval);
  3111.             this.cb.interval.call(input);
  3112.             break;
  3113.           case 'Update Now':
  3114.             $.on(input, 'click', this.update);
  3115.         }
  3116.       }
  3117.       $.add(d.body, dialog);
  3118.       $.on(d, 'QRPostSuccessful', this.cb.post);
  3119.       return $.on(d, 'visibilitychange', this.cb.visibility);
  3120.     },
  3121.     /*
  3122.     http://freesound.org/people/pierrecartoons1979/sounds/90112/
  3123.     cc-by-nc-3.0
  3124.     */
  3125.  
  3126.     audio: $.el('audio', {
  3127.       src: 'data:audio/wav;base64,UklGRjQDAABXQVZFZm10IBAAAAABAAEAgD4AAIA+AAABAAgAc21wbDwAAABBAAADAAAAAAAAAAA8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABkYXRhzAIAAGMms8em0tleMV4zIpLVo8nhfSlcPR102Ki+5JspVEkdVtKzs+K1NEhUIT7DwKrcy0g6WygsrM2k1NpiLl0zIY/WpMrjgCdbPhxw2Kq+5Z4qUkkdU9K1s+K5NkVTITzBwqnczko3WikrqM+l1NxlLF0zIIvXpsnjgydZPhxs2ay95aIrUEkdUdC3suK8N0NUIjq+xKrcz002WioppdGm091pK1w0IIjYp8jkhydXPxxq2K295aUrTkoeTs65suK+OUFUIzi7xqrb0VA0WSoootKm0t5tKlo1H4TYqMfkiydWQBxm16+85actTEseS8y7seHAPD9TIza5yKra01QyWSson9On0d5wKVk2H4DYqcfkjidUQB1j1rG75KsvSkseScu8seDCPz1TJDW2yara1FYxWSwnm9Sn0N9zKVg2H33ZqsXkkihSQR1g1bK65K0wSEsfR8i+seDEQTxUJTOzy6rY1VowWC0mmNWoz993KVc3H3rYq8TklSlRQh1d1LS647AyR0wgRMbAsN/GRDpTJTKwzKrX1l4vVy4lldWpzt97KVY4IXbUr8LZljVPRCxhw7W3z6ZISkw1VK+4sMWvXEhSPk6buay9sm5JVkZNiLWqtrJ+TldNTnquqbCwilZXU1BwpKirrpNgWFhTaZmnpquZbFlbVmWOpaOonHZcXlljhaGhpZ1+YWBdYn2cn6GdhmdhYGN3lp2enIttY2Jjco+bnJuOdGZlZXCImJqakHpoZ2Zug5WYmZJ/bGlobX6RlpeSg3BqaW16jZSVkoZ0bGtteImSk5KIeG5tbnaFkJKRinxxbm91gY2QkIt/c3BwdH6Kj4+LgnZxcXR8iI2OjIR5c3J0e4WLjYuFe3VzdHmCioyLhn52dHR5gIiKioeAeHV1eH+GiYqHgXp2dnh9hIiJh4J8eHd4fIKHiIeDfXl4eHyBhoeHhH96eHmA'
  3128.     }),
  3129.     cb: {
  3130.       post: function() {
  3131.         if (!Conf['Auto Update This']) {
  3132.           return;
  3133.         }
  3134.         Updater.unsuccessfulFetchCount = 0;
  3135.         return setTimeout(Updater.update, 500);
  3136.       },
  3137.       visibility: function() {
  3138.         if (d.hidden) {
  3139.           return;
  3140.         }
  3141.         Updater.unsuccessfulFetchCount = 0;
  3142.         if (Updater.timer.textContent < -Conf['Interval']) {
  3143.           return Updater.set('timer', -Updater.getInterval());
  3144.         }
  3145.       },
  3146.       interval: function() {
  3147.         var val;
  3148.         val = parseInt(this.value, 10);
  3149.         this.value = val > 5 ? val : 5;
  3150.         $.cb.value.call(this);
  3151.         return Updater.set('timer', -Updater.getInterval());
  3152.       },
  3153.       verbose: function() {
  3154.         if (Conf['Verbose']) {
  3155.           Updater.set('count', '+0');
  3156.           return Updater.timer.hidden = false;
  3157.         } else {
  3158.           Updater.set('count', 'Thread Updater');
  3159.           Updater.count.className = '';
  3160.           return Updater.timer.hidden = true;
  3161.         }
  3162.       },
  3163.       autoUpdate: function() {
  3164.         if (Conf['Auto Update This'] = this.checked) {
  3165.           return Updater.timeoutID = setTimeout(Updater.timeout, 1000);
  3166.         } else {
  3167.           return clearTimeout(Updater.timeoutID);
  3168.         }
  3169.       },
  3170.       scrollBG: function() {
  3171.         return Updater.scrollBG = this.checked ? function() {
  3172.           return true;
  3173.         } : function() {
  3174.           return !d.hidden;
  3175.         };
  3176.       },
  3177.       load: function() {
  3178.         switch (this.status) {
  3179.           case 404:
  3180.             Updater.set('timer', '');
  3181.             Updater.set('count', 404);
  3182.             Updater.count.className = 'warning';
  3183.             clearTimeout(Updater.timeoutID);
  3184.             g.dead = true;
  3185.             if (Conf['Unread Count']) {
  3186.               Unread.title = Unread.title.match(/^.+-/)[0] + ' 404';
  3187.             } else {
  3188.               d.title = d.title.match(/^.+-/)[0] + ' 404';
  3189.             }
  3190.             Unread.update(true);
  3191.             QR.abort();
  3192.             break;
  3193.           case 0:
  3194.           case 304:
  3195.             /*
  3196.             Status Code 304: Not modified
  3197.             By sending the `If-Modified-Since` header we get a proper status code, and no response.
  3198.             This saves bandwidth for both the user and the servers and avoid unnecessary computation.
  3199.             */
  3200.  
  3201.             Updater.unsuccessfulFetchCount++;
  3202.             Updater.set('timer', -Updater.getInterval());
  3203.             if (Conf['Verbose']) {
  3204.               Updater.set('count', '+0');
  3205.               Updater.count.className = null;
  3206.             }
  3207.             break;
  3208.           case 200:
  3209.             Updater.lastModified = this.getResponseHeader('Last-Modified');
  3210.             Updater.cb.update(JSON.parse(this.response).posts);
  3211.             Updater.set('timer', -Updater.getInterval());
  3212.             break;
  3213.           default:
  3214.             Updater.unsuccessfulFetchCount++;
  3215.             Updater.set('timer', -Updater.getInterval());
  3216.             if (Conf['Verbose']) {
  3217.               Updater.set('count', this.statusText);
  3218.               Updater.count.className = 'warning';
  3219.             }
  3220.         }
  3221.         return delete Updater.request;
  3222.       },
  3223.       update: function(posts) {
  3224.         var count, id, lastPost, nodes, post, scroll, spoilerRange, _i, _len, _ref;
  3225.         if (spoilerRange = posts[0].custom_spoiler) {
  3226.           Build.spoilerRange[g.BOARD] = spoilerRange;
  3227.         }
  3228.         lastPost = Updater.thread.lastElementChild;
  3229.         id = +lastPost.id.slice(2);
  3230.         nodes = [];
  3231.         _ref = posts.reverse();
  3232.         for (_i = 0, _len = _ref.length; _i < _len; _i++) {
  3233.           post = _ref[_i];
  3234.           if (post.no <= id) {
  3235.             break;
  3236.           }
  3237.           nodes.push(Build.postFromObject(post, g.BOARD));
  3238.         }
  3239.         count = nodes.length;
  3240.         if (Conf['Verbose']) {
  3241.           Updater.set('count', "+" + count);
  3242.           Updater.count.className = count ? 'new' : null;
  3243.         }
  3244.         if (count) {
  3245.           if (Conf['Beep'] && d.hidden && (Unread.replies.length === 0)) {
  3246.             Updater.audio.play();
  3247.           }
  3248.           Updater.unsuccessfulFetchCount = 0;
  3249.         } else {
  3250.           Updater.unsuccessfulFetchCount++;
  3251.           return;
  3252.         }
  3253.         scroll = Conf['Scrolling'] && Updater.scrollBG() && lastPost.getBoundingClientRect().bottom - d.documentElement.clientHeight < 25;
  3254.         $.add(Updater.thread, nodes.reverse());
  3255.         if (scroll) {
  3256.           return nodes[0].scrollIntoView();
  3257.         }
  3258.       }
  3259.     },
  3260.     set: function(name, text) {
  3261.       var el, node;
  3262.       el = Updater[name];
  3263.       if (node = el.firstChild) {
  3264.         return node.data = text;
  3265.       } else {
  3266.         return el.textContent = text;
  3267.       }
  3268.     },
  3269.     getInterval: function() {
  3270.       return Conf['Interval'];
  3271.     },
  3272.     timeout: function() {
  3273.       var n;
  3274.       Updater.timeoutID = setTimeout(Updater.timeout, 1000);
  3275.       n = 1 + Number(Updater.timer.firstChild.data);
  3276.       if (n === 0) {
  3277.         return Updater.update();
  3278.       } else if (n >= Updater.getInterval()) {
  3279.         Updater.unsuccessfulFetchCount++;
  3280.         Updater.set('count', 'Retry');
  3281.         Updater.count.className = null;
  3282.         return Updater.update();
  3283.       } else {
  3284.         return Updater.set('timer', n);
  3285.       }
  3286.     },
  3287.     update: function() {
  3288.       var request, url;
  3289.       Updater.set('timer', 0);
  3290.       request = Updater.request;
  3291.       if (request) {
  3292.         request.onloadend = null;
  3293.         request.abort();
  3294.       }
  3295.       url = "//api.4chan.org/" + g.BOARD + "/res/" + g.THREAD_ID + ".json";
  3296.       return Updater.request = $.ajax(url, {
  3297.         onloadend: Updater.cb.load
  3298.       }, {
  3299.         headers: {
  3300.           'If-Modified-Since': Updater.lastModified
  3301.         }
  3302.       });
  3303.     }
  3304.   };
  3305.  
  3306.   Watcher = {
  3307.     init: function() {
  3308.       var favicon, html, input, _i, _len, _ref;
  3309.       html = '<div class=move>Thread Watcher</div>';
  3310.       this.dialog = UI.dialog('watcher', 'top: 50px; left: 0px;', html);
  3311.       $.add(d.body, this.dialog);
  3312.       _ref = $$('.op input');
  3313.       for (_i = 0, _len = _ref.length; _i < _len; _i++) {
  3314.         input = _ref[_i];
  3315.         favicon = $.el('img', {
  3316.           className: 'favicon'
  3317.         });
  3318.         $.on(favicon, 'click', this.cb.toggle);
  3319.         $.before(input, favicon);
  3320.       }
  3321.       if (g.THREAD_ID === $.get('autoWatch', 0)) {
  3322.         this.watch(g.THREAD_ID);
  3323.         $["delete"]('autoWatch');
  3324.       } else {
  3325.         this.refresh();
  3326.       }
  3327.       $.on(d, 'QRPostSuccessful', this.cb.post);
  3328.       return $.sync('watched', this.refresh);
  3329.     },
  3330.     refresh: function(watched) {
  3331.       var board, div, favicon, id, link, nodes, props, watchedBoard, x, _i, _j, _len, _len1, _ref, _ref1, _ref2;
  3332.       watched || (watched = $.get('watched', {}));
  3333.       nodes = [];
  3334.       for (board in watched) {
  3335.         _ref = watched[board];
  3336.         for (id in _ref) {
  3337.           props = _ref[id];
  3338.           x = $.el('a', {
  3339.             textContent: '×',
  3340.             href: 'javascript:;'
  3341.           });
  3342.           $.on(x, 'click', Watcher.cb.x);
  3343.           link = $.el('a', props);
  3344.           link.title = link.textContent;
  3345.           div = $.el('div');
  3346.           $.add(div, [x, $.tn(' '), link]);
  3347.           nodes.push(div);
  3348.         }
  3349.       }
  3350.       _ref1 = $$('div:not(.move)', Watcher.dialog);
  3351.       for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
  3352.         div = _ref1[_i];
  3353.         $.rm(div);
  3354.       }
  3355.       $.add(Watcher.dialog, nodes);
  3356.       watchedBoard = watched[g.BOARD] || {};
  3357.       _ref2 = $$('.favicon');
  3358.       for (_j = 0, _len1 = _ref2.length; _j < _len1; _j++) {
  3359.         favicon = _ref2[_j];
  3360.         id = favicon.nextSibling.name;
  3361.         if (id in watchedBoard) {
  3362.           favicon.src = Favicon["default"];
  3363.         } else {
  3364.           favicon.src = Favicon.empty;
  3365.         }
  3366.       }
  3367.     },
  3368.     cb: {
  3369.       toggle: function() {
  3370.         return Watcher.toggle(this.parentNode);
  3371.       },
  3372.       x: function() {
  3373.         var thread;
  3374.         thread = this.nextElementSibling.pathname.split('/');
  3375.         return Watcher.unwatch(thread[3], thread[1]);
  3376.       },
  3377.       post: function(e) {
  3378.         var postID, threadID, _ref;
  3379.         _ref = e.detail, postID = _ref.postID, threadID = _ref.threadID;
  3380.         if (threadID === '0') {
  3381.           if (Conf['Auto Watch']) {
  3382.             return $.set('autoWatch', postID);
  3383.           }
  3384.         } else if (Conf['Auto Watch Reply']) {
  3385.           return Watcher.watch(threadID);
  3386.         }
  3387.       }
  3388.     },
  3389.     toggle: function(thread) {
  3390.       var id;
  3391.       id = $('.favicon + input', thread).name;
  3392.       return Watcher.watch(id) || Watcher.unwatch(id, g.BOARD);
  3393.     },
  3394.     unwatch: function(id, board) {
  3395.       var watched;
  3396.       watched = $.get('watched', {});
  3397.       delete watched[board][id];
  3398.       $.set('watched', watched);
  3399.       return Watcher.refresh();
  3400.     },
  3401.     watch: function(id) {
  3402.       var thread, watched, _name;
  3403.       thread = $.id("t" + id);
  3404.       if ($('.favicon', thread).src === Favicon["default"]) {
  3405.         return false;
  3406.       }
  3407.       watched = $.get('watched', {});
  3408.       watched[_name = g.BOARD] || (watched[_name] = {});
  3409.       watched[g.BOARD][id] = {
  3410.         href: "/" + g.BOARD + "/res/" + id,
  3411.         textContent: Get.title(thread)
  3412.       };
  3413.       $.set('watched', watched);
  3414.       Watcher.refresh();
  3415.       return true;
  3416.     }
  3417.   };
  3418.  
  3419.   Anonymize = {
  3420.     init: function() {
  3421.       return Main.callbacks.push(this.node);
  3422.     },
  3423.     node: function(post) {
  3424.       var name, parent, trip;
  3425.       if (post.isInlined && !post.isCrosspost) {
  3426.         return;
  3427.       }
  3428.       name = $('.postInfo .name', post.el);
  3429.       name.textContent = 'Anonymous';
  3430.       if ((trip = name.nextElementSibling) && trip.className === 'postertrip') {
  3431.         $.rm(trip);
  3432.       }
  3433.       if ((parent = name.parentNode).className === 'useremail' && !/^mailto:sage$/i.test(parent.href)) {
  3434.         return $.replace(parent, name);
  3435.       }
  3436.     }
  3437.   };
  3438.  
  3439.   Sauce = {
  3440.     init: function() {
  3441.       var link, _i, _len, _ref;
  3442.       if (g.BOARD === 'f') {
  3443.         return;
  3444.       }
  3445.       this.links = [];
  3446.       _ref = Conf['sauces'].split('\n');
  3447.       for (_i = 0, _len = _ref.length; _i < _len; _i++) {
  3448.         link = _ref[_i];
  3449.         if (link[0] === '#') {
  3450.           continue;
  3451.         }
  3452.         this.links.push(this.createSauceLink(link.trim()));
  3453.       }
  3454.       if (!this.links.length) {
  3455.         return;
  3456.       }
  3457.       return Main.callbacks.push(this.node);
  3458.     },
  3459.     createSauceLink: function(link) {
  3460.       var domain, el, href, m;
  3461.       link = link.replace(/(\$\d)/g, function(parameter) {
  3462.         switch (parameter) {
  3463.           case '$1':
  3464.             return "' + (isArchived ? img.firstChild.src : 'http://i.4cdn.org' + img.pathname) + '";
  3465.           case '$2':
  3466.             return "' + img.href + '";
  3467.           case '$3':
  3468.             return "' + encodeURIComponent(img.firstChild.dataset.md5) + '";
  3469.           case '$4':
  3470.             return g.BOARD;
  3471.           default:
  3472.             return parameter;
  3473.         }
  3474.       });
  3475.       domain = (m = link.match(/;text:(.+)$/)) ? m[1] : link.match(/(\w+)\.\w+\//)[1];
  3476.       href = link.replace(/;text:.+$/, '');
  3477.       href = Function('img', 'isArchived', "return '" + href + "'");
  3478.       el = $.el('a', {
  3479.         target: '_blank',
  3480.         textContent: domain
  3481.       });
  3482.       return function(img, isArchived) {
  3483.         var a;
  3484.         a = el.cloneNode(true);
  3485.         a.href = href(img, isArchived);
  3486.         return a;
  3487.       };
  3488.     },
  3489.     node: function(post) {
  3490.       var img, link, nodes, _i, _len, _ref;
  3491.       img = post.img;
  3492.       if (post.isInlined && !post.isCrosspost || !img) {
  3493.         return;
  3494.       }
  3495.       img = img.parentNode;
  3496.       nodes = [];
  3497.       _ref = Sauce.links;
  3498.       for (_i = 0, _len = _ref.length; _i < _len; _i++) {
  3499.         link = _ref[_i];
  3500.         nodes.push($.tn('\u00A0'), link(img, post.isArchived));
  3501.       }
  3502.       return $.add(post.fileInfo, nodes);
  3503.     }
  3504.   };
  3505.  
  3506.   RevealSpoilers = {
  3507.     init: function() {
  3508.       return Main.callbacks.push(this.node);
  3509.     },
  3510.     node: function(post) {
  3511.       var img, s;
  3512.       img = post.img;
  3513.       if (!(img && /^Spoiler/.test(img.alt)) || post.isInlined && !post.isCrosspost || post.isArchived) {
  3514.         return;
  3515.       }
  3516.       img.removeAttribute('style');
  3517.       s = img.style;
  3518.       s.maxHeight = s.maxWidth = /\bop\b/.test(post["class"]) ? '250px' : '125px';
  3519.       return img.src = "//t.4cdn.org" + (img.parentNode.pathname.replace(/src(\/\d+).+$/, 'thumb$1s.jpg'));
  3520.     }
  3521.   };
  3522.  
  3523.   Time = {
  3524.     init: function() {
  3525.       Time.foo();
  3526.       return Main.callbacks.push(this.node);
  3527.     },
  3528.     node: function(post) {
  3529.       var node;
  3530.       if (post.isInlined && !post.isCrosspost) {
  3531.         return;
  3532.       }
  3533.       node = $('.postInfo > .dateTime', post.el);
  3534.       Time.date = new Date(node.dataset.utc * 1000);
  3535.       return node.textContent = Time.funk(Time);
  3536.     },
  3537.     foo: function() {
  3538.       var code;
  3539.       code = Conf['time'].replace(/%([A-Za-z])/g, function(s, c) {
  3540.         if (c in Time.formatters) {
  3541.           return "' + Time.formatters." + c + "() + '";
  3542.         } else {
  3543.           return s;
  3544.         }
  3545.       });
  3546.       return Time.funk = Function('Time', "return '" + code + "'");
  3547.     },
  3548.     day: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
  3549.     month: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
  3550.     zeroPad: function(n) {
  3551.       if (n < 10) {
  3552.         return '0' + n;
  3553.       } else {
  3554.         return n;
  3555.       }
  3556.     },
  3557.     formatters: {
  3558.       a: function() {
  3559.         return Time.day[Time.date.getDay()].slice(0, 3);
  3560.       },
  3561.       A: function() {
  3562.         return Time.day[Time.date.getDay()];
  3563.       },
  3564.       b: function() {
  3565.         return Time.month[Time.date.getMonth()].slice(0, 3);
  3566.       },
  3567.       B: function() {
  3568.         return Time.month[Time.date.getMonth()];
  3569.       },
  3570.       d: function() {
  3571.         return Time.zeroPad(Time.date.getDate());
  3572.       },
  3573.       e: function() {
  3574.         return Time.date.getDate();
  3575.       },
  3576.       H: function() {
  3577.         return Time.zeroPad(Time.date.getHours());
  3578.       },
  3579.       I: function() {
  3580.         return Time.zeroPad(Time.date.getHours() % 12 || 12);
  3581.       },
  3582.       k: function() {
  3583.         return Time.date.getHours();
  3584.       },
  3585.       l: function() {
  3586.         return Time.date.getHours() % 12 || 12;
  3587.       },
  3588.       m: function() {
  3589.         return Time.zeroPad(Time.date.getMonth() + 1);
  3590.       },
  3591.       M: function() {
  3592.         return Time.zeroPad(Time.date.getMinutes());
  3593.       },
  3594.       p: function() {
  3595.         if (Time.date.getHours() < 12) {
  3596.           return 'AM';
  3597.         } else {
  3598.           return 'PM';
  3599.         }
  3600.       },
  3601.       P: function() {
  3602.         if (Time.date.getHours() < 12) {
  3603.           return 'am';
  3604.         } else {
  3605.           return 'pm';
  3606.         }
  3607.       },
  3608.       S: function() {
  3609.         return Time.zeroPad(Time.date.getSeconds());
  3610.       },
  3611.       y: function() {
  3612.         return Time.date.getFullYear() - 2000;
  3613.       }
  3614.     }
  3615.   };
  3616.  
  3617.   RelativeDates = {
  3618.     INTERVAL: $.MINUTE,
  3619.     init: function() {
  3620.       Main.callbacks.push(this.node);
  3621.       return $.on(d, 'visibilitychange', this.flush);
  3622.     },
  3623.     node: function(post) {
  3624.       var dateEl, diff, utc;
  3625.       dateEl = $('.postInfo > .dateTime', post.el);
  3626.       dateEl.title = dateEl.textContent;
  3627.       utc = dateEl.dataset.utc * 1000;
  3628.       diff = Date.now() - utc;
  3629.       dateEl.textContent = RelativeDates.relative(diff);
  3630.       RelativeDates.setUpdate(dateEl, utc, diff);
  3631.       return RelativeDates.flush();
  3632.     },
  3633.     relative: function(diff) {
  3634.       var number, rounded, unit;
  3635.       unit = (number = diff / $.DAY) > 1 ? 'day' : (number = diff / $.HOUR) > 1 ? 'hour' : (number = diff / $.MINUTE) > 1 ? 'minute' : (number = diff / $.SECOND, 'second');
  3636.       rounded = Math.round(number);
  3637.       if (rounded !== 1) {
  3638.         unit += 's';
  3639.       }
  3640.       return "" + rounded + " " + unit + " ago";
  3641.     },
  3642.     stale: [],
  3643.     flush: $.debounce($.SECOND, function() {
  3644.       var now, update, _i, _len, _ref;
  3645.       if (d.hidden) {
  3646.         return;
  3647.       }
  3648.       now = Date.now();
  3649.       _ref = RelativeDates.stale;
  3650.       for (_i = 0, _len = _ref.length; _i < _len; _i++) {
  3651.         update = _ref[_i];
  3652.         update(now);
  3653.       }
  3654.       RelativeDates.stale = [];
  3655.       clearTimeout(RelativeDates.timeout);
  3656.       return RelativeDates.timeout = setTimeout(RelativeDates.flush, RelativeDates.INTERVAL);
  3657.     }),
  3658.     setUpdate: function(dateEl, utc, diff) {
  3659.       var markStale, setOwnTimeout, update;
  3660.       setOwnTimeout = function(diff) {
  3661.         var delay;
  3662.         delay = diff < $.MINUTE ? $.SECOND - (diff + $.SECOND / 2) % $.SECOND : diff < $.HOUR ? $.MINUTE - (diff + $.MINUTE / 2) % $.MINUTE : $.HOUR - (diff + $.HOUR / 2) % $.HOUR;
  3663.         return setTimeout(markStale, delay);
  3664.       };
  3665.       update = function(now) {
  3666.         if (d.contains(dateEl)) {
  3667.           diff = now - utc;
  3668.           dateEl.textContent = RelativeDates.relative(diff);
  3669.           return setOwnTimeout(diff);
  3670.         }
  3671.       };
  3672.       markStale = function() {
  3673.         return RelativeDates.stale.push(update);
  3674.       };
  3675.       return setOwnTimeout(diff);
  3676.     }
  3677.   };
  3678.  
  3679.   FileInfo = {
  3680.     init: function() {
  3681.       if (g.BOARD === 'f') {
  3682.         return;
  3683.       }
  3684.       this.setFormats();
  3685.       return Main.callbacks.push(this.node);
  3686.     },
  3687.     node: function(post) {
  3688.       var alt, filename, node, _ref;
  3689.       if (post.isInlined && !post.isCrosspost || !post.fileInfo) {
  3690.         return;
  3691.       }
  3692.       node = post.fileInfo;
  3693.       alt = post.img.alt;
  3694.       filename = ((_ref = $('span', node)) != null ? (_ref.title || _ref.innerHTML) : void 0) || node.title;
  3695.       FileInfo.data = {
  3696.         link: post.img.parentNode.href,
  3697.         spoiler: /^Spoiler/.test(alt),
  3698.         size: alt.match(/\d+\.?\d*/)[0],
  3699.         unit: alt.match(/\w+$/)[0],
  3700.         resolution: node.textContent.match(/\d+x\d+|PDF/)[0],
  3701.         fullname: filename,
  3702.         shortname: Build.shortFilename(filename, post.ID === post.threadID)
  3703.       };
  3704.       node.setAttribute('data-filename', filename);
  3705.       return node.innerHTML = FileInfo.funk(FileInfo);
  3706.     },
  3707.     setFormats: function() {
  3708.       var code;
  3709.       code = Conf['fileInfo'].replace(/%(.)/g, function(s, c) {
  3710.         if (c in FileInfo.formatters) {
  3711.           return "' + f.formatters." + c + "() + '";
  3712.         } else {
  3713.           return s;
  3714.         }
  3715.       });
  3716.       return this.funk = Function('f', "return '" + code + "'");
  3717.     },
  3718.     convertUnit: function(unitT) {
  3719.       var i, size, unitF, units;
  3720.       size = this.data.size;
  3721.       unitF = this.data.unit;
  3722.       if (unitF !== unitT) {
  3723.         units = ['B', 'KB', 'MB'];
  3724.         i = units.indexOf(unitF) - units.indexOf(unitT);
  3725.         if (unitT === 'B') {
  3726.           unitT = 'Bytes';
  3727.         }
  3728.         if (i > 0) {
  3729.           while (i-- > 0) {
  3730.             size *= 1024;
  3731.           }
  3732.         } else if (i < 0) {
  3733.           while (i++ < 0) {
  3734.             size /= 1024;
  3735.           }
  3736.         }
  3737.         if (size < 1 && size.toString().length > size.toFixed(2).length) {
  3738.           size = size.toFixed(2);
  3739.         }
  3740.       }
  3741.       return "" + size + " " + unitT;
  3742.     },
  3743.     formatters: {
  3744.       t: function() {
  3745.         return FileInfo.data.link.match(/\d+\..+$/)[0];
  3746.       },
  3747.       T: function() {
  3748.         return "<a href=" + FileInfo.data.link + " target=_blank>" + (this.t()) + "</a>";
  3749.       },
  3750.       l: function() {
  3751.         return "<a href=" + FileInfo.data.link + " target=_blank>" + (this.n()) + "</a>";
  3752.       },
  3753.       L: function() {
  3754.         return "<a href=" + FileInfo.data.link + " target=_blank>" + (this.N()) + "</a>";
  3755.       },
  3756.       n: function() {
  3757.         if (FileInfo.data.fullname === FileInfo.data.shortname) {
  3758.           return FileInfo.data.fullname;
  3759.         } else {
  3760.           return "<span class=fntrunc>" + FileInfo.data.shortname + "</span><span class=fnfull>" + FileInfo.data.fullname + "</span>";
  3761.         }
  3762.       },
  3763.       N: function() {
  3764.         return FileInfo.data.fullname;
  3765.       },
  3766.       p: function() {
  3767.         if (FileInfo.data.spoiler) {
  3768.           return 'Spoiler, ';
  3769.         } else {
  3770.           return '';
  3771.         }
  3772.       },
  3773.       s: function() {
  3774.         return "" + FileInfo.data.size + " " + FileInfo.data.unit;
  3775.       },
  3776.       B: function() {
  3777.         return FileInfo.convertUnit('B');
  3778.       },
  3779.       K: function() {
  3780.         return FileInfo.convertUnit('KB');
  3781.       },
  3782.       M: function() {
  3783.         return FileInfo.convertUnit('MB');
  3784.       },
  3785.       r: function() {
  3786.         return FileInfo.data.resolution;
  3787.       }
  3788.     }
  3789.   };
  3790.  
  3791.   Get = {
  3792.     post: function(board, threadID, postID, root, cb) {
  3793.       var post, url;
  3794.       if (board === g.BOARD && (post = $.id("pc" + postID))) {
  3795.         $.add(root, Get.cleanPost(post.cloneNode(true)));
  3796.         return;
  3797.       }
  3798.       root.textContent = "Loading post No." + postID + "...";
  3799.       if (threadID) {
  3800.         return $.cache("//api.4chan.org/" + board + "/res/" + threadID + ".json", function() {
  3801.           return Get.parsePost(this, board, threadID, postID, root, cb);
  3802.         });
  3803.       } else if (url = Redirect.post(board, postID)) {
  3804.         return $.cache(url, function() {
  3805.           return Get.parseArchivedPost(this, board, postID, root, cb);
  3806.         });
  3807.       }
  3808.     },
  3809.     parsePost: function(req, board, threadID, postID, root, cb) {
  3810.       var post, posts, spoilerRange, status, url, _i, _len;
  3811.       status = req.status;
  3812.       if (status !== 200) {
  3813.         if (url = Redirect.post(board, postID)) {
  3814.           $.cache(url, function() {
  3815.             return Get.parseArchivedPost(this, board, postID, root, cb);
  3816.           });
  3817.         } else {
  3818.           $.addClass(root, 'warning');
  3819.           root.textContent = status === 404 ? "Thread No." + threadID + " 404'd." : "Error " + req.status + ": " + req.statusText + ".";
  3820.         }
  3821.         return;
  3822.       }
  3823.       posts = JSON.parse(req.response).posts;
  3824.       if (spoilerRange = posts[0].custom_spoiler) {
  3825.         Build.spoilerRange[board] = spoilerRange;
  3826.       }
  3827.       postID = +postID;
  3828.       for (_i = 0, _len = posts.length; _i < _len; _i++) {
  3829.         post = posts[_i];
  3830.         if (post.no === postID) {
  3831.           break;
  3832.         }
  3833.         if (post.no > postID) {
  3834.           if (url = Redirect.post(board, postID)) {
  3835.             $.cache(url, function() {
  3836.               return Get.parseArchivedPost(this, board, postID, root, cb);
  3837.             });
  3838.           } else {
  3839.             $.addClass(root, 'warning');
  3840.             root.textContent = "Post No." + postID + " was not found.";
  3841.           }
  3842.           return;
  3843.         }
  3844.       }
  3845.       $.replace(root.firstChild, Get.cleanPost(Build.postFromObject(post, board)));
  3846.       if (cb) {
  3847.         return cb();
  3848.       }
  3849.     },
  3850.     parseArchivedPost: function(req, board, postID, root, cb) {
  3851.       var bq, comment, data, o, _ref;
  3852.       data = JSON.parse(req.response);
  3853.       if (data.error) {
  3854.         $.addClass(root, 'warning');
  3855.         root.textContent = data.error;
  3856.         return;
  3857.       }
  3858.       bq = $.el('blockquote', {
  3859.         textContent: data.comment
  3860.       });
  3861.       bq.innerHTML = bq.innerHTML.replace(/\n|\[\/?b\]|\[\/?spoiler\]|\[\/?code\]|\[\/?moot\]|\[\/?banned\]/g, function(text) {
  3862.         switch (text) {
  3863.           case '\n':
  3864.             return '<br>';
  3865.           case '[b]':
  3866.             return '<b>';
  3867.           case '[/b]':
  3868.             return '</b>';
  3869.           case '[spoiler]':
  3870.             return '<span class=spoiler>';
  3871.           case '[/spoiler]':
  3872.             return '</span>';
  3873.           case '[code]':
  3874.             return '<pre class=prettyprint>';
  3875.           case '[/code]':
  3876.             return '</pre>';
  3877.           case '[moot]':
  3878.             return '<div style="padding:5px;margin-left:.5em;border-color:#faa;border:2px dashed rgba(255,0,0,.1);border-radius:2px">';
  3879.           case '[/moot]':
  3880.             return '</div>';
  3881.           case '[banned]':
  3882.             return '<b style="color: red;">';
  3883.           case '[/banned]':
  3884.             return '</b>';
  3885.         }
  3886.       });
  3887.       comment = bq.innerHTML.replace(/(^|>)(&gt;[^<$]*)(<|$)/g, '$1<span class=quote>$2</span>$3');
  3888.       comment = comment.replace(/((&gt;){2}(&gt;\/[a-z\d]+\/)?\d+)/g, '<span class=deadlink>$1</span>');
  3889.       o = {
  3890.         postID: postID,
  3891.         threadID: data.thread_num,
  3892.         board: board,
  3893.         name: data.name_processed,
  3894.         capcode: (function() {
  3895.           switch (data.capcode) {
  3896.             case 'M':
  3897.               return 'mod';
  3898.             case 'A':
  3899.               return 'admin';
  3900.             case 'D':
  3901.               return 'developer';
  3902.           }
  3903.         })(),
  3904.         tripcode: data.trip,
  3905.         uniqueID: data.poster_hash,
  3906.         email: data.email ? encodeURI(data.email) : '',
  3907.         subject: data.title_processed,
  3908.         flagCode: data.poster_country,
  3909.         flagName: data.poster_country_name_processed,
  3910.         date: data.fourchan_date,
  3911.         dateUTC: data.timestamp,
  3912.         comment: comment
  3913.       };
  3914.       if ((_ref = data.media) != null ? _ref.media_filename : void 0) {
  3915.         o.file = {
  3916.           name: data.media.media_filename_processed,
  3917.           timestamp: data.media.media_orig,
  3918.           url: data.media.media_link || data.media.remote_media_link,
  3919.           height: data.media.media_h,
  3920.           width: data.media.media_w,
  3921.           MD5: data.media.media_hash,
  3922.           size: data.media.media_size,
  3923.           turl: data.media.thumb_link || ("//t.4cdn.org/" + board + "/thumb/" + data.media.preview_orig),
  3924.           theight: data.media.preview_h,
  3925.           twidth: data.media.preview_w,
  3926.           isSpoiler: data.media.spoiler === '1'
  3927.         };
  3928.       }
  3929.       $.replace(root.firstChild, Get.cleanPost(Build.post(o, true)));
  3930.       if (cb) {
  3931.         return cb();
  3932.       }
  3933.     },
  3934.     cleanPost: function(root) {
  3935.       var child, el, els, inline, inlined, now, post, _i, _j, _k, _l, _len, _len1, _len2, _len3, _ref, _ref1, _ref2;
  3936.       post = $('.post', root);
  3937.       _ref = Array.prototype.slice.call(root.childNodes);
  3938.       for (_i = 0, _len = _ref.length; _i < _len; _i++) {
  3939.         child = _ref[_i];
  3940.         if (child !== post) {
  3941.           $.rm(child);
  3942.         }
  3943.       }
  3944.       _ref1 = $$('.inline', post);
  3945.       for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
  3946.         inline = _ref1[_j];
  3947.         $.rm(inline);
  3948.       }
  3949.       _ref2 = $$('.inlined', post);
  3950.       for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) {
  3951.         inlined = _ref2[_k];
  3952.         $.rmClass(inlined, 'inlined');
  3953.       }
  3954.       now = Date.now();
  3955.       els = $$('[id]', root);
  3956.       els.push(root);
  3957.       for (_l = 0, _len3 = els.length; _l < _len3; _l++) {
  3958.         el = els[_l];
  3959.         el.id = "" + now + "_" + el.id;
  3960.       }
  3961.       $.rmClass(root, 'forwarded');
  3962.       $.rmClass(root, 'qphl');
  3963.       $.rmClass(post, 'highlight');
  3964.       $.rmClass(post, 'qphl');
  3965.       root.hidden = post.hidden = false;
  3966.       return root;
  3967.     },
  3968.     title: function(thread) {
  3969.       var el, op, span;
  3970.       op = $('.op', thread);
  3971.       el = $('.postInfo .subject', op);
  3972.       if (!el.textContent) {
  3973.         el = $('blockquote', op);
  3974.         if (!el.textContent) {
  3975.           el = $('.nameBlock', op);
  3976.         }
  3977.       }
  3978.       span = $.el('span', {
  3979.         innerHTML: el.innerHTML.replace(/<br>/g, ' ')
  3980.       });
  3981.       return "/" + g.BOARD + "/ - " + (span.textContent.trim());
  3982.     }
  3983.   };
  3984.  
  3985.   Build = {
  3986.     spoilerRange: {},
  3987.     shortFilename: function(filename, isOP) {
  3988.       var threshold, ext;
  3989.       ext = filename.match(/\.[^.]+$/)[0];
  3990.       threshold = isOP ? 40 : 30;
  3991.       if (filename.length - ext.length > threshold) {
  3992.         return "" + filename.slice(0, threshold - 5) + "(...)" + ext;
  3993.       } else {
  3994.         return filename;
  3995.       }
  3996.     },
  3997.     postFromObject: function(data, board) {
  3998.       var o;
  3999.       o = {
  4000.         postID: data.no,
  4001.         threadID: data.resto || data.no,
  4002.         board: board,
  4003.         name: data.name,
  4004.         capcode: data.capcode,
  4005.         tripcode: data.trip,
  4006.         uniqueID: data.id,
  4007.         email: data.email ? encodeURI(data.email.replace(/&quot;/g, '"')) : '',
  4008.         subject: data.sub,
  4009.         flagCode: data.country,
  4010.         flagName: data.country_name,
  4011.         date: data.now,
  4012.         dateUTC: data.time,
  4013.         comment: data.com,
  4014.         isSticky: !!data.sticky,
  4015.         isClosed: !!data.closed
  4016.       };
  4017.       if (data.ext || data.filedeleted) {
  4018.         o.file = {
  4019.           name: data.filename + data.ext,
  4020.           timestamp: "" + data.tim + data.ext,
  4021.           url: "//i.4cdn.org/" + board + "/src/" + data.tim + data.ext,
  4022.           height: data.h,
  4023.           width: data.w,
  4024.           MD5: data.md5,
  4025.           size: data.fsize,
  4026.           turl: "//t.4cdn.org/" + board + "/thumb/" + data.tim + "s.jpg",
  4027.           theight: data.tn_h,
  4028.           twidth: data.tn_w,
  4029.           isSpoiler: !!data.spoiler,
  4030.           isDeleted: !!data.filedeleted
  4031.         };
  4032.       }
  4033.       return Build.post(o);
  4034.     },
  4035.     post: function(o, isArchived) {
  4036.       /*
  4037.       This function contains code from 4chan-JS (https://github.com/4chan/4chan-JS).
  4038.       @license: https://github.com/4chan/4chan-JS/blob/master/LICENSE
  4039.       */
  4040.  
  4041.       var a, board, capcode, capcodeClass, capcodeStart, closed, comment, container, date, dateUTC, email, emailEnd, emailStart, ext, file, fileDims, fileHTML, fileInfo, fileSize, fileThumb, filename, flag, flagCode, flagName, href, imgSrc, isClosed, isOP, isSticky, name, postID, quote, shortFilename, spoilerRange, staticPath, sticky, subject, threadID, tripcode, uniqueID, userID, _i, _len, _ref;
  4042.       postID = o.postID, threadID = o.threadID, board = o.board, name = o.name, capcode = o.capcode, tripcode = o.tripcode, uniqueID = o.uniqueID, email = o.email, subject = o.subject, flagCode = o.flagCode, flagName = o.flagName, date = o.date, dateUTC = o.dateUTC, isSticky = o.isSticky, isClosed = o.isClosed, comment = o.comment, file = o.file;
  4043.       isOP = postID === threadID;
  4044.       staticPath = '//s.4cdn.org/image';
  4045.       if (email) {
  4046.         emailStart = '<a href="mailto:' + email + '" class="useremail">';
  4047.         emailEnd = '</a>';
  4048.       } else {
  4049.         emailStart = '';
  4050.         emailEnd = '';
  4051.       }
  4052.       subject = "<span class=subject>" + (subject || '') + "</span>";
  4053.       userID = !capcode && uniqueID ? (" <span class='posteruid id_" + uniqueID + "'>(ID: ") + ("<span class=hand title='Highlight posts by this ID'>" + uniqueID + "</span>)</span> ") : '';
  4054.       switch (capcode) {
  4055.         case 'admin':
  4056.         case 'admin_highlight':
  4057.           capcodeClass = " capcodeAdmin";
  4058.           capcodeStart = " <strong class='capcode hand id_admin'" + "title='Highlight posts by the Administrator'>## Admin</strong>";
  4059.           capcode = (" <img src='" + staticPath + "/adminicon.gif' ") + "alt='This user is the 4chan Administrator.' " + "title='This user is the 4chan Administrator.' class=identityIcon>";
  4060.           break;
  4061.         case 'mod':
  4062.           capcodeClass = " capcodeMod";
  4063.           capcodeStart = " <strong class='capcode hand id_mod' " + "title='Highlight posts by Moderators'>## Mod</strong>";
  4064.           capcode = (" <img src='" + staticPath + "/modicon.gif' ") + "alt='This user is a 4chan Moderator.' " + "title='This user is a 4chan Moderator.' class=identityIcon>";
  4065.           break;
  4066.         case 'developer':
  4067.           capcodeClass = " capcodeDeveloper";
  4068.           capcodeStart = " <strong class='capcode hand id_developer' " + "title='Highlight posts by Developers'>## Developer</strong>";
  4069.           capcode = (" <img src='" + staticPath + "/developericon.gif' ") + "alt='This user is a 4chan Developer.' " + "title='This user is a 4chan Developer.' class=identityIcon>";
  4070.           break;
  4071.         default:
  4072.           capcodeClass = '';
  4073.           capcodeStart = '';
  4074.           capcode = '';
  4075.       }
  4076.       flag = flagCode ? (" <img src='" + staticPath + "/country/" + (board === 'pol' ? 'troll/' : '')) + flagCode.toLowerCase() + (".gif' alt=" + flagCode + " title='" + flagName + "' class=countryFlag>") : '';
  4077.       if (file != null ? file.isDeleted : void 0) {
  4078.         fileHTML = isOP ? ("<div class=file id=f" + postID + "><div class=fileInfo></div><span class=fileThumb>") + ("<img src='" + staticPath + "/filedeleted.gif' alt='File deleted.' class='fileDeleted retina'>") + "</span></div>" : ("<div id=f" + postID + " class=file><span class=fileThumb>") + ("<img src='" + staticPath + "/filedeleted-res.gif' alt='File deleted.' class='fileDeletedRes retina'>") + "</span></div>";
  4079.       } else if (file) {
  4080.         ext = file.name.slice(-3);
  4081.         if (!file.twidth && !file.theight && ext === 'gif') {
  4082.           file.twidth = file.width;
  4083.           file.theight = file.height;
  4084.         }
  4085.         fileSize = $.bytesToString(file.size);
  4086.         fileThumb = file.turl;
  4087.         if (file.isSpoiler) {
  4088.           fileSize = "Spoiler Image, " + fileSize;
  4089.           if (!isArchived) {
  4090.             fileThumb = '//static.4chan.org/image/spoiler';
  4091.             if (spoilerRange = Build.spoilerRange[board]) {
  4092.               fileThumb += ("-" + board) + Math.floor(1 + spoilerRange * Math.random());
  4093.             }
  4094.             fileThumb += '.png';
  4095.             file.twidth = file.theight = 100;
  4096.           }
  4097.         }
  4098.         imgSrc = ("<a class='fileThumb" + (file.isSpoiler ? ' imgspoiler' : '') + "' href='" + file.url + "' target=_blank>") + ("<img src='" + fileThumb + "' alt='" + fileSize + "' data-md5=" + file.MD5 + " style='width:" + file.twidth + "px;height:" + file.theight + "px'></a>");
  4099.         a = $.el('a', {
  4100.           innerHTML: file.name
  4101.         });
  4102.         filename = a.textContent.replace(/%22/g, '"');
  4103.         a.textContent = Build.shortFilename(filename);
  4104.         shortFilename = a.innerHTML;
  4105.         a.textContent = filename;
  4106.         filename = a.innerHTML.replace(/'/g, '&apos;');
  4107.         fileDims = ext === 'pdf' ? 'PDF' : "" + file.width + "x" + file.height;
  4108.         fileInfo = ("<span class=fileText id=fT" + postID + (file.isSpoiler ? " title='" + filename + "'" : '') + ">File: <a href='" + file.url + "' target=_blank>" + file.timestamp + "</a>") + ("-(" + fileSize + ", " + fileDims + (file.isSpoiler ? '' : ", <span title='" + filename + "'>" + shortFilename + "</span>")) + ")</span>";
  4109.         fileHTML = "<div id=f" + postID + " class=file><div class=fileInfo>" + fileInfo + "</div>" + imgSrc + "</div>";
  4110.       } else {
  4111.         fileHTML = '';
  4112.       }
  4113.       tripcode = tripcode ? " <span class=postertrip>" + tripcode + "</span>" : '';
  4114.       sticky = isSticky ? ' <img src=//static.4chan.org/image/sticky.gif alt=Sticky title=Sticky style="height:16px;width:16px">' : '';
  4115.       closed = isClosed ? ' <img src=//static.4chan.org/image/closed.gif alt=Closed title=Closed style="height:16px;width:16px">' : '';
  4116.       container = $.el('div', {
  4117.         id: "pc" + postID,
  4118.         className: "postContainer " + (isOP ? 'op' : 'reply') + "Container",
  4119.         innerHTML: (isOP ? '' : "<div class=sideArrows id=sa" + postID + ">&gt;&gt;</div>") + ("<div id=p" + postID + " class='post " + (isOP ? 'op' : 'reply') + (capcode === 'admin_highlight' ? ' highlightPost' : '') + "'>") + ("<div class='postInfoM mobile' id=pim" + postID + ">") + ("<span class='nameBlock" + capcodeClass + "'>") + ("<span class=name>" + (name || '') + "</span>") + tripcode + capcodeStart + capcode + userID + flag + sticky + closed + ("<br>" + subject) + ("</span><span class='dateTime postNum' data-utc=" + dateUTC + ">" + date) + '<br><em>' + ("<a href=" + ("/" + board + "/res/" + threadID + "#p" + postID) + ">No.</a>") + ("<a href='" + (g.REPLY && g.THREAD_ID === threadID ? "javascript:quote(" + postID + ")" : "/" + board + "/res/" + threadID + "#q" + postID) + "'>" + postID + "</a>") + '</em></span>' + '</div>' + (isOP ? fileHTML : '') + ("<div class='postInfo desktop' id=pi" + postID + ">") + ("<input type=checkbox name=" + postID + " value=delete> ") + ("" + subject + " ") + ("<span class='nameBlock" + capcodeClass + "'>") + emailStart + ("<span class=name>" + (name || '') + "</span>") + tripcode + capcodeStart + emailEnd + capcode + userID + flag + sticky + closed + ' </span> ' + ("<span class=dateTime data-utc=" + dateUTC + ">" + date + "</span> ") + "<span class='postNum desktop'>" + ("<a href=" + ("/" + board + "/res/" + threadID + "#p" + postID) + " title='Highlight this post'>No.</a>") + ("<a href='" + (g.REPLY && +g.THREAD_ID === threadID ? "javascript:quote(" + postID + ")" : "/" + board + "/res/" + threadID + "#q" + postID) + "' title='Quote this post'>" + postID + "</a>") + '</span>' + '</div>' + (isOP ? '' : fileHTML) + ("<blockquote class=postMessage id=m" + postID + ">" + (comment || '') + "</blockquote> ") + '</div>'
  4120.       });
  4121.       _ref = $$('.quotelink', container);
  4122.       for (_i = 0, _len = _ref.length; _i < _len; _i++) {
  4123.         quote = _ref[_i];
  4124.         href = quote.getAttribute('href');
  4125.         if (href[0] === '/') {
  4126.           continue;
  4127.         }
  4128.         quote.href = "/" + board + "/res/" + href;
  4129.       }
  4130.       return container;
  4131.     }
  4132.   };
  4133.  
  4134.   TitlePost = {
  4135.     init: function() {
  4136.       return d.title = Get.title();
  4137.     }
  4138.   };
  4139.  
  4140.   QuoteBacklink = {
  4141.     init: function() {
  4142.       var format;
  4143.       format = Conf['backlink'].replace(/%id/g, "' + id + '");
  4144.       this.funk = Function('id', "return '" + format + "'");
  4145.       return Main.callbacks.push(this.node);
  4146.     },
  4147.     node: function(post) {
  4148.       var a, container, el, link, qid, quote, quotes, _i, _len, _ref;
  4149.       if (post.isInlined) {
  4150.         return;
  4151.       }
  4152.       quotes = {};
  4153.       _ref = post.quotes;
  4154.       for (_i = 0, _len = _ref.length; _i < _len; _i++) {
  4155.         quote = _ref[_i];
  4156.         if (quote.parentNode.parentNode.className === 'capcodeReplies') {
  4157.           break;
  4158.         }
  4159.         if (quote.hostname === 'boards.4chan.org' && !/catalog$/.test(quote.pathname) && (qid = quote.hash.slice(2))) {
  4160.           quotes[qid] = true;
  4161.         }
  4162.       }
  4163.       a = $.el('a', {
  4164.         href: "/" + g.BOARD + "/res/" + post.threadID + "#p" + post.ID,
  4165.         className: post.el.hidden ? 'filtered backlink' : 'backlink',
  4166.         textContent: QuoteBacklink.funk(post.ID)
  4167.       });
  4168.       for (qid in quotes) {
  4169.         if (!(el = $.id("pi" + qid)) || !Conf['OP Backlinks'] && /\bop\b/.test(el.parentNode.className)) {
  4170.           continue;
  4171.         }
  4172.         link = a.cloneNode(true);
  4173.         if (Conf['Quote Preview']) {
  4174.           $.on(link, 'mouseover', QuotePreview.mouseover);
  4175.         }
  4176.         if (Conf['Quote Inline']) {
  4177.           $.on(link, 'click', QuoteInline.toggle);
  4178.         }
  4179.         if (!(container = $.id("blc" + qid))) {
  4180.           container = $.el('span', {
  4181.             className: 'container',
  4182.             id: "blc" + qid
  4183.           });
  4184.           $.add(el, container);
  4185.         }
  4186.         $.add(container, [$.tn(' '), link]);
  4187.       }
  4188.     }
  4189.   };
  4190.  
  4191.   QuoteInline = {
  4192.     init: function() {
  4193.       return Main.callbacks.push(this.node);
  4194.     },
  4195.     node: function(post) {
  4196.       var quote, _i, _j, _len, _len1, _ref, _ref1;
  4197.       _ref = post.quotes;
  4198.       for (_i = 0, _len = _ref.length; _i < _len; _i++) {
  4199.         quote = _ref[_i];
  4200.         if (!(quote.hash && quote.hostname === 'boards.4chan.org' && !/catalog$/.test(quote.pathname) || /\bdeadlink\b/.test(quote.className))) {
  4201.           continue;
  4202.         }
  4203.         $.on(quote, 'click', QuoteInline.toggle);
  4204.       }
  4205.       _ref1 = post.backlinks;
  4206.       for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
  4207.         quote = _ref1[_j];
  4208.         $.on(quote, 'click', QuoteInline.toggle);
  4209.       }
  4210.     },
  4211.     toggle: function(e) {
  4212.       var id;
  4213.       if (e.shiftKey || e.altKey || e.ctrlKey || e.metaKey || e.button !== 0) {
  4214.         return;
  4215.       }
  4216.       e.preventDefault();
  4217.       id = this.dataset.id || this.hash.slice(2);
  4218.       if (/\binlined\b/.test(this.className)) {
  4219.         QuoteInline.rm(this, id);
  4220.       } else {
  4221.         if ($.x("ancestor::div[contains(@id,'p" + id + "')]", this)) {
  4222.           return;
  4223.         }
  4224.         QuoteInline.add(this, id);
  4225.       }
  4226.       return this.classList.toggle('inlined');
  4227.     },
  4228.     add: function(q, id) {
  4229.       var board, el, i, inline, isBacklink, path, postID, root, threadID;
  4230.       if (q.host === 'boards.4chan.org') {
  4231.         path = q.pathname.split('/');
  4232.         board = path[1];
  4233.         threadID = path[3];
  4234.         postID = id;
  4235.       } else {
  4236.         board = q.dataset.board;
  4237.         threadID = 0;
  4238.         postID = q.dataset.id;
  4239.       }
  4240.       el = board === g.BOARD ? $.id("p" + postID) : false;
  4241.       inline = $.el('div', {
  4242.         id: "i" + postID,
  4243.         className: el ? 'inline' : 'inline crosspost'
  4244.       });
  4245.       root = (isBacklink = /\bbacklink\b/.test(q.className)) ? q.parentNode : $.x('ancestor-or-self::*[parent::blockquote][1]', q);
  4246.       $.after(root, inline);
  4247.       Get.post(board, threadID, postID, inline);
  4248.       if (!el) {
  4249.         return;
  4250.       }
  4251.       if (isBacklink && Conf['Forward Hiding']) {
  4252.         $.addClass(el.parentNode, 'forwarded');
  4253.         ++el.dataset.forwarded || (el.dataset.forwarded = 1);
  4254.       }
  4255.       if ((i = Unread.replies.indexOf(el)) !== -1) {
  4256.         Unread.replies.splice(i, 1);
  4257.         return Unread.update(true);
  4258.       }
  4259.     },
  4260.     rm: function(q, id) {
  4261.       var div, inlined, _i, _len, _ref;
  4262.       div = $.x("following::div[@id='i" + id + "']", q);
  4263.       $.rm(div);
  4264.       if (!Conf['Forward Hiding']) {
  4265.         return;
  4266.       }
  4267.       _ref = $$('.backlink.inlined', div);
  4268.       for (_i = 0, _len = _ref.length; _i < _len; _i++) {
  4269.         inlined = _ref[_i];
  4270.         div = $.id(inlined.hash.slice(1));
  4271.         if (!--div.dataset.forwarded) {
  4272.           $.rmClass(div.parentNode, 'forwarded');
  4273.         }
  4274.       }
  4275.       if (/\bbacklink\b/.test(q.className)) {
  4276.         div = $.id("p" + id);
  4277.         if (!--div.dataset.forwarded) {
  4278.           return $.rmClass(div.parentNode, 'forwarded');
  4279.         }
  4280.       }
  4281.     }
  4282.   };
  4283.  
  4284.   QuotePreview = {
  4285.     init: function() {
  4286.       return Main.callbacks.push(this.node);
  4287.     },
  4288.     node: function(post) {
  4289.       var quote, _i, _j, _len, _len1, _ref, _ref1;
  4290.       _ref = post.quotes;
  4291.       for (_i = 0, _len = _ref.length; _i < _len; _i++) {
  4292.         quote = _ref[_i];
  4293.         if (!(quote.hash && quote.hostname === 'boards.4chan.org' && !/catalog$/.test(quote.pathname) || /\bdeadlink\b/.test(quote.className))) {
  4294.           continue;
  4295.         }
  4296.         $.on(quote, 'mouseover', QuotePreview.mouseover);
  4297.       }
  4298.       _ref1 = post.backlinks;
  4299.       for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
  4300.         quote = _ref1[_j];
  4301.         $.on(quote, 'mouseover', QuotePreview.mouseover);
  4302.       }
  4303.     },
  4304.     mouseover: function(e) {
  4305.       var board, el, path, postID, qp, quote, quoterID, threadID, _i, _len, _ref;
  4306.       if (/\binlined\b/.test(this.className)) {
  4307.         return;
  4308.       }
  4309.       if (qp = $.id('qp')) {
  4310.         if (qp === UI.el) {
  4311.           delete UI.el;
  4312.         }
  4313.         $.rm(qp);
  4314.       }
  4315.       if (UI.el) {
  4316.         return;
  4317.       }
  4318.       if (this.host === 'boards.4chan.org') {
  4319.         path = this.pathname.split('/');
  4320.         board = path[1];
  4321.         threadID = path[3];
  4322.         postID = this.hash.slice(2);
  4323.       } else {
  4324.         board = this.dataset.board;
  4325.         threadID = 0;
  4326.         postID = this.dataset.id;
  4327.       }
  4328.       qp = UI.el = $.el('div', {
  4329.         id: 'qp',
  4330.         className: 'reply dialog'
  4331.       });
  4332.       UI.hover(e);
  4333.       $.add(d.body, qp);
  4334.       if (board === g.BOARD) {
  4335.         el = $.id("p" + postID);
  4336.       }
  4337.       Get.post(board, threadID, postID, qp, function() {
  4338.         var bq, img, post;
  4339.         bq = $('blockquote', qp);
  4340.         Main.prettify(bq);
  4341.         post = {
  4342.           el: qp,
  4343.           blockquote: bq,
  4344.           isArchived: /\barchivedPost\b/.test(qp.className)
  4345.         };
  4346.         if (img = $('img[data-md5]', qp)) {
  4347.           post.fileInfo = img.parentNode.previousElementSibling;
  4348.           post.img = img;
  4349.         }
  4350.         if (Conf['Reveal Spoilers']) {
  4351.           RevealSpoilers.node(post);
  4352.         }
  4353.         if (Conf['Image Auto-Gif']) {
  4354.           AutoGif.node(post);
  4355.         }
  4356.         if (Conf['Time Formatting']) {
  4357.           Time.node(post);
  4358.         }
  4359.         if (Conf['File Info Formatting']) {
  4360.           FileInfo.node(post);
  4361.         }
  4362.         if (Conf['Resurrect Quotes']) {
  4363.           Quotify.node(post);
  4364.         }
  4365.         if (Conf['Anonymize']) {
  4366.           return Anonymize.node(post);
  4367.         }
  4368.       });
  4369.       $.on(this, 'mousemove', UI.hover);
  4370.       $.on(this, 'mouseout click', QuotePreview.mouseout);
  4371.       if (!el) {
  4372.         return;
  4373.       }
  4374.       if (Conf['Quote Highlighting']) {
  4375.         if (/\bop\b/.test(el.className)) {
  4376.           $.addClass(el.parentNode, 'qphl');
  4377.         } else {
  4378.           $.addClass(el, 'qphl');
  4379.         }
  4380.       }
  4381.       quoterID = $.x('ancestor::*[@id][1]', this).id.match(/\d+$/)[0];
  4382.       _ref = $$('.quotelink, .backlink', qp);
  4383.       for (_i = 0, _len = _ref.length; _i < _len; _i++) {
  4384.         quote = _ref[_i];
  4385.         if (quote.hash.slice(2) === quoterID) {
  4386.           $.addClass(quote, 'forwardlink');
  4387.         }
  4388.       }
  4389.     },
  4390.     mouseout: function(e) {
  4391.       var el;
  4392.       UI.hoverend();
  4393.       if (el = $.id(this.hash.slice(1))) {
  4394.         $.rmClass(el, 'qphl');
  4395.         $.rmClass(el.parentNode, 'qphl');
  4396.       }
  4397.       $.off(this, 'mousemove', UI.hover);
  4398.       return $.off(this, 'mouseout click', QuotePreview.mouseout);
  4399.     }
  4400.   };
  4401.  
  4402.   QuoteOP = {
  4403.     init: function() {
  4404.       return Main.callbacks.push(this.node);
  4405.     },
  4406.     node: function(post) {
  4407.       var quote, _i, _len, _ref;
  4408.       if (post.isInlined && !post.isCrosspost) {
  4409.         return;
  4410.       }
  4411.       _ref = post.quotes;
  4412.       for (_i = 0, _len = _ref.length; _i < _len; _i++) {
  4413.         quote = _ref[_i];
  4414.         if (quote.hash.slice(2) === post.threadID) {
  4415.           $.add(quote, $.tn('\u00A0(OP)'));
  4416.         }
  4417.       }
  4418.     }
  4419.   };
  4420.  
  4421.   QuoteCT = {
  4422.     init: function() {
  4423.       return Main.callbacks.push(this.node);
  4424.     },
  4425.     node: function(post) {
  4426.       var path, quote, _i, _len, _ref;
  4427.       if (post.isInlined && !post.isCrosspost) {
  4428.         return;
  4429.       }
  4430.       _ref = post.quotes;
  4431.       for (_i = 0, _len = _ref.length; _i < _len; _i++) {
  4432.         quote = _ref[_i];
  4433.         if (!(quote.hash && quote.hostname === 'boards.4chan.org' && !/catalog$/.test(quote.pathname))) {
  4434.           continue;
  4435.         }
  4436.         path = quote.pathname.split('/');
  4437.         if (path[1] === g.BOARD && path[3] !== post.threadID) {
  4438.           $.add(quote, $.tn('\u00A0(Cross-thread)'));
  4439.         }
  4440.       }
  4441.     }
  4442.   };
  4443.  
  4444.   Quotify = {
  4445.     init: function() {
  4446.       return Main.callbacks.push(this.node);
  4447.     },
  4448.     node: function(post) {
  4449.       var a, board, deadlink, id, m, postBoard, quote, _i, _len, _ref, _ref1;
  4450.       if (post.isInlined && !post.isCrosspost) {
  4451.         return;
  4452.       }
  4453.       _ref = $$('.deadlink', post.blockquote);
  4454.       for (_i = 0, _len = _ref.length; _i < _len; _i++) {
  4455.         deadlink = _ref[_i];
  4456.         if (deadlink.parentNode.className === 'prettyprint') {
  4457.           $.replace(deadlink, Array.prototype.slice.call(deadlink.childNodes));
  4458.           continue;
  4459.         }
  4460.         quote = deadlink.textContent;
  4461.         a = $.el('a', {
  4462.           textContent: "" + quote + "\u00A0(Dead)"
  4463.         });
  4464.         if (!(id = (_ref1 = quote.match(/\d+$/)) != null ? _ref1[0] : void 0)) {
  4465.           continue;
  4466.         }
  4467.         if (m = quote.match(/^>>>\/([a-z\d]+)/)) {
  4468.           board = m[1];
  4469.         } else if (postBoard) {
  4470.           board = postBoard;
  4471.         } else {
  4472.           board = postBoard = $('a[title="Highlight this post"]', post.el).pathname.split('/')[1];
  4473.         }
  4474.         if (board === g.BOARD && $.id("p" + id)) {
  4475.           a.href = "#p" + id;
  4476.           a.className = 'quotelink';
  4477.         } else {
  4478.           a.href = Redirect.to({
  4479.             board: board,
  4480.             threadID: 0,
  4481.             postID: id
  4482.           });
  4483.           a.className = 'deadlink';
  4484.           a.target = '_blank';
  4485.           if (Redirect.post(board, id)) {
  4486.             $.addClass(a, 'quotelink');
  4487.             a.setAttribute('data-board', board);
  4488.             a.setAttribute('data-id', id);
  4489.           }
  4490.         }
  4491.         $.replace(deadlink, a);
  4492.       }
  4493.     }
  4494.   };
  4495.  
  4496.   DeleteLink = {
  4497.     init: function() {
  4498.       var aImage, aPost, children, div;
  4499.       div = $.el('div', {
  4500.         className: 'delete_link',
  4501.         textContent: 'Delete'
  4502.       });
  4503.       aPost = $.el('a', {
  4504.         className: 'delete_post',
  4505.         href: 'javascript:;'
  4506.       });
  4507.       aImage = $.el('a', {
  4508.         className: 'delete_image',
  4509.         href: 'javascript:;'
  4510.       });
  4511.       children = [];
  4512.       children.push({
  4513.         el: aPost,
  4514.         open: function() {
  4515.           aPost.textContent = 'Post';
  4516.           $.on(aPost, 'click', DeleteLink["delete"]);
  4517.           return true;
  4518.         }
  4519.       });
  4520.       children.push({
  4521.         el: aImage,
  4522.         open: function(post) {
  4523.           if (!post.img) {
  4524.             return false;
  4525.           }
  4526.           aImage.textContent = 'Image';
  4527.           $.on(aImage, 'click', DeleteLink["delete"]);
  4528.           return true;
  4529.         }
  4530.       });
  4531.       Menu.addEntry({
  4532.         el: div,
  4533.         open: function(post) {
  4534.           var node, seconds;
  4535.           if (post.isArchived) {
  4536.             return false;
  4537.           }
  4538.           node = div.firstChild;
  4539.           if (seconds = DeleteLink.cooldown[post.ID]) {
  4540.             node.textContent = "Delete (" + seconds + ")";
  4541.             DeleteLink.cooldown.el = node;
  4542.           } else {
  4543.             node.textContent = 'Delete';
  4544.             delete DeleteLink.cooldown.el;
  4545.           }
  4546.           return true;
  4547.         },
  4548.         children: children
  4549.       });
  4550.       return $.on(d, 'QRPostSuccessful', this.cooldown.start);
  4551.     },
  4552.     "delete": function() {
  4553.       var board, form, id, m, menu, pwd, self;
  4554.       menu = $.id('menu');
  4555.       id = menu.dataset.id;
  4556.       if (DeleteLink.cooldown[id]) {
  4557.         return;
  4558.       }
  4559.       $.off(this, 'click', DeleteLink["delete"]);
  4560.       this.textContent = 'Deleting...';
  4561.       pwd = (m = d.cookie.match(/4chan_pass=([^;]+)/)) ? decodeURIComponent(m[1]) : $.id('delPassword').value;
  4562.       board = $('a[title="Highlight this post"]', $.id(menu.dataset.rootid)).pathname.split('/')[1];
  4563.       self = this;
  4564.       form = {
  4565.         mode: 'usrdel',
  4566.         onlyimgdel: /\bdelete_image\b/.test(this.className),
  4567.         pwd: pwd
  4568.       };
  4569.       form[id] = 'delete';
  4570.       return $.ajax($.id('delform').action.replace("/" + g.BOARD + "/", "/" + board + "/"), {
  4571.         onload: function() {
  4572.           return DeleteLink.load(self, this.response);
  4573.         },
  4574.         onerror: function() {
  4575.           return DeleteLink.error(self);
  4576.         }
  4577.       }, {
  4578.         form: $.formData(form)
  4579.       });
  4580.     },
  4581.     load: function(self, html) {
  4582.       var doc, msg, s;
  4583.       doc = d.implementation.createHTMLDocument('');
  4584.       doc.documentElement.innerHTML = html;
  4585.       if (doc.title === '4chan - Banned') {
  4586.         s = 'Banned!';
  4587.       } else if (msg = doc.getElementById('errmsg')) {
  4588.         s = msg.textContent;
  4589.         $.on(self, 'click', DeleteLink["delete"]);
  4590.       } else {
  4591.         s = 'Deleted';
  4592.       }
  4593.       return self.textContent = s;
  4594.     },
  4595.     error: function(self) {
  4596.       self.textContent = 'Connection error, please retry.';
  4597.       return $.on(self, 'click', DeleteLink["delete"]);
  4598.     },
  4599.     cooldown: {
  4600.       start: function(e) {
  4601.         var seconds;
  4602.         seconds = g.BOARD === 'q' ? 600 : 30;
  4603.         return DeleteLink.cooldown.count(e.detail.postID, seconds, seconds);
  4604.       },
  4605.       count: function(postID, seconds, length) {
  4606.         var el;
  4607.         if (!((0 <= seconds && seconds <= length))) {
  4608.           return;
  4609.         }
  4610.         setTimeout(DeleteLink.cooldown.count, 1000, postID, seconds - 1, length);
  4611.         el = DeleteLink.cooldown.el;
  4612.         if (seconds === 0) {
  4613.           if (el != null) {
  4614.             el.textContent = 'Delete';
  4615.           }
  4616.           delete DeleteLink.cooldown[postID];
  4617.           delete DeleteLink.cooldown.el;
  4618.           return;
  4619.         }
  4620.         if (el != null) {
  4621.           el.textContent = "Delete (" + seconds + ")";
  4622.         }
  4623.         return DeleteLink.cooldown[postID] = seconds;
  4624.       }
  4625.     }
  4626.   };
  4627.  
  4628.   ReportLink = {
  4629.     init: function() {
  4630.       var a;
  4631.       a = $.el('a', {
  4632.         className: 'report_link',
  4633.         href: 'javascript:;',
  4634.         textContent: 'Report this post'
  4635.       });
  4636.       $.on(a, 'click', this.report);
  4637.       return Menu.addEntry({
  4638.         el: a,
  4639.         open: function(post) {
  4640.           return post.isArchived === false;
  4641.         }
  4642.       });
  4643.     },
  4644.     report: function() {
  4645.       var a, id, set, url;
  4646.       a = $('a[title="Highlight this post"]', $.id(this.parentNode.dataset.rootid));
  4647.       url = "//sys.4chan.org/" + (a.pathname.split('/')[1]) + "/imgboard.php?mode=report&no=" + this.parentNode.dataset.id;
  4648.       id = Date.now();
  4649.       set = "toolbar=0,scrollbars=0,location=0,status=1,menubar=0,resizable=1,width=685,height=200";
  4650.       return window.open(url, id, set);
  4651.     }
  4652.   };
  4653.  
  4654.   DownloadLink = {
  4655.     init: function() {
  4656.       var a;
  4657.       if ($.el('a').download === void 0) {
  4658.         return;
  4659.       }
  4660.       a = $.el('a', {
  4661.         className: 'download_link',
  4662.         textContent: 'Download file'
  4663.       });
  4664.       return Menu.addEntry({
  4665.         el: a,
  4666.         open: function(post) {
  4667.           var fileText;
  4668.           if (!post.img) {
  4669.             return false;
  4670.           }
  4671.           a.href = post.img.parentNode.href;
  4672.           fileText = post.fileInfo.firstElementChild;
  4673.           a.download = Conf['File Info Formatting'] ? fileText.dataset.filename : $('span', fileText).title;
  4674.           return true;
  4675.         }
  4676.       });
  4677.     }
  4678.   };
  4679.  
  4680.   ArchiveLink = {
  4681.     init: function() {
  4682.       var div, entry, type, _i, _len, _ref;
  4683.       div = $.el('div', {
  4684.         textContent: 'Archive'
  4685.       });
  4686.       entry = {
  4687.         el: div,
  4688.         open: function(post) {
  4689.           var path;
  4690.           path = $('a[title="Highlight this post"]', post.el).pathname.split('/');
  4691.           if ((Redirect.to({
  4692.             board: path[1],
  4693.             threadID: path[3],
  4694.             postID: post.ID
  4695.           })) === ("//boards.4chan.org/" + path[1] + "/")) {
  4696.             return false;
  4697.           }
  4698.           post.info = [path[1], path[3]];
  4699.           return true;
  4700.         },
  4701.         children: []
  4702.       };
  4703.       _ref = [['Post', 'apost'], ['Name', 'name'], ['Tripcode', 'tripcode'], ['E-mail', 'email'], ['Subject', 'subject'], ['Filename', 'filename'], ['Image MD5', 'md5']];
  4704.       for (_i = 0, _len = _ref.length; _i < _len; _i++) {
  4705.         type = _ref[_i];
  4706.         entry.children.push(this.createSubEntry(type[0], type[1]));
  4707.       }
  4708.       return Menu.addEntry(entry);
  4709.     },
  4710.     createSubEntry: function(text, type) {
  4711.       var el, open;
  4712.       el = $.el('a', {
  4713.         textContent: text,
  4714.         target: '_blank'
  4715.       });
  4716.       open = function(post) {
  4717.         var value;
  4718.         if (type === 'apost') {
  4719.           el.href = Redirect.to({
  4720.             board: post.info[0],
  4721.             threadID: post.info[1],
  4722.             postID: post.ID
  4723.           });
  4724.           return true;
  4725.         }
  4726.         value = Filter[type](post);
  4727.         if (!value) {
  4728.           return false;
  4729.         }
  4730.         return el.href = Redirect.to({
  4731.           board: post.info[0],
  4732.           type: type,
  4733.           value: value,
  4734.           isSearch: true
  4735.         });
  4736.       };
  4737.       return {
  4738.         el: el,
  4739.         open: open
  4740.       };
  4741.     }
  4742.   };
  4743.  
  4744.   ThreadStats = {
  4745.     init: function() {
  4746.       var dialog;
  4747.       dialog = UI.dialog('stats', 'bottom: 0; left: 0;', '<div class=move><span id=postcount>0</span> / <span id=imagecount>0</span></div>');
  4748.       dialog.className = 'dialog';
  4749.       $.add(d.body, dialog);
  4750.       this.posts = this.images = 0;
  4751.       this.imgLimit = (function() {
  4752.         switch (g.BOARD) {
  4753.           case 'a':
  4754.           case 'b':
  4755.           case 'v':
  4756.           case 'co':
  4757.           case 'mlp':
  4758.             return 251;
  4759.           case 'vg':
  4760.             return 376;
  4761.           default:
  4762.             return 151;
  4763.         }
  4764.       })();
  4765.       return Main.callbacks.push(this.node);
  4766.     },
  4767.     node: function(post) {
  4768.       var imgcount;
  4769.       if (post.isInlined) {
  4770.         return;
  4771.       }
  4772.       $.id('postcount').textContent = ++ThreadStats.posts;
  4773.       if (!post.img) {
  4774.         return;
  4775.       }
  4776.       imgcount = $.id('imagecount');
  4777.       imgcount.textContent = ++ThreadStats.images;
  4778.       if (ThreadStats.images > ThreadStats.imgLimit) {
  4779.         return $.addClass(imgcount, 'warning');
  4780.       }
  4781.     }
  4782.   };
  4783.  
  4784.   Unread = {
  4785.     init: function() {
  4786.       this.title = d.title;
  4787.       $.on(d, 'QRPostSuccessful', this.post);
  4788.       this.update();
  4789.       $.on(window, 'scroll', Unread.scroll);
  4790.       return Main.callbacks.push(this.node);
  4791.     },
  4792.     replies: [],
  4793.     foresee: [],
  4794.     post: function(e) {
  4795.       return Unread.foresee.push(e.detail.postID);
  4796.     },
  4797.     node: function(post) {
  4798.       var count, el, index;
  4799.       if ((index = Unread.foresee.indexOf(post.ID)) !== -1) {
  4800.         Unread.foresee.splice(index, 1);
  4801.         return;
  4802.       }
  4803.       el = post.el;
  4804.       if (el.hidden || /\bop\b/.test(post["class"]) || post.isInlined) {
  4805.         return;
  4806.       }
  4807.       count = Unread.replies.push(el);
  4808.       return Unread.update(count === 1);
  4809.     },
  4810.     scroll: function() {
  4811.       var bottom, height, i, reply, _i, _len, _ref;
  4812.       height = d.documentElement.clientHeight;
  4813.       _ref = Unread.replies;
  4814.       for (i = _i = 0, _len = _ref.length; _i < _len; i = ++_i) {
  4815.         reply = _ref[i];
  4816.         bottom = reply.getBoundingClientRect().bottom;
  4817.         if (bottom > height) {
  4818.           break;
  4819.         }
  4820.       }
  4821.       if (i === 0) {
  4822.         return;
  4823.       }
  4824.       Unread.replies = Unread.replies.slice(i);
  4825.       return Unread.update(Unread.replies.length === 0);
  4826.     },
  4827.     setTitle: function(count) {
  4828.       if (this.scheduled) {
  4829.         clearTimeout(this.scheduled);
  4830.         delete Unread.scheduled;
  4831.         this.setTitle(count);
  4832.         return;
  4833.       }
  4834.       return this.scheduled = setTimeout((function() {
  4835.         return d.title = "(" + count + ") " + Unread.title;
  4836.       }), 5);
  4837.     },
  4838.     update: function(updateFavicon) {
  4839.       var count;
  4840.       if (!g.REPLY) {
  4841.         return;
  4842.       }
  4843.       count = this.replies.length;
  4844.       if (Conf['Unread Count']) {
  4845.         this.setTitle(count);
  4846.       }
  4847.       if (!(Conf['Unread Favicon'] && updateFavicon)) {
  4848.         return;
  4849.       }
  4850.       if ($.engine === 'presto') {
  4851.         $.rm(Favicon.el);
  4852.       }
  4853.       Favicon.el.href = g.dead ? count ? Favicon.unreadDead : Favicon.dead : count ? Favicon.unread : Favicon["default"];
  4854.       if (g.dead) {
  4855.         $.addClass(Favicon.el, 'dead');
  4856.       } else {
  4857.         $.rmClass(Favicon.el, 'dead');
  4858.       }
  4859.       if (count) {
  4860.         $.addClass(Favicon.el, 'unread');
  4861.       } else {
  4862.         $.rmClass(Favicon.el, 'unread');
  4863.       }
  4864.       if ($.engine !== 'webkit') {
  4865.         return $.add(d.head, Favicon.el);
  4866.       }
  4867.     }
  4868.   };
  4869.  
  4870.   Favicon = {
  4871.     init: function() {
  4872.       var href;
  4873.       if (this.el) {
  4874.         return;
  4875.       }
  4876.       this.el = $('link[rel="shortcut icon"]', d.head);
  4877.       this.el.type = 'image/x-icon';
  4878.       href = this.el.href;
  4879.       this.SFW = /ws.ico$/.test(href);
  4880.       this["default"] = href;
  4881.       return this["switch"]();
  4882.     },
  4883.     "switch": function() {
  4884.       switch (Conf['favicon']) {
  4885.         case 'ferongr':
  4886.           this.unreadDead = 'data:image/gif;base64,R0lGODlhEAAQAOMHAOgLAnMFAL8AAOgLAukMA/+AgP+rq////////////////////////////////////yH5BAEKAAcALAAAAAAQABAAAARZ8MhJ6xwDWIBv+AM1fEEIBIVRlNKYrtpIECuGzuwpCLg974EYiXUYkUItjGbC6VQ4omXFiKROA6qSy0A8nAo9GS3YCswIWnOvLAi0be23Z1QtdSUaqXcviQAAOw==';
  4887.           this.unreadSFW = 'data:image/gif;base64,R0lGODlhEAAQAOMHAADX8QBwfgC2zADX8QDY8nnl8qLp8v///////////////////////////////////yH5BAEKAAcALAAAAAAQABAAAARZ8MhJ6xwDWIBv+AM1fEEIBIVRlNKYrtpIECuGzuwpCLg974EYiXUYkUItjGbC6VQ4omXFiKROA6qSy0A8nAo9GS3YCswIWnOvLAi0be23Z1QtdSUaqXcviQAAOw==';
  4888.           this.unreadNSFW = 'data:image/gif;base64,R0lGODlhEAAQAOMHAFT+ACh5AEncAFT+AFX/Acz/su7/5v///////////////////////////////////yH5BAEKAAcALAAAAAAQABAAAARZ8MhJ6xwDWIBv+AM1fEEIBIVRlNKYrtpIECuGzuwpCLg974EYiXUYkUItjGbC6VQ4omXFiKROA6qSy0A8nAo9GS3YCswIWnOvLAi0be23Z1QtdSUaqXcviQAAOw==';
  4889.           break;
  4890.         case 'xat-':
  4891.           this.unreadDead = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAA2ElEQVQ4y61TQQrCMBDMQ8WDIEV6LbT2A4og2Hq0veo7fIAH04dY9N4xmyYlpGmI2MCQTWYy3Wy2DAD7B2wWAzWgcTgVeZKlZRxHNYFi2jM18oBh0IcKtC6ixf22WT4IFLs0owxswXu9egm0Ls6bwfCFfNsJYJKfqoEkd3vgUgFVLWObtzNgVKyruC+ljSzr5OEnBzjvjcQecaQhbZgBb4CmGQw+PoMkTUtdbd8VSEPakcGxPOcsoIgUKy0LecY29BmdBrqRfjIwZ93KLs5loHvBnL3cLH/jF+C/+z5dgUysAAAAAElFTkSuQmCC';
  4892.           this.unreadSFW = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAA30lEQVQ4y2P4//8/AyWYgSoGQMF/GJ7Y11VVUVoyKTM9ey4Ig9ggMWQ1YA1IBvzXm34YjkH8mPyJB+Nqlp8FYRAbmxoMF6ArSNrw6T0Qf8Amh9cFMEWVR/7/A+L/uORxhgEIt5/+/3/2lf//5wAxiI0uj+4CBlBgxVUvOwtydgXQZpDmi2/+/7/0GmIQSAwkB1IDUkuUAZeABlx+g2zAZ9wGlAOjChba+LwAUgNSi2HA5Am9VciBhSsQQWyoWgZiovEDsdGI1QBYQiLJAGQalpSxyWEzAJYWkGm8clTJjQCZ1hkoVG0CygAAAABJRU5ErkJggg==';
  4893.           this.unreadNSFW = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAA4ElEQVQ4y2P4//8/AyWYgSoGQMF/GJ7YNbGqrKRiUnp21lwQBrFBYshqwBqQDPifdsYYjkH8mInxB+OWx58FYRAbmxoMF6ArKPmU9B6IP2CTw+sCmKKe/5X/gPg/LnmcYQDCs/63/1/9fzYQzwGz0eXRXcAACqy4ZfFnQc7u+V/xD6T55v+LQHwJbBBIDCQHUgNSS5QBt4Cab/2/jDDgMx4DykrKJ8FCG58XQGpAajEMmNw7uQo5sHAFIogNVctATDR+IDYasRoAS0gkGYBMw5IyNjlsBsDSAjKNV44quREAx58Mr9vt5wQAAAAASUVORK5CYII=';
  4894.           break;
  4895.         case 'Mayhem':
  4896.           this.unreadDead = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAABIUlEQVQ4jZ2ScWuDMBDFgw4pIkU0WsoQkWAYIkXZH4N9/+/V3dmfXSrKYIFHwt17j8vdGWNMIkgFuaDgzgQnwRs4EQs5KdolUQtagRN0givEDBTEOjgtGs0Zq8F7cKqqusVxrMQLaDUWcjBSrXkn8gs51tpJSWLk9b3HUa0aNIL5gPBR1/V4kJvR7lTwl8GmAm1Gf9+c3S+89qBHa8502AsmSrtBaEBPbIbj0ah2madlNAPEccdgJDfAtWifBjqWKShRBT6KoiH8QlEUn/qt0CCjnNdmPUwmFWzj9Oe6LpKuZXcwqq88z78Pch3aZU3dPwwc2sWlfZKCW5tWluV8kGvXClLm6dYN4/aUqfCbnEOzNDGhGZbNargvxCzvMGfRJD8UaDVvgkzo6QAAAABJRU5ErkJggg==';
  4897.           this.unreadSFW = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAABCElEQVQ4jZ2S4crCMAxF+0OGDJEPKYrIGKOsiJSx/fJRfSAfTJNyKqXfiuDg0C25N2RJjTGmEVrhTzhw7oStsIEtsVzT4o2Jo9ALThiEM8IdHIgNaHo8mjNWg6/ske8bohPo+63QOLzmooHp8fyAICBSQkVz0QKdsFQEV6WSW/D+7+BbgbIDHcb4Kp61XyjyI16zZ8JemGltQtDBSGxB4/GoN+7TpkkjDCsFArm0IYv3U0BbnYtf8BCy+JytsE0X6VyuKhPPK/GAJ14kvZZDZVV3pZIb8MZr6n4o4PDGKn0S5SdDmyq5PnXQsk+Xbhinp03FFzmHJw6xYRiWm9VxnohZ3vOcxdO8ARmXRvbWdtzQAAAAAElFTkSuQmCC';
  4898.           this.unreadNSFW = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAABCklEQVQ4jZ2S0WrDMAxF/TBCCKWMYhZKCSGYmFJMSNjD/mhf239qJXNcjBdTWODgRLpXKJKNMaYROuFTOHEehFb4gJZYrunwxsSXMApOmIQzwgOciE1oRjyaM1aDj+yR7xuiHvT9VmgcXnPRwO/9+wWCgEgJFc1FCwzCVhFclUpuw/u3g3cFyg50GPOjePZ+ocjPeM2RCXthpbUFwQAzsQ2Nx6PeuE+bJo0w7BQI5NKGLN5XAW11LX7BQ8jia7bCLl2kc7mqTLzuxAOeeJH0Wk6VVf0oldyEN15T948CDm+sMiZRfjK0pZIbUwcd+3TphnF62lR8kXN44hAbhmG5WQNnT8zynucsnuYJhFpBfkMzqD4AAAAASUVORK5CYII=';
  4899.           break;
  4900.         case 'Original':
  4901.           this.unreadDead = 'data:image/gif;base64,R0lGODlhEAAQAKECAAAAAP8AAP///////yH5BAEKAAMALAAAAAAQABAAAAI/nI95wsqygIRxDgGCBhTrwF3Zxowg5H1cSopS6FrGQ82PU1951ckRmYKJVCXizLRC9kAnT0aIiR6lCFT1cigAADs=';
  4902.           this.unreadSFW = 'data:image/gif;base64,R0lGODlhEAAQAKECAAAAAC6Xw////////yH5BAEKAAMALAAAAAAQABAAAAI/nI95wsqygIRxDgGCBhTrwF3Zxowg5H1cSopS6FrGQ82PU1951ckRmYKJVCXizLRC9kAnT0aIiR6lCFT1cigAADs=';
  4903.           this.unreadNSFW = 'data:image/gif;base64,R0lGODlhEAAQAKECAAAAAGbMM////////yH5BAEKAAMALAAAAAAQABAAAAI/nI95wsqygIRxDgGCBhTrwF3Zxowg5H1cSopS6FrGQ82PU1951ckRmYKJVCXizLRC9kAnT0aIiR6lCFT1cigAADs=';
  4904.       }
  4905.       return this.unread = this.SFW ? this.unreadSFW : this.unreadNSFW;
  4906.     },
  4907.     empty: 'data:image/gif;base64,R0lGODlhEAAQAJEAAAAAAP///9vb2////yH5BAEAAAMALAAAAAAQABAAAAIvnI+pq+D9DBAUoFkPFnbs7lFZKIJOJJ3MyraoB14jFpOcVMpzrnF3OKlZYsMWowAAOw==',
  4908.     dead: 'data:image/gif;base64,R0lGODlhEAAQAKECAAAAAP8AAP///////yH5BAEKAAIALAAAAAAQABAAAAIvlI+pq+D9DAgUoFkPDlbs7lFZKIJOJJ3MyraoB14jFpOcVMpzrnF3OKlZYsMWowAAOw=='
  4909.   };
  4910.  
  4911.   Redirect = {
  4912.     image: function(board, filename) {
  4913.       switch (board) {
  4914.         case 'a':
  4915.         case 'gd':
  4916.         case 'jp':
  4917.         case 'm':
  4918.         case 'q':
  4919.         case 'tg':
  4920.         case 'vg':
  4921.         case 'vp':
  4922.         case 'vr':
  4923.         case 'wsg':
  4924.           return "//archive.foolz.us/" + board + "/full_image/" + filename;
  4925.         case 'u':
  4926.           return "//nsfw.foolz.us/" + board + "/full_image/" + filename;
  4927.         case 'c':
  4928.         case 'po':
  4929.           return "//archive.thedarkcave.org/" + board + "/full_image/" + filename;
  4930.         case 'hr':
  4931.         case 'tg':
  4932.         case 'tv':
  4933.         case 'x':
  4934.           return "//archive.4plebs.org/" + board + "/full_image/" + filename;
  4935.         case 'c':
  4936.         case 'w':
  4937.         case 'wg':
  4938.           return "//archive.nyafuu.org/" + board + "/full_image/" + filename;
  4939.         case 'cm':
  4940.         case 'd':
  4941.         case 'e':
  4942.         case 'i':
  4943.         case 'n':
  4944.         case 'o':
  4945.         case 'p':
  4946.         case 's':
  4947.         case 'trv':
  4948.         case 'y':
  4949.           return "//archive.foolzashit.com/" + board + "/full_image/" + filename;
  4950.         case 'b':
  4951.         case 'e':
  4952.         case 'h':
  4953.         case 'hc':
  4954.         case 'p':
  4955.         case 's':
  4956.         case 'soc':
  4957.         case 'sp':
  4958.         case 'u':
  4959.           return "//fuuka.worldathleticproject.org/" + board + "/full_image/" + filename;
  4960.         case 'cgl':
  4961.         case 'g':
  4962.         case 'mu':
  4963.         case 'w':
  4964.           return "//rbt.asia/" + board + "/full_image/" + filename;
  4965.         case 'an':
  4966.         case 'fit':
  4967.         case 'k':
  4968.         case 'r9k':
  4969.         case 'toy':
  4970.           return "//archive.heinessen.com/" + board + "/full_image/" + filename;
  4971.         case '3':
  4972.         case 'cgl':
  4973.         case 'ck':
  4974.         case 'fa':
  4975.         case 'ic':
  4976.         case 'jp':
  4977.         case 'lit':
  4978.         case 'q':
  4979.         case 'tg':
  4980.         case 'vr':
  4981.           return "//fuuka.warosu.org/" + board + "/full_image/" + filename;
  4982.       }
  4983.     },
  4984.     post: function(board, postID) {
  4985.       switch (board) {
  4986.         case 'a':
  4987.         case 'co':
  4988.         case 'gd':
  4989.         case 'jp':
  4990.         case 'm':
  4991.         case 'q':
  4992.         case 'sp':
  4993.         case 'tg':
  4994.         case 'tv':
  4995.         case 'v':
  4996.         case 'vg':
  4997.         case 'vp':
  4998.         case 'vr':
  4999.         case 'wsg':
  5000.           return "//archive.foolz.us/_/api/chan/post/?board=" + board + "&num=" + postID;
  5001.         case 'u':
  5002.           return "//nsfw.foolz.us/_/api/chan/post/?board=" + board + "&num=" + postID;
  5003.         case 'c':
  5004.         case 'int':
  5005.         case 'out':
  5006.         case 'po':
  5007.           return "//archive.thedarkcave.org/_/api/chan/post/?board=" + board + "&num=" + postID;
  5008.         case 'hr':
  5009.         case 'tg':
  5010.         case 'tv':
  5011.         case 'x':
  5012.           return "//archive.4plebs.org/_/api/chan/post/?board=" + board + "&num=" + postID;
  5013.         case 'c':
  5014.         case 'w':
  5015.         case 'wg':
  5016.           return "//archive.nyafuu.org/_/api/chan/post/?board=" + board + "&num=" + postID;
  5017.         case 'adv':
  5018.         case 'asp':
  5019.         case 'cm':
  5020.         case 'd':
  5021.         case 'e':
  5022.         case 'i':
  5023.         case 'lgbt':
  5024.         case 'n':
  5025.         case 'o':
  5026.         case 'p':
  5027.         case 'pol':
  5028.         case 's':
  5029.         case 's4s':
  5030.         case 't':
  5031.         case 'trv':
  5032.         case 'y':
  5033.           return "//archive.foolzashit.com/_/api/chan/post/?board=" + board + "&num=" + postID;
  5034.         case 'b':
  5035.         case 'e':
  5036.         case 'h':
  5037.         case 'hc':
  5038.         case 'p':
  5039.         case 's':
  5040.         case 'soc':
  5041.         case 'sp':
  5042.         case 'u':
  5043.           return "//fuuka.worldathleticproject.org/_/api/chan/post/?board=" + board + "&num=" + postID;
  5044.         case 'diy':
  5045.         case 'g':
  5046.         case 'sci':
  5047.           return "//archive.installgentoo.net/_/api/chan/post/?board=" + board + "&num=" + postID;
  5048.         case 'cgl':
  5049.         case 'g':
  5050.         case 'mu':
  5051.         case 'w':
  5052.           return "//rbt.asia/_/api/chan/post/?board=" + board + "&num=" + postID;
  5053.         case 'an':
  5054.         case 'fit':
  5055.         case 'k':
  5056.         case 'mlp':
  5057.         case 'r9k':
  5058.         case 'toy':
  5059.           return "//archive.heinessen.com/_/api/chan/post/?board=" + board + "&num=" + postID;
  5060.         case '3':
  5061.         case 'cgl':
  5062.         case 'ck':
  5063.         case 'fa':
  5064.         case 'ic':
  5065.         case 'jp':
  5066.         case 'lit':
  5067.         case 'q':
  5068.         case 'tg':
  5069.         case 'vr':
  5070.           return "//fuuka.warosu.org/_/api/chan/post/?board=" + board + "&num=" + postID;
  5071.       }
  5072.     },
  5073.     to: function(data) {
  5074.       var board, threadID, url;
  5075.       if (!data.isSearch) {
  5076.         threadID = data.threadID;
  5077.       }
  5078.       board = data.board;
  5079.       switch (board) {
  5080.         case 'a':
  5081.         case 'co':
  5082.         case 'gd':
  5083.         case 'jp':
  5084.         case 'm':
  5085.         case 'q':
  5086.         case 'sp':
  5087.         case 'tg':
  5088.         case 'tv':
  5089.         case 'v':
  5090.         case 'vg':
  5091.         case 'vp':
  5092.         case 'vr':
  5093.         case 'wsg':
  5094.           url = Redirect.path('//archive.foolz.us', 'foolfuuka', data);
  5095.           break;
  5096.         case 'u':
  5097.           url = Redirect.path('//nsfw.foolz.us', 'foolfuuka', data);
  5098.           break;
  5099.         case 'c':
  5100.         case 'int':
  5101.         case 'out':
  5102.         case 'po':
  5103.           url = Redirect.path('//archive.thedarkcave.org', 'foolfuuka', data);
  5104.           break;
  5105.         case 'hr':
  5106.         case 'tg':
  5107.         case 'tv':
  5108.         case 'x':
  5109.           url = Redirect.path('//archive.4plebs.org', 'foolfuuka', data);
  5110.           break;
  5111.         case 'c':
  5112.         case 'w':
  5113.         case 'wg':
  5114.           url = Redirect.path('//archive.nyafuu.org', 'foolfuuka', data);
  5115.           break;
  5116.         case 'adv':
  5117.         case 'asp':
  5118.         case 'cm':
  5119.         case 'd':
  5120.         case 'e':
  5121.         case 'i':
  5122.         case 'lgbt':
  5123.         case 'n':
  5124.         case 'o':
  5125.         case 'p':
  5126.         case 'pol':
  5127.         case 's':
  5128.         case 's4s':
  5129.         case 't':
  5130.         case 'trv':
  5131.         case 'y':
  5132.           url = Redirect.path('//archive.foolzashit.com', 'foolfuuka', data);
  5133.           break;
  5134.         case 'b':
  5135.         case 'e':
  5136.         case 'h':
  5137.         case 'hc':
  5138.         case 'p':
  5139.         case 's':
  5140.         case 'soc':
  5141.         case 'sp':
  5142.         case 'u':
  5143.           url = Redirect.path('//fuuka.worldathleticproject.org', 'fuuka', data);
  5144.           break;
  5145.         case 'diy':
  5146.         case 'g':
  5147.         case 'sci':
  5148.           url = Redirect.path('//archive.installgentoo.net', 'fuuka', data);
  5149.           break;
  5150.         case 'cgl':
  5151.         case 'g':
  5152.         case 'mu':
  5153.         case 'w':
  5154.           url = Redirect.path('//rbt.asia', 'fuuka', data);
  5155.           break;
  5156.         case 'an':
  5157.         case 'fit':
  5158.         case 'k':
  5159.         case 'mlp':
  5160.         case 'r9k':
  5161.         case 'toy':
  5162.           url = Redirect.path('http://archive.heinessen.com', 'fuuka', data);
  5163.           break;
  5164.         case '3':
  5165.         case 'cgl':
  5166.         case 'ck':
  5167.         case 'fa':
  5168.         case 'ic':
  5169.         case 'jp':
  5170.         case 'lit':
  5171.         case 'q':
  5172.         case 'tg':
  5173.         case 'vr':
  5174.           url = Redirect.path('//fuuka.warosu.org', 'fuuka', data);
  5175.           break;
  5176.         default:
  5177.           if (threadID) {
  5178.             url = "//boards.4chan.org/" + board + "/";
  5179.           }
  5180.       }
  5181.       return url || null;
  5182.     },
  5183.     path: function(base, archiver, data) {
  5184.       var board, path, postID, threadID, type, value;
  5185.       if (data.isSearch) {
  5186.         board = data.board, type = data.type, value = data.value;
  5187.         type = type === 'name' ? 'username' : type === 'md5' ? 'image' : type;
  5188.         value = encodeURIComponent(value);
  5189.         if (archiver === 'foolfuuka') {
  5190.           return "" + base + "/" + board + "/search/" + type + "/" + value;
  5191.         } else if (type === 'image') {
  5192.           return "" + base + "/" + board + "/?task=search2&search_media_hash=" + value;
  5193.         } else {
  5194.           return "" + base + "/" + board + "/?task=search2&search_" + type + "=" + value;
  5195.         }
  5196.       }
  5197.       board = data.board, threadID = data.threadID, postID = data.postID;
  5198.       if (postID) {
  5199.         postID = postID.match(/\d+/)[0];
  5200.       }
  5201.       path = threadID ? "" + board + "/thread/" + threadID : "" + board + "/post/" + postID;
  5202.       if (archiver === 'foolfuuka') {
  5203.         path += '/';
  5204.       }
  5205.       if (threadID && postID) {
  5206.         path += archiver === 'foolfuuka' ? "#" + postID : "#p" + postID;
  5207.       }
  5208.       return "" + base + "/" + path;
  5209.     }
  5210.   };
  5211.  
  5212.   ImageHover = {
  5213.     init: function() {
  5214.       return Main.callbacks.push(this.node);
  5215.     },
  5216.     node: function(post) {
  5217.       if (!post.img || post.hasPdf) {
  5218.         return;
  5219.       }
  5220.       return $.on(post.img, 'mouseover', ImageHover.mouseover);
  5221.     },
  5222.     mouseover: function() {
  5223.       var el, opts;
  5224.       if (el = $.id('ihover')) {
  5225.         if (el === UI.el) {
  5226.           delete UI.el;
  5227.         }
  5228.         $.rm(el);
  5229.       }
  5230.       if (UI.el) {
  5231.         return;
  5232.       }
  5233.       opts = this.parentNode.href.reverse().indexOf('m') == 0 ? {
  5234.         id: 'ihover',
  5235.         src: this.parentNode.href,
  5236.         autoplay: true,
  5237.         loop: true
  5238.       } : {
  5239.         id: 'ihover',
  5240.         src: this.parentNode.href
  5241.       };
  5242.       el = UI.el = $.el(opts.autoplay ? 'video' : 'img', opts);
  5243.       $.add(d.body, el);
  5244.       $.on(el, 'load', ImageHover.load);
  5245.       $.on(el, 'error', ImageHover.error);
  5246.       $.on(this, 'mousemove', UI.hover);
  5247.       return $.on(this, 'mouseout', ImageHover.mouseout);
  5248.     },
  5249.     load: function() {
  5250.       var style;
  5251.       if (!this.parentNode) {
  5252.         return;
  5253.       }
  5254.       style = this.style;
  5255.       return UI.hover({
  5256.         clientX: -45 + parseInt(style.left),
  5257.         clientY: 120 + parseInt(style.top)
  5258.       });
  5259.     },
  5260.     error: function() {
  5261.       var src, timeoutID, url,
  5262.         _this = this;
  5263.       src = this.src.split('/');
  5264.       if (!(src[2] === 'i.4cdn.org' && (url = Redirect.image(src[3], src[5])))) {
  5265.         if (g.dead) {
  5266.           return;
  5267.         }
  5268.         url = "//i.4cdn.org/" + src[3] + "/src/" + src[5];
  5269.       }
  5270.       if ($.engine !== 'webkit' && url.split('/')[2] === 'i.4cdn.org') {
  5271.         return;
  5272.       }
  5273.       timeoutID = setTimeout((function() {
  5274.         return _this.src = url;
  5275.       }), 3000);
  5276.       if ($.engine !== 'webkit' || url.split('/')[2] !== 'i.4cdn.org') {
  5277.         return;
  5278.       }
  5279.       return $.ajax(url, {
  5280.         onreadystatechange: (function() {
  5281.           if (this.status === 404) {
  5282.             return clearTimeout(timeoutID);
  5283.           }
  5284.         })
  5285.       }, {
  5286.         type: 'head'
  5287.       });
  5288.     },
  5289.     mouseout: function() {
  5290.       UI.hoverend();
  5291.       $.off(this, 'mousemove', UI.hover);
  5292.       return $.off(this, 'mouseout', ImageHover.mouseout);
  5293.     }
  5294.   };
  5295.  
  5296.   AutoGif = {
  5297.     init: function() {
  5298.       var _ref;
  5299.       if ((_ref = g.BOARD) === 'gif' || _ref === 'wsg') {
  5300.         return;
  5301.       }
  5302.       return Main.callbacks.push(this.node);
  5303.     },
  5304.     node: function(post) {
  5305.       var gif, img, src;
  5306.       img = post.img;
  5307.       if (post.el.hidden || !img) {
  5308.         return;
  5309.       }
  5310.       src = img.parentNode.href;
  5311.       if (/gif$/.test(src) && !/spoiler/.test(img.src)) {
  5312.         gif = $.el('img');
  5313.         $.on(gif, 'load', function() {
  5314.           return img.src = src;
  5315.         });
  5316.         return gif.src = src;
  5317.       }
  5318.     }
  5319.   };
  5320.  
  5321.   ImageExpand = {
  5322.     videos: [],
  5323.     init: function() {
  5324.       Main.callbacks.push(this.node);
  5325.       $.on(window, 'resize scroll visibilitychange', ImageExpand.videoHandler);
  5326.       return this.dialog();
  5327.     },
  5328.     node: function(post) {
  5329.       var a;
  5330.       if (!post.img || post.hasPdf) {
  5331.         return;
  5332.       }
  5333.       a = post.img.parentNode;
  5334.       $.on(a, 'click', ImageExpand.cb.toggle);
  5335.       if (ImageExpand.on && !post.el.hidden) {
  5336.         return ImageExpand.expand(post.img);
  5337.       }
  5338.     },
  5339.     cb: {
  5340.       toggle: function(e) {
  5341.         if (e.shiftKey || e.altKey || e.ctrlKey || e.metaKey || e.button !== 0) {
  5342.           return;
  5343.         }
  5344.         e.preventDefault();
  5345.         return ImageExpand.toggle(this);
  5346.       },
  5347.       all: function() {
  5348.         var i, thumb, thumbs, _i, _j, _k, _len, _len1, _len2, _ref;
  5349.         ImageExpand.on = this.checked;
  5350.         if (ImageExpand.on) {
  5351.           thumbs = $$('img[data-md5]');
  5352.           if (Conf['Expand From Current']) {
  5353.             for (i = _i = 0, _len = thumbs.length; _i < _len; i = ++_i) {
  5354.               thumb = thumbs[i];
  5355.               if (thumb.getBoundingClientRect().top > 0) {
  5356.                 break;
  5357.               }
  5358.             }
  5359.             thumbs = thumbs.slice(i);
  5360.           }
  5361.           for (_j = 0, _len1 = thumbs.length; _j < _len1; _j++) {
  5362.             thumb = thumbs[_j];
  5363.             ImageExpand.expand(thumb);
  5364.           }
  5365.         } else {
  5366.           _ref = $$('img[data-md5][hidden]');
  5367.           for (_k = 0, _len2 = _ref.length; _k < _len2; _k++) {
  5368.             thumb = _ref[_k];
  5369.             ImageExpand.contract(thumb);
  5370.           }
  5371.         }
  5372.       },
  5373.       typeChange: function() {
  5374.         var klass;
  5375.         switch (this.value) {
  5376.           case 'full':
  5377.             klass = '';
  5378.             break;
  5379.           case 'fit width':
  5380.             klass = 'fitwidth';
  5381.             break;
  5382.           case 'fit height':
  5383.             klass = 'fitheight';
  5384.             break;
  5385.           case 'fit screen':
  5386.             klass = 'fitwidth fitheight';
  5387.         }
  5388.         $.id('delform').className = klass;
  5389.         if (/\bfitheight\b/.test(klass)) {
  5390.           $.on(window, 'resize', ImageExpand.resize);
  5391.           if (!ImageExpand.style) {
  5392.             ImageExpand.style = $.addStyle('');
  5393.           }
  5394.           return ImageExpand.resize();
  5395.         } else if (ImageExpand.style) {
  5396.           return $.off(window, 'resize', ImageExpand.resize);
  5397.         }
  5398.       }
  5399.     },
  5400.     toggle: function(a) {
  5401.       var rect, thumb;
  5402.       thumb = a.firstChild;
  5403.       if (thumb.hidden) {
  5404.         rect = a.getBoundingClientRect();
  5405.         if (rect.bottom > 0) {
  5406.           if ($.engine === 'webkit') {
  5407.             if (rect.top < 0) {
  5408.               d.body.scrollTop += rect.top - 42;
  5409.             }
  5410.             if (rect.left < 0) {
  5411.               d.body.scrollLeft += rect.left;
  5412.             }
  5413.           } else {
  5414.             if (rect.top < 0) {
  5415.               d.documentElement.scrollTop += rect.top - 42;
  5416.             }
  5417.             if (rect.left < 0) {
  5418.               d.documentElement.scrollLeft += rect.left;
  5419.             }
  5420.           }
  5421.         }
  5422.         return ImageExpand.contract(thumb);
  5423.       } else {
  5424.         return ImageExpand.expand(thumb);
  5425.       }
  5426.     },
  5427.     contract: function(thumb) {
  5428.       var node = thumb.nextSibling;
  5429.       thumb.hidden = false;
  5430.       node.hidden = true;
  5431.       if (node.loop) {
  5432.         node.pause();
  5433.         node.currentTime = 0;
  5434.       }
  5435.       return $.rmClass(thumb.parentNode.parentNode.parentNode, 'image_expanded');
  5436.     },
  5437.     expand: function(thumb, src) {
  5438.       var a, img, vid;
  5439.       if ($.x('ancestor-or-self::*[@hidden]', thumb)) {
  5440.         return;
  5441.       }
  5442.       a = thumb.parentNode;
  5443.       src || (src = a.href);
  5444.       if (/\.pdf$/.test(src)) {
  5445.         return;
  5446.       }
  5447.       thumb.hidden = true;
  5448.       $.addClass(thumb.parentNode.parentNode.parentNode, 'image_expanded');
  5449.       if ((img = thumb.nextSibling) && (img.nodeName === 'IMG' || (vid = img.nodeName === 'VIDEO'))) {
  5450.         img.hidden = false;
  5451.         vid && img.play();
  5452.         return;
  5453.       }
  5454.       img = src.reverse().lastIndexOf('m') == 0 ? $.el('video', {
  5455.         src: src,
  5456.         autoplay: true,
  5457.         loop: true
  5458.       }) : $.el('img', {
  5459.         src: src
  5460.       });
  5461.       if (img.loop) {
  5462.         ImageExpand.videos.push(img);
  5463.         $.on(img, 'canplay', ImageExpand.videoHandler);
  5464.       }
  5465.       $.on(img, 'error', ImageExpand.error);
  5466.       return $.after(thumb, img);
  5467.     },
  5468.     error: function() {
  5469.       var src, thumb, timeoutID, url;
  5470.       thumb = this.previousSibling;
  5471.       ImageExpand.contract(thumb);
  5472.       $.rm(this);
  5473.       src = this.src.split('/');
  5474.       if (!(src[2] === 'i.4cdn.org' && (url = Redirect.image(src[3], src[5])))) {
  5475.         if (g.dead) {
  5476.           return;
  5477.         }
  5478.         url = "//i.4cdn.org/" + src[3] + "/src/" + src[5];
  5479.       }
  5480.       if ($.engine !== 'webkit' && url.split('/')[2] === 'i.4cdn.org') {
  5481.         return;
  5482.       }
  5483.       timeoutID = setTimeout(ImageExpand.expand, 10000, thumb, url);
  5484.       if ($.engine !== 'webkit' || url.split('/')[2] !== 'i.4cdn.org') {
  5485.         return;
  5486.       }
  5487.       return $.ajax(url, {
  5488.         onreadystatechange: (function() {
  5489.           if (this.status === 404) {
  5490.             return clearTimeout(timeoutID);
  5491.           }
  5492.         })
  5493.       }, {
  5494.         type: 'head'
  5495.       });
  5496.     },
  5497.     dialog: function() {
  5498.       var controls, imageType, select;
  5499.       controls = $.el('div', {
  5500.         id: 'imgControls',
  5501.         innerHTML: "<select id=imageType name=imageType><option value=full>Full</option><option value='fit width'>Fit Width</option><option value='fit height'>Fit Height</option value='fit screen'><option value='fit screen'>Fit Screen</option></select><label>Expand Images<input type=checkbox id=imageExpand></label>"
  5502.       });
  5503.       imageType = $.get('imageType', 'full');
  5504.       select = $('select', controls);
  5505.       select.value = imageType;
  5506.       ImageExpand.cb.typeChange.call(select);
  5507.       $.on(select, 'change', $.cb.value);
  5508.       $.on(select, 'change', ImageExpand.cb.typeChange);
  5509.       $.on($('input', controls), 'click', ImageExpand.cb.all);
  5510.       return $.prepend($.id('delform'), controls);
  5511.     },
  5512.     resize: function() {
  5513.       return ImageExpand.style.textContent = ".fitheight img[data-md5] + *[src] {max-height:" + d.documentElement.clientHeight + "px;}";
  5514.     },
  5515.     videoHandler: function() {
  5516.       var i, _ref, v;
  5517.       _ref = ImageExpand.videos;
  5518.       for (i = 0; _ref.length > i; i++) {
  5519.         v = _ref[i];
  5520.         if ($.visible(v) && !v.hidden && !d.hidden) {
  5521.           v.play();
  5522.         } else {
  5523.           v.pause();
  5524.         }
  5525.       }
  5526.     }
  5527.   };
  5528.  
  5529.   CatalogLinks = {
  5530.     init: function() {
  5531.       var clone, el, nav, _i, _len, _ref;
  5532.       el = $.el('span', {
  5533.         className: 'toggleCatalog',
  5534.         innerHTML: '[<a href=javascript:;></a>]'
  5535.       });
  5536.       _ref = ['boardNavDesktop', 'boardNavDesktopFoot'];
  5537.       for (_i = 0, _len = _ref.length; _i < _len; _i++) {
  5538.         nav = _ref[_i];
  5539.         clone = el.cloneNode(true);
  5540.         $.on(clone.firstElementChild, 'click', this.toggle);
  5541.         $.add($.id(nav), clone);
  5542.       }
  5543.       return this.toggle(true);
  5544.     },
  5545.     toggle: function(onLoad) {
  5546.       var a, board, nav, root, useCatalog, _i, _j, _len, _len1, _ref, _ref1;
  5547.       if (onLoad === true) {
  5548.         useCatalog = $.get('CatalogIsToggled', g.CATALOG);
  5549.       } else {
  5550.         useCatalog = this.textContent === 'Catalog Off';
  5551.         $.set('CatalogIsToggled', useCatalog);
  5552.       }
  5553.       _ref = ['boardNavDesktop', 'boardNavDesktopFoot'];
  5554.       for (_i = 0, _len = _ref.length; _i < _len; _i++) {
  5555.         nav = _ref[_i];
  5556.         root = $.id(nav);
  5557.         _ref1 = $$('a[href*="boards.4chan.org"]', root);
  5558.         for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
  5559.           a = _ref1[_j];
  5560.           board = a.pathname.split('/')[1];
  5561.           if (board === 'f') {
  5562.             a.pathname = '/f/';
  5563.             continue;
  5564.           }
  5565.           a.pathname = "/" + board + "/" + (useCatalog ? 'catalog' : '');
  5566.         }
  5567.         a = $('.toggleCatalog', root).firstElementChild;
  5568.         a.textContent = "Catalog " + (useCatalog ? 'On' : 'Off');
  5569.         a.title = "Turn catalog links " + (useCatalog ? 'off' : 'on') + ".";
  5570.       }
  5571.     }
  5572.   };
  5573.  
  5574.   Main = {
  5575.     init: function() {
  5576.       var key, path, pathname, settings, temp, val;
  5577.       Main.flatten(null, Config);
  5578.       path = location.pathname;
  5579.       pathname = path.slice(1).split('/');
  5580.       g.BOARD = pathname[0], temp = pathname[1];
  5581.       switch (temp) {
  5582.         case 'res':
  5583.           g.REPLY = true;
  5584.           g.THREAD_ID = pathname[2];
  5585.           break;
  5586.         case 'catalog':
  5587.           g.CATALOG = true;
  5588.       }
  5589.       for (key in Conf) {
  5590.         val = Conf[key];
  5591.         Conf[key] = $.get(key, val);
  5592.       }
  5593.       switch (location.hostname) {
  5594.         case 'sys.4chan.org':
  5595.           if (/report/.test(location.search)) {
  5596.             $.ready(function() {
  5597.               var field, form;
  5598.               form = $('form');
  5599.               field = $.id('recaptcha_response_field');
  5600.               $.on(field, 'keydown', function(e) {
  5601.                 if (e.keyCode === 8 && !e.target.value) {
  5602.                   return window.location = 'javascript:Recaptcha.reload()';
  5603.                 }
  5604.               });
  5605.               return $.on(form, 'submit', function(e) {
  5606.                 var response;
  5607.                 e.preventDefault();
  5608.                 response = field.value.trim();
  5609.                 if (!/\s/.test(response)) {
  5610.                   field.value = "" + response + " " + response;
  5611.                 }
  5612.                 return form.submit();
  5613.               });
  5614.             });
  5615.           }
  5616.           return;
  5617.         case 'i.4cdn.org':
  5618.           $.ready(function() {
  5619.             var url;
  5620.             if (/^4chan - 404/.test(d.title) && Conf['404 Redirect']) {
  5621.               path = location.pathname.split('/');
  5622.               url = Redirect.image(path[1], path[3]);
  5623.               if (url) {
  5624.                 return location.href = url;
  5625.               }
  5626.             }
  5627.           });
  5628.           return;
  5629.       }
  5630.       if (Conf['Disable 4chan\'s extension']) {
  5631.         settings = JSON.parse(localStorage.getItem('4chan-settings')) || {};
  5632.         settings.disableAll = true;
  5633.         localStorage.setItem('4chan-settings', JSON.stringify(settings));
  5634.       }
  5635.       Main.polyfill();
  5636.       if (g.CATALOG) {
  5637.         return $.ready(Main.catalog);
  5638.       } else {
  5639.         return Main.features();
  5640.       }
  5641.     },
  5642.     polyfill: function() {
  5643.       var event, prefix, property;
  5644.       if (!('visibilityState' in document)) {
  5645.         prefix = 'mozVisibilityState' in document ? 'moz' : 'webkitVisibilityState' in document ? 'webkit' : 'o';
  5646.         property = prefix + 'VisibilityState';
  5647.         event = prefix + 'visibilitychange';
  5648.         d.visibilityState = d[property];
  5649.         d.hidden = d.visibilityState === 'hidden';
  5650.         return $.on(d, event, function() {
  5651.           d.visibilityState = d[property];
  5652.           d.hidden = d.visibilityState === 'hidden';
  5653.           return $.event(d, new CustomEvent('visibilitychange'));
  5654.         });
  5655.       }
  5656.     },
  5657.     catalog: function() {
  5658.       if (Conf['Catalog Links']) {
  5659.         CatalogLinks.init();
  5660.       }
  5661.       if (Conf['Thread Hiding']) {
  5662.         return ThreadHiding.init();
  5663.       }
  5664.     },
  5665.     features: function() {
  5666.       var cutoff, hiddenThreads, id, now, timestamp, _ref;
  5667.       Options.init();
  5668.       if (Conf['Quick Reply'] && Conf['Hide Original Post Form']) {
  5669.         Main.css += '#postForm { display: none; }';
  5670.       }
  5671.       $.addStyle(Main.css);
  5672.       now = Date.now();
  5673.       g.hiddenReplies = $.get("hiddenReplies/" + g.BOARD + "/", {});
  5674.       if ($.get('lastChecked', 0) < now - 1 * $.DAY) {
  5675.         $.set('lastChecked', now);
  5676.         cutoff = now - 7 * $.DAY;
  5677.         hiddenThreads = $.get("hiddenThreads/" + g.BOARD + "/", {});
  5678.         for (id in hiddenThreads) {
  5679.           timestamp = hiddenThreads[id];
  5680.           if (timestamp < cutoff) {
  5681.             delete hiddenThreads[id];
  5682.           }
  5683.         }
  5684.         _ref = g.hiddenReplies;
  5685.         for (id in _ref) {
  5686.           timestamp = _ref[id];
  5687.           if (timestamp < cutoff) {
  5688.             delete g.hiddenReplies[id];
  5689.           }
  5690.         }
  5691.         $.set("hiddenThreads/" + g.BOARD + "/", hiddenThreads);
  5692.         $.set("hiddenReplies/" + g.BOARD + "/", g.hiddenReplies);
  5693.       }
  5694.       if (Conf['Filter']) {
  5695.         Filter.init();
  5696.       }
  5697.       if (Conf['Reply Hiding']) {
  5698.         ReplyHiding.init();
  5699.       }
  5700.       if (Conf['Filter'] || Conf['Reply Hiding']) {
  5701.         StrikethroughQuotes.init();
  5702.       }
  5703.       if (Conf['Anonymize']) {
  5704.         Anonymize.init();
  5705.       }
  5706.       if (Conf['Time Formatting']) {
  5707.         Time.init();
  5708.       }
  5709.       if (Conf['Relative Post Dates']) {
  5710.         RelativeDates.init();
  5711.       }
  5712.       if (Conf['File Info Formatting']) {
  5713.         FileInfo.init();
  5714.       }
  5715.       if (Conf['Sauce']) {
  5716.         Sauce.init();
  5717.       }
  5718.       if (Conf['Reveal Spoilers']) {
  5719.         RevealSpoilers.init();
  5720.       }
  5721.       if (Conf['Image Auto-Gif']) {
  5722.         AutoGif.init();
  5723.       }
  5724.       if (Conf['Image Hover']) {
  5725.         ImageHover.init();
  5726.       }
  5727.       if (Conf['Menu']) {
  5728.         Menu.init();
  5729.         if (Conf['Report Link']) {
  5730.           ReportLink.init();
  5731.         }
  5732.         if (Conf['Delete Link']) {
  5733.           DeleteLink.init();
  5734.         }
  5735.         if (Conf['Filter']) {
  5736.           Filter.menuInit();
  5737.         }
  5738.         if (Conf['Download Link']) {
  5739.           DownloadLink.init();
  5740.         }
  5741.         if (Conf['Archive Link']) {
  5742.           ArchiveLink.init();
  5743.         }
  5744.       }
  5745.       if (Conf['Resurrect Quotes']) {
  5746.         Quotify.init();
  5747.       }
  5748.       if (Conf['Quote Inline']) {
  5749.         QuoteInline.init();
  5750.       }
  5751.       if (Conf['Quote Preview']) {
  5752.         QuotePreview.init();
  5753.       }
  5754.       if (Conf['Quote Backlinks']) {
  5755.         QuoteBacklink.init();
  5756.       }
  5757.       if (Conf['Indicate OP quote']) {
  5758.         QuoteOP.init();
  5759.       }
  5760.       if (Conf['Indicate Cross-thread Quotes']) {
  5761.         QuoteCT.init();
  5762.       }
  5763.       return $.ready(Main.featuresReady);
  5764.     },
  5765.     featuresReady: function() {
  5766.       var MutationObserver, a, board, nav, node, nodes, observer, _i, _j, _len, _len1, _ref, _ref1;
  5767.       $.globalEval("loadRecaptcha()");
  5768.       if (/^4chan - 404/.test(d.title)) {
  5769.         if (Conf['404 Redirect'] && /^\d+$/.test(g.THREAD_ID)) {
  5770.           location.href = Redirect.to({
  5771.             board: g.BOARD,
  5772.             threadID: g.THREAD_ID,
  5773.             postID: location.hash
  5774.           });
  5775.         }
  5776.         return;
  5777.       }
  5778.       if (!$.id('navtopright')) {
  5779.         return;
  5780.       }
  5781.       $.addClass(d.body, $.engine);
  5782.       $.addClass(d.body, 'fourchan_x');
  5783.       _ref = ['boardNavDesktop', 'boardNavDesktopFoot'];
  5784.       for (_i = 0, _len = _ref.length; _i < _len; _i++) {
  5785.         nav = _ref[_i];
  5786.         if (a = $("a[href$='/" + g.BOARD + "/']", $.id(nav))) {
  5787.           $.addClass(a, 'current');
  5788.         }
  5789.       }
  5790.       Favicon.init();
  5791.       if (Conf['Quick Reply']) {
  5792.         QR.init();
  5793.       }
  5794.       if (Conf['Image Expansion']) {
  5795.         ImageExpand.init();
  5796.       }
  5797.       if (Conf['Catalog Links']) {
  5798.         CatalogLinks.init();
  5799.       }
  5800.       if (Conf['Thread Watcher']) {
  5801.         setTimeout(function() {
  5802.           return Watcher.init();
  5803.         });
  5804.       }
  5805.       if (Conf['Keybinds']) {
  5806.         setTimeout(function() {
  5807.           return Keybinds.init();
  5808.         });
  5809.       }
  5810.       if (g.REPLY) {
  5811.         if (Conf['Thread Updater']) {
  5812.           setTimeout(function() {
  5813.             return Updater.init();
  5814.           });
  5815.         }
  5816.         if (Conf['Thread Stats']) {
  5817.           ThreadStats.init();
  5818.         }
  5819.         if (Conf['Reply Navigation']) {
  5820.           setTimeout(function() {
  5821.             return Nav.init();
  5822.           });
  5823.         }
  5824.         if (Conf['Post in Title']) {
  5825.           TitlePost.init();
  5826.         }
  5827.         if (Conf['Unread Count'] || Conf['Unread Favicon']) {
  5828.           Unread.init();
  5829.         }
  5830.       } else {
  5831.         if (Conf['Thread Hiding']) {
  5832.           ThreadHiding.init();
  5833.         }
  5834.         if (Conf['Thread Expansion']) {
  5835.           setTimeout(function() {
  5836.             return ExpandThread.init();
  5837.           });
  5838.         }
  5839.         if (Conf['Comment Expansion']) {
  5840.           setTimeout(function() {
  5841.             return ExpandComment.init();
  5842.           });
  5843.         }
  5844.         if (Conf['Index Navigation']) {
  5845.           setTimeout(function() {
  5846.             return Nav.init();
  5847.           });
  5848.         }
  5849.       }
  5850.       board = $('.board');
  5851.       nodes = [];
  5852.       _ref1 = $$('.postContainer', board);
  5853.       for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
  5854.         node = _ref1[_j];
  5855.         nodes.push(Main.preParse(node));
  5856.       }
  5857.       Main.node(nodes, true);
  5858.       Main.hasCodeTags = !!$('script[src^="//static.4chan.org/js/prettify/prettify"]');
  5859.       if (MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.OMutationObserver) {
  5860.         observer = new MutationObserver(Main.observer);
  5861.         observer.observe(board, {
  5862.           childList: true,
  5863.           subtree: true
  5864.         });
  5865.       } else {
  5866.         $.on(board, 'DOMNodeInserted', Main.listener);
  5867.       }
  5868.     },
  5869.     flatten: function(parent, obj) {
  5870.       var key, val;
  5871.       if (obj instanceof Array) {
  5872.         Conf[parent] = obj[0];
  5873.       } else if (typeof obj === 'object') {
  5874.         for (key in obj) {
  5875.           val = obj[key];
  5876.           Main.flatten(key, val);
  5877.         }
  5878.       } else {
  5879.         Conf[parent] = obj;
  5880.       }
  5881.     },
  5882.     preParse: function(node) {
  5883.       var el, img, imgParent, parentClass, post;
  5884.       parentClass = node.parentNode.className;
  5885.       el = $('.post', node);
  5886.       post = {
  5887.         root: node,
  5888.         el: el,
  5889.         "class": el.className,
  5890.         ID: el.id.match(/\d+$/)[0],
  5891.         threadID: g.THREAD_ID || $.x('ancestor::div[parent::div[@class="board"]]', node).id.match(/\d+$/)[0],
  5892.         isArchived: /\barchivedPost\b/.test(parentClass),
  5893.         isInlined: /\binline\b/.test(parentClass),
  5894.         isCrosspost: /\bcrosspost\b/.test(parentClass),
  5895.         blockquote: el.lastElementChild,
  5896.         quotes: el.getElementsByClassName('quotelink'),
  5897.         backlinks: el.getElementsByClassName('backlink'),
  5898.         fileInfo: false,
  5899.         img: false
  5900.       };
  5901.       if (img = $('img[data-md5]', el)) {
  5902.         imgParent = img.parentNode;
  5903.         post.img = img;
  5904.         post.fileInfo = $('.fileText', el);
  5905.         post.hasPdf = /\.pdf$/.test(imgParent.href);
  5906.       }
  5907.       Main.prettify(post.blockquote);
  5908.       return post;
  5909.     },
  5910.     node: function(nodes, notify) {
  5911.       var callback, err, node, _i, _j, _len, _len1, _ref;
  5912.       _ref = Main.callbacks;
  5913.       for (_i = 0, _len = _ref.length; _i < _len; _i++) {
  5914.         callback = _ref[_i];
  5915.         try {
  5916.           for (_j = 0, _len1 = nodes.length; _j < _len1; _j++) {
  5917.             node = nodes[_j];
  5918.             callback(node);
  5919.           }
  5920.         } catch (_error) {
  5921.           err = _error;
  5922.           if (notify) {
  5923.             alert("4chan X (" + Main.version + ") error: " + err.message + "\nReport the bug at mayhemydg.github.io/4chan-x/#bug-report\n\nURL: " + window.location + "\n" + err.stack);
  5924.           }
  5925.         }
  5926.       }
  5927.     },
  5928.     observer: function(mutations) {
  5929.       var addedNode, mutation, nodes, _i, _j, _len, _len1, _ref;
  5930.       nodes = [];
  5931.       for (_i = 0, _len = mutations.length; _i < _len; _i++) {
  5932.         mutation = mutations[_i];
  5933.         _ref = mutation.addedNodes;
  5934.         for (_j = 0, _len1 = _ref.length; _j < _len1; _j++) {
  5935.           addedNode = _ref[_j];
  5936.           if (/\bpostContainer\b/.test(addedNode.className)) {
  5937.             nodes.push(Main.preParse(addedNode));
  5938.           }
  5939.         }
  5940.       }
  5941.       if (nodes.length) {
  5942.         return Main.node(nodes);
  5943.       }
  5944.     },
  5945.     listener: function(e) {
  5946.       var target;
  5947.       target = e.target;
  5948.       if (/\bpostContainer\b/.test(target.className)) {
  5949.         return Main.node([Main.preParse(target)]);
  5950.       }
  5951.     },
  5952.     prettify: function(bq) {
  5953.       var code;
  5954.       if (!Main.hasCodeTags) {
  5955.         return;
  5956.       }
  5957.       code = function() {
  5958.         var pre, _i, _len, _ref;
  5959.         _ref = document.getElementById('_id_').getElementsByClassName('prettyprint');
  5960.         for (_i = 0, _len = _ref.length; _i < _len; _i++) {
  5961.           pre = _ref[_i];
  5962.           pre.innerHTML = prettyPrintOne(pre.innerHTML.replace(/\s/g, '&nbsp;'));
  5963.         }
  5964.       };
  5965.       return $.globalEval(("(" + code + ")()").replace('_id_', bq.id));
  5966.     },
  5967.     namespace: '4chan_x.',
  5968.     version: '2.39.6',
  5969.     callbacks: [],
  5970.     css: '\
  5971. /* dialog styling */\
  5972. .dialog.reply {\
  5973.  display: block;\
  5974.  border: 1px solid rgba(0,0,0,.25);\
  5975.  padding: 0;\
  5976. }\
  5977. .move {\
  5978.  cursor: move;\
  5979. }\
  5980. label, .favicon {\
  5981.  cursor: pointer;\
  5982. }\
  5983. a[href="javascript:;"] {\
  5984.  text-decoration: none;\
  5985. }\
  5986. .warning {\
  5987.  color: red;\
  5988. }\
  5989. \
  5990. .hide_thread_button:not(.hidden_thread) {\
  5991.  float: left;\
  5992. }\
  5993. \
  5994. .thread > .hidden_thread ~ *,\
  5995. [hidden],\
  5996. #content > [name=tab]:not(:checked) + div,\
  5997. #updater:not(:hover) > :not(.move),\
  5998. .autohide:not(:hover) > form,\
  5999. #qp input, .forwarded {\
  6000.  display: none !important;\
  6001. }\
  6002. \
  6003. .menu_button {\
  6004.  display: inline-block;\
  6005. }\
  6006. .menu_button > span {\
  6007.  border-top:   .5em solid;\
  6008.  border-right: .3em solid transparent;\
  6009.  border-left:  .3em solid transparent;\
  6010.  display: inline-block;\
  6011.  margin: 2px;\
  6012.  vertical-align: middle;\
  6013. }\
  6014. #menu {\
  6015.  position: absolute;\
  6016.  outline: none;\
  6017. }\
  6018. .entry {\
  6019.  border-bottom: 1px solid rgba(0, 0, 0, .25);\
  6020.  cursor: pointer;\
  6021.  display: block;\
  6022.  outline: none;\
  6023.  padding: 3px 7px;\
  6024.  position: relative;\
  6025.  text-decoration: none;\
  6026.  white-space: nowrap;\
  6027. }\
  6028. .entry:last-child {\
  6029.  border: none;\
  6030. }\
  6031. .focused.entry {\
  6032.  background: rgba(255, 255, 255, .33);\
  6033. }\
  6034. .entry.hasSubMenu {\
  6035.  padding-right: 1.5em;\
  6036. }\
  6037. .hasSubMenu::after {\
  6038.  content: "";\
  6039.  border-left:   .5em solid;\
  6040.  border-top:    .3em solid transparent;\
  6041.  border-bottom: .3em solid transparent;\
  6042.  display: inline-block;\
  6043.  margin: .3em;\
  6044.  position: absolute;\
  6045.  right: 3px;\
  6046. }\
  6047. .hasSubMenu:not(.focused) > .subMenu {\
  6048.  display: none;\
  6049. }\
  6050. .subMenu {\
  6051.  position: absolute;\
  6052.  left: 100%;\
  6053.  top: 0;\
  6054.  margin-top: -1px;\
  6055. }\
  6056. \
  6057. h1 {\
  6058.  text-align: center;\
  6059. }\
  6060. #qr > .move {\
  6061.  min-width: 300px;\
  6062.  overflow: hidden;\
  6063.  box-sizing: border-box;\
  6064.  -moz-box-sizing: border-box;\
  6065.  padding: 0 2px;\
  6066. }\
  6067. #qr > .move > span {\
  6068.  float: right;\
  6069. }\
  6070. #autohide, .close, #qr select, #dump, .remove, .captchaimg, #qr div.warning {\
  6071.  cursor: pointer;\
  6072. }\
  6073. #qr select,\
  6074. #qr > form {\
  6075.  margin: 0;\
  6076. }\
  6077. #dump {\
  6078.  background: -webkit-linear-gradient(#EEE, #CCC);\
  6079.  background: -moz-linear-gradient(#EEE, #CCC);\
  6080.  background: -o-linear-gradient(#EEE, #CCC);\
  6081.  background: linear-gradient(#EEE, #CCC);\
  6082.  width: 10%;\
  6083. }\
  6084. .gecko #dump {\
  6085.  padding: 1px 0 2px;\
  6086. }\
  6087. #dump:hover, #dump:focus {\
  6088.  background: -webkit-linear-gradient(#FFF, #DDD);\
  6089.  background: -moz-linear-gradient(#FFF, #DDD);\
  6090.  background: -o-linear-gradient(#FFF, #DDD);\
  6091.  background: linear-gradient(#FFF, #DDD);\
  6092. }\
  6093. #dump:active, .dump #dump:not(:hover):not(:focus) {\
  6094.  background: -webkit-linear-gradient(#CCC, #DDD);\
  6095.  background: -moz-linear-gradient(#CCC, #DDD);\
  6096.  background: -o-linear-gradient(#CCC, #DDD);\
  6097.  background: linear-gradient(#CCC, #DDD);\
  6098. }\
  6099. #qr:not(.dump) #replies, .dump > form > label {\
  6100.  display: none;\
  6101. }\
  6102. #replies {\
  6103.  display: block;\
  6104.  height: 100px;\
  6105.  position: relative;\
  6106.  -webkit-user-select: none;\
  6107.  -moz-user-select: none;\
  6108.  -o-user-select: none;\
  6109.  user-select: none;\
  6110. }\
  6111. #replies > div {\
  6112.  counter-reset: thumbnails;\
  6113.  top: 0; right: 0; bottom: 0; left: 0;\
  6114.  margin: 0; padding: 0;\
  6115.  overflow: hidden;\
  6116.  position: absolute;\
  6117.  white-space: pre;\
  6118. }\
  6119. #replies > div:hover {\
  6120.  bottom: -10px;\
  6121.  overflow-x: auto;\
  6122.  z-index: 1;\
  6123. }\
  6124. .thumbnail {\
  6125.  background-color: rgba(0,0,0,.2) !important;\
  6126.  background-position: 50% 20% !important;\
  6127.  background-size: cover !important;\
  6128.  border: 1px solid #666;\
  6129.  box-sizing: border-box;\
  6130.  -moz-box-sizing: border-box;\
  6131.  cursor: move;\
  6132.  display: inline-block;\
  6133.  height: 90px; width: 90px;\
  6134.  margin: 5px; padding: 2px;\
  6135.  opacity: .5;\
  6136.  outline: none;\
  6137.  overflow: hidden;\
  6138.  position: relative;\
  6139.  text-shadow: 0 1px 1px #000;\
  6140.  -webkit-transition: opacity .25s ease-in-out;\
  6141.  -moz-transition: opacity .25s ease-in-out;\
  6142.  -o-transition: opacity .25s ease-in-out;\
  6143.  transition: opacity .25s ease-in-out;\
  6144.  vertical-align: top;\
  6145. }\
  6146. .thumbnail:hover, .thumbnail:focus {\
  6147.  opacity: .9;\
  6148. }\
  6149. .thumbnail#selected {\
  6150.  opacity: 1;\
  6151. }\
  6152. .thumbnail::before {\
  6153.  counter-increment: thumbnails;\
  6154.  content: counter(thumbnails);\
  6155.  color: #FFF;\
  6156.  font-weight: 700;\
  6157.  padding: 3px;\
  6158.  position: absolute;\
  6159.  top: 0;\
  6160.  right: 0;\
  6161.  text-shadow: 0 0 3px #000, 0 0 8px #000;\
  6162. }\
  6163. .thumbnail.drag {\
  6164.  box-shadow: 0 0 10px rgba(0,0,0,.5);\
  6165. }\
  6166. .thumbnail.over {\
  6167.  border-color: #FFF;\
  6168. }\
  6169. .thumbnail > span {\
  6170.  color: #FFF;\
  6171. }\
  6172. .remove {\
  6173.  background: none;\
  6174.  color: #E00;\
  6175.  font-weight: 700;\
  6176.  padding: 3px;\
  6177. }\
  6178. .remove:hover::after {\
  6179.  content: " Remove";\
  6180. }\
  6181. .thumbnail > label {\
  6182.  background: rgba(0,0,0,.5);\
  6183.  color: #FFF;\
  6184.  right: 0; bottom: 0; left: 0;\
  6185.  position: absolute;\
  6186.  text-align: center;\
  6187. }\
  6188. .thumbnail > label > input {\
  6189.  margin: 0;\
  6190. }\
  6191. #addReply {\
  6192.  color: #333;\
  6193.  font-size: 3.5em;\
  6194.  line-height: 100px;\
  6195. }\
  6196. #addReply:hover, #addReply:focus {\
  6197.  color: #000;\
  6198. }\
  6199. .field {\
  6200.  border: 1px solid #CCC;\
  6201.  box-sizing: border-box;\
  6202.  -moz-box-sizing: border-box;\
  6203.  color: #333;\
  6204.  font: 13px sans-serif;\
  6205.  margin: 0;\
  6206.  padding: 2px 4px 3px;\
  6207.  -webkit-transition: color .25s, border .25s;\
  6208.  -moz-transition: color .25s, border .25s;\
  6209.  -o-transition: color .25s, border .25s;\
  6210.  transition: color .25s, border .25s;\
  6211. }\
  6212. .field:-moz-placeholder,\
  6213. .field:hover:-moz-placeholder {\
  6214.  color: #AAA;\
  6215. }\
  6216. .field:hover, .field:focus {\
  6217.  border-color: #999;\
  6218.  color: #000;\
  6219.  outline: none;\
  6220. }\
  6221. #qr > form > div:first-child > .field:not(#dump) {\
  6222.  width: 30%;\
  6223. }\
  6224. #qr textarea.field {\
  6225.  display: -webkit-box;\
  6226.  min-height: 160px;\
  6227.  min-width: 100%;\
  6228. }\
  6229. #qr.captcha textarea.field {\
  6230.  min-height: 120px;\
  6231. }\
  6232. .textarea {\
  6233.  position: relative;\
  6234. }\
  6235. #charCount {\
  6236.  color: #000;\
  6237.  background: hsla(0, 0%, 100%, .5);\
  6238.  font-size: 8pt;\
  6239.  margin: 1px;\
  6240.  position: absolute;\
  6241.  bottom: 0;\
  6242.  right: 0;\
  6243.  pointer-events: none;\
  6244. }\
  6245. #charCount.warning {\
  6246.  color: red;\
  6247. }\
  6248. .captchainput > .field {\
  6249.  min-width: 100%;\
  6250. }\
  6251. .captchaimg {\
  6252.  background: #FFF;\
  6253.  outline: 1px solid #CCC;\
  6254.  outline-offset: -1px;\
  6255.  text-align: center;\
  6256. }\
  6257. .captchaimg > img {\
  6258.  display: block;\
  6259.  height: 57px;\
  6260.  width: 300px;\
  6261. }\
  6262. #qr [type=file] {\
  6263.  margin: 1px 0;\
  6264.  width: 70%;\
  6265. }\
  6266. #qr [type=submit] {\
  6267.  margin: 1px 0;\
  6268.  padding: 1px; /* not Gecko */\
  6269.  width: 30%;\
  6270. }\
  6271. .gecko #qr [type=submit] {\
  6272.  padding: 0 1px; /* Gecko does not respect box-sizing: border-box */\
  6273. }\
  6274. \
  6275. .fileText:hover .fntrunc,\
  6276. .fileText:not(:hover) .fnfull {\
  6277.  display: none;\
  6278. }\
  6279. .fitwidth img[data-md5] + *[src] {\
  6280.  max-width: 100%;\
  6281. }\
  6282. .gecko  .fitwidth img[data-md5] + *[src],\
  6283. .presto .fitwidth img[data-md5] + *[src] {\
  6284.  width: 100%;\
  6285. }\
  6286. \
  6287. #qr, #qp, #updater, #stats, #ihover, #overlay, #navlinks {\
  6288.  position: fixed;\
  6289. }\
  6290. \
  6291. #ihover {\
  6292.  max-height: 97%;\
  6293.  max-width: 75%;\
  6294.  padding-bottom: 18px;\
  6295. }\
  6296. \
  6297. #navlinks {\
  6298.  font-size: 16px;\
  6299.  top: 25px;\
  6300.  right: 5px;\
  6301. }\
  6302. \
  6303. body {\
  6304.  box-sizing: border-box;\
  6305.  -moz-box-sizing: border-box;\
  6306. }\
  6307. body.unscroll {\
  6308.  overflow: hidden;\
  6309. }\
  6310. #overlay {\
  6311.  top: 0;\
  6312.  left: 0;\
  6313.  width: 100%;\
  6314.  height: 100%;\
  6315.  text-align: center;\
  6316.  background: rgba(0,0,0,.5);\
  6317.  z-index: 1;\
  6318. }\
  6319. #overlay::after {\
  6320.  content: "";\
  6321.  display: inline-block;\
  6322.  height: 100%;\
  6323.  vertical-align: middle;\
  6324. }\
  6325. #options {\
  6326.  box-sizing: border-box;\
  6327.  -moz-box-sizing: border-box;\
  6328.  display: inline-block;\
  6329.  padding: 5px;\
  6330.  position: relative;\
  6331.  text-align: left;\
  6332.  vertical-align: middle;\
  6333.  width: 600px;\
  6334.  max-width: 100%;\
  6335.  height: 500px;\
  6336.  max-height: 100%;\
  6337. }\
  6338. #credits {\
  6339.  float: right;\
  6340. }\
  6341. #options ul {\
  6342.  padding: 0;\
  6343. }\
  6344. #options article li {\
  6345.  margin: 10px 0 10px 2em;\
  6346. }\
  6347. #options code {\
  6348.  background: hsla(0, 0%, 100%, .5);\
  6349.  color: #000;\
  6350.  padding: 0 1px;\
  6351. }\
  6352. #options label {\
  6353.  text-decoration: underline;\
  6354. }\
  6355. #content {\
  6356.  overflow: auto;\
  6357.  position: absolute;\
  6358.  top: 2.5em;\
  6359.  right: 5px;\
  6360.  bottom: 5px;\
  6361.  left: 5px;\
  6362. }\
  6363. #content textarea {\
  6364.  font-family: monospace;\
  6365.  min-height: 350px;\
  6366.  resize: vertical;\
  6367.  width: 100%;\
  6368. }\
  6369. \
  6370. #updater {\
  6371.  text-align: right;\
  6372. }\
  6373. #updater:not(:hover) {\
  6374.  border: none;\
  6375.  background: transparent;\
  6376. }\
  6377. #updater input[type=number] {\
  6378.  width: 4em;\
  6379. }\
  6380. .new {\
  6381.  background: lime;\
  6382. }\
  6383. \
  6384. #watcher {\
  6385.  padding-bottom: 5px;\
  6386.  position: absolute;\
  6387.  overflow: hidden;\
  6388.  white-space: nowrap;\
  6389. }\
  6390. #watcher:not(:hover) {\
  6391.  max-height: 220px;\
  6392. }\
  6393. #watcher > div {\
  6394.  max-width: 200px;\
  6395.  overflow: hidden;\
  6396.  padding-left: 5px;\
  6397.  padding-right: 5px;\
  6398.  text-overflow: ellipsis;\
  6399. }\
  6400. #watcher > .move {\
  6401.  padding-top: 5px;\
  6402.  text-decoration: underline;\
  6403. }\
  6404. \
  6405. #qp {\
  6406.  padding: 2px 2px 5px;\
  6407. }\
  6408. #qp .post {\
  6409.  border: none;\
  6410.  margin: 0;\
  6411.  padding: 0;\
  6412. }\
  6413. #qp img {\
  6414.  max-height: 300px;\
  6415.  max-width: 500px;\
  6416. }\
  6417. .qphl {\
  6418.  box-shadow: 0 0 0 2px rgba(216, 94, 49, .7);\
  6419. }\
  6420. .quotelink.deadlink {\
  6421.  text-decoration: underline !important;\
  6422. }\
  6423. .deadlink:not(.quotelink) {\
  6424.  text-decoration: none !important;\
  6425. }\
  6426. .inlined {\
  6427.  opacity: .5;\
  6428. }\
  6429. .inline {\
  6430.  border: 1px solid rgba(128, 128, 128, 0.5);\
  6431.  display: table;\
  6432.  margin: 2px;\
  6433.  padding: 2px;\
  6434. }\
  6435. .inline .post {\
  6436.  background: none;\
  6437.  border: none;\
  6438.  margin: 0;\
  6439.  padding: 0;\
  6440. }\
  6441. div.opContainer {\
  6442.  display: block !important;\
  6443. }\
  6444. .opContainer.filter_highlight {\
  6445.  box-shadow: inset 5px 0 rgba(255, 0, 0, .5);\
  6446. }\
  6447. .opContainer.filter_highlight.qphl {\
  6448.  box-shadow: inset 5px 0 rgba(255, 0, 0, .5),\
  6449.              0 0 0 2px rgba(216, 94, 49, .7);\
  6450. }\
  6451. .filter_highlight > .reply {\
  6452.  box-shadow: -5px 0 rgba(255, 0, 0, .5);\
  6453. }\
  6454. .filter_highlight > .reply.qphl {\
  6455.  box-shadow: -5px 0 rgba(255, 0, 0, .5),\
  6456.              0 0 0 2px rgba(216, 94, 49, .7)\
  6457. }\
  6458. .filtered {\
  6459.  text-decoration: underline line-through;\
  6460. }\
  6461. .quotelink.forwardlink,\
  6462. .backlink.forwardlink {\
  6463.  text-decoration: none;\
  6464.  border-bottom: 1px dashed;\
  6465. }\
  6466. '
  6467.   };
  6468.  
  6469.   Main.init();
  6470.  
  6471. }).call(this);
  6472. document.addEventListener('keydown', function(e){
  6473.     if (e.altKey && e.keyCode == 65 && document.activeElement.name === "com") {
  6474.         document.activeElement.value += "[spoiler]​[/spoiler]";
  6475.     }
  6476. }, false)
Add Comment
Please, Sign In to add comment