Release 4chan X v1.8.1.

This commit is contained in:
ccd0 2014-06-19 01:14:45 -07:00
parent e1d695531b
commit 2794ff1133
12 changed files with 164 additions and 446 deletions

View File

@ -1,3 +1,6 @@
### v1.8.1
*2014-06-19*
**MayhemYDG** **MayhemYDG**
- More API changes: - More API changes:
- `ThreadUpdate`: - `ThreadUpdate`:

View File

@ -1,5 +1,5 @@
/* /*
* 4chan X - Version 1.8.0 - 2014-06-18 * 4chan X - Version 1.8.1 - 2014-06-19
* *
* Licensed under the MIT license. * Licensed under the MIT license.
* https://github.com/ccd0/4chan-x/blob/master/LICENSE * https://github.com/ccd0/4chan-x/blob/master/LICENSE

View File

@ -1,6 +1,6 @@
// ==UserScript== // ==UserScript==
// @name 4chan X // @name 4chan X
// @version 1.8.0 // @version 1.8.1
// @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.8.0 // @version 1.8.1
// @minGMVer 1.14 // @minGMVer 1.14
// @minFFVer 26 // @minFFVer 26
// @namespace 4chan-X // @namespace 4chan-X
@ -24,7 +24,7 @@
// ==/UserScript== // ==/UserScript==
/* /*
* 4chan X - Version 1.8.0 - 2014-06-18 * 4chan X - Version 1.8.1 - 2014-06-19
* *
* Licensed under the MIT license. * Licensed under the MIT license.
* https://github.com/ccd0/4chan-x/blob/master/LICENSE * https://github.com/ccd0/4chan-x/blob/master/LICENSE
@ -374,7 +374,7 @@
doc = d.documentElement; doc = d.documentElement;
g = { g = {
VERSION: '1.8.0', VERSION: '1.8.1',
NAMESPACE: '4chan X.', NAMESPACE: '4chan X.',
boards: {} boards: {}
}; };
@ -649,7 +649,7 @@
if (root == null) { if (root == null) {
root = d; root = d;
} }
if (typeof cloneInto === 'function') { if ((detail != null) && typeof cloneInto === 'function') {
detail = cloneInto(detail, document.defaultView); detail = cloneInto(detail, document.defaultView);
} }
return root.dispatchEvent(new CustomEvent(event, { return root.dispatchEvent(new CustomEvent(event, {
@ -1813,8 +1813,7 @@
$.sync('Header auto-hide', this.setBarVisibility); $.sync('Header auto-hide', this.setBarVisibility);
$.sync('Centered links', this.setLinkJustify); $.sync('Centered links', this.setLinkJustify);
this.addShortcut(menuButton); this.addShortcut(menuButton);
UI.addMenuEntry({ this.menu.addEntry({
type: 'header',
el: $.el('span', { el: $.el('span', {
textContent: 'Header' textContent: 'Header'
}), }),
@ -2363,8 +2362,7 @@
$.on(input, 'change', this.cb.sort); $.on(input, 'change', this.cb.sort);
} }
} }
UI.addMenuEntry({ Header.menu.addEntry({
type: 'header',
el: $.el('span', { el: $.el('span', {
textContent: 'Index Navigation' textContent: 'Index Navigation'
}), }),
@ -3072,7 +3070,7 @@
This function contains code from 4chan-JS (https://github.com/4chan/4chan-JS). This function contains code from 4chan-JS (https://github.com/4chan/4chan-JS).
@license: https://github.com/4chan/4chan-JS/blob/master/LICENSE @license: https://github.com/4chan/4chan-JS/blob/master/LICENSE
*/ */
var E, boardID, capcode, container, date, dateUTC, email, file, fileSize, fileThumb, flagCode, flagName, h_capcodeClass, h_capcodeIcon, h_capcodeStart, h_closed, h_comment, h_emailEnd, h_emailStart, h_file, h_fileDims, h_fileInfo, h_fileTitle1, h_fileTitle2, h_flag, h_gifIcon, h_imgSrc, h_pageIcon, h_postClass, h_quoteLink, h_replyLink, h_sideArrows, h_staticPath, h_sticky, h_tripcode, h_userID, href, isClosed, isOP, isSticky, name, pageNum, postID, quote, shortFilename, spoilerRange, subject, threadID, tripcode, uniqueID, _i, _len, _ref; var E, boardID, capcode, container, date, dateUTC, email, email_processed, file, fileSize, fileThumb, flagCode, flagName, h_capcodeClass, h_capcodeIcon, h_capcodeStart, h_closed, h_comment, h_emailEnd, h_emailStart, h_file, h_fileDims, h_fileInfo, h_fileTitle1, h_fileTitle2, h_flag, h_gifIcon, h_imgSrc, h_pageIcon, h_postClass, h_quoteLink, h_replyLink, h_sideArrows, h_staticPath, h_sticky, h_tripcode, h_userID, href, isClosed, isOP, isSticky, name, pageNum, postID, quote, shortFilename, spoilerRange, subject, threadID, tripcode, uniqueID, _i, _len, _ref;
E = Build.h_escape; E = Build.h_escape;
postID = o.postID, threadID = o.threadID, boardID = o.boardID, name = o.name, capcode = o.capcode, tripcode = o.tripcode, uniqueID = o.uniqueID, email = o.email, subject = o.subject, flagCode = o.flagCode, flagName = o.flagName, date = o.date, dateUTC = o.dateUTC, isSticky = o.isSticky, isClosed = o.isClosed, h_comment = o.h_comment, file = o.file; postID = o.postID, threadID = o.threadID, boardID = o.boardID, name = o.name, capcode = o.capcode, tripcode = o.tripcode, uniqueID = o.uniqueID, email = o.email, subject = o.subject, flagCode = o.flagCode, flagName = o.flagName, date = o.date, dateUTC = o.dateUTC, isSticky = o.isSticky, isClosed = o.isClosed, h_comment = o.h_comment, file = o.file;
name || (name = ''); name || (name = '');
@ -3090,8 +3088,9 @@
} else { } else {
h_tripcode = ''; h_tripcode = '';
} }
email_processed = encodeURIComponent(email).replace(/%40/g, '@');
if (email) { if (email) {
h_emailStart = "<a href='mailto:" + (E(encodeURIComponent(email))) + "' class='useremail'>"; h_emailStart = "<a href='mailto:" + (E(email_processed)) + "' class='useremail'>";
h_emailEnd = '</a>'; h_emailEnd = '</a>';
} else { } else {
h_emailStart = ''; h_emailStart = '';
@ -3538,7 +3537,7 @@
}; };
UI = (function() { UI = (function() {
var Menu, addMenuEntry, checkbox, dialog, drag, dragend, dragstart, hover, hoverend, hoverstart, menus, rmMenuEntry, touchend, touchmove; var Menu, checkbox, dialog, drag, dragend, dragstart, hover, hoverend, hoverstart, menus, touchend, touchmove;
dialog = function(id, position, properties) { dialog = function(id, position, properties) {
var child, el, move, _i, _len, _ref; var child, el, move, _i, _len, _ref;
el = $.el('div', { el = $.el('div', {
@ -3565,12 +3564,6 @@
return el; return el;
}; };
menus = {}; menus = {};
addMenuEntry = function(entry) {
return menus[entry.type].addEntry(entry);
};
rmMenuEntry = function(entry) {
return menus[entry.type].addEntry(entry);
};
Menu = (function() { Menu = (function() {
var currentMenu, lastToggledButton; var currentMenu, lastToggledButton;
@ -3580,7 +3573,6 @@
function Menu(type) { function Menu(type) {
this.type = type; this.type = type;
this.rmEntry = __bind(this.rmEntry, this);
this.addEntry = __bind(this.addEntry, this); this.addEntry = __bind(this.addEntry, this);
this.onFocus = __bind(this.onFocus, this); this.onFocus = __bind(this.onFocus, this);
this.keybinds = __bind(this.keybinds, this); this.keybinds = __bind(this.keybinds, this);
@ -3793,12 +3785,6 @@
return this.entries.push(entry); return this.entries.push(entry);
}; };
Menu.prototype.rmEntry = function(entry) {
var index;
index = this.entries.indexOf(entry);
return this.entries.splice(index, 1);
};
Menu.prototype.parseEntry = function(entry) { Menu.prototype.parseEntry = function(entry) {
var el, subEntries, subEntry, _i, _len; var el, subEntries, subEntry, _i, _len;
el = entry.el, subEntries = entry.subEntries; el = entry.el, subEntries = entry.subEntries;
@ -3984,9 +3970,7 @@
dialog: dialog, dialog: dialog,
Menu: Menu, Menu: Menu,
hover: hoverstart, hover: hoverstart,
checkbox: checkbox, checkbox: checkbox
addMenuEntry: addMenuEntry,
rmMenuEntry: rmMenuEntry
}; };
})(); })();
@ -4270,7 +4254,6 @@
textContent: 'Filter' textContent: 'Filter'
}); });
entry = { entry = {
type: 'post',
el: div, el: div,
order: 50, order: 50,
open: function(post) { open: function(post) {
@ -4284,7 +4267,7 @@
type = _ref[_i]; type = _ref[_i];
entry.subEntries.push(Filter.menu.createSubEntry(type[0], type[1])); entry.subEntries.push(Filter.menu.createSubEntry(type[0], type[1]));
} }
return UI.addMenuEntry(entry); return Menu.menu.addEntry(entry);
}, },
createSubEntry: function(text, type) { createSubEntry: function(text, type) {
var el; var el;
@ -4390,8 +4373,7 @@
thisPost = UI.checkbox('thisPost', ' This post', true); thisPost = UI.checkbox('thisPost', ' This post', true);
replies = UI.checkbox('replies', ' Hide replies', Conf['Recursive Hiding']); replies = UI.checkbox('replies', ' Hide replies', Conf['Recursive Hiding']);
makeStub = UI.checkbox('makeStub', ' Make stub', Conf['Stubs']); makeStub = UI.checkbox('makeStub', ' Make stub', Conf['Stubs']);
UI.addMenuEntry({ Menu.menu.addEntry({
type: 'post',
el: div, el: div,
order: 20, order: 20,
open: function(post) { open: function(post) {
@ -4429,8 +4411,7 @@
href: 'javascript:;' href: 'javascript:;'
}); });
$.on(hideStubLink, 'click', PostHiding.menu.hideStub); $.on(hideStubLink, 'click', PostHiding.menu.hideStub);
UI.addMenuEntry({ Menu.menu.addEntry({
type: 'post',
el: div, el: div,
order: 20, order: 20,
open: function(post) { open: function(post) {
@ -4460,8 +4441,7 @@
} }
] ]
}); });
return UI.addMenuEntry({ return Menu.menu.addEntry({
type: 'post',
el: hideStubLink, el: hideStubLink,
order: 15, order: 15,
open: function(post) { open: function(post) {
@ -4792,8 +4772,7 @@
}); });
$.on(apply, 'click', ThreadHiding.menu.hide); $.on(apply, 'click', ThreadHiding.menu.hide);
makeStub = UI.checkbox('Stubs', ' Make stub'); makeStub = UI.checkbox('Stubs', ' Make stub');
UI.addMenuEntry({ Menu.menu.addEntry({
type: 'post',
el: div, el: div,
order: 20, order: 20,
open: function(_arg) { open: function(_arg) {
@ -4819,8 +4798,7 @@
href: 'javascript:;' href: 'javascript:;'
}); });
$.on(div, 'click', ThreadHiding.menu.show); $.on(div, 'click', ThreadHiding.menu.show);
UI.addMenuEntry({ Menu.menu.addEntry({
type: 'post',
el: div, el: div,
order: 20, order: 20,
open: function(_arg) { open: function(_arg) {
@ -4838,8 +4816,7 @@
href: 'javascript:;' href: 'javascript:;'
}); });
$.on(hideStubLink, 'click', ThreadHiding.menu.hideStub); $.on(hideStubLink, 'click', ThreadHiding.menu.hideStub);
return UI.addMenuEntry({ return Menu.menu.addEntry({
type: 'post',
el: hideStubLink, el: hideStubLink,
order: 15, order: 15,
open: function(_arg) { open: function(_arg) {
@ -5366,8 +5343,7 @@
}); });
input = $('input', this.controls); input = $('input', this.controls);
$.on(input, 'change', this.toggle); $.on(input, 'change', this.toggle);
UI.addMenuEntry(this.entry = { Header.menu.addEntry(this.entry = {
type: 'header',
el: this.controls, el: this.controls,
order: 98 order: 98
}); });
@ -6571,13 +6547,12 @@
}); });
ThreadUpdater.postID = postID; ThreadUpdater.postID = postID;
$.event('QRPostSuccessful', { $.event('QRPostSuccessful', {
board: { boardID: g.BOARD.ID,
ID: g.BOARD.ID
},
threadID: threadID, threadID: threadID,
postID: postID postID: postID
}); });
$.event('QRPostSuccessful_', { $.event('QRPostSuccessful_', {
boardID: g.BOARD.ID,
threadID: threadID, threadID: threadID,
postID: postID postID: postID
}); });
@ -7472,8 +7447,7 @@
el.title = "" + type + " Tyme"; el.title = "" + type + " Tyme";
FappeTyme[lc] = input = el.firstElementChild; FappeTyme[lc] = input = el.firstElementChild;
$.on(input, 'change', FappeTyme.cb.toggle.bind(input)); $.on(input, 'change', FappeTyme.cb.toggle.bind(input));
UI.addMenuEntry({ Header.menu.addEntry({
type: 'header',
el: el, el: el,
order: 97 order: 97
}); });
@ -7572,8 +7546,7 @@
createSubEntry = Gallery.menu.createSubEntry; createSubEntry = Gallery.menu.createSubEntry;
for (name in Config.gallery) { for (name in Config.gallery) {
el = createSubEntry(name).el; el = createSubEntry(name).el;
UI.addMenuEntry({ nodes.menu.addEntry({
type: 'gallery',
el: el, el: el,
order: 0 order: 0
}); });
@ -7807,8 +7780,7 @@
for (name in Config.gallery) { for (name in Config.gallery) {
subEntries.push(createSubEntry(name)); subEntries.push(createSubEntry(name));
} }
return UI.addMenuEntry({ return Header.menu.addEntry({
type: 'header',
el: el, el: el,
order: 105, order: 105,
subEntries: subEntries subEntries: subEntries
@ -8152,8 +8124,7 @@
conf = _ref[name]; conf = _ref[name];
subEntries.push(createSubEntry(name, conf[1])); subEntries.push(createSubEntry(name, conf[1]));
} }
return UI.addMenuEntry({ return Header.menu.addEntry({
type: 'header',
el: el, el: el,
order: 105, order: 105,
subEntries: subEntries subEntries: subEntries
@ -8325,8 +8296,7 @@
}); });
this.el = prefetch.firstElementChild; this.el = prefetch.firstElementChild;
$.on(this.el, 'change', this.toggle); $.on(this.el, 'change', this.toggle);
return UI.addMenuEntry({ return Header.menu.addEntry({
type: 'header',
el: prefetch, el: prefetch,
order: 104 order: 104
}); });
@ -9083,7 +9053,6 @@
textContent: 'Archive' textContent: 'Archive'
}); });
entry = { entry = {
type: 'post',
el: div, el: div,
order: 90, order: 90,
open: function(_arg) { open: function(_arg) {
@ -9102,7 +9071,7 @@
type = _ref[_i]; type = _ref[_i];
entry.subEntries.push(this.createSubEntry(type[0], type[1])); entry.subEntries.push(this.createSubEntry(type[0], type[1]));
} }
return UI.addMenuEntry(entry); return Menu.menu.addEntry(entry);
}, },
createSubEntry: function(text, type) { createSubEntry: function(text, type) {
var el, open; var el, open;
@ -9179,8 +9148,7 @@
return true; return true;
} }
}; };
return UI.addMenuEntry({ return Menu.menu.addEntry({
type: 'post',
el: div, el: div,
order: 40, order: 40,
open: function(post) { open: function(post) {
@ -9304,8 +9272,7 @@
}; };
})(this)); })(this));
}); });
return UI.addMenuEntry({ return Menu.menu.addEntry({
type: 'post',
el: a, el: a,
order: 100, order: 100,
open: function(_arg) { open: function(_arg) {
@ -9373,8 +9340,7 @@
textContent: 'Report this post' textContent: 'Report this post'
}); });
$.on(a, 'click', ReportLink.report); $.on(a, 'click', ReportLink.report);
return UI.addMenuEntry({ return Menu.menu.addEntry({
type: 'post',
el: a, el: a,
order: 10, order: 10,
open: function(post) { open: function(post) {
@ -9621,8 +9587,7 @@
subEntries.push({ subEntries.push({
el: this.settings el: this.settings
}); });
UI.addMenuEntry(this.entry = { Header.menu.addEntry(this.entry = {
type: 'header',
el: $.el('span', { el: $.el('span', {
textContent: 'Updater' textContent: 'Updater'
}), }),
@ -9732,9 +9697,7 @@
ThreadUpdater.thread.kill(); ThreadUpdater.thread.kill();
$.event('ThreadUpdate', { $.event('ThreadUpdate', {
404: true, 404: true,
thread: { threadID: ThreadUpdater.thread.fullID
fullID: ThreadUpdater.thread.fullID
}
}); });
break; break;
default: default:
@ -9828,7 +9791,7 @@
return new Notice('info', "The thread is " + change + ".", 30); return new Notice('info', "The thread is " + change + ".", 30);
}, },
parse: function(postObjects) { parse: function(postObjects) {
var OP, count, deletedFiles, deletedPosts, files, index, node, num, post, postObject, posts, root, scroll, _i, _j, _len, _len1; var OP, count, files, index, node, num, post, postObject, posts, root, scroll, _i, _j, _len, _len1;
OP = postObjects[0]; OP = postObjects[0];
Build.spoilerRange[ThreadUpdater.thread.board] = OP.custom_spoiler; Build.spoilerRange[ThreadUpdater.thread.board] = OP.custom_spoiler;
ThreadUpdater.updateThreadStatus('Sticky', !!OP.sticky); ThreadUpdater.updateThreadStatus('Sticky', !!OP.sticky);
@ -9853,25 +9816,15 @@
node = Build.postFromObject(postObject, ThreadUpdater.thread.board.ID); node = Build.postFromObject(postObject, ThreadUpdater.thread.board.ID);
posts.push(new Post(node, ThreadUpdater.thread, ThreadUpdater.thread.board)); posts.push(new Post(node, ThreadUpdater.thread, ThreadUpdater.thread.board));
} }
deletedPosts = [];
deletedFiles = [];
ThreadUpdater.thread.posts.forEach(function(post) { ThreadUpdater.thread.posts.forEach(function(post) {
var ID; var ID;
ID = +post.ID; ID = +post.ID;
if (__indexOf.call(index, ID) < 0) { if (__indexOf.call(index, ID) < 0) {
post.kill(); post.kill();
deletedPosts.push({
ID: post.ID,
fullID: post.fullID
});
} else if (post.isDead) { } else if (post.isDead) {
post.resurrect(); post.resurrect();
} else if (post.file && !(post.file.isDead || __indexOf.call(files, ID) >= 0)) { } else if (post.file && !(post.file.isDead || __indexOf.call(files, ID) >= 0)) {
post.kill(true); post.kill(true);
deletedFiles.push({
ID: post.ID,
fullID: post.fullID
});
} }
if (ThreadUpdater.postID && ThreadUpdater.postID === ID) { if (ThreadUpdater.postID && ThreadUpdater.postID === ID) {
return ThreadUpdater.foundPost = true; return ThreadUpdater.foundPost = true;
@ -9923,24 +9876,10 @@
} }
return $.event('ThreadUpdate', { return $.event('ThreadUpdate', {
404: false, 404: false,
thread: { threadID: ThreadUpdater.thread.fullID,
ID: ThreadUpdater.thread.ID, newPosts: posts.map(function(post) {
fullID: ThreadUpdater.thread.fullID return post.fullID;
}, }),
newPosts: (function() {
var _k, _len2, _results;
_results = [];
for (_k = 0, _len2 = posts.length; _k < _len2; _k++) {
post = posts[_k];
_results.push({
ID: post.ID,
fullID: post.fullID
});
}
return _results;
})(),
deletedPosts: deletedPosts,
deletedFiles: deletedFiles,
postCount: OP.replies + 1, postCount: OP.replies + 1,
fileCount: OP.images + (!!ThreadUpdater.thread.OP.file && !ThreadUpdater.thread.OP.file.isDead) fileCount: OP.images + (!!ThreadUpdater.thread.OP.file && !ThreadUpdater.thread.OP.file.isDead)
}); });
@ -10075,14 +10014,14 @@
return ThreadWatcher.rm(boardID, +threadID); return ThreadWatcher.rm(boardID, +threadID);
}, },
post: function(e) { post: function(e) {
var board, postID, threadID, _ref; var boardID, postID, threadID, _ref;
_ref = e.detail, board = _ref.board, postID = _ref.postID, threadID = _ref.threadID; _ref = e.detail, boardID = _ref.boardID, threadID = _ref.threadID, postID = _ref.postID;
if (postID === threadID) { if (postID === threadID) {
if (Conf['Auto Watch']) { if (Conf['Auto Watch']) {
return $.set('AutoWatch', threadID); return $.set('AutoWatch', threadID);
} }
} else if (Conf['Auto Watch Reply']) { } else if (Conf['Auto Watch Reply']) {
return ThreadWatcher.add(g.boards[board.ID].threads[threadID]); return ThreadWatcher.add(g.threads[boardID + '.' + threadID]);
} }
}, },
onIndexRefresh: function() { onIndexRefresh: function() {
@ -10112,7 +10051,7 @@
}, },
onThreadRefresh: function(e) { onThreadRefresh: function(e) {
var thread; var thread;
thread = g.threads[e.detail.thread.fullID]; thread = g.threads[e.detail.threadID];
if (!(e.detail[404] && ThreadWatcher.db.get({ if (!(e.detail[404] && ThreadWatcher.db.get({
boardID: thread.board.ID, boardID: thread.board.ID,
threadID: thread.ID threadID: thread.ID
@ -10324,7 +10263,7 @@
if (!Conf['Thread Watcher']) { if (!Conf['Thread Watcher']) {
return; return;
} }
menu = new UI.Menu('thread watcher'); menu = this.menu = new UI.Menu('thread watcher');
$.on($('.menu-button', ThreadWatcher.dialog), 'click', function(e) { $.on($('.menu-button', ThreadWatcher.dialog), 'click', function(e) {
return menu.toggle(e, this, ThreadWatcher); return menu.toggle(e, this, ThreadWatcher);
}); });
@ -10339,8 +10278,7 @@
entryEl = $.el('a', { entryEl = $.el('a', {
href: 'javascript:;' href: 'javascript:;'
}); });
UI.addMenuEntry({ Header.menu.addEntry({
type: 'header',
el: entryEl, el: entryEl,
order: 60 order: 60
}); });
@ -10361,7 +10299,6 @@
entries.push({ entries.push({
cb: ThreadWatcher.cb.openAll, cb: ThreadWatcher.cb.openAll,
entry: { entry: {
type: 'thread watcher',
el: $.el('a', { el: $.el('a', {
textContent: 'Open all threads' textContent: 'Open all threads'
}) })
@ -10373,7 +10310,6 @@
entries.push({ entries.push({
cb: ThreadWatcher.cb.checkThreads, cb: ThreadWatcher.cb.checkThreads,
entry: { entry: {
type: 'thread watcher',
el: $.el('a', { el: $.el('a', {
textContent: 'Check 404\'d threads' textContent: 'Check 404\'d threads'
}) })
@ -10385,7 +10321,6 @@
entries.push({ entries.push({
cb: ThreadWatcher.cb.pruneDeads, cb: ThreadWatcher.cb.pruneDeads,
entry: { entry: {
type: 'thread watcher',
el: $.el('a', { el: $.el('a', {
textContent: 'Prune 404\'d threads' textContent: 'Prune 404\'d threads'
}) })
@ -10402,7 +10337,6 @@
} }
entries.push({ entries.push({
entry: { entry: {
type: 'thread watcher',
el: $.el('span', { el: $.el('span', {
textContent: 'Settings' textContent: 'Settings'
}), }),
@ -10420,7 +10354,7 @@
if (refresh) { if (refresh) {
this.refreshers.push(refresh.bind(entry)); this.refreshers.push(refresh.bind(entry));
} }
UI.addMenuEntry(entry); this.menu.addEntry(entry);
} }
}, },
createSubEntry: function(name, desc) { createSubEntry: function(name, desc) {
@ -10597,20 +10531,12 @@
}; };
}, },
onUpdate: function(e) { onUpdate: function(e) {
var post;
if (e.detail[404]) { if (e.detail[404]) {
return Unread.update(); return Unread.update();
} else if (!QuoteThreading.enabled) { } else if (!QuoteThreading.enabled) {
return Unread.addPosts((function() { return Unread.addPosts(e.detail.newPosts.map(function(fullID) {
var _i, _len, _ref, _results; return g.posts[fullID];
_ref = e.detail.newPosts; }));
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
post = _ref[_i];
_results.push(g.posts[post.fullID]);
}
return _results;
})());
} else { } else {
Unread.read(); Unread.read();
return Unread.update(); return Unread.update();
@ -10819,7 +10745,6 @@
return; return;
} }
entry = { entry = {
type: 'header',
el: $.el('a', { el: $.el('a', {
textContent: 'Show announcement', textContent: 'Show announcement',
className: 'show-announcement', className: 'show-announcement',
@ -10830,7 +10755,7 @@
return psa.hidden; return psa.hidden;
} }
}; };
UI.addMenuEntry(entry); Header.menu.addEntry(entry);
$.on(entry.el, 'click', PSAHiding.toggle); $.on(entry.el, 'click', PSAHiding.toggle);
PSAHiding.btn = btn = $.el('span', { PSAHiding.btn = btn = $.el('span', {
innerHTML: '[<a href="javascript:;">Dismiss</a>]', innerHTML: '[<a href="javascript:;">Dismiss</a>]',
@ -10983,8 +10908,7 @@
input = $('input', el); input = $('input', el);
$.on(input, 'change', this.toggle); $.on(input, 'change', this.toggle);
$.sync('Header catalog links', CatalogLinks.set); $.sync('Header catalog links', CatalogLinks.set);
UI.addMenuEntry({ Header.menu.addEntry({
type: 'header',
el: el, el: el,
order: 95 order: 95
}); });
@ -11481,7 +11405,7 @@
}); });
} }
if (board === 'sci') { if (board === 'sci') {
$.globalEval('window.addEventListener(\'jsmath\', function(e) {\n if (!jsMath) return;\n if (jsMath.loaded) {\n // process one post\n jsMath.ProcessBeforeShowing(document.getElementById(\'p\' + e.detail));\n } else if (jsMath.Autoload && jsMath.Autoload.checked) {\n // load jsMath and process whole document\n jsMath.Autoload.Script.Push(\'ProcessBeforeShowing\', [null]);\n jsMath.Autoload.LoadJsMath();\n }\n}, false);'); $.globalEval('window.addEventListener(\'jsmath\', function(e) {\n if (!jsMath) return;\n if (jsMath.loaded) {\n // process one post\n jsMath.ProcessBeforeShowing(document.getElementById(e.detail));\n } else if (jsMath.Autoload && jsMath.Autoload.checked) {\n // load jsMath and process whole document\n jsMath.Autoload.Script.Push(\'ProcessBeforeShowing\', [null]);\n jsMath.Autoload.LoadJsMath();\n }\n}, false);');
return Post.callbacks.push({ return Post.callbacks.push({
name: 'Parse /sci/ math', name: 'Parse /sci/ math',
cb: this.math cb: this.math
@ -11514,7 +11438,7 @@
}; };
})(this)), (function(_this) { })(this)), (function(_this) {
return function() { return function() {
return $.event('jsmath', _this.ID, window); return $.event('jsmath', _this.nodes.post.id, window);
}; };
})(this)); })(this));
}, },
@ -12362,7 +12286,7 @@
Settings.dialog = dialog = $.el('div', { Settings.dialog = dialog = $.el('div', {
id: 'fourchanx-settings', id: 'fourchanx-settings',
className: 'dialog', className: 'dialog',
innerHTML: '<nav><div class=sections-list></div><p class=\'imp-exp-result warning\'></p><div class=credits><a class=export>Export</a>&nbsp|&nbsp<a class=import>Import</a>&nbsp|&nbsp<a class=reset>Reset Settings</a>&nbsp|&nbsp<input type=file hidden><a href=\'https://github.com/ccd0/4chan-x\' target=_blank>4chan X</a>&nbsp|&nbsp<a href=\'https://github.com/ccd0/4chan-x/blob/master/CHANGELOG.md\' target=_blank>1.8.0</a>&nbsp|&nbsp<a href=\'https://github.com/ccd0/4chan-x/issues\' target=_blank>Issues</a>&nbsp|&nbsp<a href=javascript:; class=\'close fa fa-times\' title=Close></a></div></nav><div class=section-container><section></section></div>' innerHTML: '<nav><div class=sections-list></div><p class=\'imp-exp-result warning\'></p><div class=credits><a class=export>Export</a>&nbsp|&nbsp<a class=import>Import</a>&nbsp|&nbsp<a class=reset>Reset Settings</a>&nbsp|&nbsp<input type=file hidden><a href=\'https://github.com/ccd0/4chan-x\' target=_blank>4chan X</a>&nbsp|&nbsp<a href=\'https://github.com/ccd0/4chan-x/blob/master/CHANGELOG.md\' target=_blank>1.8.1</a>&nbsp|&nbsp<a href=\'https://github.com/ccd0/4chan-x/issues\' target=_blank>Issues</a>&nbsp|&nbsp<a href=javascript:; class=\'close fa fa-times\' title=Close></a></div></nav><div class=section-container><section></section></div>'
}); });
$.on($('.export', Settings.dialog), 'click', Settings["export"]); $.on($('.export', Settings.dialog), 'click', Settings["export"]);
$.on($('.import', Settings.dialog), 'click', Settings["import"]); $.on($('.import', Settings.dialog), 'click', Settings["import"]);
@ -13206,7 +13130,7 @@
} }
if (previousversion) { if (previousversion) {
el = $.el('span', { el = $.el('span', {
innerHTML: '4chan X has been updated to <a href="https://github.com/ccd0/4chan-x/blob/master/CHANGELOG.md" target="_blank">version 1.8.0</a>.' innerHTML: '4chan X has been updated to <a href="https://github.com/ccd0/4chan-x/blob/master/CHANGELOG.md" target="_blank">version 1.8.1</a>.'
}); });
new Notice('info', el, 15); new Notice('info', el, 15);
} else { } else {
@ -13249,25 +13173,6 @@
}; };
return softTask(); return softTask();
}, },
addCallback: function(e) {
var Klass, obj;
obj = e.detail;
if (typeof obj.callback.name !== 'string') {
throw new Error("Invalid callback name: " + obj.callback.name);
}
switch (obj.type) {
case 'Post':
Klass = Post;
break;
case 'Thread':
Klass = Thread;
break;
default:
return;
}
obj.callback.isAddon = true;
return Klass.callbacks.push(obj.callback);
},
handleErrors: function(errors) { handleErrors: function(errors) {
var div, error, logs, _i, _len; var div, error, logs, _i, _len;
if (!(errors instanceof Array)) { if (!(errors instanceof Array)) {

Binary file not shown.

Binary file not shown.

View File

@ -1,6 +1,6 @@
{ {
"name": "4chan X", "name": "4chan X",
"version": "1.8.0", "version": "1.8.1",
"manifest_version": 2, "manifest_version": 2,
"description": "Cross-browser userscript for maximum lurking on 4chan.", "description": "Cross-browser userscript for maximum lurking on 4chan.",
"icons": { "icons": {

View File

@ -1,6 +1,6 @@
// Generated by CoffeeScript // Generated by CoffeeScript
/* /*
* 4chan X - Version 1.8.0 - 2014-06-18 * 4chan X - Version 1.8.1 - 2014-06-19
* *
* Licensed under the MIT license. * Licensed under the MIT license.
* https://github.com/ccd0/4chan-x/blob/master/LICENSE * https://github.com/ccd0/4chan-x/blob/master/LICENSE
@ -349,7 +349,7 @@
doc = d.documentElement; doc = d.documentElement;
g = { g = {
VERSION: '1.8.0', VERSION: '1.8.1',
NAMESPACE: '4chan X.', NAMESPACE: '4chan X.',
boards: {} boards: {}
}; };
@ -1845,8 +1845,7 @@
$.sync('Header auto-hide', this.setBarVisibility); $.sync('Header auto-hide', this.setBarVisibility);
$.sync('Centered links', this.setLinkJustify); $.sync('Centered links', this.setLinkJustify);
this.addShortcut(menuButton); this.addShortcut(menuButton);
UI.addMenuEntry({ this.menu.addEntry({
type: 'header',
el: $.el('span', { el: $.el('span', {
textContent: 'Header' textContent: 'Header'
}), }),
@ -2395,8 +2394,7 @@
$.on(input, 'change', this.cb.sort); $.on(input, 'change', this.cb.sort);
} }
} }
UI.addMenuEntry({ Header.menu.addEntry({
type: 'header',
el: $.el('span', { el: $.el('span', {
textContent: 'Index Navigation' textContent: 'Index Navigation'
}), }),
@ -3104,7 +3102,7 @@
This function contains code from 4chan-JS (https://github.com/4chan/4chan-JS). This function contains code from 4chan-JS (https://github.com/4chan/4chan-JS).
@license: https://github.com/4chan/4chan-JS/blob/master/LICENSE @license: https://github.com/4chan/4chan-JS/blob/master/LICENSE
*/ */
var E, boardID, capcode, container, date, dateUTC, email, file, fileSize, fileThumb, flagCode, flagName, h_capcodeClass, h_capcodeIcon, h_capcodeStart, h_closed, h_comment, h_emailEnd, h_emailStart, h_file, h_fileDims, h_fileInfo, h_fileTitle1, h_fileTitle2, h_flag, h_gifIcon, h_imgSrc, h_pageIcon, h_postClass, h_quoteLink, h_replyLink, h_sideArrows, h_staticPath, h_sticky, h_tripcode, h_userID, href, isClosed, isOP, isSticky, name, pageNum, postID, quote, shortFilename, spoilerRange, subject, threadID, tripcode, uniqueID, _i, _len, _ref; var E, boardID, capcode, container, date, dateUTC, email, email_processed, file, fileSize, fileThumb, flagCode, flagName, h_capcodeClass, h_capcodeIcon, h_capcodeStart, h_closed, h_comment, h_emailEnd, h_emailStart, h_file, h_fileDims, h_fileInfo, h_fileTitle1, h_fileTitle2, h_flag, h_gifIcon, h_imgSrc, h_pageIcon, h_postClass, h_quoteLink, h_replyLink, h_sideArrows, h_staticPath, h_sticky, h_tripcode, h_userID, href, isClosed, isOP, isSticky, name, pageNum, postID, quote, shortFilename, spoilerRange, subject, threadID, tripcode, uniqueID, _i, _len, _ref;
E = Build.h_escape; E = Build.h_escape;
postID = o.postID, threadID = o.threadID, boardID = o.boardID, name = o.name, capcode = o.capcode, tripcode = o.tripcode, uniqueID = o.uniqueID, email = o.email, subject = o.subject, flagCode = o.flagCode, flagName = o.flagName, date = o.date, dateUTC = o.dateUTC, isSticky = o.isSticky, isClosed = o.isClosed, h_comment = o.h_comment, file = o.file; postID = o.postID, threadID = o.threadID, boardID = o.boardID, name = o.name, capcode = o.capcode, tripcode = o.tripcode, uniqueID = o.uniqueID, email = o.email, subject = o.subject, flagCode = o.flagCode, flagName = o.flagName, date = o.date, dateUTC = o.dateUTC, isSticky = o.isSticky, isClosed = o.isClosed, h_comment = o.h_comment, file = o.file;
name || (name = ''); name || (name = '');
@ -3122,8 +3120,9 @@
} else { } else {
h_tripcode = ''; h_tripcode = '';
} }
email_processed = encodeURIComponent(email).replace(/%40/g, '@');
if (email) { if (email) {
h_emailStart = "<a href='mailto:" + (E(encodeURIComponent(email))) + "' class='useremail'>"; h_emailStart = "<a href='mailto:" + (E(email_processed)) + "' class='useremail'>";
h_emailEnd = '</a>'; h_emailEnd = '</a>';
} else { } else {
h_emailStart = ''; h_emailStart = '';
@ -3570,7 +3569,7 @@
}; };
UI = (function() { UI = (function() {
var Menu, addMenuEntry, checkbox, dialog, drag, dragend, dragstart, hover, hoverend, hoverstart, menus, rmMenuEntry, touchend, touchmove; var Menu, checkbox, dialog, drag, dragend, dragstart, hover, hoverend, hoverstart, menus, touchend, touchmove;
dialog = function(id, position, properties) { dialog = function(id, position, properties) {
var child, el, move, _i, _len, _ref; var child, el, move, _i, _len, _ref;
el = $.el('div', { el = $.el('div', {
@ -3597,12 +3596,6 @@
return el; return el;
}; };
menus = {}; menus = {};
addMenuEntry = function(entry) {
return menus[entry.type].addEntry(entry);
};
rmMenuEntry = function(entry) {
return menus[entry.type].addEntry(entry);
};
Menu = (function() { Menu = (function() {
var currentMenu, lastToggledButton; var currentMenu, lastToggledButton;
@ -3612,7 +3605,6 @@
function Menu(type) { function Menu(type) {
this.type = type; this.type = type;
this.rmEntry = __bind(this.rmEntry, this);
this.addEntry = __bind(this.addEntry, this); this.addEntry = __bind(this.addEntry, this);
this.onFocus = __bind(this.onFocus, this); this.onFocus = __bind(this.onFocus, this);
this.keybinds = __bind(this.keybinds, this); this.keybinds = __bind(this.keybinds, this);
@ -3825,12 +3817,6 @@
return this.entries.push(entry); return this.entries.push(entry);
}; };
Menu.prototype.rmEntry = function(entry) {
var index;
index = this.entries.indexOf(entry);
return this.entries.splice(index, 1);
};
Menu.prototype.parseEntry = function(entry) { Menu.prototype.parseEntry = function(entry) {
var el, subEntries, subEntry, _i, _len; var el, subEntries, subEntry, _i, _len;
el = entry.el, subEntries = entry.subEntries; el = entry.el, subEntries = entry.subEntries;
@ -4009,9 +3995,7 @@
dialog: dialog, dialog: dialog,
Menu: Menu, Menu: Menu,
hover: hoverstart, hover: hoverstart,
checkbox: checkbox, checkbox: checkbox
addMenuEntry: addMenuEntry,
rmMenuEntry: rmMenuEntry
}; };
})(); })();
@ -4292,7 +4276,6 @@
textContent: 'Filter' textContent: 'Filter'
}); });
entry = { entry = {
type: 'post',
el: div, el: div,
order: 50, order: 50,
open: function(post) { open: function(post) {
@ -4306,7 +4289,7 @@
type = _ref[_i]; type = _ref[_i];
entry.subEntries.push(Filter.menu.createSubEntry(type[0], type[1])); entry.subEntries.push(Filter.menu.createSubEntry(type[0], type[1]));
} }
return UI.addMenuEntry(entry); return Menu.menu.addEntry(entry);
}, },
createSubEntry: function(text, type) { createSubEntry: function(text, type) {
var el; var el;
@ -4412,8 +4395,7 @@
thisPost = UI.checkbox('thisPost', ' This post', true); thisPost = UI.checkbox('thisPost', ' This post', true);
replies = UI.checkbox('replies', ' Hide replies', Conf['Recursive Hiding']); replies = UI.checkbox('replies', ' Hide replies', Conf['Recursive Hiding']);
makeStub = UI.checkbox('makeStub', ' Make stub', Conf['Stubs']); makeStub = UI.checkbox('makeStub', ' Make stub', Conf['Stubs']);
UI.addMenuEntry({ Menu.menu.addEntry({
type: 'post',
el: div, el: div,
order: 20, order: 20,
open: function(post) { open: function(post) {
@ -4451,8 +4433,7 @@
href: 'javascript:;' href: 'javascript:;'
}); });
$.on(hideStubLink, 'click', PostHiding.menu.hideStub); $.on(hideStubLink, 'click', PostHiding.menu.hideStub);
UI.addMenuEntry({ Menu.menu.addEntry({
type: 'post',
el: div, el: div,
order: 20, order: 20,
open: function(post) { open: function(post) {
@ -4482,8 +4463,7 @@
} }
] ]
}); });
return UI.addMenuEntry({ return Menu.menu.addEntry({
type: 'post',
el: hideStubLink, el: hideStubLink,
order: 15, order: 15,
open: function(post) { open: function(post) {
@ -4814,8 +4794,7 @@
}); });
$.on(apply, 'click', ThreadHiding.menu.hide); $.on(apply, 'click', ThreadHiding.menu.hide);
makeStub = UI.checkbox('Stubs', ' Make stub'); makeStub = UI.checkbox('Stubs', ' Make stub');
UI.addMenuEntry({ Menu.menu.addEntry({
type: 'post',
el: div, el: div,
order: 20, order: 20,
open: function(_arg) { open: function(_arg) {
@ -4841,8 +4820,7 @@
href: 'javascript:;' href: 'javascript:;'
}); });
$.on(div, 'click', ThreadHiding.menu.show); $.on(div, 'click', ThreadHiding.menu.show);
UI.addMenuEntry({ Menu.menu.addEntry({
type: 'post',
el: div, el: div,
order: 20, order: 20,
open: function(_arg) { open: function(_arg) {
@ -4860,8 +4838,7 @@
href: 'javascript:;' href: 'javascript:;'
}); });
$.on(hideStubLink, 'click', ThreadHiding.menu.hideStub); $.on(hideStubLink, 'click', ThreadHiding.menu.hideStub);
return UI.addMenuEntry({ return Menu.menu.addEntry({
type: 'post',
el: hideStubLink, el: hideStubLink,
order: 15, order: 15,
open: function(_arg) { open: function(_arg) {
@ -5388,8 +5365,7 @@
}); });
input = $('input', this.controls); input = $('input', this.controls);
$.on(input, 'change', this.toggle); $.on(input, 'change', this.toggle);
UI.addMenuEntry(this.entry = { Header.menu.addEntry(this.entry = {
type: 'header',
el: this.controls, el: this.controls,
order: 98 order: 98
}); });
@ -6591,13 +6567,12 @@
}); });
ThreadUpdater.postID = postID; ThreadUpdater.postID = postID;
$.event('QRPostSuccessful', { $.event('QRPostSuccessful', {
board: { boardID: g.BOARD.ID,
ID: g.BOARD.ID
},
threadID: threadID, threadID: threadID,
postID: postID postID: postID
}); });
$.event('QRPostSuccessful_', { $.event('QRPostSuccessful_', {
boardID: g.BOARD.ID,
threadID: threadID, threadID: threadID,
postID: postID postID: postID
}); });
@ -7486,8 +7461,7 @@
el.title = "" + type + " Tyme"; el.title = "" + type + " Tyme";
FappeTyme[lc] = input = el.firstElementChild; FappeTyme[lc] = input = el.firstElementChild;
$.on(input, 'change', FappeTyme.cb.toggle.bind(input)); $.on(input, 'change', FappeTyme.cb.toggle.bind(input));
UI.addMenuEntry({ Header.menu.addEntry({
type: 'header',
el: el, el: el,
order: 97 order: 97
}); });
@ -7586,8 +7560,7 @@
createSubEntry = Gallery.menu.createSubEntry; createSubEntry = Gallery.menu.createSubEntry;
for (name in Config.gallery) { for (name in Config.gallery) {
el = createSubEntry(name).el; el = createSubEntry(name).el;
UI.addMenuEntry({ nodes.menu.addEntry({
type: 'gallery',
el: el, el: el,
order: 0 order: 0
}); });
@ -7821,8 +7794,7 @@
for (name in Config.gallery) { for (name in Config.gallery) {
subEntries.push(createSubEntry(name)); subEntries.push(createSubEntry(name));
} }
return UI.addMenuEntry({ return Header.menu.addEntry({
type: 'header',
el: el, el: el,
order: 105, order: 105,
subEntries: subEntries subEntries: subEntries
@ -8155,8 +8127,7 @@
conf = _ref[name]; conf = _ref[name];
subEntries.push(createSubEntry(name, conf[1])); subEntries.push(createSubEntry(name, conf[1]));
} }
return UI.addMenuEntry({ return Header.menu.addEntry({
type: 'header',
el: el, el: el,
order: 105, order: 105,
subEntries: subEntries subEntries: subEntries
@ -8317,8 +8288,7 @@
}); });
this.el = prefetch.firstElementChild; this.el = prefetch.firstElementChild;
$.on(this.el, 'change', this.toggle); $.on(this.el, 'change', this.toggle);
return UI.addMenuEntry({ return Header.menu.addEntry({
type: 'header',
el: prefetch, el: prefetch,
order: 104 order: 104
}); });
@ -9075,7 +9045,6 @@
textContent: 'Archive' textContent: 'Archive'
}); });
entry = { entry = {
type: 'post',
el: div, el: div,
order: 90, order: 90,
open: function(_arg) { open: function(_arg) {
@ -9094,7 +9063,7 @@
type = _ref[_i]; type = _ref[_i];
entry.subEntries.push(this.createSubEntry(type[0], type[1])); entry.subEntries.push(this.createSubEntry(type[0], type[1]));
} }
return UI.addMenuEntry(entry); return Menu.menu.addEntry(entry);
}, },
createSubEntry: function(text, type) { createSubEntry: function(text, type) {
var el, open; var el, open;
@ -9171,8 +9140,7 @@
return true; return true;
} }
}; };
return UI.addMenuEntry({ return Menu.menu.addEntry({
type: 'post',
el: div, el: div,
order: 40, order: 40,
open: function(post) { open: function(post) {
@ -9296,8 +9264,7 @@
}; };
})(this)); })(this));
}); });
return UI.addMenuEntry({ return Menu.menu.addEntry({
type: 'post',
el: a, el: a,
order: 100, order: 100,
open: function(_arg) { open: function(_arg) {
@ -9365,8 +9332,7 @@
textContent: 'Report this post' textContent: 'Report this post'
}); });
$.on(a, 'click', ReportLink.report); $.on(a, 'click', ReportLink.report);
return UI.addMenuEntry({ return Menu.menu.addEntry({
type: 'post',
el: a, el: a,
order: 10, order: 10,
open: function(post) { open: function(post) {
@ -9613,8 +9579,7 @@
subEntries.push({ subEntries.push({
el: this.settings el: this.settings
}); });
UI.addMenuEntry(this.entry = { Header.menu.addEntry(this.entry = {
type: 'header',
el: $.el('span', { el: $.el('span', {
textContent: 'Updater' textContent: 'Updater'
}), }),
@ -9724,9 +9689,7 @@
ThreadUpdater.thread.kill(); ThreadUpdater.thread.kill();
$.event('ThreadUpdate', { $.event('ThreadUpdate', {
404: true, 404: true,
thread: { threadID: ThreadUpdater.thread.fullID
fullID: ThreadUpdater.thread.fullID
}
}); });
break; break;
default: default:
@ -9820,7 +9783,7 @@
return new Notice('info', "The thread is " + change + ".", 30); return new Notice('info', "The thread is " + change + ".", 30);
}, },
parse: function(postObjects) { parse: function(postObjects) {
var OP, count, deletedFiles, deletedPosts, files, index, node, num, post, postObject, posts, root, scroll, _i, _j, _len, _len1; var OP, count, files, index, node, num, post, postObject, posts, root, scroll, _i, _j, _len, _len1;
OP = postObjects[0]; OP = postObjects[0];
Build.spoilerRange[ThreadUpdater.thread.board] = OP.custom_spoiler; Build.spoilerRange[ThreadUpdater.thread.board] = OP.custom_spoiler;
ThreadUpdater.updateThreadStatus('Sticky', !!OP.sticky); ThreadUpdater.updateThreadStatus('Sticky', !!OP.sticky);
@ -9845,25 +9808,15 @@
node = Build.postFromObject(postObject, ThreadUpdater.thread.board.ID); node = Build.postFromObject(postObject, ThreadUpdater.thread.board.ID);
posts.push(new Post(node, ThreadUpdater.thread, ThreadUpdater.thread.board)); posts.push(new Post(node, ThreadUpdater.thread, ThreadUpdater.thread.board));
} }
deletedPosts = [];
deletedFiles = [];
ThreadUpdater.thread.posts.forEach(function(post) { ThreadUpdater.thread.posts.forEach(function(post) {
var ID; var ID;
ID = +post.ID; ID = +post.ID;
if (__indexOf.call(index, ID) < 0) { if (__indexOf.call(index, ID) < 0) {
post.kill(); post.kill();
deletedPosts.push({
ID: post.ID,
fullID: post.fullID
});
} else if (post.isDead) { } else if (post.isDead) {
post.resurrect(); post.resurrect();
} else if (post.file && !(post.file.isDead || __indexOf.call(files, ID) >= 0)) { } else if (post.file && !(post.file.isDead || __indexOf.call(files, ID) >= 0)) {
post.kill(true); post.kill(true);
deletedFiles.push({
ID: post.ID,
fullID: post.fullID
});
} }
if (ThreadUpdater.postID && ThreadUpdater.postID === ID) { if (ThreadUpdater.postID && ThreadUpdater.postID === ID) {
return ThreadUpdater.foundPost = true; return ThreadUpdater.foundPost = true;
@ -9915,24 +9868,10 @@
} }
return $.event('ThreadUpdate', { return $.event('ThreadUpdate', {
404: false, 404: false,
thread: { threadID: ThreadUpdater.thread.fullID,
ID: ThreadUpdater.thread.ID, newPosts: posts.map(function(post) {
fullID: ThreadUpdater.thread.fullID return post.fullID;
}, }),
newPosts: (function() {
var _k, _len2, _results;
_results = [];
for (_k = 0, _len2 = posts.length; _k < _len2; _k++) {
post = posts[_k];
_results.push({
ID: post.ID,
fullID: post.fullID
});
}
return _results;
})(),
deletedPosts: deletedPosts,
deletedFiles: deletedFiles,
postCount: OP.replies + 1, postCount: OP.replies + 1,
fileCount: OP.images + (!!ThreadUpdater.thread.OP.file && !ThreadUpdater.thread.OP.file.isDead) fileCount: OP.images + (!!ThreadUpdater.thread.OP.file && !ThreadUpdater.thread.OP.file.isDead)
}); });
@ -10067,14 +10006,14 @@
return ThreadWatcher.rm(boardID, +threadID); return ThreadWatcher.rm(boardID, +threadID);
}, },
post: function(e) { post: function(e) {
var board, postID, threadID, _ref; var boardID, postID, threadID, _ref;
_ref = e.detail, board = _ref.board, postID = _ref.postID, threadID = _ref.threadID; _ref = e.detail, boardID = _ref.boardID, threadID = _ref.threadID, postID = _ref.postID;
if (postID === threadID) { if (postID === threadID) {
if (Conf['Auto Watch']) { if (Conf['Auto Watch']) {
return $.set('AutoWatch', threadID); return $.set('AutoWatch', threadID);
} }
} else if (Conf['Auto Watch Reply']) { } else if (Conf['Auto Watch Reply']) {
return ThreadWatcher.add(g.boards[board.ID].threads[threadID]); return ThreadWatcher.add(g.threads[boardID + '.' + threadID]);
} }
}, },
onIndexRefresh: function() { onIndexRefresh: function() {
@ -10104,7 +10043,7 @@
}, },
onThreadRefresh: function(e) { onThreadRefresh: function(e) {
var thread; var thread;
thread = g.threads[e.detail.thread.fullID]; thread = g.threads[e.detail.threadID];
if (!(e.detail[404] && ThreadWatcher.db.get({ if (!(e.detail[404] && ThreadWatcher.db.get({
boardID: thread.board.ID, boardID: thread.board.ID,
threadID: thread.ID threadID: thread.ID
@ -10316,7 +10255,7 @@
if (!Conf['Thread Watcher']) { if (!Conf['Thread Watcher']) {
return; return;
} }
menu = new UI.Menu('thread watcher'); menu = this.menu = new UI.Menu('thread watcher');
$.on($('.menu-button', ThreadWatcher.dialog), 'click', function(e) { $.on($('.menu-button', ThreadWatcher.dialog), 'click', function(e) {
return menu.toggle(e, this, ThreadWatcher); return menu.toggle(e, this, ThreadWatcher);
}); });
@ -10331,8 +10270,7 @@
entryEl = $.el('a', { entryEl = $.el('a', {
href: 'javascript:;' href: 'javascript:;'
}); });
UI.addMenuEntry({ Header.menu.addEntry({
type: 'header',
el: entryEl, el: entryEl,
order: 60 order: 60
}); });
@ -10353,7 +10291,6 @@
entries.push({ entries.push({
cb: ThreadWatcher.cb.openAll, cb: ThreadWatcher.cb.openAll,
entry: { entry: {
type: 'thread watcher',
el: $.el('a', { el: $.el('a', {
textContent: 'Open all threads' textContent: 'Open all threads'
}) })
@ -10365,7 +10302,6 @@
entries.push({ entries.push({
cb: ThreadWatcher.cb.checkThreads, cb: ThreadWatcher.cb.checkThreads,
entry: { entry: {
type: 'thread watcher',
el: $.el('a', { el: $.el('a', {
textContent: 'Check 404\'d threads' textContent: 'Check 404\'d threads'
}) })
@ -10377,7 +10313,6 @@
entries.push({ entries.push({
cb: ThreadWatcher.cb.pruneDeads, cb: ThreadWatcher.cb.pruneDeads,
entry: { entry: {
type: 'thread watcher',
el: $.el('a', { el: $.el('a', {
textContent: 'Prune 404\'d threads' textContent: 'Prune 404\'d threads'
}) })
@ -10394,7 +10329,6 @@
} }
entries.push({ entries.push({
entry: { entry: {
type: 'thread watcher',
el: $.el('span', { el: $.el('span', {
textContent: 'Settings' textContent: 'Settings'
}), }),
@ -10412,7 +10346,7 @@
if (refresh) { if (refresh) {
this.refreshers.push(refresh.bind(entry)); this.refreshers.push(refresh.bind(entry));
} }
UI.addMenuEntry(entry); this.menu.addEntry(entry);
} }
}, },
createSubEntry: function(name, desc) { createSubEntry: function(name, desc) {
@ -10589,20 +10523,12 @@
}; };
}, },
onUpdate: function(e) { onUpdate: function(e) {
var post;
if (e.detail[404]) { if (e.detail[404]) {
return Unread.update(); return Unread.update();
} else if (!QuoteThreading.enabled) { } else if (!QuoteThreading.enabled) {
return Unread.addPosts((function() { return Unread.addPosts(e.detail.newPosts.map(function(fullID) {
var _i, _len, _ref, _results; return g.posts[fullID];
_ref = e.detail.newPosts; }));
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
post = _ref[_i];
_results.push(g.posts[post.fullID]);
}
return _results;
})());
} else { } else {
Unread.read(); Unread.read();
return Unread.update(); return Unread.update();
@ -10810,7 +10736,6 @@
return; return;
} }
entry = { entry = {
type: 'header',
el: $.el('a', { el: $.el('a', {
textContent: 'Show announcement', textContent: 'Show announcement',
className: 'show-announcement', className: 'show-announcement',
@ -10821,7 +10746,7 @@
return psa.hidden; return psa.hidden;
} }
}; };
UI.addMenuEntry(entry); Header.menu.addEntry(entry);
$.on(entry.el, 'click', PSAHiding.toggle); $.on(entry.el, 'click', PSAHiding.toggle);
PSAHiding.btn = btn = $.el('span', { PSAHiding.btn = btn = $.el('span', {
innerHTML: '[<a href="javascript:;">Dismiss</a>]', innerHTML: '[<a href="javascript:;">Dismiss</a>]',
@ -10974,8 +10899,7 @@
input = $('input', el); input = $('input', el);
$.on(input, 'change', this.toggle); $.on(input, 'change', this.toggle);
$.sync('Header catalog links', CatalogLinks.set); $.sync('Header catalog links', CatalogLinks.set);
UI.addMenuEntry({ Header.menu.addEntry({
type: 'header',
el: el, el: el,
order: 95 order: 95
}); });
@ -11472,7 +11396,7 @@
}); });
} }
if (board === 'sci') { if (board === 'sci') {
$.globalEval('window.addEventListener(\'jsmath\', function(e) {\n if (!jsMath) return;\n if (jsMath.loaded) {\n // process one post\n jsMath.ProcessBeforeShowing(document.getElementById(\'p\' + e.detail));\n } else if (jsMath.Autoload && jsMath.Autoload.checked) {\n // load jsMath and process whole document\n jsMath.Autoload.Script.Push(\'ProcessBeforeShowing\', [null]);\n jsMath.Autoload.LoadJsMath();\n }\n}, false);'); $.globalEval('window.addEventListener(\'jsmath\', function(e) {\n if (!jsMath) return;\n if (jsMath.loaded) {\n // process one post\n jsMath.ProcessBeforeShowing(document.getElementById(e.detail));\n } else if (jsMath.Autoload && jsMath.Autoload.checked) {\n // load jsMath and process whole document\n jsMath.Autoload.Script.Push(\'ProcessBeforeShowing\', [null]);\n jsMath.Autoload.LoadJsMath();\n }\n}, false);');
return Post.callbacks.push({ return Post.callbacks.push({
name: 'Parse /sci/ math', name: 'Parse /sci/ math',
cb: this.math cb: this.math
@ -11505,7 +11429,7 @@
}; };
})(this)), (function(_this) { })(this)), (function(_this) {
return function() { return function() {
return $.event('jsmath', _this.ID, window); return $.event('jsmath', _this.nodes.post.id, window);
}; };
})(this)); })(this));
}, },
@ -12353,7 +12277,7 @@
Settings.dialog = dialog = $.el('div', { Settings.dialog = dialog = $.el('div', {
id: 'fourchanx-settings', id: 'fourchanx-settings',
className: 'dialog', className: 'dialog',
innerHTML: '<nav><div class=sections-list></div><p class=\'imp-exp-result warning\'></p><div class=credits><a class=export>Export</a>&nbsp|&nbsp<a class=import>Import</a>&nbsp|&nbsp<a class=reset>Reset Settings</a>&nbsp|&nbsp<input type=file hidden><a href=\'https://github.com/ccd0/4chan-x\' target=_blank>4chan X</a>&nbsp|&nbsp<a href=\'https://github.com/ccd0/4chan-x/blob/master/CHANGELOG.md\' target=_blank>1.8.0</a>&nbsp|&nbsp<a href=\'https://github.com/ccd0/4chan-x/issues\' target=_blank>Issues</a>&nbsp|&nbsp<a href=javascript:; class=\'close fa fa-times\' title=Close></a></div></nav><div class=section-container><section></section></div>' innerHTML: '<nav><div class=sections-list></div><p class=\'imp-exp-result warning\'></p><div class=credits><a class=export>Export</a>&nbsp|&nbsp<a class=import>Import</a>&nbsp|&nbsp<a class=reset>Reset Settings</a>&nbsp|&nbsp<input type=file hidden><a href=\'https://github.com/ccd0/4chan-x\' target=_blank>4chan X</a>&nbsp|&nbsp<a href=\'https://github.com/ccd0/4chan-x/blob/master/CHANGELOG.md\' target=_blank>1.8.1</a>&nbsp|&nbsp<a href=\'https://github.com/ccd0/4chan-x/issues\' target=_blank>Issues</a>&nbsp|&nbsp<a href=javascript:; class=\'close fa fa-times\' title=Close></a></div></nav><div class=section-container><section></section></div>'
}); });
$.on($('.export', Settings.dialog), 'click', Settings["export"]); $.on($('.export', Settings.dialog), 'click', Settings["export"]);
$.on($('.import', Settings.dialog), 'click', Settings["import"]); $.on($('.import', Settings.dialog), 'click', Settings["import"]);
@ -13184,7 +13108,7 @@
} }
if (previousversion) { if (previousversion) {
el = $.el('span', { el = $.el('span', {
innerHTML: '4chan X has been updated to <a href="https://github.com/ccd0/4chan-x/blob/master/CHANGELOG.md" target="_blank">version 1.8.0</a>.' innerHTML: '4chan X has been updated to <a href="https://github.com/ccd0/4chan-x/blob/master/CHANGELOG.md" target="_blank">version 1.8.1</a>.'
}); });
new Notice('info', el, 15); new Notice('info', el, 15);
} else { } else {
@ -13227,25 +13151,6 @@
}; };
return softTask(); return softTask();
}, },
addCallback: function(e) {
var Klass, obj;
obj = e.detail;
if (typeof obj.callback.name !== 'string') {
throw new Error("Invalid callback name: " + obj.callback.name);
}
switch (obj.type) {
case 'Post':
Klass = Post;
break;
case 'Thread':
Klass = Thread;
break;
default:
return;
}
obj.callback.isAddon = true;
return Klass.callbacks.push(obj.callback);
},
handleErrors: function(errors) { handleErrors: function(errors) {
var div, error, logs, _i, _len; var div, error, logs, _i, _len;
if (!(errors instanceof Array)) { if (!(errors instanceof Array)) {

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://ccd0.github.io/4chan-x/builds/crx.crx' version='1.8.0' /> <updatecheck codebase='https://ccd0.github.io/4chan-x/builds/crx.crx' version='1.8.1' />
</app> </app>
</gupdate> </gupdate>

View File

@ -1,6 +1,6 @@
{ {
"name": "4chan X", "name": "4chan X",
"version": "1.8.0", "version": "1.8.1",
"manifest_version": 2, "manifest_version": 2,
"description": "Cross-browser userscript for maximum lurking on 4chan.", "description": "Cross-browser userscript for maximum lurking on 4chan.",
"icons": { "icons": {

View File

@ -1,6 +1,6 @@
// Generated by CoffeeScript // Generated by CoffeeScript
/* /*
* 4chan X - Version 1.8.0 - 2014-06-18 * 4chan X - Version 1.8.1 - 2014-06-19
* *
* Licensed under the MIT license. * Licensed under the MIT license.
* https://github.com/ccd0/4chan-x/blob/master/LICENSE * https://github.com/ccd0/4chan-x/blob/master/LICENSE
@ -349,7 +349,7 @@
doc = d.documentElement; doc = d.documentElement;
g = { g = {
VERSION: '1.8.0', VERSION: '1.8.1',
NAMESPACE: '4chan X.', NAMESPACE: '4chan X.',
boards: {} boards: {}
}; };
@ -1845,8 +1845,7 @@
$.sync('Header auto-hide', this.setBarVisibility); $.sync('Header auto-hide', this.setBarVisibility);
$.sync('Centered links', this.setLinkJustify); $.sync('Centered links', this.setLinkJustify);
this.addShortcut(menuButton); this.addShortcut(menuButton);
UI.addMenuEntry({ this.menu.addEntry({
type: 'header',
el: $.el('span', { el: $.el('span', {
textContent: 'Header' textContent: 'Header'
}), }),
@ -2395,8 +2394,7 @@
$.on(input, 'change', this.cb.sort); $.on(input, 'change', this.cb.sort);
} }
} }
UI.addMenuEntry({ Header.menu.addEntry({
type: 'header',
el: $.el('span', { el: $.el('span', {
textContent: 'Index Navigation' textContent: 'Index Navigation'
}), }),
@ -3104,7 +3102,7 @@
This function contains code from 4chan-JS (https://github.com/4chan/4chan-JS). This function contains code from 4chan-JS (https://github.com/4chan/4chan-JS).
@license: https://github.com/4chan/4chan-JS/blob/master/LICENSE @license: https://github.com/4chan/4chan-JS/blob/master/LICENSE
*/ */
var E, boardID, capcode, container, date, dateUTC, email, file, fileSize, fileThumb, flagCode, flagName, h_capcodeClass, h_capcodeIcon, h_capcodeStart, h_closed, h_comment, h_emailEnd, h_emailStart, h_file, h_fileDims, h_fileInfo, h_fileTitle1, h_fileTitle2, h_flag, h_gifIcon, h_imgSrc, h_pageIcon, h_postClass, h_quoteLink, h_replyLink, h_sideArrows, h_staticPath, h_sticky, h_tripcode, h_userID, href, isClosed, isOP, isSticky, name, pageNum, postID, quote, shortFilename, spoilerRange, subject, threadID, tripcode, uniqueID, _i, _len, _ref; var E, boardID, capcode, container, date, dateUTC, email, email_processed, file, fileSize, fileThumb, flagCode, flagName, h_capcodeClass, h_capcodeIcon, h_capcodeStart, h_closed, h_comment, h_emailEnd, h_emailStart, h_file, h_fileDims, h_fileInfo, h_fileTitle1, h_fileTitle2, h_flag, h_gifIcon, h_imgSrc, h_pageIcon, h_postClass, h_quoteLink, h_replyLink, h_sideArrows, h_staticPath, h_sticky, h_tripcode, h_userID, href, isClosed, isOP, isSticky, name, pageNum, postID, quote, shortFilename, spoilerRange, subject, threadID, tripcode, uniqueID, _i, _len, _ref;
E = Build.h_escape; E = Build.h_escape;
postID = o.postID, threadID = o.threadID, boardID = o.boardID, name = o.name, capcode = o.capcode, tripcode = o.tripcode, uniqueID = o.uniqueID, email = o.email, subject = o.subject, flagCode = o.flagCode, flagName = o.flagName, date = o.date, dateUTC = o.dateUTC, isSticky = o.isSticky, isClosed = o.isClosed, h_comment = o.h_comment, file = o.file; postID = o.postID, threadID = o.threadID, boardID = o.boardID, name = o.name, capcode = o.capcode, tripcode = o.tripcode, uniqueID = o.uniqueID, email = o.email, subject = o.subject, flagCode = o.flagCode, flagName = o.flagName, date = o.date, dateUTC = o.dateUTC, isSticky = o.isSticky, isClosed = o.isClosed, h_comment = o.h_comment, file = o.file;
name || (name = ''); name || (name = '');
@ -3122,8 +3120,9 @@
} else { } else {
h_tripcode = ''; h_tripcode = '';
} }
email_processed = encodeURIComponent(email).replace(/%40/g, '@');
if (email) { if (email) {
h_emailStart = "<a href='mailto:" + (E(encodeURIComponent(email))) + "' class='useremail'>"; h_emailStart = "<a href='mailto:" + (E(email_processed)) + "' class='useremail'>";
h_emailEnd = '</a>'; h_emailEnd = '</a>';
} else { } else {
h_emailStart = ''; h_emailStart = '';
@ -3570,7 +3569,7 @@
}; };
UI = (function() { UI = (function() {
var Menu, addMenuEntry, checkbox, dialog, drag, dragend, dragstart, hover, hoverend, hoverstart, menus, rmMenuEntry, touchend, touchmove; var Menu, checkbox, dialog, drag, dragend, dragstart, hover, hoverend, hoverstart, menus, touchend, touchmove;
dialog = function(id, position, properties) { dialog = function(id, position, properties) {
var child, el, move, _i, _len, _ref; var child, el, move, _i, _len, _ref;
el = $.el('div', { el = $.el('div', {
@ -3597,12 +3596,6 @@
return el; return el;
}; };
menus = {}; menus = {};
addMenuEntry = function(entry) {
return menus[entry.type].addEntry(entry);
};
rmMenuEntry = function(entry) {
return menus[entry.type].addEntry(entry);
};
Menu = (function() { Menu = (function() {
var currentMenu, lastToggledButton; var currentMenu, lastToggledButton;
@ -3612,7 +3605,6 @@
function Menu(type) { function Menu(type) {
this.type = type; this.type = type;
this.rmEntry = __bind(this.rmEntry, this);
this.addEntry = __bind(this.addEntry, this); this.addEntry = __bind(this.addEntry, this);
this.onFocus = __bind(this.onFocus, this); this.onFocus = __bind(this.onFocus, this);
this.keybinds = __bind(this.keybinds, this); this.keybinds = __bind(this.keybinds, this);
@ -3825,12 +3817,6 @@
return this.entries.push(entry); return this.entries.push(entry);
}; };
Menu.prototype.rmEntry = function(entry) {
var index;
index = this.entries.indexOf(entry);
return this.entries.splice(index, 1);
};
Menu.prototype.parseEntry = function(entry) { Menu.prototype.parseEntry = function(entry) {
var el, subEntries, subEntry, _i, _len; var el, subEntries, subEntry, _i, _len;
el = entry.el, subEntries = entry.subEntries; el = entry.el, subEntries = entry.subEntries;
@ -4009,9 +3995,7 @@
dialog: dialog, dialog: dialog,
Menu: Menu, Menu: Menu,
hover: hoverstart, hover: hoverstart,
checkbox: checkbox, checkbox: checkbox
addMenuEntry: addMenuEntry,
rmMenuEntry: rmMenuEntry
}; };
})(); })();
@ -4292,7 +4276,6 @@
textContent: 'Filter' textContent: 'Filter'
}); });
entry = { entry = {
type: 'post',
el: div, el: div,
order: 50, order: 50,
open: function(post) { open: function(post) {
@ -4306,7 +4289,7 @@
type = _ref[_i]; type = _ref[_i];
entry.subEntries.push(Filter.menu.createSubEntry(type[0], type[1])); entry.subEntries.push(Filter.menu.createSubEntry(type[0], type[1]));
} }
return UI.addMenuEntry(entry); return Menu.menu.addEntry(entry);
}, },
createSubEntry: function(text, type) { createSubEntry: function(text, type) {
var el; var el;
@ -4412,8 +4395,7 @@
thisPost = UI.checkbox('thisPost', ' This post', true); thisPost = UI.checkbox('thisPost', ' This post', true);
replies = UI.checkbox('replies', ' Hide replies', Conf['Recursive Hiding']); replies = UI.checkbox('replies', ' Hide replies', Conf['Recursive Hiding']);
makeStub = UI.checkbox('makeStub', ' Make stub', Conf['Stubs']); makeStub = UI.checkbox('makeStub', ' Make stub', Conf['Stubs']);
UI.addMenuEntry({ Menu.menu.addEntry({
type: 'post',
el: div, el: div,
order: 20, order: 20,
open: function(post) { open: function(post) {
@ -4451,8 +4433,7 @@
href: 'javascript:;' href: 'javascript:;'
}); });
$.on(hideStubLink, 'click', PostHiding.menu.hideStub); $.on(hideStubLink, 'click', PostHiding.menu.hideStub);
UI.addMenuEntry({ Menu.menu.addEntry({
type: 'post',
el: div, el: div,
order: 20, order: 20,
open: function(post) { open: function(post) {
@ -4482,8 +4463,7 @@
} }
] ]
}); });
return UI.addMenuEntry({ return Menu.menu.addEntry({
type: 'post',
el: hideStubLink, el: hideStubLink,
order: 15, order: 15,
open: function(post) { open: function(post) {
@ -4814,8 +4794,7 @@
}); });
$.on(apply, 'click', ThreadHiding.menu.hide); $.on(apply, 'click', ThreadHiding.menu.hide);
makeStub = UI.checkbox('Stubs', ' Make stub'); makeStub = UI.checkbox('Stubs', ' Make stub');
UI.addMenuEntry({ Menu.menu.addEntry({
type: 'post',
el: div, el: div,
order: 20, order: 20,
open: function(_arg) { open: function(_arg) {
@ -4841,8 +4820,7 @@
href: 'javascript:;' href: 'javascript:;'
}); });
$.on(div, 'click', ThreadHiding.menu.show); $.on(div, 'click', ThreadHiding.menu.show);
UI.addMenuEntry({ Menu.menu.addEntry({
type: 'post',
el: div, el: div,
order: 20, order: 20,
open: function(_arg) { open: function(_arg) {
@ -4860,8 +4838,7 @@
href: 'javascript:;' href: 'javascript:;'
}); });
$.on(hideStubLink, 'click', ThreadHiding.menu.hideStub); $.on(hideStubLink, 'click', ThreadHiding.menu.hideStub);
return UI.addMenuEntry({ return Menu.menu.addEntry({
type: 'post',
el: hideStubLink, el: hideStubLink,
order: 15, order: 15,
open: function(_arg) { open: function(_arg) {
@ -5388,8 +5365,7 @@
}); });
input = $('input', this.controls); input = $('input', this.controls);
$.on(input, 'change', this.toggle); $.on(input, 'change', this.toggle);
UI.addMenuEntry(this.entry = { Header.menu.addEntry(this.entry = {
type: 'header',
el: this.controls, el: this.controls,
order: 98 order: 98
}); });
@ -6591,13 +6567,12 @@
}); });
ThreadUpdater.postID = postID; ThreadUpdater.postID = postID;
$.event('QRPostSuccessful', { $.event('QRPostSuccessful', {
board: { boardID: g.BOARD.ID,
ID: g.BOARD.ID
},
threadID: threadID, threadID: threadID,
postID: postID postID: postID
}); });
$.event('QRPostSuccessful_', { $.event('QRPostSuccessful_', {
boardID: g.BOARD.ID,
threadID: threadID, threadID: threadID,
postID: postID postID: postID
}); });
@ -7486,8 +7461,7 @@
el.title = "" + type + " Tyme"; el.title = "" + type + " Tyme";
FappeTyme[lc] = input = el.firstElementChild; FappeTyme[lc] = input = el.firstElementChild;
$.on(input, 'change', FappeTyme.cb.toggle.bind(input)); $.on(input, 'change', FappeTyme.cb.toggle.bind(input));
UI.addMenuEntry({ Header.menu.addEntry({
type: 'header',
el: el, el: el,
order: 97 order: 97
}); });
@ -7586,8 +7560,7 @@
createSubEntry = Gallery.menu.createSubEntry; createSubEntry = Gallery.menu.createSubEntry;
for (name in Config.gallery) { for (name in Config.gallery) {
el = createSubEntry(name).el; el = createSubEntry(name).el;
UI.addMenuEntry({ nodes.menu.addEntry({
type: 'gallery',
el: el, el: el,
order: 0 order: 0
}); });
@ -7821,8 +7794,7 @@
for (name in Config.gallery) { for (name in Config.gallery) {
subEntries.push(createSubEntry(name)); subEntries.push(createSubEntry(name));
} }
return UI.addMenuEntry({ return Header.menu.addEntry({
type: 'header',
el: el, el: el,
order: 105, order: 105,
subEntries: subEntries subEntries: subEntries
@ -8155,8 +8127,7 @@
conf = _ref[name]; conf = _ref[name];
subEntries.push(createSubEntry(name, conf[1])); subEntries.push(createSubEntry(name, conf[1]));
} }
return UI.addMenuEntry({ return Header.menu.addEntry({
type: 'header',
el: el, el: el,
order: 105, order: 105,
subEntries: subEntries subEntries: subEntries
@ -8317,8 +8288,7 @@
}); });
this.el = prefetch.firstElementChild; this.el = prefetch.firstElementChild;
$.on(this.el, 'change', this.toggle); $.on(this.el, 'change', this.toggle);
return UI.addMenuEntry({ return Header.menu.addEntry({
type: 'header',
el: prefetch, el: prefetch,
order: 104 order: 104
}); });
@ -9075,7 +9045,6 @@
textContent: 'Archive' textContent: 'Archive'
}); });
entry = { entry = {
type: 'post',
el: div, el: div,
order: 90, order: 90,
open: function(_arg) { open: function(_arg) {
@ -9094,7 +9063,7 @@
type = _ref[_i]; type = _ref[_i];
entry.subEntries.push(this.createSubEntry(type[0], type[1])); entry.subEntries.push(this.createSubEntry(type[0], type[1]));
} }
return UI.addMenuEntry(entry); return Menu.menu.addEntry(entry);
}, },
createSubEntry: function(text, type) { createSubEntry: function(text, type) {
var el, open; var el, open;
@ -9171,8 +9140,7 @@
return true; return true;
} }
}; };
return UI.addMenuEntry({ return Menu.menu.addEntry({
type: 'post',
el: div, el: div,
order: 40, order: 40,
open: function(post) { open: function(post) {
@ -9296,8 +9264,7 @@
}; };
})(this)); })(this));
}); });
return UI.addMenuEntry({ return Menu.menu.addEntry({
type: 'post',
el: a, el: a,
order: 100, order: 100,
open: function(_arg) { open: function(_arg) {
@ -9365,8 +9332,7 @@
textContent: 'Report this post' textContent: 'Report this post'
}); });
$.on(a, 'click', ReportLink.report); $.on(a, 'click', ReportLink.report);
return UI.addMenuEntry({ return Menu.menu.addEntry({
type: 'post',
el: a, el: a,
order: 10, order: 10,
open: function(post) { open: function(post) {
@ -9613,8 +9579,7 @@
subEntries.push({ subEntries.push({
el: this.settings el: this.settings
}); });
UI.addMenuEntry(this.entry = { Header.menu.addEntry(this.entry = {
type: 'header',
el: $.el('span', { el: $.el('span', {
textContent: 'Updater' textContent: 'Updater'
}), }),
@ -9724,9 +9689,7 @@
ThreadUpdater.thread.kill(); ThreadUpdater.thread.kill();
$.event('ThreadUpdate', { $.event('ThreadUpdate', {
404: true, 404: true,
thread: { threadID: ThreadUpdater.thread.fullID
fullID: ThreadUpdater.thread.fullID
}
}); });
break; break;
default: default:
@ -9820,7 +9783,7 @@
return new Notice('info', "The thread is " + change + ".", 30); return new Notice('info', "The thread is " + change + ".", 30);
}, },
parse: function(postObjects) { parse: function(postObjects) {
var OP, count, deletedFiles, deletedPosts, files, index, node, num, post, postObject, posts, root, scroll, _i, _j, _len, _len1; var OP, count, files, index, node, num, post, postObject, posts, root, scroll, _i, _j, _len, _len1;
OP = postObjects[0]; OP = postObjects[0];
Build.spoilerRange[ThreadUpdater.thread.board] = OP.custom_spoiler; Build.spoilerRange[ThreadUpdater.thread.board] = OP.custom_spoiler;
ThreadUpdater.updateThreadStatus('Sticky', !!OP.sticky); ThreadUpdater.updateThreadStatus('Sticky', !!OP.sticky);
@ -9845,25 +9808,15 @@
node = Build.postFromObject(postObject, ThreadUpdater.thread.board.ID); node = Build.postFromObject(postObject, ThreadUpdater.thread.board.ID);
posts.push(new Post(node, ThreadUpdater.thread, ThreadUpdater.thread.board)); posts.push(new Post(node, ThreadUpdater.thread, ThreadUpdater.thread.board));
} }
deletedPosts = [];
deletedFiles = [];
ThreadUpdater.thread.posts.forEach(function(post) { ThreadUpdater.thread.posts.forEach(function(post) {
var ID; var ID;
ID = +post.ID; ID = +post.ID;
if (__indexOf.call(index, ID) < 0) { if (__indexOf.call(index, ID) < 0) {
post.kill(); post.kill();
deletedPosts.push({
ID: post.ID,
fullID: post.fullID
});
} else if (post.isDead) { } else if (post.isDead) {
post.resurrect(); post.resurrect();
} else if (post.file && !(post.file.isDead || __indexOf.call(files, ID) >= 0)) { } else if (post.file && !(post.file.isDead || __indexOf.call(files, ID) >= 0)) {
post.kill(true); post.kill(true);
deletedFiles.push({
ID: post.ID,
fullID: post.fullID
});
} }
if (ThreadUpdater.postID && ThreadUpdater.postID === ID) { if (ThreadUpdater.postID && ThreadUpdater.postID === ID) {
return ThreadUpdater.foundPost = true; return ThreadUpdater.foundPost = true;
@ -9915,24 +9868,10 @@
} }
return $.event('ThreadUpdate', { return $.event('ThreadUpdate', {
404: false, 404: false,
thread: { threadID: ThreadUpdater.thread.fullID,
ID: ThreadUpdater.thread.ID, newPosts: posts.map(function(post) {
fullID: ThreadUpdater.thread.fullID return post.fullID;
}, }),
newPosts: (function() {
var _k, _len2, _results;
_results = [];
for (_k = 0, _len2 = posts.length; _k < _len2; _k++) {
post = posts[_k];
_results.push({
ID: post.ID,
fullID: post.fullID
});
}
return _results;
})(),
deletedPosts: deletedPosts,
deletedFiles: deletedFiles,
postCount: OP.replies + 1, postCount: OP.replies + 1,
fileCount: OP.images + (!!ThreadUpdater.thread.OP.file && !ThreadUpdater.thread.OP.file.isDead) fileCount: OP.images + (!!ThreadUpdater.thread.OP.file && !ThreadUpdater.thread.OP.file.isDead)
}); });
@ -10067,14 +10006,14 @@
return ThreadWatcher.rm(boardID, +threadID); return ThreadWatcher.rm(boardID, +threadID);
}, },
post: function(e) { post: function(e) {
var board, postID, threadID, _ref; var boardID, postID, threadID, _ref;
_ref = e.detail, board = _ref.board, postID = _ref.postID, threadID = _ref.threadID; _ref = e.detail, boardID = _ref.boardID, threadID = _ref.threadID, postID = _ref.postID;
if (postID === threadID) { if (postID === threadID) {
if (Conf['Auto Watch']) { if (Conf['Auto Watch']) {
return $.set('AutoWatch', threadID); return $.set('AutoWatch', threadID);
} }
} else if (Conf['Auto Watch Reply']) { } else if (Conf['Auto Watch Reply']) {
return ThreadWatcher.add(g.boards[board.ID].threads[threadID]); return ThreadWatcher.add(g.threads[boardID + '.' + threadID]);
} }
}, },
onIndexRefresh: function() { onIndexRefresh: function() {
@ -10104,7 +10043,7 @@
}, },
onThreadRefresh: function(e) { onThreadRefresh: function(e) {
var thread; var thread;
thread = g.threads[e.detail.thread.fullID]; thread = g.threads[e.detail.threadID];
if (!(e.detail[404] && ThreadWatcher.db.get({ if (!(e.detail[404] && ThreadWatcher.db.get({
boardID: thread.board.ID, boardID: thread.board.ID,
threadID: thread.ID threadID: thread.ID
@ -10316,7 +10255,7 @@
if (!Conf['Thread Watcher']) { if (!Conf['Thread Watcher']) {
return; return;
} }
menu = new UI.Menu('thread watcher'); menu = this.menu = new UI.Menu('thread watcher');
$.on($('.menu-button', ThreadWatcher.dialog), 'click', function(e) { $.on($('.menu-button', ThreadWatcher.dialog), 'click', function(e) {
return menu.toggle(e, this, ThreadWatcher); return menu.toggle(e, this, ThreadWatcher);
}); });
@ -10331,8 +10270,7 @@
entryEl = $.el('a', { entryEl = $.el('a', {
href: 'javascript:;' href: 'javascript:;'
}); });
UI.addMenuEntry({ Header.menu.addEntry({
type: 'header',
el: entryEl, el: entryEl,
order: 60 order: 60
}); });
@ -10353,7 +10291,6 @@
entries.push({ entries.push({
cb: ThreadWatcher.cb.openAll, cb: ThreadWatcher.cb.openAll,
entry: { entry: {
type: 'thread watcher',
el: $.el('a', { el: $.el('a', {
textContent: 'Open all threads' textContent: 'Open all threads'
}) })
@ -10365,7 +10302,6 @@
entries.push({ entries.push({
cb: ThreadWatcher.cb.checkThreads, cb: ThreadWatcher.cb.checkThreads,
entry: { entry: {
type: 'thread watcher',
el: $.el('a', { el: $.el('a', {
textContent: 'Check 404\'d threads' textContent: 'Check 404\'d threads'
}) })
@ -10377,7 +10313,6 @@
entries.push({ entries.push({
cb: ThreadWatcher.cb.pruneDeads, cb: ThreadWatcher.cb.pruneDeads,
entry: { entry: {
type: 'thread watcher',
el: $.el('a', { el: $.el('a', {
textContent: 'Prune 404\'d threads' textContent: 'Prune 404\'d threads'
}) })
@ -10394,7 +10329,6 @@
} }
entries.push({ entries.push({
entry: { entry: {
type: 'thread watcher',
el: $.el('span', { el: $.el('span', {
textContent: 'Settings' textContent: 'Settings'
}), }),
@ -10412,7 +10346,7 @@
if (refresh) { if (refresh) {
this.refreshers.push(refresh.bind(entry)); this.refreshers.push(refresh.bind(entry));
} }
UI.addMenuEntry(entry); this.menu.addEntry(entry);
} }
}, },
createSubEntry: function(name, desc) { createSubEntry: function(name, desc) {
@ -10589,20 +10523,12 @@
}; };
}, },
onUpdate: function(e) { onUpdate: function(e) {
var post;
if (e.detail[404]) { if (e.detail[404]) {
return Unread.update(); return Unread.update();
} else if (!QuoteThreading.enabled) { } else if (!QuoteThreading.enabled) {
return Unread.addPosts((function() { return Unread.addPosts(e.detail.newPosts.map(function(fullID) {
var _i, _len, _ref, _results; return g.posts[fullID];
_ref = e.detail.newPosts; }));
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
post = _ref[_i];
_results.push(g.posts[post.fullID]);
}
return _results;
})());
} else { } else {
Unread.read(); Unread.read();
return Unread.update(); return Unread.update();
@ -10810,7 +10736,6 @@
return; return;
} }
entry = { entry = {
type: 'header',
el: $.el('a', { el: $.el('a', {
textContent: 'Show announcement', textContent: 'Show announcement',
className: 'show-announcement', className: 'show-announcement',
@ -10821,7 +10746,7 @@
return psa.hidden; return psa.hidden;
} }
}; };
UI.addMenuEntry(entry); Header.menu.addEntry(entry);
$.on(entry.el, 'click', PSAHiding.toggle); $.on(entry.el, 'click', PSAHiding.toggle);
PSAHiding.btn = btn = $.el('span', { PSAHiding.btn = btn = $.el('span', {
innerHTML: '[<a href="javascript:;">Dismiss</a>]', innerHTML: '[<a href="javascript:;">Dismiss</a>]',
@ -10974,8 +10899,7 @@
input = $('input', el); input = $('input', el);
$.on(input, 'change', this.toggle); $.on(input, 'change', this.toggle);
$.sync('Header catalog links', CatalogLinks.set); $.sync('Header catalog links', CatalogLinks.set);
UI.addMenuEntry({ Header.menu.addEntry({
type: 'header',
el: el, el: el,
order: 95 order: 95
}); });
@ -11472,7 +11396,7 @@
}); });
} }
if (board === 'sci') { if (board === 'sci') {
$.globalEval('window.addEventListener(\'jsmath\', function(e) {\n if (!jsMath) return;\n if (jsMath.loaded) {\n // process one post\n jsMath.ProcessBeforeShowing(document.getElementById(\'p\' + e.detail));\n } else if (jsMath.Autoload && jsMath.Autoload.checked) {\n // load jsMath and process whole document\n jsMath.Autoload.Script.Push(\'ProcessBeforeShowing\', [null]);\n jsMath.Autoload.LoadJsMath();\n }\n}, false);'); $.globalEval('window.addEventListener(\'jsmath\', function(e) {\n if (!jsMath) return;\n if (jsMath.loaded) {\n // process one post\n jsMath.ProcessBeforeShowing(document.getElementById(e.detail));\n } else if (jsMath.Autoload && jsMath.Autoload.checked) {\n // load jsMath and process whole document\n jsMath.Autoload.Script.Push(\'ProcessBeforeShowing\', [null]);\n jsMath.Autoload.LoadJsMath();\n }\n}, false);');
return Post.callbacks.push({ return Post.callbacks.push({
name: 'Parse /sci/ math', name: 'Parse /sci/ math',
cb: this.math cb: this.math
@ -11505,7 +11429,7 @@
}; };
})(this)), (function(_this) { })(this)), (function(_this) {
return function() { return function() {
return $.event('jsmath', _this.ID, window); return $.event('jsmath', _this.nodes.post.id, window);
}; };
})(this)); })(this));
}, },
@ -12353,7 +12277,7 @@
Settings.dialog = dialog = $.el('div', { Settings.dialog = dialog = $.el('div', {
id: 'fourchanx-settings', id: 'fourchanx-settings',
className: 'dialog', className: 'dialog',
innerHTML: '<nav><div class=sections-list></div><p class=\'imp-exp-result warning\'></p><div class=credits><a class=export>Export</a>&nbsp|&nbsp<a class=import>Import</a>&nbsp|&nbsp<a class=reset>Reset Settings</a>&nbsp|&nbsp<input type=file hidden><a href=\'https://github.com/ccd0/4chan-x\' target=_blank>4chan X</a>&nbsp|&nbsp<a href=\'https://github.com/ccd0/4chan-x/blob/master/CHANGELOG.md\' target=_blank>1.8.0</a>&nbsp|&nbsp<a href=\'https://github.com/ccd0/4chan-x/issues\' target=_blank>Issues</a>&nbsp|&nbsp<a href=javascript:; class=\'close fa fa-times\' title=Close></a></div></nav><div class=section-container><section></section></div>' innerHTML: '<nav><div class=sections-list></div><p class=\'imp-exp-result warning\'></p><div class=credits><a class=export>Export</a>&nbsp|&nbsp<a class=import>Import</a>&nbsp|&nbsp<a class=reset>Reset Settings</a>&nbsp|&nbsp<input type=file hidden><a href=\'https://github.com/ccd0/4chan-x\' target=_blank>4chan X</a>&nbsp|&nbsp<a href=\'https://github.com/ccd0/4chan-x/blob/master/CHANGELOG.md\' target=_blank>1.8.1</a>&nbsp|&nbsp<a href=\'https://github.com/ccd0/4chan-x/issues\' target=_blank>Issues</a>&nbsp|&nbsp<a href=javascript:; class=\'close fa fa-times\' title=Close></a></div></nav><div class=section-container><section></section></div>'
}); });
$.on($('.export', Settings.dialog), 'click', Settings["export"]); $.on($('.export', Settings.dialog), 'click', Settings["export"]);
$.on($('.import', Settings.dialog), 'click', Settings["import"]); $.on($('.import', Settings.dialog), 'click', Settings["import"]);
@ -13184,7 +13108,7 @@
} }
if (previousversion) { if (previousversion) {
el = $.el('span', { el = $.el('span', {
innerHTML: '4chan X has been updated to <a href="https://github.com/ccd0/4chan-x/blob/master/CHANGELOG.md" target="_blank">version 1.8.0</a>.' innerHTML: '4chan X has been updated to <a href="https://github.com/ccd0/4chan-x/blob/master/CHANGELOG.md" target="_blank">version 1.8.1</a>.'
}); });
new Notice('info', el, 15); new Notice('info', el, 15);
} else { } else {
@ -13227,25 +13151,6 @@
}; };
return softTask(); return softTask();
}, },
addCallback: function(e) {
var Klass, obj;
obj = e.detail;
if (typeof obj.callback.name !== 'string') {
throw new Error("Invalid callback name: " + obj.callback.name);
}
switch (obj.type) {
case 'Post':
Klass = Post;
break;
case 'Thread':
Klass = Thread;
break;
default:
return;
}
obj.callback.isAddon = true;
return Klass.callbacks.push(obj.callback);
},
handleErrors: function(errors) { handleErrors: function(errors) {
var div, error, logs, _i, _len; var div, error, logs, _i, _len;
if (!(errors instanceof Array)) { if (!(errors instanceof Array)) {

View File

@ -1,6 +1,6 @@
{ {
"name": "4chan-X", "name": "4chan-X",
"version": "1.8.0", "version": "1.8.1",
"description": "Cross-browser userscript for maximum lurking on 4chan.", "description": "Cross-browser userscript for maximum lurking on 4chan.",
"meta": { "meta": {
"name": "4chan X", "name": "4chan X",