Release 4chan X v1.11.23.0.

This commit is contained in:
ccd0 2016-01-24 20:52:02 -08:00
parent 96ba5f10ca
commit 96884b82b6
13 changed files with 733 additions and 678 deletions

View File

@ -2,6 +2,13 @@
Sometimes the changelog has notes (not comprehensive) acknowledging people's work. This does not mean the changes are their fault, only that their code was used. All changes to the script are chosen by and the fault of the maintainer (ccd0). Sometimes the changelog has notes (not comprehensive) acknowledging people's work. This does not mean the changes are their fault, only that their code was used. All changes to the script are chosen by and the fault of the maintainer (ccd0).
### v1.11.23
**v1.11.23.0** *(2016-01-24)* - [[Firefox](https://raw.githubusercontent.com/ccd0/4chan-x/1.11.23.0/builds/4chan-X-noupdate.user.js "Firefox version")] [[Chromium](https://raw.githubusercontent.com/ccd0/4chan-x/1.11.23.0/builds/4chan-X-noupdate.crx "Chromium version")]
- Based on v1.11.22.4.
- Show warnings when running multiple copies of 4chan X or the page doesn't load completely.
- Minor bugfixes.
### v1.11.22 ### v1.11.22
**v1.11.22.4** *(2016-01-23)* - [[Firefox](https://raw.githubusercontent.com/ccd0/4chan-x/1.11.22.4/builds/4chan-X-noupdate.user.js "Firefox version")] [[Chromium](https://raw.githubusercontent.com/ccd0/4chan-x/1.11.22.4/builds/4chan-X-noupdate.crx "Chromium version")] **v1.11.22.4** *(2016-01-23)* - [[Firefox](https://raw.githubusercontent.com/ccd0/4chan-x/1.11.22.4/builds/4chan-X-noupdate.user.js "Firefox version")] [[Chromium](https://raw.githubusercontent.com/ccd0/4chan-x/1.11.22.4/builds/4chan-X-noupdate.crx "Chromium version")]

Binary file not shown.

View File

@ -1,6 +1,6 @@
// ==UserScript== // ==UserScript==
// @name 4chan X beta // @name 4chan X beta
// @version 1.11.22.4 // @version 1.11.23.0
// @minGMVer 1.14 // @minGMVer 1.14
// @minFFVer 26 // @minFFVer 26
// @namespace 4chan-X // @namespace 4chan-X

View File

@ -1,7 +1,7 @@
// Generated by CoffeeScript // Generated by CoffeeScript
// ==UserScript== // ==UserScript==
// @name 4chan X beta // @name 4chan X beta
// @version 1.11.22.4 // @version 1.11.23.0
// @minGMVer 1.14 // @minGMVer 1.14
// @minFFVer 26 // @minFFVer 26
// @namespace 4chan-X // @namespace 4chan-X
@ -434,7 +434,7 @@
doc = d.documentElement; doc = d.documentElement;
g = { g = {
VERSION: '1.11.22.4', VERSION: '1.11.23.0',
NAMESPACE: '4chan X.', NAMESPACE: '4chan X.',
boards: {} boards: {}
}; };
@ -602,7 +602,7 @@
if (req = reqs[url]) { if (req = reqs[url]) {
if (req.readyState === 4) { if (req.readyState === 4) {
$.queueTask(function() { $.queueTask(function() {
return cb.call(req, req.evt); return cb.call(req, req.evt, true);
}); });
} else { } else {
req.callbacks.push(cb); req.callbacks.push(cb);
@ -622,13 +622,16 @@
} }
$.on(req, 'load', function(e) { $.on(req, 'load', function(e) {
var k, len1, ref; var k, len1, ref;
this.evt = e;
ref = this.callbacks; ref = this.callbacks;
for (k = 0, len1 = ref.length; k < len1; k++) { for (k = 0, len1 = ref.length; k < len1; k++) {
cb = ref[k]; cb = ref[k];
cb.call(this, e); $.queueTask((function(_this) {
return function() {
return cb.call(_this, e, false);
};
})(this));
} }
this.evt = e;
this.cached = true;
return delete this.callbacks; return delete this.callbacks;
}); });
$.on(req, 'abort error', rm); $.on(req, 'abort error', rm);
@ -2326,8 +2329,8 @@
this.root.textContent = "Loading post No." + this.postID + "..."; this.root.textContent = "Loading post No." + this.postID + "...";
if (this.threadID) { if (this.threadID) {
$.cache("//a.4cdn.org/" + this.boardID + "/thread/" + this.threadID + ".json", (function(_this) { $.cache("//a.4cdn.org/" + this.boardID + "/thread/" + this.threadID + ".json", (function(_this) {
return function(e) { return function(e, isCached) {
return _this.fetchedPost(e.target); return _this.fetchedPost(e.target, isCached);
}; };
})(this)); })(this));
} else { } else {
@ -2358,7 +2361,7 @@
return $.event('PostsInserted'); return $.event('PostsInserted');
}; };
Fetcher.prototype.fetchedPost = function(req) { Fetcher.prototype.fetchedPost = function(req, isCached) {
var api, board, k, len1, post, posts, status, thread; var api, board, k, len1, post, posts, status, thread;
if (post = g.posts[this.boardID + "." + this.postID]) { if (post = g.posts[this.boardID + "." + this.postID]) {
this.insert(post); this.insert(post);
@ -2382,14 +2385,14 @@
} }
} }
if (post.no !== this.postID) { if (post.no !== this.postID) {
if (req.cached) { if (isCached) {
api = "//a.4cdn.org/" + this.boardID + "/thread/" + this.threadID + ".json"; api = "//a.4cdn.org/" + this.boardID + "/thread/" + this.threadID + ".json";
$.cleanCache(function(url) { $.cleanCache(function(url) {
return url === api; return url === api;
}); });
$.cache(api, (function(_this) { $.cache(api, (function(_this) {
return function(e) { return function(e) {
return _this.fetchedPost(e.target); return _this.fetchedPost(e.target, false);
}; };
})(this)); })(this));
return; return;
@ -2424,7 +2427,7 @@
if (/^https:\/\//.test(url) || location.protocol === 'http:') { if (/^https:\/\//.test(url) || location.protocol === 'http:') {
$.cache(url, (function(_this) { $.cache(url, (function(_this) {
return function(e) { return function(e) {
return _this.parseArchivedPost(e.target.response, url); return _this.parseArchivedPost(e.target.response, url, archive);
}; };
})(this), { })(this), {
responseType: 'json', responseType: 'json',
@ -2445,7 +2448,7 @@
} }
} }
} }
return _this.parseArchivedPost(response, url); return _this.parseArchivedPost(response, url, archive);
}; };
})(this)); })(this));
return true; return true;
@ -2453,12 +2456,17 @@
return false; return false;
}; };
Fetcher.prototype.parseArchivedPost = function(data, url) { Fetcher.prototype.parseArchivedPost = function(data, url, archive) {
var board, comment, greentext, i, j, key, o, post, ref, ref1, text, text2, thread, val; var board, comment, greentext, i, j, key, o, post, ref, ref1, text, text2, thread, val;
if (post = g.posts[this.boardID + "." + this.postID]) { if (post = g.posts[this.boardID + "." + this.postID]) {
this.insert(post); this.insert(post);
return; return;
} }
if (data == null) {
$.addClass(this.root, 'warning');
this.root.textContent = "Error fetching Post No." + this.postID + " from " + archive.name + ".";
return;
}
if (data.error) { if (data.error) {
$.addClass(this.root, 'warning'); $.addClass(this.root, 'warning');
this.root.textContent = data.error; this.root.textContent = data.error;
@ -2741,11 +2749,11 @@
a.className = 'current'; a.className = 'current';
} }
Main.ready(function() { Main.ready(function() {
var oldFooter; var absbot, oldFooter;
if (oldFooter = $.id('boardNavDesktopFoot')) { if ((oldFooter = $.id('boardNavDesktopFoot'))) {
return $.replace($('.boardList', oldFooter), Header.bottomBoardList); return $.replace($('.boardList', oldFooter), Header.bottomBoardList);
} else { } else if ((absbot = $.id('absbot'))) {
$.before($.id('absbot'), footer); $.before(absbot, footer);
return $.globalEval('window.cloneTopNav = function() {};'); return $.globalEval('window.cloneTopNav = function() {};');
} }
}); });
@ -3256,12 +3264,12 @@
Index = { Index = {
showHiddenThreads: false, showHiddenThreads: false,
changed: {},
init: function() { init: function() {
var anchorEntry, input, k, label, len1, len2, name, pinEntry, q, ref, ref1, ref2, ref3, ref4, ref5, ref6, refNavEntry, repliesEntry, select; var anchorEntry, input, k, label, len1, len2, name, pinEntry, q, ref, ref1, ref2, ref3, ref4, ref5, refNavEntry, repliesEntry, select;
if (g.BOARD.ID === 'f' || !Conf['JSON Navigation'] || g.VIEW !== 'index') { if (g.BOARD.ID === 'f' || !Conf['JSON Navigation'] || g.VIEW !== 'index') {
return; return;
} }
this.board = "" + g.BOARD;
CatalogThread.callbacks.push({ CatalogThread.callbacks.push({
name: 'Catalog Features', name: 'Catalog Features',
cb: this.catalogNode cb: this.catalogNode
@ -3271,10 +3279,10 @@
Conf['Index Mode'] = (ref2 = history.state) != null ? ref2.mode : void 0; Conf['Index Mode'] = (ref2 = history.state) != null ? ref2.mode : void 0;
} }
this.currentPage = this.getCurrentPage(); this.currentPage = this.getCurrentPage();
this.pushState({ this.processHash();
command: (ref3 = location.href.match(/#(.*)/)) != null ? ref3[1] : void 0, $.addClass(doc, 'index-loading', (Conf['Index Mode'].replace(/\ /g, '-')) + "-mode");
replace: true $.on(window, 'popstate', this.cb.popstate);
}); $.on(d, 'scroll', Index.scroll);
this.button = $.el('a', { this.button = $.el('a', {
className: 'index-refresh-shortcut fa fa-refresh', className: 'index-refresh-shortcut fa fa-refresh',
title: 'Refresh', title: 'Refresh',
@ -3300,9 +3308,9 @@
pinEntry.el.title = 'Move watched threads to the start of the index.'; pinEntry.el.title = 'Move watched threads to the start of the index.';
anchorEntry.el.title = 'Move hidden threads to the end of the index.'; anchorEntry.el.title = 'Move hidden threads to the end of the index.';
refNavEntry.el.title = 'Refresh index when navigating through pages.'; refNavEntry.el.title = 'Refresh index when navigating through pages.';
ref4 = [repliesEntry, pinEntry, anchorEntry, refNavEntry]; ref3 = [repliesEntry, pinEntry, anchorEntry, refNavEntry];
for (k = 0, len1 = ref4.length; k < len1; k++) { for (k = 0, len1 = ref3.length; k < len1; k++) {
label = ref4[k]; label = ref3[k];
input = label.el.firstChild; input = label.el.firstChild;
name = input.name; name = input.name;
$.on(input, 'change', $.cb.checked); $.on(input, 'change', $.cb.checked);
@ -3322,69 +3330,59 @@
order: 100, order: 100,
subEntries: [repliesEntry, pinEntry, anchorEntry, refNavEntry] subEntries: [repliesEntry, pinEntry, anchorEntry, refNavEntry]
}); });
$.addClass(doc, 'index-loading', (Conf['Index Mode'].replace(/\ /g, '-')) + "-mode");
this.root = $.el('div', {
className: 'board'
});
this.cb.size();
this.pagelist = $.el('div', {
className: 'pagelist'
});
$.extend(this.pagelist, {
innerHTML: "<div class=\"prev\"><a><button disabled>Previous</button></a></div><div class=\"pages\"></div><div class=\"next\"><a><button disabled>Next</button></a></div><div class=\"pages cataloglink\"><a href=\"./catalog\">Catalog</a></div>"
});
$('.cataloglink a', this.pagelist).href = CatalogLinks.catalog();
this.navLinks = $.el('div', { this.navLinks = $.el('div', {
className: 'navLinks' className: 'navLinks json-index'
}); });
$.extend(this.navLinks, { $.extend(this.navLinks, {
innerHTML: "<span class=\"brackets-wrap indexlink\"><a href=\"#index\">Index</a></span> <span class=\"brackets-wrap cataloglink\"><a href=\"#catalog\">Catalog</a></span> <span class=\"brackets-wrap archlistlink\"><a href=\"./archive\">Archive</a></span> <span class=\"brackets-wrap bottomlink\"><a href=\"#bottom\">Bottom</a></span> <span class=\"brackets-wrap\" id=\"index-last-refresh\"><a href=\"javascript:;\"><time title=\"Last index refresh\">...</time></a></span> <input type=\"search\" id=\"index-search\" class=\"field\" placeholder=\"Search\"><a id=\"index-search-clear\" href=\"javascript:;\" title=\"Clear search\">×</a><span id=\"hidden-label\" hidden> &mdash; <span id=\"hidden-count\"></span> <span id=\"hidden-toggle\">[<a href=\"javascript:;\">Show</a>]</span></span><select id=\"index-mode\" name=\"Index Mode\"><option disabled>Index Mode</option><option value=\"paged\">Paged</option><option value=\"infinite\">Infinite scrolling</option><option value=\"all pages\">All threads</option><option value=\"catalog\">Catalog</option></select><select id=\"index-sort\" name=\"Index Sort\"><option disabled>Index Sort</option><option value=\"bump\">Bump order</option><option value=\"lastreply\">Last reply</option><option value=\"birth\">Creation date</option><option value=\"replycount\">Reply count</option><option value=\"filecount\">File count</option></select><select id=\"index-size\" name=\"Index Size\"><option disabled>Image Size</option><option value=\"small\">Small</option><option value=\"large\">Large</option></select>" innerHTML: "<span class=\"brackets-wrap indexlink\"><a href=\"#index\">Index</a></span> <span class=\"brackets-wrap cataloglink\"><a href=\"#catalog\">Catalog</a></span> <span class=\"brackets-wrap archlistlink\"><a href=\"./archive\">Archive</a></span> <span class=\"brackets-wrap bottomlink\"><a href=\"#bottom\">Bottom</a></span> <span class=\"brackets-wrap\" id=\"index-last-refresh\"><a href=\"javascript:;\"><time title=\"Last index refresh\">...</time></a></span> <input type=\"search\" id=\"index-search\" class=\"field\" placeholder=\"Search\"><a id=\"index-search-clear\" href=\"javascript:;\" title=\"Clear search\">×</a><span id=\"hidden-label\" hidden> &mdash; <span id=\"hidden-count\"></span> <span id=\"hidden-toggle\">[<a href=\"javascript:;\">Show</a>]</span></span><select id=\"index-mode\" name=\"Index Mode\"><option disabled>Index Mode</option><option value=\"paged\">Paged</option><option value=\"infinite\">Infinite scrolling</option><option value=\"all pages\">All threads</option><option value=\"catalog\">Catalog</option></select><select id=\"index-sort\" name=\"Index Sort\"><option disabled>Index Sort</option><option value=\"bump\">Bump order</option><option value=\"lastreply\">Last reply</option><option value=\"birth\">Creation date</option><option value=\"replycount\">Reply count</option><option value=\"filecount\">File count</option></select><select id=\"index-size\" name=\"Index Size\"><option disabled>Image Size</option><option value=\"small\">Small</option><option value=\"large\">Large</option></select>"
}); });
$('.cataloglink a', this.navLinks).href = CatalogLinks.catalog(); $('.cataloglink a', this.navLinks).href = CatalogLinks.catalog();
if ((ref5 = g.BOARD.ID) === 'b' || ref5 === 'trash') { if ((ref4 = g.BOARD.ID) === 'b' || ref4 === 'trash') {
$('.archlistlink', this.navLinks).hidden = true; $('.archlistlink', this.navLinks).hidden = true;
} }
$.on($('#index-last-refresh a', this.navLinks), 'click', this.cb.refreshFront);
this.searchInput = $('#index-search', this.navLinks); this.searchInput = $('#index-search', this.navLinks);
this.setupSearch(); this.setupSearch();
$.on(this.searchInput, 'input', this.onSearchInput);
$.on($('#index-search-clear', this.navLinks), 'click', this.clearSearch);
this.hideLabel = $('#hidden-label', this.navLinks); this.hideLabel = $('#hidden-label', this.navLinks);
$.on($('#hidden-toggle a', this.navLinks), 'click', this.cb.toggleHiddenThreads);
this.selectMode = $('#index-mode', this.navLinks); this.selectMode = $('#index-mode', this.navLinks);
this.selectSort = $('#index-sort', this.navLinks); this.selectSort = $('#index-sort', this.navLinks);
this.selectSize = $('#index-size', this.navLinks); this.selectSize = $('#index-size', this.navLinks);
$.on(window, 'popstate', this.cb.popstate);
$.on(d, 'scroll', Index.scroll);
$.on(this.pagelist, 'click', this.cb.pageNav);
$.on(this.searchInput, 'input', this.onSearchInput);
$.on($('#index-last-refresh a', this.navLinks), 'click', this.cb.refreshFront);
$.on($('#index-search-clear', this.navLinks), 'click', this.clearSearch);
$.on($('#hidden-toggle a', this.navLinks), 'click', this.cb.toggleHiddenThreads);
$.on(this.selectMode, 'change', this.cb.mode); $.on(this.selectMode, 'change', this.cb.mode);
ref6 = [this.selectMode, this.selectSort, this.selectSize]; ref5 = [this.selectMode, this.selectSort, this.selectSize];
for (q = 0, len2 = ref6.length; q < len2; q++) { for (q = 0, len2 = ref5.length; q < len2; q++) {
select = ref6[q]; select = ref5[q];
select.value = Conf[select.name]; select.value = Conf[select.name];
$.on(select, 'change', $.cb.value); $.on(select, 'change', $.cb.value);
} }
$.on(this.selectSort, 'change', this.cb.sort); $.on(this.selectSort, 'change', this.cb.sort);
$.on(this.selectSize, 'change', this.cb.size); $.on(this.selectSize, 'change', this.cb.size);
this.update(); this.root = $.el('div', {
$.asap((function() { className: 'board json-index'
return $('title + *', doc) || d.readyState !== 'loading'; });
}), function() { this.cb.size();
this.pagelist = $.el('div', {
className: 'pagelist json-index'
});
$.extend(this.pagelist, {
innerHTML: "<div class=\"prev\"><a><button disabled>Previous</button></a></div><div class=\"pages\"></div><div class=\"next\"><a><button disabled>Next</button></a></div><div class=\"pages cataloglink\"><a href=\"./catalog\">Catalog</a></div>"
});
$('.cataloglink a', this.pagelist).href = CatalogLinks.catalog();
$.on(this.pagelist, 'click', this.cb.pageNav);
this.update(true);
$.onExists(doc, 'title + *', function() {
return d.title = d.title.replace(/\ -\ Page\ \d+/, ''); return d.title = d.title.replace(/\ -\ Page\ \d+/, '');
}); });
$.asap((function() { $.onExists(doc, '.board > .thread > .postContainer, .board + *', function() {
return $('.board > .thread > .postContainer', doc) || d.readyState !== 'loading'; var board, el, len3, len4, ref6, ref7, threadRoot, topNavPos, u, v;
}), function() {
var board, el, len3, len4, ref7, ref8, threadRoot, topNavPos, u, v;
if (!Main.isThisPageLegit()) {
return;
}
Index.hat = $('.board > .thread > img:first-child'); Index.hat = $('.board > .thread > img:first-child');
if (Index.hat) { if (Index.hat) {
if (Index.nodes) { if (Index.nodes) {
ref7 = Index.nodes; ref6 = Index.nodes;
for (u = 0, len3 = ref7.length; u < len3; u++) { for (u = 0, len3 = ref6.length; u < len3; u++) {
threadRoot = ref7[u]; threadRoot = ref6[u];
$.prepend(threadRoot, Index.hat.cloneNode(false)); $.prepend(threadRoot, Index.hat.cloneNode(false));
} }
} }
@ -3397,9 +3395,9 @@
try { try {
d.implementation.createDocument(null, null, null).appendChild(board); d.implementation.createDocument(null, null, null).appendChild(board);
} catch (_error) {} } catch (_error) {}
ref8 = $$('.navLinks'); ref7 = $$('.navLinks');
for (v = 0, len4 = ref8.length; v < len4; v++) { for (v = 0, len4 = ref7.length; v < len4; v++) {
el = ref8[v]; el = ref7[v];
$.rm(el); $.rm(el);
} }
$.rm($.id('ctrl-top')); $.rm($.id('ctrl-top'));
@ -3407,17 +3405,10 @@
$.before(topNavPos, $.el('hr')); $.before(topNavPos, $.el('hr'));
return $.before(topNavPos, Index.navLinks); return $.before(topNavPos, Index.navLinks);
}); });
return $.asap((function() { return Main.ready(function() {
return $('.pagelist', doc) || d.readyState !== 'loading';
}), function() {
var pagelist; var pagelist;
if (!Main.isThisPageLegit()) { if ((pagelist = $('.pagelist'))) {
return;
}
if (pagelist = $('.pagelist')) {
$.replace(pagelist, Index.pagelist); $.replace(pagelist, Index.pagelist);
} else {
$.after($.id('delform'), Index.pagelist);
} }
return $.rmClass(doc, 'index-loading'); return $.rmClass(doc, 'index-loading');
}); });
@ -3428,7 +3419,7 @@
return; return;
} }
if (Index.pageNum == null) { if (Index.pageNum == null) {
Index.pageNum = Index.getCurrentPage(); Index.pageNum = Index.currentPage;
} }
pageNum = ++Index.pageNum; pageNum = ++Index.pageNum;
if (pageNum > Index.pagesNum) { if (pageNum > Index.pagesNum) {
@ -3546,9 +3537,10 @@
Conf['Previous Index Mode'] = mode; Conf['Previous Index Mode'] = mode;
$.set('Previous Index Mode', mode); $.set('Previous Index Mode', mode);
} }
return Index.pageLoad(Index.pushState({ Index.pushState({
mode: mode mode: mode
})); });
return Index.pageLoad(false);
}, },
sort: function() { sort: function() {
Index.sort(); Index.sort();
@ -3575,32 +3567,19 @@
return Index.buildIndex(); return Index.buildIndex();
}, },
popstate: function(e) { popstate: function(e) {
var mode, page, ref, ref1, searched, state; var mode, page, ref, searched;
if (e != null ? e.state : void 0) { if (e != null ? e.state : void 0) {
ref = e.state, searched = ref.searched, mode = ref.mode; ref = e.state, searched = ref.searched, mode = ref.mode;
state = {};
if (Index.search !== searched) {
state.search = Index.search = searched;
}
if (Conf['Index Mode'] !== mode) {
state.mode = mode;
Index.saveMode(mode);
}
page = Index.getCurrentPage(); page = Index.getCurrentPage();
if (Index.currentPage !== page) { Index.setState({
state.page = Index.currentPage = page; search: searched,
} mode: mode,
if ((state.search != null) || (state.mode != null) || (state.page != null)) { page: page
return Index.pageLoad(state);
}
} else {
state = Index.pushState({
command: (ref1 = location.href.match(/#(.*)/)) != null ? ref1[1] : void 0,
replace: true,
scroll: true
}); });
if (state.command) { return Index.pageLoad(false);
return Index[Conf['Refreshed Navigation'] ? 'update' : 'pageLoad'](state); } else {
if (Index.processHash()) {
return Index[Conf['Refreshed Navigation'] ? 'update' : 'pageLoad']();
} }
} }
}, },
@ -3627,43 +3606,35 @@
return Index.userPageNav(+a.pathname.split(/\/+/)[2] || 1); return Index.userPageNav(+a.pathname.split(/\/+/)[2] || 1);
}, },
refreshFront: function() { refreshFront: function() {
return Index.update(Index.pushState({ Index.pushState({
page: 1, page: 1
scroll: true });
})); return Index.update();
} }
}, },
scrollToIndex: function() { scrollToIndex: function() {
return Header.scrollToIfNeeded(Index.navLinks); return Header.scrollToIfNeeded(Index.navLinks);
}, },
getCurrentPage: function() { getCurrentPage: function() {
var ref;
if ((ref = Conf['Index Mode']) === 'all pages' || ref === 'catalog') {
return 1;
} else {
return +window.location.pathname.split(/\/+/)[2] || 1; return +window.location.pathname.split(/\/+/)[2] || 1;
}
}, },
userPageNav: function(page) { userPageNav: function(page) {
var state; Index.pushState({
state = Index.pushState({ page: page
page: page,
scroll: true
}); });
if (Conf['Refreshed Navigation']) { if (Conf['Refreshed Navigation']) {
return Index.update(state); return Index.update();
} else { } else {
if (state.page) { return Index.pageLoad();
return Index.pageLoad(state);
}
} }
}, },
pushState: function(state) { processHash: function() {
var command, hash, mode, page, pageBeforeSearch, pathname, ref, search; var command, hash, ref, state;
pathname = location.pathname, hash = location.hash; hash = ((ref = location.href.match(/#.*/)) != null ? ref[0] : void 0) || '';
pageBeforeSearch = (ref = history.state) != null ? ref.oldpage : void 0; command = hash.slice(1);
if (state.command != null) { state = {
command = state.command; replace: true
};
if (command === 'paged' || command === 'infinite' || command === 'all-pages' || command === 'catalog') { if (command === 'paged' || command === 'infinite' || command === 'all-pages' || command === 'catalog') {
state.mode = command.replace(/-/g, ' '); state.mode = command.replace(/-/g, ' ');
} else if (command === 'index') { } else if (command === 'index') {
@ -3671,76 +3642,81 @@
state.page = 1; state.page = 1;
} else if (/^s=/.test(command)) { } else if (/^s=/.test(command)) {
state.search = decodeURIComponent(command.slice(2)).replace(/\+/g, ' ').trim(); state.search = decodeURIComponent(command.slice(2)).replace(/\+/g, ' ').trim();
hash = '';
} else { } else {
delete state.command; state.hash = hash;
} }
} Index.pushState(state);
if (state.search != null) { return state.hash == null;
search = state.search; },
pushState: function(state) {
var hash, pageBeforeSearch, pathname, ref, replace, search;
search = state.search, hash = state.hash, replace = state.replace;
pageBeforeSearch = (ref = history.state) != null ? ref.oldpage : void 0;
if ((search != null) && search !== Index.search) {
state.page = search ? 1 : pageBeforeSearch || 1; state.page = search ? 1 : pageBeforeSearch || 1;
if (!search) { if (!search) {
pageBeforeSearch = void 0; pageBeforeSearch = void 0;
} else if (!Index.search) { } else if (!Index.search) {
pageBeforeSearch = Index.currentPage; pageBeforeSearch = Index.currentPage;
} }
Index.search = search;
} }
if (state.mode != null) { Index.setState(state);
mode = state.mode; pathname = Index.currentPage === 1 ? "/" + g.BOARD + "/" : "/" + g.BOARD + "/" + Index.currentPage;
if (mode === Conf['Index Mode']) { hash || (hash = '');
delete state.mode; return history[replace ? 'replaceState' : 'pushState']({
}
Index.saveMode(mode);
if (mode === 'all pages' || mode === 'catalog') {
state.page = 1;
}
hash = '';
}
if (state.page != null) {
page = state.page;
if (page === Index.currentPage) {
delete state.page;
}
Index.currentPage = page;
pathname = page === 1 ? "/" + g.BOARD + "/" : "/" + g.BOARD + "/" + page;
hash = '';
}
history[state.replace ? 'replaceState' : 'pushState']({
mode: Conf['Index Mode'], mode: Conf['Index Mode'],
searched: Index.search, searched: Index.search,
oldpage: pageBeforeSearch oldpage: pageBeforeSearch
}, '', location.protocol + "//" + location.host + pathname + hash); }, '', location.protocol + "//" + location.host + pathname + hash);
return state;
}, },
saveMode: function(mode) { setState: function(arg) {
if (Conf['Index Mode'] !== mode) { var mode, page, ref, search;
search = arg.search, mode = arg.mode, page = arg.page;
if ((search != null) && search !== Index.search) {
Index.changed.search = true;
Index.search = search;
}
if ((mode != null) && mode !== Conf['Index Mode']) {
Index.changed.mode = true;
Conf['Index Mode'] = mode; Conf['Index Mode'] = mode;
$.set('Index Mode', mode); $.set('Index Mode', mode);
}
if (!(mode === 'catalog' || Conf['Previous Index Mode'] === mode)) { if (!(mode === 'catalog' || Conf['Previous Index Mode'] === mode)) {
Conf['Previous Index Mode'] = mode; Conf['Previous Index Mode'] = mode;
return $.set('Previous Index Mode', mode); $.set('Previous Index Mode', mode);
}
}
if ((ref = Conf['Index Mode']) === 'all pages' || ref === 'catalog') {
page = 1;
}
if ((page != null) && page !== Index.currentPage) {
Index.changed.page = true;
return Index.currentPage = page;
} }
}, },
pageLoad: function(arg) { pageLoad: function(scroll) {
var mode, scroll, search, sort; var mode, page, ref, search, threads;
sort = arg.sort, search = arg.search, mode = arg.mode, scroll = arg.scroll; if (scroll == null) {
if (sort || (search != null)) { scroll = true;
}
ref = Index.changed, threads = ref.threads, search = ref.search, mode = ref.mode, page = ref.page;
if (threads || search) {
Index.sort(); Index.sort();
Index.buildPagelist(); Index.buildPagelist();
} }
if (search != null) { if (search) {
Index.setupSearch(); Index.setupSearch();
} }
if (mode != null) { if (mode) {
Index.applyMode(); Index.applyMode();
} }
if (threads || search || mode || page) {
Index.buildIndex(); Index.buildIndex();
Index.setPage(); Index.setPage();
if (scroll) {
return Index.scrollToIndex();
} }
if (scroll) {
Index.scrollToIndex();
}
return Index.changed = {};
}, },
applyMode: function() { applyMode: function() {
var k, len1, mode, ref; var k, len1, mode, ref;
@ -3783,7 +3759,7 @@
}, },
setPage: function() { setPage: function() {
var a, href, maxPageNum, next, pageNum, pagesRoot, prev, strong; var a, href, maxPageNum, next, pageNum, pagesRoot, prev, strong;
pageNum = Index.getCurrentPage(); pageNum = Index.currentPage;
maxPageNum = Index.getMaxPageNum(); maxPageNum = Index.getMaxPageNum();
pagesRoot = $('.pages', Index.pagelist); pagesRoot = $('.pages', Index.pagelist);
prev = pagesRoot.previousSibling.firstChild; prev = pagesRoot.previousSibling.firstChild;
@ -3828,7 +3804,7 @@
Index.hideLabel.hidden = false; Index.hideLabel.hidden = false;
return $('#hidden-count', Index.navLinks).textContent = hiddenCount === 1 ? '1 hidden thread' : hiddenCount + " hidden threads"; return $('#hidden-count', Index.navLinks).textContent = hiddenCount === 1 ? '1 hidden thread' : hiddenCount + " hidden threads";
}, },
update: function(state) { update: function(firstTime) {
var now, ref, ref1; var now, ref, ref1;
if ((ref = Index.req) != null) { if ((ref = Index.req) != null) {
ref.abort(); ref.abort();
@ -3848,16 +3824,18 @@
}), 3 * $.SECOND - (Date.now() - now)); }), 3 * $.SECOND - (Date.now() - now));
}); });
} }
Index.req = $.ajax("//a.4cdn.org/" + g.BOARD + "/catalog.json", { if (!firstTime && d.readyState !== 'loading' && !$('.board + *')) {
onloadend: function(e) { location.reload();
return Index.load(e, state); return;
} }
Index.req = $.ajax("//a.4cdn.org/" + g.BOARD + "/catalog.json", {
onloadend: Index.load
}, { }, {
whenModified: 'Index' whenModified: 'Index'
}); });
return $.addClass(Index.button, 'fa-spin'); return $.addClass(Index.button, 'fa-spin');
}, },
load: function(e, state) { load: function(e) {
var err, nTimeout, notice, ref, req, timeEl; var err, nTimeout, notice, ref, req, timeEl;
$.rmClass(Index.button, 'fa-spin'); $.rmClass(Index.button, 'fa-spin');
req = Index.req, notice = Index.notice, nTimeout = Index.nTimeout; req = Index.req, notice = Index.notice, nTimeout = Index.nTimeout;
@ -3885,9 +3863,9 @@
} }
try { try {
if (req.status === 200) { if (req.status === 200) {
Index.parse(req.response, state); Index.parse(req.response);
} else if (req.status === 304 && (state != null)) { } else if (req.status === 304) {
Index.pageLoad(state); Index.pageLoad();
} }
} catch (_error) { } catch (_error) {
err = _error; err = _error;
@ -3912,18 +3890,16 @@
} }
timeEl = $('#index-last-refresh time', Index.navLinks); timeEl = $('#index-last-refresh time', Index.navLinks);
timeEl.dataset.utc = Date.parse(req.getResponseHeader('Last-Modified')); timeEl.dataset.utc = Date.parse(req.getResponseHeader('Last-Modified'));
RelativeDates.update(timeEl); return RelativeDates.update(timeEl);
return Index.scrollToIndex();
}, },
parse: function(pages, state) { parse: function(pages) {
$.cleanCache(function(url) { $.cleanCache(function(url) {
return /^\/\/a\.4cdn\.org\//.test(url); return /^\/\/a\.4cdn\.org\//.test(url);
}); });
Index.parseThreadList(pages); Index.parseThreadList(pages);
Index.buildThreads(); Index.buildThreads();
state || (state = {}); Index.changed.threads = true;
state.sort = true; return Index.pageLoad();
return Index.pageLoad(state);
}, },
parseThreadList: function(pages) { parseThreadList: function(pages) {
Index.pagesNum = pages.length; Index.pagesNum = pages.length;
@ -4140,14 +4116,15 @@
i++; i++;
} }
page = Math.floor(i / Index.threadsNumPerPage) + 1; page = Math.floor(i / Index.threadsNumPerPage) + 1;
if (page !== Index.getCurrentPage()) { if (page !== Index.currentPage) {
Index.currentPage = page;
Index.pushState({ Index.pushState({
page: page page: page
}); });
Index.setPage(); Index.setPage();
} }
} }
nodes = Index.buildSinglePage(Index.getCurrentPage()); nodes = Index.buildSinglePage(Index.currentPage);
} }
delete Index.pageNum; delete Index.pageNum;
$.rmAll(Index.root); $.rmAll(Index.root);
@ -4190,10 +4167,8 @@
Index.onSearchInput(); Index.onSearchInput();
return Index.searchInput.focus(); return Index.searchInput.focus();
}, },
setupSearch: function(noUpdate) { setupSearch: function() {
if (!noUpdate) {
Index.searchInput.value = Index.search; Index.searchInput.value = Index.search;
}
if (Index.search) { if (Index.search) {
return Index.searchInput.dataset.searching = 1; return Index.searchInput.dataset.searching = 1;
} else { } else {
@ -4206,10 +4181,11 @@
if (search === Index.search) { if (search === Index.search) {
return; return;
} }
return Index.pageLoad(Index.pushState({ Index.pushState({
search: search, search: search,
replace: !!search === !!Index.search replace: !!search === !!Index.search
})); });
return Index.pageLoad(false);
}, },
querySearch: function(query) { querySearch: function(query) {
var keywords; var keywords;
@ -6335,7 +6311,7 @@
} }
}, },
process: function(link, clone) { process: function(link, clone) {
if (Conf['Inline Cross-thread Quotes Only'] && link.getAttribute('href')[0] === '#') { if (Conf['Inline Cross-thread Quotes Only'] && link.pathname === location.pathname && link.host === location.host && link.protocol === location.protocol) {
return; return;
} }
if (Conf['Quote Hash Navigation']) { if (Conf['Quote Hash Navigation']) {
@ -6619,7 +6595,10 @@
return $.asap((function() { return $.asap((function() {
return !Conf['Thread Updater'] || $('.navLinksBot > .updatelink'); return !Conf['Thread Updater'] || $('.navLinksBot > .updatelink');
}), function() { }), function() {
return $.add($('.navLinksBot'), [$.tn(' '), QuoteThreading.threadNewLink]); var navLinksBot;
if ((navLinksBot = $('.navLinksBot'))) {
return $.add(navLinksBot, [$.tn(' '), QuoteThreading.threadNewLink]);
}
}); });
}, },
node: function() { node: function() {
@ -7029,7 +7008,7 @@
} }
}, },
initReady: function() { initReady: function() {
var link, linkBot, origToggle; var link, linkBot, navLinksBot, origToggle;
$.off(d, '4chanXInitFinished', this.initReady); $.off(d, '4chanXInitFinished', this.initReady);
QR.postingIsEnabled = !!$.id('postForm'); QR.postingIsEnabled = !!$.id('postForm');
if (!QR.postingIsEnabled) { if (!QR.postingIsEnabled) {
@ -7057,7 +7036,9 @@
QR.open(); QR.open();
return QR.nodes.com.focus(); return QR.nodes.com.focus();
}); });
$.prepend($('.navLinksBot'), linkBot); if ((navLinksBot = $('.navLinksBot'))) {
$.prepend(navLinksBot, linkBot);
}
} }
origToggle = $.id('togglePostFormLink'); origToggle = $.id('togglePostFormLink');
$.before(origToggle, link); $.before(origToggle, link);
@ -12503,7 +12484,6 @@
}); });
$.add(a, range.extractContents()); $.add(a, range.extractContents());
range.insertNode(a); range.insertNode(a);
range.detach();
return a; return a;
} }
}; };
@ -13168,7 +13148,10 @@
innerHTML: "<a href=\"javascript:;\">Update</a>" innerHTML: "<a href=\"javascript:;\">Update</a>"
}); });
Main.ready(function() { Main.ready(function() {
return $.add($('.navLinksBot'), [$.tn(' '), updateLink]); var navLinksBot;
if ((navLinksBot = $('.navLinksBot'))) {
return $.add(navLinksBot, [$.tn(' '), updateLink]);
}
}); });
$.on(updateLink.firstElementChild, 'click', this.update); $.on(updateLink.firstElementChild, 'click', this.update);
subEntries = []; subEntries = [];
@ -15644,7 +15627,15 @@
}); });
} }
return Main.ready(function() { return Main.ready(function() {
return $.globalEval('(function() {\n window.clickable_ids = false;\n var nodes = document.querySelectorAll(\'.posteruid, .capcode\');\n for (var i = 0; i < nodes.length; i++) {\n nodes[i].removeEventListener("click", window.idClick, false);\n }\n window.removeEventListener("message", Report.onMessage, false);\n})();'); return $.global(function() {
var k, len1, node, ref1;
window.clickable_ids = false;
ref1 = document.querySelectorAll('.posteruid, .capcode');
for (k = 0, len1 = ref1.length; k < len1; k++) {
node = ref1[k];
node.removeEventListener('click', window.idClick, false);
}
});
}); });
}, },
code: function() { code: function() {
@ -17650,6 +17641,14 @@
}); });
return; return;
} }
$.on(d, '4chanXInitFinished', function() {
if (Main.expectInitFinished) {
return delete Main.expectInitFinished;
} else {
new Notice('error', 'Error: Multiple copies of 4chan X are enabled.');
return $.addClass(doc, 'tainted');
}
});
flatten = function(parent, obj) { flatten = function(parent, obj) {
var key, val; var key, val;
if (obj instanceof Array) { if (obj instanceof Array) {
@ -17814,7 +17813,7 @@
}, },
initStyle: function() { initStyle: function() {
var keyboard, ref; var keyboard, ref;
if (!Main.isThisPageLegit() || $.hasClass(doc, 'fourchan-x')) { if (!Main.isThisPageLegit()) {
return; return;
} }
if ((ref = $('link[href*=mobile]', d.head)) != null) { if ((ref = $('link[href*=mobile]', d.head)) != null) {
@ -17876,7 +17875,7 @@
}); });
}, },
initReady: function() { initReady: function() {
var ref, ref1; var msg, ref, ref1, ref2;
if (g.VIEW === 'thread' && (((ref = d.title) === '4chan - Temporarily Offline' || ref === '4chan - 404 Not Found') || ($('.board') && !$('.opContainer')))) { if (g.VIEW === 'thread' && (((ref = d.title) === '4chan - Temporarily Offline' || ref === '4chan - 404 Not Found') || ($('.board') && !$('.opContainer')))) {
ThreadWatcher.set404(g.BOARD.ID, g.THREADID, function() { ThreadWatcher.set404(g.BOARD.ID, g.THREADID, function() {
if (Conf['404 Redirect']) { if (Conf['404 Redirect']) {
@ -17892,15 +17891,25 @@
if ((ref1 = d.title) === '4chan - Temporarily Offline' || ref1 === '4chan - 404 Not Found') { if ((ref1 = d.title) === '4chan - Temporarily Offline' || ref1 === '4chan - 404 Not Found') {
return; return;
} }
if (((ref2 = g.VIEW) === 'index' || ref2 === 'thread') && !$('.board + *')) {
msg = $.el('div', {
innerHTML: "The page didn&#039;t load completely.<br>Some features may not work unless you <a href=\"javascript:;\">reload</a>."
});
$.on($('a', msg), 'click', function() {
return location.reload();
});
new Notice('warning', msg);
}
if (!(Conf['JSON Navigation'] && g.VIEW === 'index')) { if (!(Conf['JSON Navigation'] && g.VIEW === 'index')) {
return Main.initThread(); return Main.initThread();
} else { } else {
Main.expectInitFinished = true;
return $.event('4chanXInitFinished'); return $.event('4chanXInitFinished');
} }
}, },
initThread: function() { initThread: function() {
var board, err, errors, k, len1, len2, m, postRoot, posts, q, ref, ref1, scriptData, thread, threadRoot, threads; var board, err, errors, k, len1, len2, m, postRoot, posts, q, ref, ref1, scriptData, thread, threadRoot, threads;
if (board = $('.board')) { if ((board = $('.board'))) {
threads = []; threads = [];
posts = []; posts = [];
ref = $$('.board > .thread', board); ref = $$('.board > .thread', board);
@ -17911,6 +17920,7 @@
ref1 = $$('.thread > .postContainer', threadRoot); ref1 = $$('.thread > .postContainer', threadRoot);
for (q = 0, len2 = ref1.length; q < len2; q++) { for (q = 0, len2 = ref1.length; q < len2; q++) {
postRoot = ref1[q]; postRoot = ref1[q];
if ($('.postMessage', postRoot)) {
try { try {
posts.push(new Post(postRoot, thread, g.BOARD)); posts.push(new Post(postRoot, thread, g.BOARD));
} catch (_error) { } catch (_error) {
@ -17925,6 +17935,7 @@
} }
} }
} }
}
if (errors) { if (errors) {
Main.handleErrors(errors); Main.handleErrors(errors);
} }
@ -17941,9 +17952,11 @@
post = posts[u]; post = posts[u];
QuoteThreading.insert(post); QuoteThreading.insert(post);
} }
Main.expectInitFinished = true;
return $.event('4chanXInitFinished'); return $.event('4chanXInitFinished');
}); });
} else { } else {
Main.expectInitFinished = true;
return $.event('4chanXInitFinished'); return $.event('4chanXInitFinished');
} }
}, },
@ -18034,7 +18047,7 @@
details = details.replace(/file:\/{3}.+\//g, ''); details = details.replace(/file:\/{3}.+\//g, '');
url = "https://gitreports.com/issue/ccd0/4chan-x?issue_title=" + (encodeURIComponent(title)) + "&details=" + (encodeURIComponent(details)); url = "https://gitreports.com/issue/ccd0/4chan-x?issue_title=" + (encodeURIComponent(title)) + "&details=" + (encodeURIComponent(details));
return { return {
innerHTML: " [<a href=\"" + E(url) + "\" target=\"_blank\">report</a>]" innerHTML: "<span class=\"report-error\"> [<a href=\"" + E(url) + "\" target=\"_blank\">report</a>]</span>"
}; };
}, },
isThisPageLegit: function() { isThisPageLegit: function() {
@ -19139,6 +19152,9 @@
".message a {\n" + ".message a {\n" +
" text-decoration: underline;\n" + " text-decoration: underline;\n" +
"}\n" + "}\n" +
":root.tainted .report-error {\n" +
" display: none;\n" +
"}\n" +
"/* Settings */\n" + "/* Settings */\n" +
":root.fourchan-x body {\n" + ":root.fourchan-x body {\n" +
" -moz-box-sizing: border-box;\n" + " -moz-box-sizing: border-box;\n" +
@ -19328,9 +19344,9 @@
" overflow: hidden;\n" + " overflow: hidden;\n" +
"}\n" + "}\n" +
"/* Index */\n" + "/* Index */\n" +
":root.index-loading .navLinks,\n" + ":root.index-loading .navLinks:not(.json-index),\n" +
":root.index-loading .board,\n" + ":root.index-loading .board:not(.json-index),\n" +
":root.index-loading .pagelist,\n" + ":root.index-loading .pagelist:not(.json-index),\n" +
":root.infinite-mode .pagelist,\n" + ":root.infinite-mode .pagelist,\n" +
":root.all-pages-mode .pagelist,\n" + ":root.all-pages-mode .pagelist,\n" +
":root.catalog-mode .pagelist,\n" + ":root.catalog-mode .pagelist,\n" +

Binary file not shown.

View File

@ -1,7 +1,7 @@
// Generated by CoffeeScript // Generated by CoffeeScript
// ==UserScript== // ==UserScript==
// @name 4chan X // @name 4chan X
// @version 1.11.22.4 // @version 1.11.23.0
// @minGMVer 1.14 // @minGMVer 1.14
// @minFFVer 26 // @minFFVer 26
// @namespace 4chan-X // @namespace 4chan-X
@ -434,7 +434,7 @@
doc = d.documentElement; doc = d.documentElement;
g = { g = {
VERSION: '1.11.22.4', VERSION: '1.11.23.0',
NAMESPACE: '4chan X.', NAMESPACE: '4chan X.',
boards: {} boards: {}
}; };
@ -602,7 +602,7 @@
if (req = reqs[url]) { if (req = reqs[url]) {
if (req.readyState === 4) { if (req.readyState === 4) {
$.queueTask(function() { $.queueTask(function() {
return cb.call(req, req.evt); return cb.call(req, req.evt, true);
}); });
} else { } else {
req.callbacks.push(cb); req.callbacks.push(cb);
@ -622,13 +622,16 @@
} }
$.on(req, 'load', function(e) { $.on(req, 'load', function(e) {
var k, len1, ref; var k, len1, ref;
this.evt = e;
ref = this.callbacks; ref = this.callbacks;
for (k = 0, len1 = ref.length; k < len1; k++) { for (k = 0, len1 = ref.length; k < len1; k++) {
cb = ref[k]; cb = ref[k];
cb.call(this, e); $.queueTask((function(_this) {
return function() {
return cb.call(_this, e, false);
};
})(this));
} }
this.evt = e;
this.cached = true;
return delete this.callbacks; return delete this.callbacks;
}); });
$.on(req, 'abort error', rm); $.on(req, 'abort error', rm);
@ -2326,8 +2329,8 @@
this.root.textContent = "Loading post No." + this.postID + "..."; this.root.textContent = "Loading post No." + this.postID + "...";
if (this.threadID) { if (this.threadID) {
$.cache("//a.4cdn.org/" + this.boardID + "/thread/" + this.threadID + ".json", (function(_this) { $.cache("//a.4cdn.org/" + this.boardID + "/thread/" + this.threadID + ".json", (function(_this) {
return function(e) { return function(e, isCached) {
return _this.fetchedPost(e.target); return _this.fetchedPost(e.target, isCached);
}; };
})(this)); })(this));
} else { } else {
@ -2358,7 +2361,7 @@
return $.event('PostsInserted'); return $.event('PostsInserted');
}; };
Fetcher.prototype.fetchedPost = function(req) { Fetcher.prototype.fetchedPost = function(req, isCached) {
var api, board, k, len1, post, posts, status, thread; var api, board, k, len1, post, posts, status, thread;
if (post = g.posts[this.boardID + "." + this.postID]) { if (post = g.posts[this.boardID + "." + this.postID]) {
this.insert(post); this.insert(post);
@ -2382,14 +2385,14 @@
} }
} }
if (post.no !== this.postID) { if (post.no !== this.postID) {
if (req.cached) { if (isCached) {
api = "//a.4cdn.org/" + this.boardID + "/thread/" + this.threadID + ".json"; api = "//a.4cdn.org/" + this.boardID + "/thread/" + this.threadID + ".json";
$.cleanCache(function(url) { $.cleanCache(function(url) {
return url === api; return url === api;
}); });
$.cache(api, (function(_this) { $.cache(api, (function(_this) {
return function(e) { return function(e) {
return _this.fetchedPost(e.target); return _this.fetchedPost(e.target, false);
}; };
})(this)); })(this));
return; return;
@ -2424,7 +2427,7 @@
if (/^https:\/\//.test(url) || location.protocol === 'http:') { if (/^https:\/\//.test(url) || location.protocol === 'http:') {
$.cache(url, (function(_this) { $.cache(url, (function(_this) {
return function(e) { return function(e) {
return _this.parseArchivedPost(e.target.response, url); return _this.parseArchivedPost(e.target.response, url, archive);
}; };
})(this), { })(this), {
responseType: 'json', responseType: 'json',
@ -2445,7 +2448,7 @@
} }
} }
} }
return _this.parseArchivedPost(response, url); return _this.parseArchivedPost(response, url, archive);
}; };
})(this)); })(this));
return true; return true;
@ -2453,12 +2456,17 @@
return false; return false;
}; };
Fetcher.prototype.parseArchivedPost = function(data, url) { Fetcher.prototype.parseArchivedPost = function(data, url, archive) {
var board, comment, greentext, i, j, key, o, post, ref, ref1, text, text2, thread, val; var board, comment, greentext, i, j, key, o, post, ref, ref1, text, text2, thread, val;
if (post = g.posts[this.boardID + "." + this.postID]) { if (post = g.posts[this.boardID + "." + this.postID]) {
this.insert(post); this.insert(post);
return; return;
} }
if (data == null) {
$.addClass(this.root, 'warning');
this.root.textContent = "Error fetching Post No." + this.postID + " from " + archive.name + ".";
return;
}
if (data.error) { if (data.error) {
$.addClass(this.root, 'warning'); $.addClass(this.root, 'warning');
this.root.textContent = data.error; this.root.textContent = data.error;
@ -2741,11 +2749,11 @@
a.className = 'current'; a.className = 'current';
} }
Main.ready(function() { Main.ready(function() {
var oldFooter; var absbot, oldFooter;
if (oldFooter = $.id('boardNavDesktopFoot')) { if ((oldFooter = $.id('boardNavDesktopFoot'))) {
return $.replace($('.boardList', oldFooter), Header.bottomBoardList); return $.replace($('.boardList', oldFooter), Header.bottomBoardList);
} else { } else if ((absbot = $.id('absbot'))) {
$.before($.id('absbot'), footer); $.before(absbot, footer);
return $.globalEval('window.cloneTopNav = function() {};'); return $.globalEval('window.cloneTopNav = function() {};');
} }
}); });
@ -3256,12 +3264,12 @@
Index = { Index = {
showHiddenThreads: false, showHiddenThreads: false,
changed: {},
init: function() { init: function() {
var anchorEntry, input, k, label, len1, len2, name, pinEntry, q, ref, ref1, ref2, ref3, ref4, ref5, ref6, refNavEntry, repliesEntry, select; var anchorEntry, input, k, label, len1, len2, name, pinEntry, q, ref, ref1, ref2, ref3, ref4, ref5, refNavEntry, repliesEntry, select;
if (g.BOARD.ID === 'f' || !Conf['JSON Navigation'] || g.VIEW !== 'index') { if (g.BOARD.ID === 'f' || !Conf['JSON Navigation'] || g.VIEW !== 'index') {
return; return;
} }
this.board = "" + g.BOARD;
CatalogThread.callbacks.push({ CatalogThread.callbacks.push({
name: 'Catalog Features', name: 'Catalog Features',
cb: this.catalogNode cb: this.catalogNode
@ -3271,10 +3279,10 @@
Conf['Index Mode'] = (ref2 = history.state) != null ? ref2.mode : void 0; Conf['Index Mode'] = (ref2 = history.state) != null ? ref2.mode : void 0;
} }
this.currentPage = this.getCurrentPage(); this.currentPage = this.getCurrentPage();
this.pushState({ this.processHash();
command: (ref3 = location.href.match(/#(.*)/)) != null ? ref3[1] : void 0, $.addClass(doc, 'index-loading', (Conf['Index Mode'].replace(/\ /g, '-')) + "-mode");
replace: true $.on(window, 'popstate', this.cb.popstate);
}); $.on(d, 'scroll', Index.scroll);
this.button = $.el('a', { this.button = $.el('a', {
className: 'index-refresh-shortcut fa fa-refresh', className: 'index-refresh-shortcut fa fa-refresh',
title: 'Refresh', title: 'Refresh',
@ -3300,9 +3308,9 @@
pinEntry.el.title = 'Move watched threads to the start of the index.'; pinEntry.el.title = 'Move watched threads to the start of the index.';
anchorEntry.el.title = 'Move hidden threads to the end of the index.'; anchorEntry.el.title = 'Move hidden threads to the end of the index.';
refNavEntry.el.title = 'Refresh index when navigating through pages.'; refNavEntry.el.title = 'Refresh index when navigating through pages.';
ref4 = [repliesEntry, pinEntry, anchorEntry, refNavEntry]; ref3 = [repliesEntry, pinEntry, anchorEntry, refNavEntry];
for (k = 0, len1 = ref4.length; k < len1; k++) { for (k = 0, len1 = ref3.length; k < len1; k++) {
label = ref4[k]; label = ref3[k];
input = label.el.firstChild; input = label.el.firstChild;
name = input.name; name = input.name;
$.on(input, 'change', $.cb.checked); $.on(input, 'change', $.cb.checked);
@ -3322,69 +3330,59 @@
order: 100, order: 100,
subEntries: [repliesEntry, pinEntry, anchorEntry, refNavEntry] subEntries: [repliesEntry, pinEntry, anchorEntry, refNavEntry]
}); });
$.addClass(doc, 'index-loading', (Conf['Index Mode'].replace(/\ /g, '-')) + "-mode");
this.root = $.el('div', {
className: 'board'
});
this.cb.size();
this.pagelist = $.el('div', {
className: 'pagelist'
});
$.extend(this.pagelist, {
innerHTML: "<div class=\"prev\"><a><button disabled>Previous</button></a></div><div class=\"pages\"></div><div class=\"next\"><a><button disabled>Next</button></a></div><div class=\"pages cataloglink\"><a href=\"./catalog\">Catalog</a></div>"
});
$('.cataloglink a', this.pagelist).href = CatalogLinks.catalog();
this.navLinks = $.el('div', { this.navLinks = $.el('div', {
className: 'navLinks' className: 'navLinks json-index'
}); });
$.extend(this.navLinks, { $.extend(this.navLinks, {
innerHTML: "<span class=\"brackets-wrap indexlink\"><a href=\"#index\">Index</a></span> <span class=\"brackets-wrap cataloglink\"><a href=\"#catalog\">Catalog</a></span> <span class=\"brackets-wrap archlistlink\"><a href=\"./archive\">Archive</a></span> <span class=\"brackets-wrap bottomlink\"><a href=\"#bottom\">Bottom</a></span> <span class=\"brackets-wrap\" id=\"index-last-refresh\"><a href=\"javascript:;\"><time title=\"Last index refresh\">...</time></a></span> <input type=\"search\" id=\"index-search\" class=\"field\" placeholder=\"Search\"><a id=\"index-search-clear\" href=\"javascript:;\" title=\"Clear search\">×</a><span id=\"hidden-label\" hidden> &mdash; <span id=\"hidden-count\"></span> <span id=\"hidden-toggle\">[<a href=\"javascript:;\">Show</a>]</span></span><select id=\"index-mode\" name=\"Index Mode\"><option disabled>Index Mode</option><option value=\"paged\">Paged</option><option value=\"infinite\">Infinite scrolling</option><option value=\"all pages\">All threads</option><option value=\"catalog\">Catalog</option></select><select id=\"index-sort\" name=\"Index Sort\"><option disabled>Index Sort</option><option value=\"bump\">Bump order</option><option value=\"lastreply\">Last reply</option><option value=\"birth\">Creation date</option><option value=\"replycount\">Reply count</option><option value=\"filecount\">File count</option></select><select id=\"index-size\" name=\"Index Size\"><option disabled>Image Size</option><option value=\"small\">Small</option><option value=\"large\">Large</option></select>" innerHTML: "<span class=\"brackets-wrap indexlink\"><a href=\"#index\">Index</a></span> <span class=\"brackets-wrap cataloglink\"><a href=\"#catalog\">Catalog</a></span> <span class=\"brackets-wrap archlistlink\"><a href=\"./archive\">Archive</a></span> <span class=\"brackets-wrap bottomlink\"><a href=\"#bottom\">Bottom</a></span> <span class=\"brackets-wrap\" id=\"index-last-refresh\"><a href=\"javascript:;\"><time title=\"Last index refresh\">...</time></a></span> <input type=\"search\" id=\"index-search\" class=\"field\" placeholder=\"Search\"><a id=\"index-search-clear\" href=\"javascript:;\" title=\"Clear search\">×</a><span id=\"hidden-label\" hidden> &mdash; <span id=\"hidden-count\"></span> <span id=\"hidden-toggle\">[<a href=\"javascript:;\">Show</a>]</span></span><select id=\"index-mode\" name=\"Index Mode\"><option disabled>Index Mode</option><option value=\"paged\">Paged</option><option value=\"infinite\">Infinite scrolling</option><option value=\"all pages\">All threads</option><option value=\"catalog\">Catalog</option></select><select id=\"index-sort\" name=\"Index Sort\"><option disabled>Index Sort</option><option value=\"bump\">Bump order</option><option value=\"lastreply\">Last reply</option><option value=\"birth\">Creation date</option><option value=\"replycount\">Reply count</option><option value=\"filecount\">File count</option></select><select id=\"index-size\" name=\"Index Size\"><option disabled>Image Size</option><option value=\"small\">Small</option><option value=\"large\">Large</option></select>"
}); });
$('.cataloglink a', this.navLinks).href = CatalogLinks.catalog(); $('.cataloglink a', this.navLinks).href = CatalogLinks.catalog();
if ((ref5 = g.BOARD.ID) === 'b' || ref5 === 'trash') { if ((ref4 = g.BOARD.ID) === 'b' || ref4 === 'trash') {
$('.archlistlink', this.navLinks).hidden = true; $('.archlistlink', this.navLinks).hidden = true;
} }
$.on($('#index-last-refresh a', this.navLinks), 'click', this.cb.refreshFront);
this.searchInput = $('#index-search', this.navLinks); this.searchInput = $('#index-search', this.navLinks);
this.setupSearch(); this.setupSearch();
$.on(this.searchInput, 'input', this.onSearchInput);
$.on($('#index-search-clear', this.navLinks), 'click', this.clearSearch);
this.hideLabel = $('#hidden-label', this.navLinks); this.hideLabel = $('#hidden-label', this.navLinks);
$.on($('#hidden-toggle a', this.navLinks), 'click', this.cb.toggleHiddenThreads);
this.selectMode = $('#index-mode', this.navLinks); this.selectMode = $('#index-mode', this.navLinks);
this.selectSort = $('#index-sort', this.navLinks); this.selectSort = $('#index-sort', this.navLinks);
this.selectSize = $('#index-size', this.navLinks); this.selectSize = $('#index-size', this.navLinks);
$.on(window, 'popstate', this.cb.popstate);
$.on(d, 'scroll', Index.scroll);
$.on(this.pagelist, 'click', this.cb.pageNav);
$.on(this.searchInput, 'input', this.onSearchInput);
$.on($('#index-last-refresh a', this.navLinks), 'click', this.cb.refreshFront);
$.on($('#index-search-clear', this.navLinks), 'click', this.clearSearch);
$.on($('#hidden-toggle a', this.navLinks), 'click', this.cb.toggleHiddenThreads);
$.on(this.selectMode, 'change', this.cb.mode); $.on(this.selectMode, 'change', this.cb.mode);
ref6 = [this.selectMode, this.selectSort, this.selectSize]; ref5 = [this.selectMode, this.selectSort, this.selectSize];
for (q = 0, len2 = ref6.length; q < len2; q++) { for (q = 0, len2 = ref5.length; q < len2; q++) {
select = ref6[q]; select = ref5[q];
select.value = Conf[select.name]; select.value = Conf[select.name];
$.on(select, 'change', $.cb.value); $.on(select, 'change', $.cb.value);
} }
$.on(this.selectSort, 'change', this.cb.sort); $.on(this.selectSort, 'change', this.cb.sort);
$.on(this.selectSize, 'change', this.cb.size); $.on(this.selectSize, 'change', this.cb.size);
this.update(); this.root = $.el('div', {
$.asap((function() { className: 'board json-index'
return $('title + *', doc) || d.readyState !== 'loading'; });
}), function() { this.cb.size();
this.pagelist = $.el('div', {
className: 'pagelist json-index'
});
$.extend(this.pagelist, {
innerHTML: "<div class=\"prev\"><a><button disabled>Previous</button></a></div><div class=\"pages\"></div><div class=\"next\"><a><button disabled>Next</button></a></div><div class=\"pages cataloglink\"><a href=\"./catalog\">Catalog</a></div>"
});
$('.cataloglink a', this.pagelist).href = CatalogLinks.catalog();
$.on(this.pagelist, 'click', this.cb.pageNav);
this.update(true);
$.onExists(doc, 'title + *', function() {
return d.title = d.title.replace(/\ -\ Page\ \d+/, ''); return d.title = d.title.replace(/\ -\ Page\ \d+/, '');
}); });
$.asap((function() { $.onExists(doc, '.board > .thread > .postContainer, .board + *', function() {
return $('.board > .thread > .postContainer', doc) || d.readyState !== 'loading'; var board, el, len3, len4, ref6, ref7, threadRoot, topNavPos, u, v;
}), function() {
var board, el, len3, len4, ref7, ref8, threadRoot, topNavPos, u, v;
if (!Main.isThisPageLegit()) {
return;
}
Index.hat = $('.board > .thread > img:first-child'); Index.hat = $('.board > .thread > img:first-child');
if (Index.hat) { if (Index.hat) {
if (Index.nodes) { if (Index.nodes) {
ref7 = Index.nodes; ref6 = Index.nodes;
for (u = 0, len3 = ref7.length; u < len3; u++) { for (u = 0, len3 = ref6.length; u < len3; u++) {
threadRoot = ref7[u]; threadRoot = ref6[u];
$.prepend(threadRoot, Index.hat.cloneNode(false)); $.prepend(threadRoot, Index.hat.cloneNode(false));
} }
} }
@ -3397,9 +3395,9 @@
try { try {
d.implementation.createDocument(null, null, null).appendChild(board); d.implementation.createDocument(null, null, null).appendChild(board);
} catch (_error) {} } catch (_error) {}
ref8 = $$('.navLinks'); ref7 = $$('.navLinks');
for (v = 0, len4 = ref8.length; v < len4; v++) { for (v = 0, len4 = ref7.length; v < len4; v++) {
el = ref8[v]; el = ref7[v];
$.rm(el); $.rm(el);
} }
$.rm($.id('ctrl-top')); $.rm($.id('ctrl-top'));
@ -3407,17 +3405,10 @@
$.before(topNavPos, $.el('hr')); $.before(topNavPos, $.el('hr'));
return $.before(topNavPos, Index.navLinks); return $.before(topNavPos, Index.navLinks);
}); });
return $.asap((function() { return Main.ready(function() {
return $('.pagelist', doc) || d.readyState !== 'loading';
}), function() {
var pagelist; var pagelist;
if (!Main.isThisPageLegit()) { if ((pagelist = $('.pagelist'))) {
return;
}
if (pagelist = $('.pagelist')) {
$.replace(pagelist, Index.pagelist); $.replace(pagelist, Index.pagelist);
} else {
$.after($.id('delform'), Index.pagelist);
} }
return $.rmClass(doc, 'index-loading'); return $.rmClass(doc, 'index-loading');
}); });
@ -3428,7 +3419,7 @@
return; return;
} }
if (Index.pageNum == null) { if (Index.pageNum == null) {
Index.pageNum = Index.getCurrentPage(); Index.pageNum = Index.currentPage;
} }
pageNum = ++Index.pageNum; pageNum = ++Index.pageNum;
if (pageNum > Index.pagesNum) { if (pageNum > Index.pagesNum) {
@ -3546,9 +3537,10 @@
Conf['Previous Index Mode'] = mode; Conf['Previous Index Mode'] = mode;
$.set('Previous Index Mode', mode); $.set('Previous Index Mode', mode);
} }
return Index.pageLoad(Index.pushState({ Index.pushState({
mode: mode mode: mode
})); });
return Index.pageLoad(false);
}, },
sort: function() { sort: function() {
Index.sort(); Index.sort();
@ -3575,32 +3567,19 @@
return Index.buildIndex(); return Index.buildIndex();
}, },
popstate: function(e) { popstate: function(e) {
var mode, page, ref, ref1, searched, state; var mode, page, ref, searched;
if (e != null ? e.state : void 0) { if (e != null ? e.state : void 0) {
ref = e.state, searched = ref.searched, mode = ref.mode; ref = e.state, searched = ref.searched, mode = ref.mode;
state = {};
if (Index.search !== searched) {
state.search = Index.search = searched;
}
if (Conf['Index Mode'] !== mode) {
state.mode = mode;
Index.saveMode(mode);
}
page = Index.getCurrentPage(); page = Index.getCurrentPage();
if (Index.currentPage !== page) { Index.setState({
state.page = Index.currentPage = page; search: searched,
} mode: mode,
if ((state.search != null) || (state.mode != null) || (state.page != null)) { page: page
return Index.pageLoad(state);
}
} else {
state = Index.pushState({
command: (ref1 = location.href.match(/#(.*)/)) != null ? ref1[1] : void 0,
replace: true,
scroll: true
}); });
if (state.command) { return Index.pageLoad(false);
return Index[Conf['Refreshed Navigation'] ? 'update' : 'pageLoad'](state); } else {
if (Index.processHash()) {
return Index[Conf['Refreshed Navigation'] ? 'update' : 'pageLoad']();
} }
} }
}, },
@ -3627,43 +3606,35 @@
return Index.userPageNav(+a.pathname.split(/\/+/)[2] || 1); return Index.userPageNav(+a.pathname.split(/\/+/)[2] || 1);
}, },
refreshFront: function() { refreshFront: function() {
return Index.update(Index.pushState({ Index.pushState({
page: 1, page: 1
scroll: true });
})); return Index.update();
} }
}, },
scrollToIndex: function() { scrollToIndex: function() {
return Header.scrollToIfNeeded(Index.navLinks); return Header.scrollToIfNeeded(Index.navLinks);
}, },
getCurrentPage: function() { getCurrentPage: function() {
var ref;
if ((ref = Conf['Index Mode']) === 'all pages' || ref === 'catalog') {
return 1;
} else {
return +window.location.pathname.split(/\/+/)[2] || 1; return +window.location.pathname.split(/\/+/)[2] || 1;
}
}, },
userPageNav: function(page) { userPageNav: function(page) {
var state; Index.pushState({
state = Index.pushState({ page: page
page: page,
scroll: true
}); });
if (Conf['Refreshed Navigation']) { if (Conf['Refreshed Navigation']) {
return Index.update(state); return Index.update();
} else { } else {
if (state.page) { return Index.pageLoad();
return Index.pageLoad(state);
}
} }
}, },
pushState: function(state) { processHash: function() {
var command, hash, mode, page, pageBeforeSearch, pathname, ref, search; var command, hash, ref, state;
pathname = location.pathname, hash = location.hash; hash = ((ref = location.href.match(/#.*/)) != null ? ref[0] : void 0) || '';
pageBeforeSearch = (ref = history.state) != null ? ref.oldpage : void 0; command = hash.slice(1);
if (state.command != null) { state = {
command = state.command; replace: true
};
if (command === 'paged' || command === 'infinite' || command === 'all-pages' || command === 'catalog') { if (command === 'paged' || command === 'infinite' || command === 'all-pages' || command === 'catalog') {
state.mode = command.replace(/-/g, ' '); state.mode = command.replace(/-/g, ' ');
} else if (command === 'index') { } else if (command === 'index') {
@ -3671,76 +3642,81 @@
state.page = 1; state.page = 1;
} else if (/^s=/.test(command)) { } else if (/^s=/.test(command)) {
state.search = decodeURIComponent(command.slice(2)).replace(/\+/g, ' ').trim(); state.search = decodeURIComponent(command.slice(2)).replace(/\+/g, ' ').trim();
hash = '';
} else { } else {
delete state.command; state.hash = hash;
} }
} Index.pushState(state);
if (state.search != null) { return state.hash == null;
search = state.search; },
pushState: function(state) {
var hash, pageBeforeSearch, pathname, ref, replace, search;
search = state.search, hash = state.hash, replace = state.replace;
pageBeforeSearch = (ref = history.state) != null ? ref.oldpage : void 0;
if ((search != null) && search !== Index.search) {
state.page = search ? 1 : pageBeforeSearch || 1; state.page = search ? 1 : pageBeforeSearch || 1;
if (!search) { if (!search) {
pageBeforeSearch = void 0; pageBeforeSearch = void 0;
} else if (!Index.search) { } else if (!Index.search) {
pageBeforeSearch = Index.currentPage; pageBeforeSearch = Index.currentPage;
} }
Index.search = search;
} }
if (state.mode != null) { Index.setState(state);
mode = state.mode; pathname = Index.currentPage === 1 ? "/" + g.BOARD + "/" : "/" + g.BOARD + "/" + Index.currentPage;
if (mode === Conf['Index Mode']) { hash || (hash = '');
delete state.mode; return history[replace ? 'replaceState' : 'pushState']({
}
Index.saveMode(mode);
if (mode === 'all pages' || mode === 'catalog') {
state.page = 1;
}
hash = '';
}
if (state.page != null) {
page = state.page;
if (page === Index.currentPage) {
delete state.page;
}
Index.currentPage = page;
pathname = page === 1 ? "/" + g.BOARD + "/" : "/" + g.BOARD + "/" + page;
hash = '';
}
history[state.replace ? 'replaceState' : 'pushState']({
mode: Conf['Index Mode'], mode: Conf['Index Mode'],
searched: Index.search, searched: Index.search,
oldpage: pageBeforeSearch oldpage: pageBeforeSearch
}, '', location.protocol + "//" + location.host + pathname + hash); }, '', location.protocol + "//" + location.host + pathname + hash);
return state;
}, },
saveMode: function(mode) { setState: function(arg) {
if (Conf['Index Mode'] !== mode) { var mode, page, ref, search;
search = arg.search, mode = arg.mode, page = arg.page;
if ((search != null) && search !== Index.search) {
Index.changed.search = true;
Index.search = search;
}
if ((mode != null) && mode !== Conf['Index Mode']) {
Index.changed.mode = true;
Conf['Index Mode'] = mode; Conf['Index Mode'] = mode;
$.set('Index Mode', mode); $.set('Index Mode', mode);
}
if (!(mode === 'catalog' || Conf['Previous Index Mode'] === mode)) { if (!(mode === 'catalog' || Conf['Previous Index Mode'] === mode)) {
Conf['Previous Index Mode'] = mode; Conf['Previous Index Mode'] = mode;
return $.set('Previous Index Mode', mode); $.set('Previous Index Mode', mode);
}
}
if ((ref = Conf['Index Mode']) === 'all pages' || ref === 'catalog') {
page = 1;
}
if ((page != null) && page !== Index.currentPage) {
Index.changed.page = true;
return Index.currentPage = page;
} }
}, },
pageLoad: function(arg) { pageLoad: function(scroll) {
var mode, scroll, search, sort; var mode, page, ref, search, threads;
sort = arg.sort, search = arg.search, mode = arg.mode, scroll = arg.scroll; if (scroll == null) {
if (sort || (search != null)) { scroll = true;
}
ref = Index.changed, threads = ref.threads, search = ref.search, mode = ref.mode, page = ref.page;
if (threads || search) {
Index.sort(); Index.sort();
Index.buildPagelist(); Index.buildPagelist();
} }
if (search != null) { if (search) {
Index.setupSearch(); Index.setupSearch();
} }
if (mode != null) { if (mode) {
Index.applyMode(); Index.applyMode();
} }
if (threads || search || mode || page) {
Index.buildIndex(); Index.buildIndex();
Index.setPage(); Index.setPage();
if (scroll) {
return Index.scrollToIndex();
} }
if (scroll) {
Index.scrollToIndex();
}
return Index.changed = {};
}, },
applyMode: function() { applyMode: function() {
var k, len1, mode, ref; var k, len1, mode, ref;
@ -3783,7 +3759,7 @@
}, },
setPage: function() { setPage: function() {
var a, href, maxPageNum, next, pageNum, pagesRoot, prev, strong; var a, href, maxPageNum, next, pageNum, pagesRoot, prev, strong;
pageNum = Index.getCurrentPage(); pageNum = Index.currentPage;
maxPageNum = Index.getMaxPageNum(); maxPageNum = Index.getMaxPageNum();
pagesRoot = $('.pages', Index.pagelist); pagesRoot = $('.pages', Index.pagelist);
prev = pagesRoot.previousSibling.firstChild; prev = pagesRoot.previousSibling.firstChild;
@ -3828,7 +3804,7 @@
Index.hideLabel.hidden = false; Index.hideLabel.hidden = false;
return $('#hidden-count', Index.navLinks).textContent = hiddenCount === 1 ? '1 hidden thread' : hiddenCount + " hidden threads"; return $('#hidden-count', Index.navLinks).textContent = hiddenCount === 1 ? '1 hidden thread' : hiddenCount + " hidden threads";
}, },
update: function(state) { update: function(firstTime) {
var now, ref, ref1; var now, ref, ref1;
if ((ref = Index.req) != null) { if ((ref = Index.req) != null) {
ref.abort(); ref.abort();
@ -3848,16 +3824,18 @@
}), 3 * $.SECOND - (Date.now() - now)); }), 3 * $.SECOND - (Date.now() - now));
}); });
} }
Index.req = $.ajax("//a.4cdn.org/" + g.BOARD + "/catalog.json", { if (!firstTime && d.readyState !== 'loading' && !$('.board + *')) {
onloadend: function(e) { location.reload();
return Index.load(e, state); return;
} }
Index.req = $.ajax("//a.4cdn.org/" + g.BOARD + "/catalog.json", {
onloadend: Index.load
}, { }, {
whenModified: 'Index' whenModified: 'Index'
}); });
return $.addClass(Index.button, 'fa-spin'); return $.addClass(Index.button, 'fa-spin');
}, },
load: function(e, state) { load: function(e) {
var err, nTimeout, notice, ref, req, timeEl; var err, nTimeout, notice, ref, req, timeEl;
$.rmClass(Index.button, 'fa-spin'); $.rmClass(Index.button, 'fa-spin');
req = Index.req, notice = Index.notice, nTimeout = Index.nTimeout; req = Index.req, notice = Index.notice, nTimeout = Index.nTimeout;
@ -3885,9 +3863,9 @@
} }
try { try {
if (req.status === 200) { if (req.status === 200) {
Index.parse(req.response, state); Index.parse(req.response);
} else if (req.status === 304 && (state != null)) { } else if (req.status === 304) {
Index.pageLoad(state); Index.pageLoad();
} }
} catch (_error) { } catch (_error) {
err = _error; err = _error;
@ -3912,18 +3890,16 @@
} }
timeEl = $('#index-last-refresh time', Index.navLinks); timeEl = $('#index-last-refresh time', Index.navLinks);
timeEl.dataset.utc = Date.parse(req.getResponseHeader('Last-Modified')); timeEl.dataset.utc = Date.parse(req.getResponseHeader('Last-Modified'));
RelativeDates.update(timeEl); return RelativeDates.update(timeEl);
return Index.scrollToIndex();
}, },
parse: function(pages, state) { parse: function(pages) {
$.cleanCache(function(url) { $.cleanCache(function(url) {
return /^\/\/a\.4cdn\.org\//.test(url); return /^\/\/a\.4cdn\.org\//.test(url);
}); });
Index.parseThreadList(pages); Index.parseThreadList(pages);
Index.buildThreads(); Index.buildThreads();
state || (state = {}); Index.changed.threads = true;
state.sort = true; return Index.pageLoad();
return Index.pageLoad(state);
}, },
parseThreadList: function(pages) { parseThreadList: function(pages) {
Index.pagesNum = pages.length; Index.pagesNum = pages.length;
@ -4140,14 +4116,15 @@
i++; i++;
} }
page = Math.floor(i / Index.threadsNumPerPage) + 1; page = Math.floor(i / Index.threadsNumPerPage) + 1;
if (page !== Index.getCurrentPage()) { if (page !== Index.currentPage) {
Index.currentPage = page;
Index.pushState({ Index.pushState({
page: page page: page
}); });
Index.setPage(); Index.setPage();
} }
} }
nodes = Index.buildSinglePage(Index.getCurrentPage()); nodes = Index.buildSinglePage(Index.currentPage);
} }
delete Index.pageNum; delete Index.pageNum;
$.rmAll(Index.root); $.rmAll(Index.root);
@ -4190,10 +4167,8 @@
Index.onSearchInput(); Index.onSearchInput();
return Index.searchInput.focus(); return Index.searchInput.focus();
}, },
setupSearch: function(noUpdate) { setupSearch: function() {
if (!noUpdate) {
Index.searchInput.value = Index.search; Index.searchInput.value = Index.search;
}
if (Index.search) { if (Index.search) {
return Index.searchInput.dataset.searching = 1; return Index.searchInput.dataset.searching = 1;
} else { } else {
@ -4206,10 +4181,11 @@
if (search === Index.search) { if (search === Index.search) {
return; return;
} }
return Index.pageLoad(Index.pushState({ Index.pushState({
search: search, search: search,
replace: !!search === !!Index.search replace: !!search === !!Index.search
})); });
return Index.pageLoad(false);
}, },
querySearch: function(query) { querySearch: function(query) {
var keywords; var keywords;
@ -6335,7 +6311,7 @@
} }
}, },
process: function(link, clone) { process: function(link, clone) {
if (Conf['Inline Cross-thread Quotes Only'] && link.getAttribute('href')[0] === '#') { if (Conf['Inline Cross-thread Quotes Only'] && link.pathname === location.pathname && link.host === location.host && link.protocol === location.protocol) {
return; return;
} }
if (Conf['Quote Hash Navigation']) { if (Conf['Quote Hash Navigation']) {
@ -6619,7 +6595,10 @@
return $.asap((function() { return $.asap((function() {
return !Conf['Thread Updater'] || $('.navLinksBot > .updatelink'); return !Conf['Thread Updater'] || $('.navLinksBot > .updatelink');
}), function() { }), function() {
return $.add($('.navLinksBot'), [$.tn(' '), QuoteThreading.threadNewLink]); var navLinksBot;
if ((navLinksBot = $('.navLinksBot'))) {
return $.add(navLinksBot, [$.tn(' '), QuoteThreading.threadNewLink]);
}
}); });
}, },
node: function() { node: function() {
@ -7029,7 +7008,7 @@
} }
}, },
initReady: function() { initReady: function() {
var link, linkBot, origToggle; var link, linkBot, navLinksBot, origToggle;
$.off(d, '4chanXInitFinished', this.initReady); $.off(d, '4chanXInitFinished', this.initReady);
QR.postingIsEnabled = !!$.id('postForm'); QR.postingIsEnabled = !!$.id('postForm');
if (!QR.postingIsEnabled) { if (!QR.postingIsEnabled) {
@ -7057,7 +7036,9 @@
QR.open(); QR.open();
return QR.nodes.com.focus(); return QR.nodes.com.focus();
}); });
$.prepend($('.navLinksBot'), linkBot); if ((navLinksBot = $('.navLinksBot'))) {
$.prepend(navLinksBot, linkBot);
}
} }
origToggle = $.id('togglePostFormLink'); origToggle = $.id('togglePostFormLink');
$.before(origToggle, link); $.before(origToggle, link);
@ -12503,7 +12484,6 @@
}); });
$.add(a, range.extractContents()); $.add(a, range.extractContents());
range.insertNode(a); range.insertNode(a);
range.detach();
return a; return a;
} }
}; };
@ -13168,7 +13148,10 @@
innerHTML: "<a href=\"javascript:;\">Update</a>" innerHTML: "<a href=\"javascript:;\">Update</a>"
}); });
Main.ready(function() { Main.ready(function() {
return $.add($('.navLinksBot'), [$.tn(' '), updateLink]); var navLinksBot;
if ((navLinksBot = $('.navLinksBot'))) {
return $.add(navLinksBot, [$.tn(' '), updateLink]);
}
}); });
$.on(updateLink.firstElementChild, 'click', this.update); $.on(updateLink.firstElementChild, 'click', this.update);
subEntries = []; subEntries = [];
@ -15644,7 +15627,15 @@
}); });
} }
return Main.ready(function() { return Main.ready(function() {
return $.globalEval('(function() {\n window.clickable_ids = false;\n var nodes = document.querySelectorAll(\'.posteruid, .capcode\');\n for (var i = 0; i < nodes.length; i++) {\n nodes[i].removeEventListener("click", window.idClick, false);\n }\n window.removeEventListener("message", Report.onMessage, false);\n})();'); return $.global(function() {
var k, len1, node, ref1;
window.clickable_ids = false;
ref1 = document.querySelectorAll('.posteruid, .capcode');
for (k = 0, len1 = ref1.length; k < len1; k++) {
node = ref1[k];
node.removeEventListener('click', window.idClick, false);
}
});
}); });
}, },
code: function() { code: function() {
@ -17650,6 +17641,14 @@
}); });
return; return;
} }
$.on(d, '4chanXInitFinished', function() {
if (Main.expectInitFinished) {
return delete Main.expectInitFinished;
} else {
new Notice('error', 'Error: Multiple copies of 4chan X are enabled.');
return $.addClass(doc, 'tainted');
}
});
flatten = function(parent, obj) { flatten = function(parent, obj) {
var key, val; var key, val;
if (obj instanceof Array) { if (obj instanceof Array) {
@ -17814,7 +17813,7 @@
}, },
initStyle: function() { initStyle: function() {
var keyboard, ref; var keyboard, ref;
if (!Main.isThisPageLegit() || $.hasClass(doc, 'fourchan-x')) { if (!Main.isThisPageLegit()) {
return; return;
} }
if ((ref = $('link[href*=mobile]', d.head)) != null) { if ((ref = $('link[href*=mobile]', d.head)) != null) {
@ -17876,7 +17875,7 @@
}); });
}, },
initReady: function() { initReady: function() {
var ref, ref1; var msg, ref, ref1, ref2;
if (g.VIEW === 'thread' && (((ref = d.title) === '4chan - Temporarily Offline' || ref === '4chan - 404 Not Found') || ($('.board') && !$('.opContainer')))) { if (g.VIEW === 'thread' && (((ref = d.title) === '4chan - Temporarily Offline' || ref === '4chan - 404 Not Found') || ($('.board') && !$('.opContainer')))) {
ThreadWatcher.set404(g.BOARD.ID, g.THREADID, function() { ThreadWatcher.set404(g.BOARD.ID, g.THREADID, function() {
if (Conf['404 Redirect']) { if (Conf['404 Redirect']) {
@ -17892,15 +17891,25 @@
if ((ref1 = d.title) === '4chan - Temporarily Offline' || ref1 === '4chan - 404 Not Found') { if ((ref1 = d.title) === '4chan - Temporarily Offline' || ref1 === '4chan - 404 Not Found') {
return; return;
} }
if (((ref2 = g.VIEW) === 'index' || ref2 === 'thread') && !$('.board + *')) {
msg = $.el('div', {
innerHTML: "The page didn&#039;t load completely.<br>Some features may not work unless you <a href=\"javascript:;\">reload</a>."
});
$.on($('a', msg), 'click', function() {
return location.reload();
});
new Notice('warning', msg);
}
if (!(Conf['JSON Navigation'] && g.VIEW === 'index')) { if (!(Conf['JSON Navigation'] && g.VIEW === 'index')) {
return Main.initThread(); return Main.initThread();
} else { } else {
Main.expectInitFinished = true;
return $.event('4chanXInitFinished'); return $.event('4chanXInitFinished');
} }
}, },
initThread: function() { initThread: function() {
var board, err, errors, k, len1, len2, m, postRoot, posts, q, ref, ref1, scriptData, thread, threadRoot, threads; var board, err, errors, k, len1, len2, m, postRoot, posts, q, ref, ref1, scriptData, thread, threadRoot, threads;
if (board = $('.board')) { if ((board = $('.board'))) {
threads = []; threads = [];
posts = []; posts = [];
ref = $$('.board > .thread', board); ref = $$('.board > .thread', board);
@ -17911,6 +17920,7 @@
ref1 = $$('.thread > .postContainer', threadRoot); ref1 = $$('.thread > .postContainer', threadRoot);
for (q = 0, len2 = ref1.length; q < len2; q++) { for (q = 0, len2 = ref1.length; q < len2; q++) {
postRoot = ref1[q]; postRoot = ref1[q];
if ($('.postMessage', postRoot)) {
try { try {
posts.push(new Post(postRoot, thread, g.BOARD)); posts.push(new Post(postRoot, thread, g.BOARD));
} catch (_error) { } catch (_error) {
@ -17925,6 +17935,7 @@
} }
} }
} }
}
if (errors) { if (errors) {
Main.handleErrors(errors); Main.handleErrors(errors);
} }
@ -17941,9 +17952,11 @@
post = posts[u]; post = posts[u];
QuoteThreading.insert(post); QuoteThreading.insert(post);
} }
Main.expectInitFinished = true;
return $.event('4chanXInitFinished'); return $.event('4chanXInitFinished');
}); });
} else { } else {
Main.expectInitFinished = true;
return $.event('4chanXInitFinished'); return $.event('4chanXInitFinished');
} }
}, },
@ -18034,7 +18047,7 @@
details = details.replace(/file:\/{3}.+\//g, ''); details = details.replace(/file:\/{3}.+\//g, '');
url = "https://gitreports.com/issue/ccd0/4chan-x?issue_title=" + (encodeURIComponent(title)) + "&details=" + (encodeURIComponent(details)); url = "https://gitreports.com/issue/ccd0/4chan-x?issue_title=" + (encodeURIComponent(title)) + "&details=" + (encodeURIComponent(details));
return { return {
innerHTML: " [<a href=\"" + E(url) + "\" target=\"_blank\">report</a>]" innerHTML: "<span class=\"report-error\"> [<a href=\"" + E(url) + "\" target=\"_blank\">report</a>]</span>"
}; };
}, },
isThisPageLegit: function() { isThisPageLegit: function() {
@ -19139,6 +19152,9 @@
".message a {\n" + ".message a {\n" +
" text-decoration: underline;\n" + " text-decoration: underline;\n" +
"}\n" + "}\n" +
":root.tainted .report-error {\n" +
" display: none;\n" +
"}\n" +
"/* Settings */\n" + "/* Settings */\n" +
":root.fourchan-x body {\n" + ":root.fourchan-x body {\n" +
" -moz-box-sizing: border-box;\n" + " -moz-box-sizing: border-box;\n" +
@ -19328,9 +19344,9 @@
" overflow: hidden;\n" + " overflow: hidden;\n" +
"}\n" + "}\n" +
"/* Index */\n" + "/* Index */\n" +
":root.index-loading .navLinks,\n" + ":root.index-loading .navLinks:not(.json-index),\n" +
":root.index-loading .board,\n" + ":root.index-loading .board:not(.json-index),\n" +
":root.index-loading .pagelist,\n" + ":root.index-loading .pagelist:not(.json-index),\n" +
":root.infinite-mode .pagelist,\n" + ":root.infinite-mode .pagelist,\n" +
":root.all-pages-mode .pagelist,\n" + ":root.all-pages-mode .pagelist,\n" +
":root.catalog-mode .pagelist,\n" + ":root.catalog-mode .pagelist,\n" +

Binary file not shown.

View File

@ -1,6 +1,6 @@
// ==UserScript== // ==UserScript==
// @name 4chan X // @name 4chan X
// @version 1.11.22.4 // @version 1.11.23.0
// @minGMVer 1.14 // @minGMVer 1.14
// @minFFVer 26 // @minFFVer 26
// @namespace 4chan-X // @namespace 4chan-X

View File

@ -1,7 +1,7 @@
// Generated by CoffeeScript // Generated by CoffeeScript
// ==UserScript== // ==UserScript==
// @name 4chan X // @name 4chan X
// @version 1.11.22.4 // @version 1.11.23.0
// @minGMVer 1.14 // @minGMVer 1.14
// @minFFVer 26 // @minFFVer 26
// @namespace 4chan-X // @namespace 4chan-X
@ -434,7 +434,7 @@
doc = d.documentElement; doc = d.documentElement;
g = { g = {
VERSION: '1.11.22.4', VERSION: '1.11.23.0',
NAMESPACE: '4chan X.', NAMESPACE: '4chan X.',
boards: {} boards: {}
}; };
@ -602,7 +602,7 @@
if (req = reqs[url]) { if (req = reqs[url]) {
if (req.readyState === 4) { if (req.readyState === 4) {
$.queueTask(function() { $.queueTask(function() {
return cb.call(req, req.evt); return cb.call(req, req.evt, true);
}); });
} else { } else {
req.callbacks.push(cb); req.callbacks.push(cb);
@ -622,13 +622,16 @@
} }
$.on(req, 'load', function(e) { $.on(req, 'load', function(e) {
var k, len1, ref; var k, len1, ref;
this.evt = e;
ref = this.callbacks; ref = this.callbacks;
for (k = 0, len1 = ref.length; k < len1; k++) { for (k = 0, len1 = ref.length; k < len1; k++) {
cb = ref[k]; cb = ref[k];
cb.call(this, e); $.queueTask((function(_this) {
return function() {
return cb.call(_this, e, false);
};
})(this));
} }
this.evt = e;
this.cached = true;
return delete this.callbacks; return delete this.callbacks;
}); });
$.on(req, 'abort error', rm); $.on(req, 'abort error', rm);
@ -2326,8 +2329,8 @@
this.root.textContent = "Loading post No." + this.postID + "..."; this.root.textContent = "Loading post No." + this.postID + "...";
if (this.threadID) { if (this.threadID) {
$.cache("//a.4cdn.org/" + this.boardID + "/thread/" + this.threadID + ".json", (function(_this) { $.cache("//a.4cdn.org/" + this.boardID + "/thread/" + this.threadID + ".json", (function(_this) {
return function(e) { return function(e, isCached) {
return _this.fetchedPost(e.target); return _this.fetchedPost(e.target, isCached);
}; };
})(this)); })(this));
} else { } else {
@ -2358,7 +2361,7 @@
return $.event('PostsInserted'); return $.event('PostsInserted');
}; };
Fetcher.prototype.fetchedPost = function(req) { Fetcher.prototype.fetchedPost = function(req, isCached) {
var api, board, k, len1, post, posts, status, thread; var api, board, k, len1, post, posts, status, thread;
if (post = g.posts[this.boardID + "." + this.postID]) { if (post = g.posts[this.boardID + "." + this.postID]) {
this.insert(post); this.insert(post);
@ -2382,14 +2385,14 @@
} }
} }
if (post.no !== this.postID) { if (post.no !== this.postID) {
if (req.cached) { if (isCached) {
api = "//a.4cdn.org/" + this.boardID + "/thread/" + this.threadID + ".json"; api = "//a.4cdn.org/" + this.boardID + "/thread/" + this.threadID + ".json";
$.cleanCache(function(url) { $.cleanCache(function(url) {
return url === api; return url === api;
}); });
$.cache(api, (function(_this) { $.cache(api, (function(_this) {
return function(e) { return function(e) {
return _this.fetchedPost(e.target); return _this.fetchedPost(e.target, false);
}; };
})(this)); })(this));
return; return;
@ -2424,7 +2427,7 @@
if (/^https:\/\//.test(url) || location.protocol === 'http:') { if (/^https:\/\//.test(url) || location.protocol === 'http:') {
$.cache(url, (function(_this) { $.cache(url, (function(_this) {
return function(e) { return function(e) {
return _this.parseArchivedPost(e.target.response, url); return _this.parseArchivedPost(e.target.response, url, archive);
}; };
})(this), { })(this), {
responseType: 'json', responseType: 'json',
@ -2445,7 +2448,7 @@
} }
} }
} }
return _this.parseArchivedPost(response, url); return _this.parseArchivedPost(response, url, archive);
}; };
})(this)); })(this));
return true; return true;
@ -2453,12 +2456,17 @@
return false; return false;
}; };
Fetcher.prototype.parseArchivedPost = function(data, url) { Fetcher.prototype.parseArchivedPost = function(data, url, archive) {
var board, comment, greentext, i, j, key, o, post, ref, ref1, text, text2, thread, val; var board, comment, greentext, i, j, key, o, post, ref, ref1, text, text2, thread, val;
if (post = g.posts[this.boardID + "." + this.postID]) { if (post = g.posts[this.boardID + "." + this.postID]) {
this.insert(post); this.insert(post);
return; return;
} }
if (data == null) {
$.addClass(this.root, 'warning');
this.root.textContent = "Error fetching Post No." + this.postID + " from " + archive.name + ".";
return;
}
if (data.error) { if (data.error) {
$.addClass(this.root, 'warning'); $.addClass(this.root, 'warning');
this.root.textContent = data.error; this.root.textContent = data.error;
@ -2741,11 +2749,11 @@
a.className = 'current'; a.className = 'current';
} }
Main.ready(function() { Main.ready(function() {
var oldFooter; var absbot, oldFooter;
if (oldFooter = $.id('boardNavDesktopFoot')) { if ((oldFooter = $.id('boardNavDesktopFoot'))) {
return $.replace($('.boardList', oldFooter), Header.bottomBoardList); return $.replace($('.boardList', oldFooter), Header.bottomBoardList);
} else { } else if ((absbot = $.id('absbot'))) {
$.before($.id('absbot'), footer); $.before(absbot, footer);
return $.globalEval('window.cloneTopNav = function() {};'); return $.globalEval('window.cloneTopNav = function() {};');
} }
}); });
@ -3256,12 +3264,12 @@
Index = { Index = {
showHiddenThreads: false, showHiddenThreads: false,
changed: {},
init: function() { init: function() {
var anchorEntry, input, k, label, len1, len2, name, pinEntry, q, ref, ref1, ref2, ref3, ref4, ref5, ref6, refNavEntry, repliesEntry, select; var anchorEntry, input, k, label, len1, len2, name, pinEntry, q, ref, ref1, ref2, ref3, ref4, ref5, refNavEntry, repliesEntry, select;
if (g.BOARD.ID === 'f' || !Conf['JSON Navigation'] || g.VIEW !== 'index') { if (g.BOARD.ID === 'f' || !Conf['JSON Navigation'] || g.VIEW !== 'index') {
return; return;
} }
this.board = "" + g.BOARD;
CatalogThread.callbacks.push({ CatalogThread.callbacks.push({
name: 'Catalog Features', name: 'Catalog Features',
cb: this.catalogNode cb: this.catalogNode
@ -3271,10 +3279,10 @@
Conf['Index Mode'] = (ref2 = history.state) != null ? ref2.mode : void 0; Conf['Index Mode'] = (ref2 = history.state) != null ? ref2.mode : void 0;
} }
this.currentPage = this.getCurrentPage(); this.currentPage = this.getCurrentPage();
this.pushState({ this.processHash();
command: (ref3 = location.href.match(/#(.*)/)) != null ? ref3[1] : void 0, $.addClass(doc, 'index-loading', (Conf['Index Mode'].replace(/\ /g, '-')) + "-mode");
replace: true $.on(window, 'popstate', this.cb.popstate);
}); $.on(d, 'scroll', Index.scroll);
this.button = $.el('a', { this.button = $.el('a', {
className: 'index-refresh-shortcut fa fa-refresh', className: 'index-refresh-shortcut fa fa-refresh',
title: 'Refresh', title: 'Refresh',
@ -3300,9 +3308,9 @@
pinEntry.el.title = 'Move watched threads to the start of the index.'; pinEntry.el.title = 'Move watched threads to the start of the index.';
anchorEntry.el.title = 'Move hidden threads to the end of the index.'; anchorEntry.el.title = 'Move hidden threads to the end of the index.';
refNavEntry.el.title = 'Refresh index when navigating through pages.'; refNavEntry.el.title = 'Refresh index when navigating through pages.';
ref4 = [repliesEntry, pinEntry, anchorEntry, refNavEntry]; ref3 = [repliesEntry, pinEntry, anchorEntry, refNavEntry];
for (k = 0, len1 = ref4.length; k < len1; k++) { for (k = 0, len1 = ref3.length; k < len1; k++) {
label = ref4[k]; label = ref3[k];
input = label.el.firstChild; input = label.el.firstChild;
name = input.name; name = input.name;
$.on(input, 'change', $.cb.checked); $.on(input, 'change', $.cb.checked);
@ -3322,69 +3330,59 @@
order: 100, order: 100,
subEntries: [repliesEntry, pinEntry, anchorEntry, refNavEntry] subEntries: [repliesEntry, pinEntry, anchorEntry, refNavEntry]
}); });
$.addClass(doc, 'index-loading', (Conf['Index Mode'].replace(/\ /g, '-')) + "-mode");
this.root = $.el('div', {
className: 'board'
});
this.cb.size();
this.pagelist = $.el('div', {
className: 'pagelist'
});
$.extend(this.pagelist, {
innerHTML: "<div class=\"prev\"><a><button disabled>Previous</button></a></div><div class=\"pages\"></div><div class=\"next\"><a><button disabled>Next</button></a></div><div class=\"pages cataloglink\"><a href=\"./catalog\">Catalog</a></div>"
});
$('.cataloglink a', this.pagelist).href = CatalogLinks.catalog();
this.navLinks = $.el('div', { this.navLinks = $.el('div', {
className: 'navLinks' className: 'navLinks json-index'
}); });
$.extend(this.navLinks, { $.extend(this.navLinks, {
innerHTML: "<span class=\"brackets-wrap indexlink\"><a href=\"#index\">Index</a></span> <span class=\"brackets-wrap cataloglink\"><a href=\"#catalog\">Catalog</a></span> <span class=\"brackets-wrap archlistlink\"><a href=\"./archive\">Archive</a></span> <span class=\"brackets-wrap bottomlink\"><a href=\"#bottom\">Bottom</a></span> <span class=\"brackets-wrap\" id=\"index-last-refresh\"><a href=\"javascript:;\"><time title=\"Last index refresh\">...</time></a></span> <input type=\"search\" id=\"index-search\" class=\"field\" placeholder=\"Search\"><a id=\"index-search-clear\" href=\"javascript:;\" title=\"Clear search\">×</a><span id=\"hidden-label\" hidden> &mdash; <span id=\"hidden-count\"></span> <span id=\"hidden-toggle\">[<a href=\"javascript:;\">Show</a>]</span></span><select id=\"index-mode\" name=\"Index Mode\"><option disabled>Index Mode</option><option value=\"paged\">Paged</option><option value=\"infinite\">Infinite scrolling</option><option value=\"all pages\">All threads</option><option value=\"catalog\">Catalog</option></select><select id=\"index-sort\" name=\"Index Sort\"><option disabled>Index Sort</option><option value=\"bump\">Bump order</option><option value=\"lastreply\">Last reply</option><option value=\"birth\">Creation date</option><option value=\"replycount\">Reply count</option><option value=\"filecount\">File count</option></select><select id=\"index-size\" name=\"Index Size\"><option disabled>Image Size</option><option value=\"small\">Small</option><option value=\"large\">Large</option></select>" innerHTML: "<span class=\"brackets-wrap indexlink\"><a href=\"#index\">Index</a></span> <span class=\"brackets-wrap cataloglink\"><a href=\"#catalog\">Catalog</a></span> <span class=\"brackets-wrap archlistlink\"><a href=\"./archive\">Archive</a></span> <span class=\"brackets-wrap bottomlink\"><a href=\"#bottom\">Bottom</a></span> <span class=\"brackets-wrap\" id=\"index-last-refresh\"><a href=\"javascript:;\"><time title=\"Last index refresh\">...</time></a></span> <input type=\"search\" id=\"index-search\" class=\"field\" placeholder=\"Search\"><a id=\"index-search-clear\" href=\"javascript:;\" title=\"Clear search\">×</a><span id=\"hidden-label\" hidden> &mdash; <span id=\"hidden-count\"></span> <span id=\"hidden-toggle\">[<a href=\"javascript:;\">Show</a>]</span></span><select id=\"index-mode\" name=\"Index Mode\"><option disabled>Index Mode</option><option value=\"paged\">Paged</option><option value=\"infinite\">Infinite scrolling</option><option value=\"all pages\">All threads</option><option value=\"catalog\">Catalog</option></select><select id=\"index-sort\" name=\"Index Sort\"><option disabled>Index Sort</option><option value=\"bump\">Bump order</option><option value=\"lastreply\">Last reply</option><option value=\"birth\">Creation date</option><option value=\"replycount\">Reply count</option><option value=\"filecount\">File count</option></select><select id=\"index-size\" name=\"Index Size\"><option disabled>Image Size</option><option value=\"small\">Small</option><option value=\"large\">Large</option></select>"
}); });
$('.cataloglink a', this.navLinks).href = CatalogLinks.catalog(); $('.cataloglink a', this.navLinks).href = CatalogLinks.catalog();
if ((ref5 = g.BOARD.ID) === 'b' || ref5 === 'trash') { if ((ref4 = g.BOARD.ID) === 'b' || ref4 === 'trash') {
$('.archlistlink', this.navLinks).hidden = true; $('.archlistlink', this.navLinks).hidden = true;
} }
$.on($('#index-last-refresh a', this.navLinks), 'click', this.cb.refreshFront);
this.searchInput = $('#index-search', this.navLinks); this.searchInput = $('#index-search', this.navLinks);
this.setupSearch(); this.setupSearch();
$.on(this.searchInput, 'input', this.onSearchInput);
$.on($('#index-search-clear', this.navLinks), 'click', this.clearSearch);
this.hideLabel = $('#hidden-label', this.navLinks); this.hideLabel = $('#hidden-label', this.navLinks);
$.on($('#hidden-toggle a', this.navLinks), 'click', this.cb.toggleHiddenThreads);
this.selectMode = $('#index-mode', this.navLinks); this.selectMode = $('#index-mode', this.navLinks);
this.selectSort = $('#index-sort', this.navLinks); this.selectSort = $('#index-sort', this.navLinks);
this.selectSize = $('#index-size', this.navLinks); this.selectSize = $('#index-size', this.navLinks);
$.on(window, 'popstate', this.cb.popstate);
$.on(d, 'scroll', Index.scroll);
$.on(this.pagelist, 'click', this.cb.pageNav);
$.on(this.searchInput, 'input', this.onSearchInput);
$.on($('#index-last-refresh a', this.navLinks), 'click', this.cb.refreshFront);
$.on($('#index-search-clear', this.navLinks), 'click', this.clearSearch);
$.on($('#hidden-toggle a', this.navLinks), 'click', this.cb.toggleHiddenThreads);
$.on(this.selectMode, 'change', this.cb.mode); $.on(this.selectMode, 'change', this.cb.mode);
ref6 = [this.selectMode, this.selectSort, this.selectSize]; ref5 = [this.selectMode, this.selectSort, this.selectSize];
for (q = 0, len2 = ref6.length; q < len2; q++) { for (q = 0, len2 = ref5.length; q < len2; q++) {
select = ref6[q]; select = ref5[q];
select.value = Conf[select.name]; select.value = Conf[select.name];
$.on(select, 'change', $.cb.value); $.on(select, 'change', $.cb.value);
} }
$.on(this.selectSort, 'change', this.cb.sort); $.on(this.selectSort, 'change', this.cb.sort);
$.on(this.selectSize, 'change', this.cb.size); $.on(this.selectSize, 'change', this.cb.size);
this.update(); this.root = $.el('div', {
$.asap((function() { className: 'board json-index'
return $('title + *', doc) || d.readyState !== 'loading'; });
}), function() { this.cb.size();
this.pagelist = $.el('div', {
className: 'pagelist json-index'
});
$.extend(this.pagelist, {
innerHTML: "<div class=\"prev\"><a><button disabled>Previous</button></a></div><div class=\"pages\"></div><div class=\"next\"><a><button disabled>Next</button></a></div><div class=\"pages cataloglink\"><a href=\"./catalog\">Catalog</a></div>"
});
$('.cataloglink a', this.pagelist).href = CatalogLinks.catalog();
$.on(this.pagelist, 'click', this.cb.pageNav);
this.update(true);
$.onExists(doc, 'title + *', function() {
return d.title = d.title.replace(/\ -\ Page\ \d+/, ''); return d.title = d.title.replace(/\ -\ Page\ \d+/, '');
}); });
$.asap((function() { $.onExists(doc, '.board > .thread > .postContainer, .board + *', function() {
return $('.board > .thread > .postContainer', doc) || d.readyState !== 'loading'; var board, el, len3, len4, ref6, ref7, threadRoot, topNavPos, u, v;
}), function() {
var board, el, len3, len4, ref7, ref8, threadRoot, topNavPos, u, v;
if (!Main.isThisPageLegit()) {
return;
}
Index.hat = $('.board > .thread > img:first-child'); Index.hat = $('.board > .thread > img:first-child');
if (Index.hat) { if (Index.hat) {
if (Index.nodes) { if (Index.nodes) {
ref7 = Index.nodes; ref6 = Index.nodes;
for (u = 0, len3 = ref7.length; u < len3; u++) { for (u = 0, len3 = ref6.length; u < len3; u++) {
threadRoot = ref7[u]; threadRoot = ref6[u];
$.prepend(threadRoot, Index.hat.cloneNode(false)); $.prepend(threadRoot, Index.hat.cloneNode(false));
} }
} }
@ -3397,9 +3395,9 @@
try { try {
d.implementation.createDocument(null, null, null).appendChild(board); d.implementation.createDocument(null, null, null).appendChild(board);
} catch (_error) {} } catch (_error) {}
ref8 = $$('.navLinks'); ref7 = $$('.navLinks');
for (v = 0, len4 = ref8.length; v < len4; v++) { for (v = 0, len4 = ref7.length; v < len4; v++) {
el = ref8[v]; el = ref7[v];
$.rm(el); $.rm(el);
} }
$.rm($.id('ctrl-top')); $.rm($.id('ctrl-top'));
@ -3407,17 +3405,10 @@
$.before(topNavPos, $.el('hr')); $.before(topNavPos, $.el('hr'));
return $.before(topNavPos, Index.navLinks); return $.before(topNavPos, Index.navLinks);
}); });
return $.asap((function() { return Main.ready(function() {
return $('.pagelist', doc) || d.readyState !== 'loading';
}), function() {
var pagelist; var pagelist;
if (!Main.isThisPageLegit()) { if ((pagelist = $('.pagelist'))) {
return;
}
if (pagelist = $('.pagelist')) {
$.replace(pagelist, Index.pagelist); $.replace(pagelist, Index.pagelist);
} else {
$.after($.id('delform'), Index.pagelist);
} }
return $.rmClass(doc, 'index-loading'); return $.rmClass(doc, 'index-loading');
}); });
@ -3428,7 +3419,7 @@
return; return;
} }
if (Index.pageNum == null) { if (Index.pageNum == null) {
Index.pageNum = Index.getCurrentPage(); Index.pageNum = Index.currentPage;
} }
pageNum = ++Index.pageNum; pageNum = ++Index.pageNum;
if (pageNum > Index.pagesNum) { if (pageNum > Index.pagesNum) {
@ -3546,9 +3537,10 @@
Conf['Previous Index Mode'] = mode; Conf['Previous Index Mode'] = mode;
$.set('Previous Index Mode', mode); $.set('Previous Index Mode', mode);
} }
return Index.pageLoad(Index.pushState({ Index.pushState({
mode: mode mode: mode
})); });
return Index.pageLoad(false);
}, },
sort: function() { sort: function() {
Index.sort(); Index.sort();
@ -3575,32 +3567,19 @@
return Index.buildIndex(); return Index.buildIndex();
}, },
popstate: function(e) { popstate: function(e) {
var mode, page, ref, ref1, searched, state; var mode, page, ref, searched;
if (e != null ? e.state : void 0) { if (e != null ? e.state : void 0) {
ref = e.state, searched = ref.searched, mode = ref.mode; ref = e.state, searched = ref.searched, mode = ref.mode;
state = {};
if (Index.search !== searched) {
state.search = Index.search = searched;
}
if (Conf['Index Mode'] !== mode) {
state.mode = mode;
Index.saveMode(mode);
}
page = Index.getCurrentPage(); page = Index.getCurrentPage();
if (Index.currentPage !== page) { Index.setState({
state.page = Index.currentPage = page; search: searched,
} mode: mode,
if ((state.search != null) || (state.mode != null) || (state.page != null)) { page: page
return Index.pageLoad(state);
}
} else {
state = Index.pushState({
command: (ref1 = location.href.match(/#(.*)/)) != null ? ref1[1] : void 0,
replace: true,
scroll: true
}); });
if (state.command) { return Index.pageLoad(false);
return Index[Conf['Refreshed Navigation'] ? 'update' : 'pageLoad'](state); } else {
if (Index.processHash()) {
return Index[Conf['Refreshed Navigation'] ? 'update' : 'pageLoad']();
} }
} }
}, },
@ -3627,43 +3606,35 @@
return Index.userPageNav(+a.pathname.split(/\/+/)[2] || 1); return Index.userPageNav(+a.pathname.split(/\/+/)[2] || 1);
}, },
refreshFront: function() { refreshFront: function() {
return Index.update(Index.pushState({ Index.pushState({
page: 1, page: 1
scroll: true });
})); return Index.update();
} }
}, },
scrollToIndex: function() { scrollToIndex: function() {
return Header.scrollToIfNeeded(Index.navLinks); return Header.scrollToIfNeeded(Index.navLinks);
}, },
getCurrentPage: function() { getCurrentPage: function() {
var ref;
if ((ref = Conf['Index Mode']) === 'all pages' || ref === 'catalog') {
return 1;
} else {
return +window.location.pathname.split(/\/+/)[2] || 1; return +window.location.pathname.split(/\/+/)[2] || 1;
}
}, },
userPageNav: function(page) { userPageNav: function(page) {
var state; Index.pushState({
state = Index.pushState({ page: page
page: page,
scroll: true
}); });
if (Conf['Refreshed Navigation']) { if (Conf['Refreshed Navigation']) {
return Index.update(state); return Index.update();
} else { } else {
if (state.page) { return Index.pageLoad();
return Index.pageLoad(state);
}
} }
}, },
pushState: function(state) { processHash: function() {
var command, hash, mode, page, pageBeforeSearch, pathname, ref, search; var command, hash, ref, state;
pathname = location.pathname, hash = location.hash; hash = ((ref = location.href.match(/#.*/)) != null ? ref[0] : void 0) || '';
pageBeforeSearch = (ref = history.state) != null ? ref.oldpage : void 0; command = hash.slice(1);
if (state.command != null) { state = {
command = state.command; replace: true
};
if (command === 'paged' || command === 'infinite' || command === 'all-pages' || command === 'catalog') { if (command === 'paged' || command === 'infinite' || command === 'all-pages' || command === 'catalog') {
state.mode = command.replace(/-/g, ' '); state.mode = command.replace(/-/g, ' ');
} else if (command === 'index') { } else if (command === 'index') {
@ -3671,76 +3642,81 @@
state.page = 1; state.page = 1;
} else if (/^s=/.test(command)) { } else if (/^s=/.test(command)) {
state.search = decodeURIComponent(command.slice(2)).replace(/\+/g, ' ').trim(); state.search = decodeURIComponent(command.slice(2)).replace(/\+/g, ' ').trim();
hash = '';
} else { } else {
delete state.command; state.hash = hash;
} }
} Index.pushState(state);
if (state.search != null) { return state.hash == null;
search = state.search; },
pushState: function(state) {
var hash, pageBeforeSearch, pathname, ref, replace, search;
search = state.search, hash = state.hash, replace = state.replace;
pageBeforeSearch = (ref = history.state) != null ? ref.oldpage : void 0;
if ((search != null) && search !== Index.search) {
state.page = search ? 1 : pageBeforeSearch || 1; state.page = search ? 1 : pageBeforeSearch || 1;
if (!search) { if (!search) {
pageBeforeSearch = void 0; pageBeforeSearch = void 0;
} else if (!Index.search) { } else if (!Index.search) {
pageBeforeSearch = Index.currentPage; pageBeforeSearch = Index.currentPage;
} }
Index.search = search;
} }
if (state.mode != null) { Index.setState(state);
mode = state.mode; pathname = Index.currentPage === 1 ? "/" + g.BOARD + "/" : "/" + g.BOARD + "/" + Index.currentPage;
if (mode === Conf['Index Mode']) { hash || (hash = '');
delete state.mode; return history[replace ? 'replaceState' : 'pushState']({
}
Index.saveMode(mode);
if (mode === 'all pages' || mode === 'catalog') {
state.page = 1;
}
hash = '';
}
if (state.page != null) {
page = state.page;
if (page === Index.currentPage) {
delete state.page;
}
Index.currentPage = page;
pathname = page === 1 ? "/" + g.BOARD + "/" : "/" + g.BOARD + "/" + page;
hash = '';
}
history[state.replace ? 'replaceState' : 'pushState']({
mode: Conf['Index Mode'], mode: Conf['Index Mode'],
searched: Index.search, searched: Index.search,
oldpage: pageBeforeSearch oldpage: pageBeforeSearch
}, '', location.protocol + "//" + location.host + pathname + hash); }, '', location.protocol + "//" + location.host + pathname + hash);
return state;
}, },
saveMode: function(mode) { setState: function(arg) {
if (Conf['Index Mode'] !== mode) { var mode, page, ref, search;
search = arg.search, mode = arg.mode, page = arg.page;
if ((search != null) && search !== Index.search) {
Index.changed.search = true;
Index.search = search;
}
if ((mode != null) && mode !== Conf['Index Mode']) {
Index.changed.mode = true;
Conf['Index Mode'] = mode; Conf['Index Mode'] = mode;
$.set('Index Mode', mode); $.set('Index Mode', mode);
}
if (!(mode === 'catalog' || Conf['Previous Index Mode'] === mode)) { if (!(mode === 'catalog' || Conf['Previous Index Mode'] === mode)) {
Conf['Previous Index Mode'] = mode; Conf['Previous Index Mode'] = mode;
return $.set('Previous Index Mode', mode); $.set('Previous Index Mode', mode);
}
}
if ((ref = Conf['Index Mode']) === 'all pages' || ref === 'catalog') {
page = 1;
}
if ((page != null) && page !== Index.currentPage) {
Index.changed.page = true;
return Index.currentPage = page;
} }
}, },
pageLoad: function(arg) { pageLoad: function(scroll) {
var mode, scroll, search, sort; var mode, page, ref, search, threads;
sort = arg.sort, search = arg.search, mode = arg.mode, scroll = arg.scroll; if (scroll == null) {
if (sort || (search != null)) { scroll = true;
}
ref = Index.changed, threads = ref.threads, search = ref.search, mode = ref.mode, page = ref.page;
if (threads || search) {
Index.sort(); Index.sort();
Index.buildPagelist(); Index.buildPagelist();
} }
if (search != null) { if (search) {
Index.setupSearch(); Index.setupSearch();
} }
if (mode != null) { if (mode) {
Index.applyMode(); Index.applyMode();
} }
if (threads || search || mode || page) {
Index.buildIndex(); Index.buildIndex();
Index.setPage(); Index.setPage();
if (scroll) {
return Index.scrollToIndex();
} }
if (scroll) {
Index.scrollToIndex();
}
return Index.changed = {};
}, },
applyMode: function() { applyMode: function() {
var k, len1, mode, ref; var k, len1, mode, ref;
@ -3783,7 +3759,7 @@
}, },
setPage: function() { setPage: function() {
var a, href, maxPageNum, next, pageNum, pagesRoot, prev, strong; var a, href, maxPageNum, next, pageNum, pagesRoot, prev, strong;
pageNum = Index.getCurrentPage(); pageNum = Index.currentPage;
maxPageNum = Index.getMaxPageNum(); maxPageNum = Index.getMaxPageNum();
pagesRoot = $('.pages', Index.pagelist); pagesRoot = $('.pages', Index.pagelist);
prev = pagesRoot.previousSibling.firstChild; prev = pagesRoot.previousSibling.firstChild;
@ -3828,7 +3804,7 @@
Index.hideLabel.hidden = false; Index.hideLabel.hidden = false;
return $('#hidden-count', Index.navLinks).textContent = hiddenCount === 1 ? '1 hidden thread' : hiddenCount + " hidden threads"; return $('#hidden-count', Index.navLinks).textContent = hiddenCount === 1 ? '1 hidden thread' : hiddenCount + " hidden threads";
}, },
update: function(state) { update: function(firstTime) {
var now, ref, ref1; var now, ref, ref1;
if ((ref = Index.req) != null) { if ((ref = Index.req) != null) {
ref.abort(); ref.abort();
@ -3848,16 +3824,18 @@
}), 3 * $.SECOND - (Date.now() - now)); }), 3 * $.SECOND - (Date.now() - now));
}); });
} }
Index.req = $.ajax("//a.4cdn.org/" + g.BOARD + "/catalog.json", { if (!firstTime && d.readyState !== 'loading' && !$('.board + *')) {
onloadend: function(e) { location.reload();
return Index.load(e, state); return;
} }
Index.req = $.ajax("//a.4cdn.org/" + g.BOARD + "/catalog.json", {
onloadend: Index.load
}, { }, {
whenModified: 'Index' whenModified: 'Index'
}); });
return $.addClass(Index.button, 'fa-spin'); return $.addClass(Index.button, 'fa-spin');
}, },
load: function(e, state) { load: function(e) {
var err, nTimeout, notice, ref, req, timeEl; var err, nTimeout, notice, ref, req, timeEl;
$.rmClass(Index.button, 'fa-spin'); $.rmClass(Index.button, 'fa-spin');
req = Index.req, notice = Index.notice, nTimeout = Index.nTimeout; req = Index.req, notice = Index.notice, nTimeout = Index.nTimeout;
@ -3885,9 +3863,9 @@
} }
try { try {
if (req.status === 200) { if (req.status === 200) {
Index.parse(req.response, state); Index.parse(req.response);
} else if (req.status === 304 && (state != null)) { } else if (req.status === 304) {
Index.pageLoad(state); Index.pageLoad();
} }
} catch (_error) { } catch (_error) {
err = _error; err = _error;
@ -3912,18 +3890,16 @@
} }
timeEl = $('#index-last-refresh time', Index.navLinks); timeEl = $('#index-last-refresh time', Index.navLinks);
timeEl.dataset.utc = Date.parse(req.getResponseHeader('Last-Modified')); timeEl.dataset.utc = Date.parse(req.getResponseHeader('Last-Modified'));
RelativeDates.update(timeEl); return RelativeDates.update(timeEl);
return Index.scrollToIndex();
}, },
parse: function(pages, state) { parse: function(pages) {
$.cleanCache(function(url) { $.cleanCache(function(url) {
return /^\/\/a\.4cdn\.org\//.test(url); return /^\/\/a\.4cdn\.org\//.test(url);
}); });
Index.parseThreadList(pages); Index.parseThreadList(pages);
Index.buildThreads(); Index.buildThreads();
state || (state = {}); Index.changed.threads = true;
state.sort = true; return Index.pageLoad();
return Index.pageLoad(state);
}, },
parseThreadList: function(pages) { parseThreadList: function(pages) {
Index.pagesNum = pages.length; Index.pagesNum = pages.length;
@ -4140,14 +4116,15 @@
i++; i++;
} }
page = Math.floor(i / Index.threadsNumPerPage) + 1; page = Math.floor(i / Index.threadsNumPerPage) + 1;
if (page !== Index.getCurrentPage()) { if (page !== Index.currentPage) {
Index.currentPage = page;
Index.pushState({ Index.pushState({
page: page page: page
}); });
Index.setPage(); Index.setPage();
} }
} }
nodes = Index.buildSinglePage(Index.getCurrentPage()); nodes = Index.buildSinglePage(Index.currentPage);
} }
delete Index.pageNum; delete Index.pageNum;
$.rmAll(Index.root); $.rmAll(Index.root);
@ -4190,10 +4167,8 @@
Index.onSearchInput(); Index.onSearchInput();
return Index.searchInput.focus(); return Index.searchInput.focus();
}, },
setupSearch: function(noUpdate) { setupSearch: function() {
if (!noUpdate) {
Index.searchInput.value = Index.search; Index.searchInput.value = Index.search;
}
if (Index.search) { if (Index.search) {
return Index.searchInput.dataset.searching = 1; return Index.searchInput.dataset.searching = 1;
} else { } else {
@ -4206,10 +4181,11 @@
if (search === Index.search) { if (search === Index.search) {
return; return;
} }
return Index.pageLoad(Index.pushState({ Index.pushState({
search: search, search: search,
replace: !!search === !!Index.search replace: !!search === !!Index.search
})); });
return Index.pageLoad(false);
}, },
querySearch: function(query) { querySearch: function(query) {
var keywords; var keywords;
@ -6335,7 +6311,7 @@
} }
}, },
process: function(link, clone) { process: function(link, clone) {
if (Conf['Inline Cross-thread Quotes Only'] && link.getAttribute('href')[0] === '#') { if (Conf['Inline Cross-thread Quotes Only'] && link.pathname === location.pathname && link.host === location.host && link.protocol === location.protocol) {
return; return;
} }
if (Conf['Quote Hash Navigation']) { if (Conf['Quote Hash Navigation']) {
@ -6619,7 +6595,10 @@
return $.asap((function() { return $.asap((function() {
return !Conf['Thread Updater'] || $('.navLinksBot > .updatelink'); return !Conf['Thread Updater'] || $('.navLinksBot > .updatelink');
}), function() { }), function() {
return $.add($('.navLinksBot'), [$.tn(' '), QuoteThreading.threadNewLink]); var navLinksBot;
if ((navLinksBot = $('.navLinksBot'))) {
return $.add(navLinksBot, [$.tn(' '), QuoteThreading.threadNewLink]);
}
}); });
}, },
node: function() { node: function() {
@ -7029,7 +7008,7 @@
} }
}, },
initReady: function() { initReady: function() {
var link, linkBot, origToggle; var link, linkBot, navLinksBot, origToggle;
$.off(d, '4chanXInitFinished', this.initReady); $.off(d, '4chanXInitFinished', this.initReady);
QR.postingIsEnabled = !!$.id('postForm'); QR.postingIsEnabled = !!$.id('postForm');
if (!QR.postingIsEnabled) { if (!QR.postingIsEnabled) {
@ -7057,7 +7036,9 @@
QR.open(); QR.open();
return QR.nodes.com.focus(); return QR.nodes.com.focus();
}); });
$.prepend($('.navLinksBot'), linkBot); if ((navLinksBot = $('.navLinksBot'))) {
$.prepend(navLinksBot, linkBot);
}
} }
origToggle = $.id('togglePostFormLink'); origToggle = $.id('togglePostFormLink');
$.before(origToggle, link); $.before(origToggle, link);
@ -12503,7 +12484,6 @@
}); });
$.add(a, range.extractContents()); $.add(a, range.extractContents());
range.insertNode(a); range.insertNode(a);
range.detach();
return a; return a;
} }
}; };
@ -13168,7 +13148,10 @@
innerHTML: "<a href=\"javascript:;\">Update</a>" innerHTML: "<a href=\"javascript:;\">Update</a>"
}); });
Main.ready(function() { Main.ready(function() {
return $.add($('.navLinksBot'), [$.tn(' '), updateLink]); var navLinksBot;
if ((navLinksBot = $('.navLinksBot'))) {
return $.add(navLinksBot, [$.tn(' '), updateLink]);
}
}); });
$.on(updateLink.firstElementChild, 'click', this.update); $.on(updateLink.firstElementChild, 'click', this.update);
subEntries = []; subEntries = [];
@ -15644,7 +15627,15 @@
}); });
} }
return Main.ready(function() { return Main.ready(function() {
return $.globalEval('(function() {\n window.clickable_ids = false;\n var nodes = document.querySelectorAll(\'.posteruid, .capcode\');\n for (var i = 0; i < nodes.length; i++) {\n nodes[i].removeEventListener("click", window.idClick, false);\n }\n window.removeEventListener("message", Report.onMessage, false);\n})();'); return $.global(function() {
var k, len1, node, ref1;
window.clickable_ids = false;
ref1 = document.querySelectorAll('.posteruid, .capcode');
for (k = 0, len1 = ref1.length; k < len1; k++) {
node = ref1[k];
node.removeEventListener('click', window.idClick, false);
}
});
}); });
}, },
code: function() { code: function() {
@ -17650,6 +17641,14 @@
}); });
return; return;
} }
$.on(d, '4chanXInitFinished', function() {
if (Main.expectInitFinished) {
return delete Main.expectInitFinished;
} else {
new Notice('error', 'Error: Multiple copies of 4chan X are enabled.');
return $.addClass(doc, 'tainted');
}
});
flatten = function(parent, obj) { flatten = function(parent, obj) {
var key, val; var key, val;
if (obj instanceof Array) { if (obj instanceof Array) {
@ -17814,7 +17813,7 @@
}, },
initStyle: function() { initStyle: function() {
var keyboard, ref; var keyboard, ref;
if (!Main.isThisPageLegit() || $.hasClass(doc, 'fourchan-x')) { if (!Main.isThisPageLegit()) {
return; return;
} }
if ((ref = $('link[href*=mobile]', d.head)) != null) { if ((ref = $('link[href*=mobile]', d.head)) != null) {
@ -17876,7 +17875,7 @@
}); });
}, },
initReady: function() { initReady: function() {
var ref, ref1; var msg, ref, ref1, ref2;
if (g.VIEW === 'thread' && (((ref = d.title) === '4chan - Temporarily Offline' || ref === '4chan - 404 Not Found') || ($('.board') && !$('.opContainer')))) { if (g.VIEW === 'thread' && (((ref = d.title) === '4chan - Temporarily Offline' || ref === '4chan - 404 Not Found') || ($('.board') && !$('.opContainer')))) {
ThreadWatcher.set404(g.BOARD.ID, g.THREADID, function() { ThreadWatcher.set404(g.BOARD.ID, g.THREADID, function() {
if (Conf['404 Redirect']) { if (Conf['404 Redirect']) {
@ -17892,15 +17891,25 @@
if ((ref1 = d.title) === '4chan - Temporarily Offline' || ref1 === '4chan - 404 Not Found') { if ((ref1 = d.title) === '4chan - Temporarily Offline' || ref1 === '4chan - 404 Not Found') {
return; return;
} }
if (((ref2 = g.VIEW) === 'index' || ref2 === 'thread') && !$('.board + *')) {
msg = $.el('div', {
innerHTML: "The page didn&#039;t load completely.<br>Some features may not work unless you <a href=\"javascript:;\">reload</a>."
});
$.on($('a', msg), 'click', function() {
return location.reload();
});
new Notice('warning', msg);
}
if (!(Conf['JSON Navigation'] && g.VIEW === 'index')) { if (!(Conf['JSON Navigation'] && g.VIEW === 'index')) {
return Main.initThread(); return Main.initThread();
} else { } else {
Main.expectInitFinished = true;
return $.event('4chanXInitFinished'); return $.event('4chanXInitFinished');
} }
}, },
initThread: function() { initThread: function() {
var board, err, errors, k, len1, len2, m, postRoot, posts, q, ref, ref1, scriptData, thread, threadRoot, threads; var board, err, errors, k, len1, len2, m, postRoot, posts, q, ref, ref1, scriptData, thread, threadRoot, threads;
if (board = $('.board')) { if ((board = $('.board'))) {
threads = []; threads = [];
posts = []; posts = [];
ref = $$('.board > .thread', board); ref = $$('.board > .thread', board);
@ -17911,6 +17920,7 @@
ref1 = $$('.thread > .postContainer', threadRoot); ref1 = $$('.thread > .postContainer', threadRoot);
for (q = 0, len2 = ref1.length; q < len2; q++) { for (q = 0, len2 = ref1.length; q < len2; q++) {
postRoot = ref1[q]; postRoot = ref1[q];
if ($('.postMessage', postRoot)) {
try { try {
posts.push(new Post(postRoot, thread, g.BOARD)); posts.push(new Post(postRoot, thread, g.BOARD));
} catch (_error) { } catch (_error) {
@ -17925,6 +17935,7 @@
} }
} }
} }
}
if (errors) { if (errors) {
Main.handleErrors(errors); Main.handleErrors(errors);
} }
@ -17941,9 +17952,11 @@
post = posts[u]; post = posts[u];
QuoteThreading.insert(post); QuoteThreading.insert(post);
} }
Main.expectInitFinished = true;
return $.event('4chanXInitFinished'); return $.event('4chanXInitFinished');
}); });
} else { } else {
Main.expectInitFinished = true;
return $.event('4chanXInitFinished'); return $.event('4chanXInitFinished');
} }
}, },
@ -18034,7 +18047,7 @@
details = details.replace(/file:\/{3}.+\//g, ''); details = details.replace(/file:\/{3}.+\//g, '');
url = "https://gitreports.com/issue/ccd0/4chan-x?issue_title=" + (encodeURIComponent(title)) + "&details=" + (encodeURIComponent(details)); url = "https://gitreports.com/issue/ccd0/4chan-x?issue_title=" + (encodeURIComponent(title)) + "&details=" + (encodeURIComponent(details));
return { return {
innerHTML: " [<a href=\"" + E(url) + "\" target=\"_blank\">report</a>]" innerHTML: "<span class=\"report-error\"> [<a href=\"" + E(url) + "\" target=\"_blank\">report</a>]</span>"
}; };
}, },
isThisPageLegit: function() { isThisPageLegit: function() {
@ -19139,6 +19152,9 @@
".message a {\n" + ".message a {\n" +
" text-decoration: underline;\n" + " text-decoration: underline;\n" +
"}\n" + "}\n" +
":root.tainted .report-error {\n" +
" display: none;\n" +
"}\n" +
"/* Settings */\n" + "/* Settings */\n" +
":root.fourchan-x body {\n" + ":root.fourchan-x body {\n" +
" -moz-box-sizing: border-box;\n" + " -moz-box-sizing: border-box;\n" +
@ -19328,9 +19344,9 @@
" overflow: hidden;\n" + " overflow: hidden;\n" +
"}\n" + "}\n" +
"/* Index */\n" + "/* Index */\n" +
":root.index-loading .navLinks,\n" + ":root.index-loading .navLinks:not(.json-index),\n" +
":root.index-loading .board,\n" + ":root.index-loading .board:not(.json-index),\n" +
":root.index-loading .pagelist,\n" + ":root.index-loading .pagelist:not(.json-index),\n" +
":root.infinite-mode .pagelist,\n" + ":root.infinite-mode .pagelist,\n" +
":root.all-pages-mode .pagelist,\n" + ":root.all-pages-mode .pagelist,\n" +
":root.catalog-mode .pagelist,\n" + ":root.catalog-mode .pagelist,\n" +

Binary file not shown.

View File

@ -1,7 +1,7 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<gupdate xmlns='http://www.google.com/update2/response' protocol='2.0'> <gupdate xmlns='http://www.google.com/update2/response' protocol='2.0'>
<app appid='lacclbnghgdicfifcamcmcnilckjamag'> <app appid='lacclbnghgdicfifcamcmcnilckjamag'>
<updatecheck codebase='https://www.4chan-x.net/builds/4chan-X-beta.crx' version='1.11.22.4' /> <updatecheck codebase='https://www.4chan-x.net/builds/4chan-X-beta.crx' version='1.11.23.0' />
</app> </app>
</gupdate> </gupdate>

View File

@ -1,7 +1,7 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<gupdate xmlns='http://www.google.com/update2/response' protocol='2.0'> <gupdate xmlns='http://www.google.com/update2/response' protocol='2.0'>
<app appid='lacclbnghgdicfifcamcmcnilckjamag'> <app appid='lacclbnghgdicfifcamcmcnilckjamag'>
<updatecheck codebase='https://www.4chan-x.net/builds/4chan-X.crx' version='1.11.22.4' /> <updatecheck codebase='https://www.4chan-x.net/builds/4chan-X.crx' version='1.11.23.0' />
</app> </app>
</gupdate> </gupdate>

View File

@ -1,4 +1,4 @@
{ {
"version": "1.11.22.4", "version": "1.11.23.0",
"date": "2016-01-24T05:47:35.520Z" "date": "2016-01-25T04:51:14.827Z"
} }