diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d0c05641..9deaed3be 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## v1.8.0 +*2014-06-18* + **ccd0** - Add compatibility with Greasemonkey 2.0. - Much of Mayhem's [API](https://github.com/MayhemYDG/4chan-x/wiki) has been removed due to issues with Greasemonkey 2.0. diff --git a/LICENSE b/LICENSE index 46c33356a..67d7582b2 100755 --- a/LICENSE +++ b/LICENSE @@ -1,5 +1,5 @@ /* -* 4chan X - Version 1.7.63 - 2014-06-16 +* 4chan X - Version 1.8.0 - 2014-06-18 * * Licensed under the MIT license. * https://github.com/ccd0/4chan-x/blob/master/LICENSE diff --git a/builds/4chan-X.meta.js b/builds/4chan-X.meta.js index ac51c6127..52f4a95b9 100755 --- a/builds/4chan-X.meta.js +++ b/builds/4chan-X.meta.js @@ -1,6 +1,6 @@ // ==UserScript== // @name 4chan X -// @version 1.7.63 +// @version 1.8.0 // @minGMVer 1.14 // @minFFVer 26 // @namespace 4chan-X diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index 39936cb89..8af133be9 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -1,7 +1,7 @@ // Generated by CoffeeScript // ==UserScript== // @name 4chan X -// @version 1.7.63 +// @version 1.8.0 // @minGMVer 1.14 // @minFFVer 26 // @namespace 4chan-X @@ -24,7 +24,7 @@ // ==/UserScript== /* -* 4chan X - Version 1.7.63 - 2014-06-16 +* 4chan X - Version 1.8.0 - 2014-06-18 * * Licensed under the MIT license. * https://github.com/ccd0/4chan-x/blob/master/LICENSE @@ -374,7 +374,7 @@ doc = d.documentElement; g = { - VERSION: '1.7.63', + VERSION: '1.8.0', NAMESPACE: '4chan X.', boards: {} }; @@ -386,16 +386,6 @@ return root.querySelector(selector); }; - $.extend = function(obj, prop) { - var key, val; - for (key in prop) { - val = prop[key]; - if (prop.hasOwnProperty(key)) { - obj[key] = val; - } - } - }; - $.DAY = 24 * ($.HOUR = 60 * ($.MINUTE = 60 * ($.SECOND = 1000))); $.id = function(id) { @@ -659,6 +649,9 @@ if (root == null) { root = d; } + if (typeof cloneInto === 'function') { + detail = cloneInto(detail, document.defaultView); + } return root.dispatchEvent(new CustomEvent(event, { bubbles: true, detail: detail @@ -840,36 +833,19 @@ Callbacks.prototype.push = function(_arg) { var cb, name; name = _arg.name, cb = _arg.cb; - if (this[name]) { - this.connect(name); - } if (!this[name]) { this.keys.push(name); } return this[name] = cb; }; - Callbacks.prototype.connect = function(name) { - if (this[name].disconnected) { - return delete this[name].disconnected; - } - }; - - Callbacks.prototype.disconnect = function(name) { - if (this[name]) { - return this[name].disconnected = true; - } - }; - Callbacks.prototype.execute = function(node) { var err, errors, name, _i, _len, _ref; _ref = this.keys; for (_i = 0, _len = _ref.length; _i < _len; _i++) { name = _ref[_i]; try { - if (!this[name].disconnected) { - this[name].call(node); - } + this[name].call(node); } catch (_error) { err = _error; if (!errors) { @@ -1515,12 +1491,6 @@ return typeof this.sync === "function" ? this.sync() : void 0; }; - DataBoard.prototype.disconnect = function() { - $.desync(this.key); - delete this.sync; - return delete this.data; - }; - return DataBoard; })(); @@ -1843,7 +1813,7 @@ $.sync('Header auto-hide', this.setBarVisibility); $.sync('Centered links', this.setLinkJustify); this.addShortcut(menuButton); - $.event('AddMenuEntry', { + UI.addMenuEntry({ type: 'header', el: $.el('span', { textContent: 'Header' @@ -2251,12 +2221,9 @@ return Header.menu.toggle(e, this, g); }, createNotification: function(e) { - var cb, content, lifetime, notice, type, _ref; - _ref = e.detail, type = _ref.type, content = _ref.content, lifetime = _ref.lifetime, cb = _ref.cb; - notice = new Notice(type, content, lifetime); - if (cb) { - return cb(notice); - } + var content, lifetime, notice, type, _ref; + _ref = e.detail, type = _ref.type, content = _ref.content, lifetime = _ref.lifetime; + return notice = new Notice(type, content, lifetime); }, areNotificationsEnabled: false, enableDesktopNotifications: function() { @@ -2396,7 +2363,7 @@ $.on(input, 'change', this.cb.sort); } } - $.event('AddMenuEntry', { + UI.addMenuEntry({ type: 'header', el: $.el('span', { textContent: 'Index Navigation' @@ -2922,14 +2889,12 @@ return nodes; }, buildStructure: function(nodes) { - var i, node, result; - result = $.frag(); - i = 0; - while (node = nodes[i++]) { - $.add(result, [node, $.el('hr')]); + var node, _i, _len; + for (_i = 0, _len = nodes.length; _i < _len; _i++) { + node = nodes[_i]; + $.add(Index.root, [node, $.el('hr')]); } - $.event('IndexBuild', result.children); - return $.add(Index.root, result); + return ThreadHiding.onIndexBuild(nodes); }, isSearching: false, clearSearch: function() { @@ -3573,7 +3538,7 @@ }; UI = (function() { - var Menu, checkbox, dialog, drag, dragend, dragstart, hover, hoverend, hoverstart, touchend, touchmove; + var Menu, addMenuEntry, checkbox, dialog, drag, dragend, dragstart, hover, hoverend, hoverstart, menus, rmMenuEntry, touchend, touchmove; dialog = function(id, position, properties) { var child, el, move, _i, _len, _ref; el = $.el('div', { @@ -3599,6 +3564,13 @@ } return el; }; + menus = {}; + addMenuEntry = function(entry) { + return menus[entry.type].addEntry(entry); + }; + rmMenuEntry = function(entry) { + return menus[entry.type].addEntry(entry); + }; Menu = (function() { var currentMenu, lastToggledButton; @@ -3613,9 +3585,19 @@ this.onFocus = __bind(this.onFocus, this); this.keybinds = __bind(this.keybinds, this); this.close = __bind(this.close, this); - $.on(d, 'AddMenuEntry', this.addEntry); - $.on(d, 'rmMenuEntry', this.rmEntry); + $.on(d, 'AddMenuEntry', (function(_this) { + return function(_arg) { + var detail; + detail = _arg.detail; + if (detail.type !== _this.type) { + return; + } + delete detail.open; + return _this.addEntry(detail); + }; + })(this)); this.entries = []; + menus[this.type] = this; } Menu.prototype.makeMenu = function() { @@ -3806,22 +3788,13 @@ return style.right = right; }; - Menu.prototype.addEntry = function(e) { - var entry; - entry = e.detail; - if (entry.type !== this.type) { - return; - } + Menu.prototype.addEntry = function(entry) { this.parseEntry(entry); return this.entries.push(entry); }; - Menu.prototype.rmEntry = function(e) { - var entry, index; - entry = e.detail; - if (entry.type !== this.type) { - return; - } + Menu.prototype.rmEntry = function(entry) { + var index; index = this.entries.indexOf(entry); return this.entries.splice(index, 1); }; @@ -4011,7 +3984,9 @@ dialog: dialog, Menu: Menu, hover: hoverstart, - checkbox: checkbox + checkbox: checkbox, + addMenuEntry: addMenuEntry, + rmMenuEntry: rmMenuEntry }; })(); @@ -4309,7 +4284,7 @@ type = _ref[_i]; entry.subEntries.push(Filter.menu.createSubEntry(type[0], type[1])); } - return $.event('AddMenuEntry', entry); + return UI.addMenuEntry(entry); }, createSubEntry: function(text, type) { var el; @@ -4415,7 +4390,7 @@ thisPost = UI.checkbox('thisPost', ' This post', true); replies = UI.checkbox('replies', ' Hide replies', Conf['Recursive Hiding']); makeStub = UI.checkbox('makeStub', ' Make stub', Conf['Stubs']); - $.event('AddMenuEntry', { + UI.addMenuEntry({ type: 'post', el: div, order: 20, @@ -4454,7 +4429,7 @@ href: 'javascript:;' }); $.on(hideStubLink, 'click', PostHiding.menu.hideStub); - $.event('AddMenuEntry', { + UI.addMenuEntry({ type: 'post', el: div, order: 20, @@ -4485,7 +4460,7 @@ } ] }); - return $.event('AddMenuEntry', { + return UI.addMenuEntry({ type: 'post', el: hideStubLink, order: 15, @@ -4723,7 +4698,6 @@ } this.db = new DataBoard('hiddenThreads'); this.syncCatalog(); - $.on(d, 'IndexBuild', this.onIndexBuild); return Thread.callbacks.push({ name: 'Thread Hiding', cb: this.node @@ -4742,16 +4716,12 @@ } return $.prepend(this.OP.nodes.root, ThreadHiding.makeButton(this, 'hide')); }, - onIndexBuild: function(_arg) { - var i, nodes, root, thread, _i, _len; - nodes = _arg.detail; - for (i = _i = 0, _len = nodes.length; _i < _len; i = _i += 2) { - root = nodes[i]; + onIndexBuild: function(nodes) { + var root, thread, _i, _len; + for (_i = 0, _len = nodes.length; _i < _len; _i++) { + root = nodes[_i]; thread = Get.threadFromRoot(root); - if (!thread.isHidden) { - continue; - } - if (thread.stub && root.contains(thread.stub)) { + if (thread.isHidden && thread.stub && !root.contains(thread.stub)) { ThreadHiding.makeStub(thread, root); } } @@ -4822,7 +4792,7 @@ }); $.on(apply, 'click', ThreadHiding.menu.hide); makeStub = UI.checkbox('Stubs', ' Make stub'); - $.event('AddMenuEntry', { + UI.addMenuEntry({ type: 'post', el: div, order: 20, @@ -4849,7 +4819,7 @@ href: 'javascript:;' }); $.on(div, 'click', ThreadHiding.menu.show); - $.event('AddMenuEntry', { + UI.addMenuEntry({ type: 'post', el: div, order: 20, @@ -4868,7 +4838,7 @@ href: 'javascript:;' }); $.on(hideStubLink, 'click', ThreadHiding.menu.hideStub); - return $.event('AddMenuEntry', { + return UI.addMenuEntry({ type: 'post', el: hideStubLink, order: 15, @@ -5396,7 +5366,7 @@ }); input = $('input', this.controls); $.on(input, 'change', this.toggle); - $.event('AddMenuEntry', this.entry = { + UI.addMenuEntry(this.entry = { type: 'header', el: this.controls, order: 98 @@ -5409,19 +5379,6 @@ cb: this.node }); }, - disconnect: function() { - var input; - if (!(Conf['Quote Threading'] && g.VIEW === 'thread')) { - return; - } - input = $('input', this.controls); - $.off(input, 'change', this.toggle); - $.event('rmMenuEntry', this.entry); - delete this.enabled; - delete this.controls; - delete this.entry; - return Post.callbacks.disconnect('Quote Threading'); - }, ready: function() { $.off(d, '4chanXInitFinished', QuoteThreading.ready); return QuoteThreading.force(); @@ -5824,16 +5781,6 @@ $.prepend($('.navLinksBot'), linkBot); } $.before($.id('togglePostFormLink'), link); - $.on(d, 'QRGetSelectedPost', function(_arg) { - var cb; - cb = _arg.detail; - return cb(QR.selected); - }); - $.on(d, 'QRAddPreSubmitHook', function(_arg) { - var cb; - cb = _arg.detail; - return QR.preSubmitHooks.push(cb); - }); $.on(d, 'paste', QR.paste); $.on(d, 'dragover', QR.dragOver); $.on(d, 'drop', QR.dropFile); @@ -6455,9 +6402,8 @@ return $.add(nodes.form, flag); } }, - preSubmitHooks: [], submit: function(e) { - var challenge, err, extra, filetag, formData, hook, options, post, response, textOnly, thread, threadID, _i, _len, _ref, _ref1; + var challenge, err, extra, filetag, formData, options, post, response, textOnly, thread, threadID, _ref; if (e != null) { e.preventDefault(); } @@ -6490,17 +6436,9 @@ err = 'No file selected.'; } else if (post.file && thread.fileLimit) { err = 'Max limit of image replies has been reached.'; - } else { - _ref = QR.preSubmitHooks; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - hook = _ref[_i]; - if (err = hook(post, thread)) { - break; - } - } } if (QR.captcha.isEnabled && !err) { - _ref1 = QR.captcha.getOne(), challenge = _ref1.challenge, response = _ref1.response; + _ref = QR.captcha.getOne(), challenge = _ref.challenge, response = _ref.response; if (!response) { err = 'No valid captcha.'; } @@ -6633,7 +6571,9 @@ }); ThreadUpdater.postID = postID; $.event('QRPostSuccessful', { - board: g.BOARD, + board: { + ID: g.BOARD.ID + }, threadID: threadID, postID: postID }); @@ -7260,8 +7200,7 @@ rectEl = this.nodes.el.getBoundingClientRect(); rectList = this.nodes.el.parentNode.getBoundingClientRect(); this.nodes.el.parentNode.scrollLeft += rectEl.left + rectEl.width / 2 - rectList.left - rectList.width / 2; - this.load(); - return $.event('QRPostSelection', this); + return this.load(); }; _Class.prototype.load = function() { @@ -7533,7 +7472,7 @@ el.title = "" + type + " Tyme"; FappeTyme[lc] = input = el.firstElementChild; $.on(input, 'change', FappeTyme.cb.toggle.bind(input)); - $.event('AddMenuEntry', { + UI.addMenuEntry({ type: 'header', el: el, order: 97 @@ -7633,7 +7572,7 @@ createSubEntry = Gallery.menu.createSubEntry; for (name in Config.gallery) { el = createSubEntry(name).el; - $.event('AddMenuEntry', { + UI.addMenuEntry({ type: 'gallery', el: el, order: 0 @@ -7868,7 +7807,7 @@ for (name in Config.gallery) { subEntries.push(createSubEntry(name)); } - return $.event('AddMenuEntry', { + return UI.addMenuEntry({ type: 'header', el: el, order: 105, @@ -8213,7 +8152,7 @@ conf = _ref[name]; subEntries.push(createSubEntry(name, conf[1])); } - return $.event('AddMenuEntry', { + return UI.addMenuEntry({ type: 'header', el: el, order: 105, @@ -8386,7 +8325,7 @@ }); this.el = prefetch.firstElementChild; $.on(this.el, 'change', this.toggle); - return $.event('AddMenuEntry', { + return UI.addMenuEntry({ type: 'header', el: prefetch, order: 104 @@ -9163,7 +9102,7 @@ type = _ref[_i]; entry.subEntries.push(this.createSubEntry(type[0], type[1])); } - return $.event('AddMenuEntry', entry); + return UI.addMenuEntry(entry); }, createSubEntry: function(text, type) { var el, open; @@ -9240,7 +9179,7 @@ return true; } }; - return $.event('AddMenuEntry', { + return UI.addMenuEntry({ type: 'post', el: div, order: 40, @@ -9365,7 +9304,7 @@ }; })(this)); }); - return $.event('AddMenuEntry', { + return UI.addMenuEntry({ type: 'post', el: a, order: 100, @@ -9434,7 +9373,7 @@ textContent: 'Report this post' }); $.on(a, 'click', ReportLink.report); - return $.event('AddMenuEntry', { + return UI.addMenuEntry({ type: 'post', el: a, order: 10, @@ -9512,12 +9451,6 @@ }, node: function() { return d.title = Get.threadExcerpt(this); - }, - disconnect: function() { - if (g.VIEW !== 'thread' || !Conf['Thread Excerpt']) { - return; - } - return Thread.callbacks.disconnect('Thread Excerpt'); } }; @@ -9569,25 +9502,6 @@ ThreadStats.update(postCount, fileCount); return $.on(d, 'ThreadUpdate', ThreadStats.onUpdate); }, - disconnect: function() { - if (g.VIEW !== 'thread' || !Conf['Thread Stats']) { - return; - } - if (Conf['Updater and Stats in Header']) { - Header.rmShortcut(this.dialog); - } else { - $.rm(this.dialog); - } - clearTimeout(this.timeout); - delete this.timeout; - delete this.thread; - delete this.postCountEl; - delete this.fileCountEl; - delete this.pageCountEl; - delete this.dialog; - Thread.callbacks.disconnect('Thread Stats'); - return $.off(d, 'ThreadUpdate', ThreadStats.onUpdate); - }, onUpdate: function(e) { var fileCount, postCount, _ref; if (e.detail[404]) { @@ -9707,7 +9621,7 @@ subEntries.push({ el: this.settings }); - $.event('AddMenuEntry', this.entry = { + UI.addMenuEntry(this.entry = { type: 'header', el: $.el('span', { textContent: 'Updater' @@ -9720,45 +9634,6 @@ cb: this.node }); }, - disconnect: function() { - var el, entry, input, name, _i, _j, _len, _len1, _ref, _ref1; - if (g.VIEW !== 'thread' || !Conf['Thread Updater']) { - return; - } - $.off(this.timer, 'click', this.update); - $.off(this.status, 'click', this.update); - if (this.timeoutID) { - clearTimeout(this.timeoutID); - } - _ref = this.entry.subEntries; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - entry = _ref[_i]; - el = entry.el; - input = el.firstElementChild; - $.off(input, 'change', $.cb.checked); - $.off(input, 'change', this.cb.scrollBG); - $.off(input, 'change', this.cb.update); - } - $.off(this.settings, 'click', this.intervalShortcut); - $.off(window, 'online offline', this.cb.online); - $.off(d, 'QRPostSuccessful', this.cb.checkpost); - $.off(d, 'visibilitychange', this.cb.visibility); - this.set('timer', null); - this.set('status', 'Offline'); - $.event('rmMenuEntry', this.entry); - if (Conf['Updater and Stats in Header']) { - Header.rmShortcut(this.dialog); - } else { - $.rmClass(doc, 'float'); - $.rm(this.dialog); - } - _ref1 = ['checkPostCount', 'timer', 'status', 'isUpdating', 'entry', 'dialog', 'thread', 'root', 'lastPost', 'outdateCount', 'online', 'seconds', 'timeoutID']; - for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) { - name = _ref1[_j]; - delete this[name]; - } - return Thread.callbacks.disconnect('Thread Updater'); - }, node: function() { ThreadUpdater.thread = this; ThreadUpdater.root = this.OP.nodes.root.parentNode; @@ -9857,7 +9732,9 @@ ThreadUpdater.thread.kill(); $.event('ThreadUpdate', { 404: true, - thread: ThreadUpdater.thread + thread: { + fullID: ThreadUpdater.thread.fullID + } }); break; default: @@ -9983,12 +9860,18 @@ ID = +post.ID; if (__indexOf.call(index, ID) < 0) { post.kill(); - deletedPosts.push(post); + deletedPosts.push({ + ID: post.ID, + fullID: post.fullID + }); } else if (post.isDead) { post.resurrect(); } else if (post.file && !(post.file.isDead || __indexOf.call(files, ID) >= 0)) { post.kill(true); - deletedFiles.push(post); + deletedFiles.push({ + ID: post.ID, + fullID: post.fullID + }); } if (ThreadUpdater.postID && ThreadUpdater.postID === ID) { return ThreadUpdater.foundPost = true; @@ -10040,8 +9923,22 @@ } return $.event('ThreadUpdate', { 404: false, - thread: ThreadUpdater.thread, - newPosts: posts, + thread: { + ID: ThreadUpdater.thread.ID, + fullID: ThreadUpdater.thread.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, @@ -10070,9 +9967,6 @@ this.status = $('#watcher-status', this.dialog); this.list = this.dialog.lastElementChild; $.on(d, 'QRPostSuccessful', this.cb.post); - if (g.VIEW === 'thread') { - $.on(d, 'ThreadUpdate', this.cb.threadUpdate); - } $.on(sc, 'click', this.toggleWatcher); $.on($('.move>.close', ThreadWatcher.dialog), 'click', this.toggleWatcher); $.on(d, '4chanXInitFinished', this.ready); @@ -10188,7 +10082,7 @@ return $.set('AutoWatch', threadID); } } else if (Conf['Auto Watch Reply']) { - return ThreadWatcher.add(board.threads[threadID]); + return ThreadWatcher.add(g.boards[board.ID].threads[threadID]); } }, onIndexRefresh: function() { @@ -10218,7 +10112,7 @@ }, onThreadRefresh: function(e) { var thread; - thread = e.detail.thread; + thread = g.threads[e.detail.thread.fullID]; if (!(e.detail[404] && ThreadWatcher.db.get({ boardID: thread.board.ID, threadID: thread.ID @@ -10445,7 +10339,7 @@ entryEl = $.el('a', { href: 'javascript:;' }); - $.event('AddMenuEntry', { + UI.addMenuEntry({ type: 'header', el: entryEl, order: 60 @@ -10526,7 +10420,7 @@ if (refresh) { this.refreshers.push(refresh.bind(entry)); } - $.event('AddMenuEntry', entry); + UI.addMenuEntry(entry); } }, createSubEntry: function(name, desc) { @@ -10562,28 +10456,6 @@ cb: this.node }); }, - disconnect: function() { - var hr, name, _i, _len, _ref; - if (g.VIEW !== 'thread' || !Conf['Unread Count'] && !Conf['Unread Favicon'] && !Conf['Desktop Notifications']) { - return; - } - Unread.db.disconnect(); - if (hr = Unread.hr, Unread) { - $.rm(hr); - } - _ref = ['db', 'hr', 'posts', 'postsQuotingYou', 'thread', 'title', 'lastReadPost']; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - name = _ref[_i]; - delete this[name]; - } - $.off(d, '4chanXInitFinished', this.ready); - $.off(d, 'ThreadUpdate', this.onUpdate); - $.off(d, 'scroll visibilitychange', this.read); - if (Conf['Unread Line'] && !Conf['Quote Threading']) { - $.off(d, 'visibilitychange', this.setLine); - } - return Thread.callbacks.disconnect('Unread'); - }, node: function() { Unread.thread = this; Unread.title = d.title; @@ -10725,10 +10597,20 @@ }; }, onUpdate: function(e) { + var post; if (e.detail[404]) { return Unread.update(); } else if (!QuoteThreading.enabled) { - return Unread.addPosts(e.detail.newPosts); + return Unread.addPosts((function() { + var _i, _len, _ref, _results; + _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 { Unread.read(); return Unread.update(); @@ -10948,7 +10830,7 @@ return psa.hidden; } }; - $.event('AddMenuEntry', entry); + UI.addMenuEntry(entry); $.on(entry.el, 'click', PSAHiding.toggle); PSAHiding.btn = btn = $.el('span', { innerHTML: '[Dismiss]', @@ -11101,7 +10983,7 @@ input = $('input', el); $.on(input, 'change', this.toggle); $.sync('Header catalog links', CatalogLinks.set); - $.event('AddMenuEntry', { + UI.addMenuEntry({ type: 'header', el: el, order: 95 @@ -11599,7 +11481,7 @@ }); } if (board === 'sci') { - $.globalEval('window.addEventListener(\'jsmath\', function(e) {\n if (!jsMath) return;\n if (jsMath.loaded) {\n // process one post\n jsMath.ProcessBeforeShowing(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(\'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);'); return Post.callbacks.push({ name: 'Parse /sci/ math', cb: this.math @@ -11632,7 +11514,7 @@ }; })(this)), (function(_this) { return function() { - return $.event('jsmath', _this.nodes.post, window); + return $.event('jsmath', _this.ID, window); }; })(this)); }, @@ -12480,7 +12362,7 @@ Settings.dialog = dialog = $.el('div', { id: 'fourchanx-settings', className: 'dialog', - innerHTML: '
' + innerHTML: '
' }); $.on($('.export', Settings.dialog), 'click', Settings["export"]); $.on($('.import', Settings.dialog), 'click', Settings["import"]); @@ -13185,7 +13067,6 @@ }); } } - $.on(d, 'AddCallback', Main.addCallback); return $.ready(Main.initReady); }, initStyle: function() { @@ -13325,7 +13206,7 @@ } if (previousversion) { el = $.el('span', { - innerHTML: '4chan X has been updated to version 1.7.63.' + innerHTML: '4chan X has been updated to version 1.8.0.' }); new Notice('info', el, 15); } else { diff --git a/builds/4chan-X.zip b/builds/4chan-X.zip index 150a374a6..6bd7f9c41 100644 Binary files a/builds/4chan-X.zip and b/builds/4chan-X.zip differ diff --git a/builds/crx.crx b/builds/crx.crx index 0cfa77c54..2b979582c 100644 Binary files a/builds/crx.crx and b/builds/crx.crx differ diff --git a/builds/crx/manifest.json b/builds/crx/manifest.json index 375196003..0344b5c06 100755 --- a/builds/crx/manifest.json +++ b/builds/crx/manifest.json @@ -1,6 +1,6 @@ { "name": "4chan X", - "version": "1.7.63", + "version": "1.8.0", "manifest_version": 2, "description": "Cross-browser userscript for maximum lurking on 4chan.", "icons": { diff --git a/builds/crx/script.js b/builds/crx/script.js index dadcf1dda..7212aeabd 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -1,6 +1,6 @@ // Generated by CoffeeScript /* -* 4chan X - Version 1.7.63 - 2014-06-16 +* 4chan X - Version 1.8.0 - 2014-06-18 * * Licensed under the MIT license. * https://github.com/ccd0/4chan-x/blob/master/LICENSE @@ -349,7 +349,7 @@ doc = d.documentElement; g = { - VERSION: '1.7.63', + VERSION: '1.8.0', NAMESPACE: '4chan X.', boards: {} }; @@ -361,16 +361,6 @@ return root.querySelector(selector); }; - $.extend = function(obj, prop) { - var key, val; - for (key in prop) { - val = prop[key]; - if (prop.hasOwnProperty(key)) { - obj[key] = val; - } - } - }; - $.DAY = 24 * ($.HOUR = 60 * ($.MINUTE = 60 * ($.SECOND = 1000))); $.id = function(id) { @@ -875,36 +865,19 @@ Callbacks.prototype.push = function(_arg) { var cb, name; name = _arg.name, cb = _arg.cb; - if (this[name]) { - this.connect(name); - } if (!this[name]) { this.keys.push(name); } return this[name] = cb; }; - Callbacks.prototype.connect = function(name) { - if (this[name].disconnected) { - return delete this[name].disconnected; - } - }; - - Callbacks.prototype.disconnect = function(name) { - if (this[name]) { - return this[name].disconnected = true; - } - }; - Callbacks.prototype.execute = function(node) { var err, errors, name, _i, _len, _ref; _ref = this.keys; for (_i = 0, _len = _ref.length; _i < _len; _i++) { name = _ref[_i]; try { - if (!this[name].disconnected) { - this[name].call(node); - } + this[name].call(node); } catch (_error) { err = _error; if (!errors) { @@ -1550,12 +1523,6 @@ return typeof this.sync === "function" ? this.sync() : void 0; }; - DataBoard.prototype.disconnect = function() { - $.desync(this.key); - delete this.sync; - return delete this.data; - }; - return DataBoard; })(); @@ -1878,7 +1845,7 @@ $.sync('Header auto-hide', this.setBarVisibility); $.sync('Centered links', this.setLinkJustify); this.addShortcut(menuButton); - $.event('AddMenuEntry', { + UI.addMenuEntry({ type: 'header', el: $.el('span', { textContent: 'Header' @@ -2286,12 +2253,9 @@ return Header.menu.toggle(e, this, g); }, createNotification: function(e) { - var cb, content, lifetime, notice, type, _ref; - _ref = e.detail, type = _ref.type, content = _ref.content, lifetime = _ref.lifetime, cb = _ref.cb; - notice = new Notice(type, content, lifetime); - if (cb) { - return cb(notice); - } + var content, lifetime, notice, type, _ref; + _ref = e.detail, type = _ref.type, content = _ref.content, lifetime = _ref.lifetime; + return notice = new Notice(type, content, lifetime); }, areNotificationsEnabled: false, enableDesktopNotifications: function() { @@ -2431,7 +2395,7 @@ $.on(input, 'change', this.cb.sort); } } - $.event('AddMenuEntry', { + UI.addMenuEntry({ type: 'header', el: $.el('span', { textContent: 'Index Navigation' @@ -2957,14 +2921,12 @@ return nodes; }, buildStructure: function(nodes) { - var i, node, result; - result = $.frag(); - i = 0; - while (node = nodes[i++]) { - $.add(result, [node, $.el('hr')]); + var node, _i, _len; + for (_i = 0, _len = nodes.length; _i < _len; _i++) { + node = nodes[_i]; + $.add(Index.root, [node, $.el('hr')]); } - $.event('IndexBuild', result.children); - return $.add(Index.root, result); + return ThreadHiding.onIndexBuild(nodes); }, isSearching: false, clearSearch: function() { @@ -3608,7 +3570,7 @@ }; UI = (function() { - var Menu, checkbox, dialog, drag, dragend, dragstart, hover, hoverend, hoverstart, touchend, touchmove; + var Menu, addMenuEntry, checkbox, dialog, drag, dragend, dragstart, hover, hoverend, hoverstart, menus, rmMenuEntry, touchend, touchmove; dialog = function(id, position, properties) { var child, el, move, _i, _len, _ref; el = $.el('div', { @@ -3634,6 +3596,13 @@ } return el; }; + menus = {}; + addMenuEntry = function(entry) { + return menus[entry.type].addEntry(entry); + }; + rmMenuEntry = function(entry) { + return menus[entry.type].addEntry(entry); + }; Menu = (function() { var currentMenu, lastToggledButton; @@ -3648,9 +3617,19 @@ this.onFocus = __bind(this.onFocus, this); this.keybinds = __bind(this.keybinds, this); this.close = __bind(this.close, this); - $.on(d, 'AddMenuEntry', this.addEntry); - $.on(d, 'rmMenuEntry', this.rmEntry); + $.on(d, 'AddMenuEntry', (function(_this) { + return function(_arg) { + var detail; + detail = _arg.detail; + if (detail.type !== _this.type) { + return; + } + delete detail.open; + return _this.addEntry(detail); + }; + })(this)); this.entries = []; + menus[this.type] = this; } Menu.prototype.makeMenu = function() { @@ -3841,22 +3820,13 @@ return style.right = right; }; - Menu.prototype.addEntry = function(e) { - var entry; - entry = e.detail; - if (entry.type !== this.type) { - return; - } + Menu.prototype.addEntry = function(entry) { this.parseEntry(entry); return this.entries.push(entry); }; - Menu.prototype.rmEntry = function(e) { - var entry, index; - entry = e.detail; - if (entry.type !== this.type) { - return; - } + Menu.prototype.rmEntry = function(entry) { + var index; index = this.entries.indexOf(entry); return this.entries.splice(index, 1); }; @@ -4039,7 +4009,9 @@ dialog: dialog, Menu: Menu, hover: hoverstart, - checkbox: checkbox + checkbox: checkbox, + addMenuEntry: addMenuEntry, + rmMenuEntry: rmMenuEntry }; })(); @@ -4334,7 +4306,7 @@ type = _ref[_i]; entry.subEntries.push(Filter.menu.createSubEntry(type[0], type[1])); } - return $.event('AddMenuEntry', entry); + return UI.addMenuEntry(entry); }, createSubEntry: function(text, type) { var el; @@ -4440,7 +4412,7 @@ thisPost = UI.checkbox('thisPost', ' This post', true); replies = UI.checkbox('replies', ' Hide replies', Conf['Recursive Hiding']); makeStub = UI.checkbox('makeStub', ' Make stub', Conf['Stubs']); - $.event('AddMenuEntry', { + UI.addMenuEntry({ type: 'post', el: div, order: 20, @@ -4479,7 +4451,7 @@ href: 'javascript:;' }); $.on(hideStubLink, 'click', PostHiding.menu.hideStub); - $.event('AddMenuEntry', { + UI.addMenuEntry({ type: 'post', el: div, order: 20, @@ -4510,7 +4482,7 @@ } ] }); - return $.event('AddMenuEntry', { + return UI.addMenuEntry({ type: 'post', el: hideStubLink, order: 15, @@ -4748,7 +4720,6 @@ } this.db = new DataBoard('hiddenThreads'); this.syncCatalog(); - $.on(d, 'IndexBuild', this.onIndexBuild); return Thread.callbacks.push({ name: 'Thread Hiding', cb: this.node @@ -4767,16 +4738,12 @@ } return $.prepend(this.OP.nodes.root, ThreadHiding.makeButton(this, 'hide')); }, - onIndexBuild: function(_arg) { - var i, nodes, root, thread, _i, _len; - nodes = _arg.detail; - for (i = _i = 0, _len = nodes.length; _i < _len; i = _i += 2) { - root = nodes[i]; + onIndexBuild: function(nodes) { + var root, thread, _i, _len; + for (_i = 0, _len = nodes.length; _i < _len; _i++) { + root = nodes[_i]; thread = Get.threadFromRoot(root); - if (!thread.isHidden) { - continue; - } - if (thread.stub && root.contains(thread.stub)) { + if (thread.isHidden && thread.stub && !root.contains(thread.stub)) { ThreadHiding.makeStub(thread, root); } } @@ -4847,7 +4814,7 @@ }); $.on(apply, 'click', ThreadHiding.menu.hide); makeStub = UI.checkbox('Stubs', ' Make stub'); - $.event('AddMenuEntry', { + UI.addMenuEntry({ type: 'post', el: div, order: 20, @@ -4874,7 +4841,7 @@ href: 'javascript:;' }); $.on(div, 'click', ThreadHiding.menu.show); - $.event('AddMenuEntry', { + UI.addMenuEntry({ type: 'post', el: div, order: 20, @@ -4893,7 +4860,7 @@ href: 'javascript:;' }); $.on(hideStubLink, 'click', ThreadHiding.menu.hideStub); - return $.event('AddMenuEntry', { + return UI.addMenuEntry({ type: 'post', el: hideStubLink, order: 15, @@ -5421,7 +5388,7 @@ }); input = $('input', this.controls); $.on(input, 'change', this.toggle); - $.event('AddMenuEntry', this.entry = { + UI.addMenuEntry(this.entry = { type: 'header', el: this.controls, order: 98 @@ -5434,19 +5401,6 @@ cb: this.node }); }, - disconnect: function() { - var input; - if (!(Conf['Quote Threading'] && g.VIEW === 'thread')) { - return; - } - input = $('input', this.controls); - $.off(input, 'change', this.toggle); - $.event('rmMenuEntry', this.entry); - delete this.enabled; - delete this.controls; - delete this.entry; - return Post.callbacks.disconnect('Quote Threading'); - }, ready: function() { $.off(d, '4chanXInitFinished', QuoteThreading.ready); return QuoteThreading.force(); @@ -5849,16 +5803,6 @@ $.prepend($('.navLinksBot'), linkBot); } $.before($.id('togglePostFormLink'), link); - $.on(d, 'QRGetSelectedPost', function(_arg) { - var cb; - cb = _arg.detail; - return cb(QR.selected); - }); - $.on(d, 'QRAddPreSubmitHook', function(_arg) { - var cb; - cb = _arg.detail; - return QR.preSubmitHooks.push(cb); - }); $.on(d, 'paste', QR.paste); $.on(d, 'dragover', QR.dragOver); $.on(d, 'drop', QR.dropFile); @@ -6478,9 +6422,8 @@ return $.add(nodes.form, flag); } }, - preSubmitHooks: [], submit: function(e) { - var challenge, err, extra, filetag, formData, hook, options, post, response, textOnly, thread, threadID, _i, _len, _ref, _ref1; + var challenge, err, extra, filetag, formData, options, post, response, textOnly, thread, threadID, _ref; if (e != null) { e.preventDefault(); } @@ -6513,17 +6456,9 @@ err = 'No file selected.'; } else if (post.file && thread.fileLimit) { err = 'Max limit of image replies has been reached.'; - } else { - _ref = QR.preSubmitHooks; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - hook = _ref[_i]; - if (err = hook(post, thread)) { - break; - } - } } if (QR.captcha.isEnabled && !err) { - _ref1 = QR.captcha.getOne(), challenge = _ref1.challenge, response = _ref1.response; + _ref = QR.captcha.getOne(), challenge = _ref.challenge, response = _ref.response; if (!response) { err = 'No valid captcha.'; } @@ -6656,7 +6591,9 @@ }); ThreadUpdater.postID = postID; $.event('QRPostSuccessful', { - board: g.BOARD, + board: { + ID: g.BOARD.ID + }, threadID: threadID, postID: postID }); @@ -7277,8 +7214,7 @@ rectEl = this.nodes.el.getBoundingClientRect(); rectList = this.nodes.el.parentNode.getBoundingClientRect(); this.nodes.el.parentNode.scrollLeft += rectEl.left + rectEl.width / 2 - rectList.left - rectList.width / 2; - this.load(); - return $.event('QRPostSelection', this); + return this.load(); }; _Class.prototype.load = function() { @@ -7550,7 +7486,7 @@ el.title = "" + type + " Tyme"; FappeTyme[lc] = input = el.firstElementChild; $.on(input, 'change', FappeTyme.cb.toggle.bind(input)); - $.event('AddMenuEntry', { + UI.addMenuEntry({ type: 'header', el: el, order: 97 @@ -7650,7 +7586,7 @@ createSubEntry = Gallery.menu.createSubEntry; for (name in Config.gallery) { el = createSubEntry(name).el; - $.event('AddMenuEntry', { + UI.addMenuEntry({ type: 'gallery', el: el, order: 0 @@ -7885,7 +7821,7 @@ for (name in Config.gallery) { subEntries.push(createSubEntry(name)); } - return $.event('AddMenuEntry', { + return UI.addMenuEntry({ type: 'header', el: el, order: 105, @@ -8219,7 +8155,7 @@ conf = _ref[name]; subEntries.push(createSubEntry(name, conf[1])); } - return $.event('AddMenuEntry', { + return UI.addMenuEntry({ type: 'header', el: el, order: 105, @@ -8381,7 +8317,7 @@ }); this.el = prefetch.firstElementChild; $.on(this.el, 'change', this.toggle); - return $.event('AddMenuEntry', { + return UI.addMenuEntry({ type: 'header', el: prefetch, order: 104 @@ -9158,7 +9094,7 @@ type = _ref[_i]; entry.subEntries.push(this.createSubEntry(type[0], type[1])); } - return $.event('AddMenuEntry', entry); + return UI.addMenuEntry(entry); }, createSubEntry: function(text, type) { var el, open; @@ -9235,7 +9171,7 @@ return true; } }; - return $.event('AddMenuEntry', { + return UI.addMenuEntry({ type: 'post', el: div, order: 40, @@ -9360,7 +9296,7 @@ }; })(this)); }); - return $.event('AddMenuEntry', { + return UI.addMenuEntry({ type: 'post', el: a, order: 100, @@ -9429,7 +9365,7 @@ textContent: 'Report this post' }); $.on(a, 'click', ReportLink.report); - return $.event('AddMenuEntry', { + return UI.addMenuEntry({ type: 'post', el: a, order: 10, @@ -9507,12 +9443,6 @@ }, node: function() { return d.title = Get.threadExcerpt(this); - }, - disconnect: function() { - if (g.VIEW !== 'thread' || !Conf['Thread Excerpt']) { - return; - } - return Thread.callbacks.disconnect('Thread Excerpt'); } }; @@ -9564,25 +9494,6 @@ ThreadStats.update(postCount, fileCount); return $.on(d, 'ThreadUpdate', ThreadStats.onUpdate); }, - disconnect: function() { - if (g.VIEW !== 'thread' || !Conf['Thread Stats']) { - return; - } - if (Conf['Updater and Stats in Header']) { - Header.rmShortcut(this.dialog); - } else { - $.rm(this.dialog); - } - clearTimeout(this.timeout); - delete this.timeout; - delete this.thread; - delete this.postCountEl; - delete this.fileCountEl; - delete this.pageCountEl; - delete this.dialog; - Thread.callbacks.disconnect('Thread Stats'); - return $.off(d, 'ThreadUpdate', ThreadStats.onUpdate); - }, onUpdate: function(e) { var fileCount, postCount, _ref; if (e.detail[404]) { @@ -9702,7 +9613,7 @@ subEntries.push({ el: this.settings }); - $.event('AddMenuEntry', this.entry = { + UI.addMenuEntry(this.entry = { type: 'header', el: $.el('span', { textContent: 'Updater' @@ -9715,45 +9626,6 @@ cb: this.node }); }, - disconnect: function() { - var el, entry, input, name, _i, _j, _len, _len1, _ref, _ref1; - if (g.VIEW !== 'thread' || !Conf['Thread Updater']) { - return; - } - $.off(this.timer, 'click', this.update); - $.off(this.status, 'click', this.update); - if (this.timeoutID) { - clearTimeout(this.timeoutID); - } - _ref = this.entry.subEntries; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - entry = _ref[_i]; - el = entry.el; - input = el.firstElementChild; - $.off(input, 'change', $.cb.checked); - $.off(input, 'change', this.cb.scrollBG); - $.off(input, 'change', this.cb.update); - } - $.off(this.settings, 'click', this.intervalShortcut); - $.off(window, 'online offline', this.cb.online); - $.off(d, 'QRPostSuccessful', this.cb.checkpost); - $.off(d, 'visibilitychange', this.cb.visibility); - this.set('timer', null); - this.set('status', 'Offline'); - $.event('rmMenuEntry', this.entry); - if (Conf['Updater and Stats in Header']) { - Header.rmShortcut(this.dialog); - } else { - $.rmClass(doc, 'float'); - $.rm(this.dialog); - } - _ref1 = ['checkPostCount', 'timer', 'status', 'isUpdating', 'entry', 'dialog', 'thread', 'root', 'lastPost', 'outdateCount', 'online', 'seconds', 'timeoutID']; - for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) { - name = _ref1[_j]; - delete this[name]; - } - return Thread.callbacks.disconnect('Thread Updater'); - }, node: function() { ThreadUpdater.thread = this; ThreadUpdater.root = this.OP.nodes.root.parentNode; @@ -9852,7 +9724,9 @@ ThreadUpdater.thread.kill(); $.event('ThreadUpdate', { 404: true, - thread: ThreadUpdater.thread + thread: { + fullID: ThreadUpdater.thread.fullID + } }); break; default: @@ -9978,12 +9852,18 @@ ID = +post.ID; if (__indexOf.call(index, ID) < 0) { post.kill(); - deletedPosts.push(post); + deletedPosts.push({ + ID: post.ID, + fullID: post.fullID + }); } else if (post.isDead) { post.resurrect(); } else if (post.file && !(post.file.isDead || __indexOf.call(files, ID) >= 0)) { post.kill(true); - deletedFiles.push(post); + deletedFiles.push({ + ID: post.ID, + fullID: post.fullID + }); } if (ThreadUpdater.postID && ThreadUpdater.postID === ID) { return ThreadUpdater.foundPost = true; @@ -10035,8 +9915,22 @@ } return $.event('ThreadUpdate', { 404: false, - thread: ThreadUpdater.thread, - newPosts: posts, + thread: { + ID: ThreadUpdater.thread.ID, + fullID: ThreadUpdater.thread.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, @@ -10065,9 +9959,6 @@ this.status = $('#watcher-status', this.dialog); this.list = this.dialog.lastElementChild; $.on(d, 'QRPostSuccessful', this.cb.post); - if (g.VIEW === 'thread') { - $.on(d, 'ThreadUpdate', this.cb.threadUpdate); - } $.on(sc, 'click', this.toggleWatcher); $.on($('.move>.close', ThreadWatcher.dialog), 'click', this.toggleWatcher); $.on(d, '4chanXInitFinished', this.ready); @@ -10183,7 +10074,7 @@ return $.set('AutoWatch', threadID); } } else if (Conf['Auto Watch Reply']) { - return ThreadWatcher.add(board.threads[threadID]); + return ThreadWatcher.add(g.boards[board.ID].threads[threadID]); } }, onIndexRefresh: function() { @@ -10213,7 +10104,7 @@ }, onThreadRefresh: function(e) { var thread; - thread = e.detail.thread; + thread = g.threads[e.detail.thread.fullID]; if (!(e.detail[404] && ThreadWatcher.db.get({ boardID: thread.board.ID, threadID: thread.ID @@ -10440,7 +10331,7 @@ entryEl = $.el('a', { href: 'javascript:;' }); - $.event('AddMenuEntry', { + UI.addMenuEntry({ type: 'header', el: entryEl, order: 60 @@ -10521,7 +10412,7 @@ if (refresh) { this.refreshers.push(refresh.bind(entry)); } - $.event('AddMenuEntry', entry); + UI.addMenuEntry(entry); } }, createSubEntry: function(name, desc) { @@ -10557,28 +10448,6 @@ cb: this.node }); }, - disconnect: function() { - var hr, name, _i, _len, _ref; - if (g.VIEW !== 'thread' || !Conf['Unread Count'] && !Conf['Unread Favicon'] && !Conf['Desktop Notifications']) { - return; - } - Unread.db.disconnect(); - if (hr = Unread.hr, Unread) { - $.rm(hr); - } - _ref = ['db', 'hr', 'posts', 'postsQuotingYou', 'thread', 'title', 'lastReadPost']; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - name = _ref[_i]; - delete this[name]; - } - $.off(d, '4chanXInitFinished', this.ready); - $.off(d, 'ThreadUpdate', this.onUpdate); - $.off(d, 'scroll visibilitychange', this.read); - if (Conf['Unread Line'] && !Conf['Quote Threading']) { - $.off(d, 'visibilitychange', this.setLine); - } - return Thread.callbacks.disconnect('Unread'); - }, node: function() { Unread.thread = this; Unread.title = d.title; @@ -10720,10 +10589,20 @@ }; }, onUpdate: function(e) { + var post; if (e.detail[404]) { return Unread.update(); } else if (!QuoteThreading.enabled) { - return Unread.addPosts(e.detail.newPosts); + return Unread.addPosts((function() { + var _i, _len, _ref, _results; + _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 { Unread.read(); return Unread.update(); @@ -10942,7 +10821,7 @@ return psa.hidden; } }; - $.event('AddMenuEntry', entry); + UI.addMenuEntry(entry); $.on(entry.el, 'click', PSAHiding.toggle); PSAHiding.btn = btn = $.el('span', { innerHTML: '[Dismiss]', @@ -11095,7 +10974,7 @@ input = $('input', el); $.on(input, 'change', this.toggle); $.sync('Header catalog links', CatalogLinks.set); - $.event('AddMenuEntry', { + UI.addMenuEntry({ type: 'header', el: el, order: 95 @@ -11593,7 +11472,7 @@ }); } if (board === 'sci') { - $.globalEval('window.addEventListener(\'jsmath\', function(e) {\n if (!jsMath) return;\n if (jsMath.loaded) {\n // process one post\n jsMath.ProcessBeforeShowing(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(\'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);'); return Post.callbacks.push({ name: 'Parse /sci/ math', cb: this.math @@ -11626,7 +11505,7 @@ }; })(this)), (function(_this) { return function() { - return $.event('jsmath', _this.nodes.post, window); + return $.event('jsmath', _this.ID, window); }; })(this)); }, @@ -12474,7 +12353,7 @@ Settings.dialog = dialog = $.el('div', { id: 'fourchanx-settings', className: 'dialog', - innerHTML: '
' + innerHTML: '
' }); $.on($('.export', Settings.dialog), 'click', Settings["export"]); $.on($('.import', Settings.dialog), 'click', Settings["import"]); @@ -13176,7 +13055,6 @@ }); } } - $.on(d, 'AddCallback', Main.addCallback); return $.ready(Main.initReady); }, initStyle: function() { @@ -13306,7 +13184,7 @@ } if (previousversion) { el = $.el('span', { - innerHTML: '4chan X has been updated to version 1.7.63.' + innerHTML: '4chan X has been updated to version 1.8.0.' }); new Notice('info', el, 15); } else { diff --git a/builds/updates.xml b/builds/updates.xml index 0b5556be6..c9a5654d8 100644 --- a/builds/updates.xml +++ b/builds/updates.xml @@ -1,7 +1,7 @@ - + diff --git a/builds/wcrx/manifest.json b/builds/wcrx/manifest.json index 15d520cf8..e99e6244f 100644 --- a/builds/wcrx/manifest.json +++ b/builds/wcrx/manifest.json @@ -1,6 +1,6 @@ { "name": "4chan X", - "version": "1.7.63", + "version": "1.8.0", "manifest_version": 2, "description": "Cross-browser userscript for maximum lurking on 4chan.", "icons": { diff --git a/builds/wcrx/script.js b/builds/wcrx/script.js index dadcf1dda..7212aeabd 100644 --- a/builds/wcrx/script.js +++ b/builds/wcrx/script.js @@ -1,6 +1,6 @@ // Generated by CoffeeScript /* -* 4chan X - Version 1.7.63 - 2014-06-16 +* 4chan X - Version 1.8.0 - 2014-06-18 * * Licensed under the MIT license. * https://github.com/ccd0/4chan-x/blob/master/LICENSE @@ -349,7 +349,7 @@ doc = d.documentElement; g = { - VERSION: '1.7.63', + VERSION: '1.8.0', NAMESPACE: '4chan X.', boards: {} }; @@ -361,16 +361,6 @@ return root.querySelector(selector); }; - $.extend = function(obj, prop) { - var key, val; - for (key in prop) { - val = prop[key]; - if (prop.hasOwnProperty(key)) { - obj[key] = val; - } - } - }; - $.DAY = 24 * ($.HOUR = 60 * ($.MINUTE = 60 * ($.SECOND = 1000))); $.id = function(id) { @@ -875,36 +865,19 @@ Callbacks.prototype.push = function(_arg) { var cb, name; name = _arg.name, cb = _arg.cb; - if (this[name]) { - this.connect(name); - } if (!this[name]) { this.keys.push(name); } return this[name] = cb; }; - Callbacks.prototype.connect = function(name) { - if (this[name].disconnected) { - return delete this[name].disconnected; - } - }; - - Callbacks.prototype.disconnect = function(name) { - if (this[name]) { - return this[name].disconnected = true; - } - }; - Callbacks.prototype.execute = function(node) { var err, errors, name, _i, _len, _ref; _ref = this.keys; for (_i = 0, _len = _ref.length; _i < _len; _i++) { name = _ref[_i]; try { - if (!this[name].disconnected) { - this[name].call(node); - } + this[name].call(node); } catch (_error) { err = _error; if (!errors) { @@ -1550,12 +1523,6 @@ return typeof this.sync === "function" ? this.sync() : void 0; }; - DataBoard.prototype.disconnect = function() { - $.desync(this.key); - delete this.sync; - return delete this.data; - }; - return DataBoard; })(); @@ -1878,7 +1845,7 @@ $.sync('Header auto-hide', this.setBarVisibility); $.sync('Centered links', this.setLinkJustify); this.addShortcut(menuButton); - $.event('AddMenuEntry', { + UI.addMenuEntry({ type: 'header', el: $.el('span', { textContent: 'Header' @@ -2286,12 +2253,9 @@ return Header.menu.toggle(e, this, g); }, createNotification: function(e) { - var cb, content, lifetime, notice, type, _ref; - _ref = e.detail, type = _ref.type, content = _ref.content, lifetime = _ref.lifetime, cb = _ref.cb; - notice = new Notice(type, content, lifetime); - if (cb) { - return cb(notice); - } + var content, lifetime, notice, type, _ref; + _ref = e.detail, type = _ref.type, content = _ref.content, lifetime = _ref.lifetime; + return notice = new Notice(type, content, lifetime); }, areNotificationsEnabled: false, enableDesktopNotifications: function() { @@ -2431,7 +2395,7 @@ $.on(input, 'change', this.cb.sort); } } - $.event('AddMenuEntry', { + UI.addMenuEntry({ type: 'header', el: $.el('span', { textContent: 'Index Navigation' @@ -2957,14 +2921,12 @@ return nodes; }, buildStructure: function(nodes) { - var i, node, result; - result = $.frag(); - i = 0; - while (node = nodes[i++]) { - $.add(result, [node, $.el('hr')]); + var node, _i, _len; + for (_i = 0, _len = nodes.length; _i < _len; _i++) { + node = nodes[_i]; + $.add(Index.root, [node, $.el('hr')]); } - $.event('IndexBuild', result.children); - return $.add(Index.root, result); + return ThreadHiding.onIndexBuild(nodes); }, isSearching: false, clearSearch: function() { @@ -3608,7 +3570,7 @@ }; UI = (function() { - var Menu, checkbox, dialog, drag, dragend, dragstart, hover, hoverend, hoverstart, touchend, touchmove; + var Menu, addMenuEntry, checkbox, dialog, drag, dragend, dragstart, hover, hoverend, hoverstart, menus, rmMenuEntry, touchend, touchmove; dialog = function(id, position, properties) { var child, el, move, _i, _len, _ref; el = $.el('div', { @@ -3634,6 +3596,13 @@ } return el; }; + menus = {}; + addMenuEntry = function(entry) { + return menus[entry.type].addEntry(entry); + }; + rmMenuEntry = function(entry) { + return menus[entry.type].addEntry(entry); + }; Menu = (function() { var currentMenu, lastToggledButton; @@ -3648,9 +3617,19 @@ this.onFocus = __bind(this.onFocus, this); this.keybinds = __bind(this.keybinds, this); this.close = __bind(this.close, this); - $.on(d, 'AddMenuEntry', this.addEntry); - $.on(d, 'rmMenuEntry', this.rmEntry); + $.on(d, 'AddMenuEntry', (function(_this) { + return function(_arg) { + var detail; + detail = _arg.detail; + if (detail.type !== _this.type) { + return; + } + delete detail.open; + return _this.addEntry(detail); + }; + })(this)); this.entries = []; + menus[this.type] = this; } Menu.prototype.makeMenu = function() { @@ -3841,22 +3820,13 @@ return style.right = right; }; - Menu.prototype.addEntry = function(e) { - var entry; - entry = e.detail; - if (entry.type !== this.type) { - return; - } + Menu.prototype.addEntry = function(entry) { this.parseEntry(entry); return this.entries.push(entry); }; - Menu.prototype.rmEntry = function(e) { - var entry, index; - entry = e.detail; - if (entry.type !== this.type) { - return; - } + Menu.prototype.rmEntry = function(entry) { + var index; index = this.entries.indexOf(entry); return this.entries.splice(index, 1); }; @@ -4039,7 +4009,9 @@ dialog: dialog, Menu: Menu, hover: hoverstart, - checkbox: checkbox + checkbox: checkbox, + addMenuEntry: addMenuEntry, + rmMenuEntry: rmMenuEntry }; })(); @@ -4334,7 +4306,7 @@ type = _ref[_i]; entry.subEntries.push(Filter.menu.createSubEntry(type[0], type[1])); } - return $.event('AddMenuEntry', entry); + return UI.addMenuEntry(entry); }, createSubEntry: function(text, type) { var el; @@ -4440,7 +4412,7 @@ thisPost = UI.checkbox('thisPost', ' This post', true); replies = UI.checkbox('replies', ' Hide replies', Conf['Recursive Hiding']); makeStub = UI.checkbox('makeStub', ' Make stub', Conf['Stubs']); - $.event('AddMenuEntry', { + UI.addMenuEntry({ type: 'post', el: div, order: 20, @@ -4479,7 +4451,7 @@ href: 'javascript:;' }); $.on(hideStubLink, 'click', PostHiding.menu.hideStub); - $.event('AddMenuEntry', { + UI.addMenuEntry({ type: 'post', el: div, order: 20, @@ -4510,7 +4482,7 @@ } ] }); - return $.event('AddMenuEntry', { + return UI.addMenuEntry({ type: 'post', el: hideStubLink, order: 15, @@ -4748,7 +4720,6 @@ } this.db = new DataBoard('hiddenThreads'); this.syncCatalog(); - $.on(d, 'IndexBuild', this.onIndexBuild); return Thread.callbacks.push({ name: 'Thread Hiding', cb: this.node @@ -4767,16 +4738,12 @@ } return $.prepend(this.OP.nodes.root, ThreadHiding.makeButton(this, 'hide')); }, - onIndexBuild: function(_arg) { - var i, nodes, root, thread, _i, _len; - nodes = _arg.detail; - for (i = _i = 0, _len = nodes.length; _i < _len; i = _i += 2) { - root = nodes[i]; + onIndexBuild: function(nodes) { + var root, thread, _i, _len; + for (_i = 0, _len = nodes.length; _i < _len; _i++) { + root = nodes[_i]; thread = Get.threadFromRoot(root); - if (!thread.isHidden) { - continue; - } - if (thread.stub && root.contains(thread.stub)) { + if (thread.isHidden && thread.stub && !root.contains(thread.stub)) { ThreadHiding.makeStub(thread, root); } } @@ -4847,7 +4814,7 @@ }); $.on(apply, 'click', ThreadHiding.menu.hide); makeStub = UI.checkbox('Stubs', ' Make stub'); - $.event('AddMenuEntry', { + UI.addMenuEntry({ type: 'post', el: div, order: 20, @@ -4874,7 +4841,7 @@ href: 'javascript:;' }); $.on(div, 'click', ThreadHiding.menu.show); - $.event('AddMenuEntry', { + UI.addMenuEntry({ type: 'post', el: div, order: 20, @@ -4893,7 +4860,7 @@ href: 'javascript:;' }); $.on(hideStubLink, 'click', ThreadHiding.menu.hideStub); - return $.event('AddMenuEntry', { + return UI.addMenuEntry({ type: 'post', el: hideStubLink, order: 15, @@ -5421,7 +5388,7 @@ }); input = $('input', this.controls); $.on(input, 'change', this.toggle); - $.event('AddMenuEntry', this.entry = { + UI.addMenuEntry(this.entry = { type: 'header', el: this.controls, order: 98 @@ -5434,19 +5401,6 @@ cb: this.node }); }, - disconnect: function() { - var input; - if (!(Conf['Quote Threading'] && g.VIEW === 'thread')) { - return; - } - input = $('input', this.controls); - $.off(input, 'change', this.toggle); - $.event('rmMenuEntry', this.entry); - delete this.enabled; - delete this.controls; - delete this.entry; - return Post.callbacks.disconnect('Quote Threading'); - }, ready: function() { $.off(d, '4chanXInitFinished', QuoteThreading.ready); return QuoteThreading.force(); @@ -5849,16 +5803,6 @@ $.prepend($('.navLinksBot'), linkBot); } $.before($.id('togglePostFormLink'), link); - $.on(d, 'QRGetSelectedPost', function(_arg) { - var cb; - cb = _arg.detail; - return cb(QR.selected); - }); - $.on(d, 'QRAddPreSubmitHook', function(_arg) { - var cb; - cb = _arg.detail; - return QR.preSubmitHooks.push(cb); - }); $.on(d, 'paste', QR.paste); $.on(d, 'dragover', QR.dragOver); $.on(d, 'drop', QR.dropFile); @@ -6478,9 +6422,8 @@ return $.add(nodes.form, flag); } }, - preSubmitHooks: [], submit: function(e) { - var challenge, err, extra, filetag, formData, hook, options, post, response, textOnly, thread, threadID, _i, _len, _ref, _ref1; + var challenge, err, extra, filetag, formData, options, post, response, textOnly, thread, threadID, _ref; if (e != null) { e.preventDefault(); } @@ -6513,17 +6456,9 @@ err = 'No file selected.'; } else if (post.file && thread.fileLimit) { err = 'Max limit of image replies has been reached.'; - } else { - _ref = QR.preSubmitHooks; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - hook = _ref[_i]; - if (err = hook(post, thread)) { - break; - } - } } if (QR.captcha.isEnabled && !err) { - _ref1 = QR.captcha.getOne(), challenge = _ref1.challenge, response = _ref1.response; + _ref = QR.captcha.getOne(), challenge = _ref.challenge, response = _ref.response; if (!response) { err = 'No valid captcha.'; } @@ -6656,7 +6591,9 @@ }); ThreadUpdater.postID = postID; $.event('QRPostSuccessful', { - board: g.BOARD, + board: { + ID: g.BOARD.ID + }, threadID: threadID, postID: postID }); @@ -7277,8 +7214,7 @@ rectEl = this.nodes.el.getBoundingClientRect(); rectList = this.nodes.el.parentNode.getBoundingClientRect(); this.nodes.el.parentNode.scrollLeft += rectEl.left + rectEl.width / 2 - rectList.left - rectList.width / 2; - this.load(); - return $.event('QRPostSelection', this); + return this.load(); }; _Class.prototype.load = function() { @@ -7550,7 +7486,7 @@ el.title = "" + type + " Tyme"; FappeTyme[lc] = input = el.firstElementChild; $.on(input, 'change', FappeTyme.cb.toggle.bind(input)); - $.event('AddMenuEntry', { + UI.addMenuEntry({ type: 'header', el: el, order: 97 @@ -7650,7 +7586,7 @@ createSubEntry = Gallery.menu.createSubEntry; for (name in Config.gallery) { el = createSubEntry(name).el; - $.event('AddMenuEntry', { + UI.addMenuEntry({ type: 'gallery', el: el, order: 0 @@ -7885,7 +7821,7 @@ for (name in Config.gallery) { subEntries.push(createSubEntry(name)); } - return $.event('AddMenuEntry', { + return UI.addMenuEntry({ type: 'header', el: el, order: 105, @@ -8219,7 +8155,7 @@ conf = _ref[name]; subEntries.push(createSubEntry(name, conf[1])); } - return $.event('AddMenuEntry', { + return UI.addMenuEntry({ type: 'header', el: el, order: 105, @@ -8381,7 +8317,7 @@ }); this.el = prefetch.firstElementChild; $.on(this.el, 'change', this.toggle); - return $.event('AddMenuEntry', { + return UI.addMenuEntry({ type: 'header', el: prefetch, order: 104 @@ -9158,7 +9094,7 @@ type = _ref[_i]; entry.subEntries.push(this.createSubEntry(type[0], type[1])); } - return $.event('AddMenuEntry', entry); + return UI.addMenuEntry(entry); }, createSubEntry: function(text, type) { var el, open; @@ -9235,7 +9171,7 @@ return true; } }; - return $.event('AddMenuEntry', { + return UI.addMenuEntry({ type: 'post', el: div, order: 40, @@ -9360,7 +9296,7 @@ }; })(this)); }); - return $.event('AddMenuEntry', { + return UI.addMenuEntry({ type: 'post', el: a, order: 100, @@ -9429,7 +9365,7 @@ textContent: 'Report this post' }); $.on(a, 'click', ReportLink.report); - return $.event('AddMenuEntry', { + return UI.addMenuEntry({ type: 'post', el: a, order: 10, @@ -9507,12 +9443,6 @@ }, node: function() { return d.title = Get.threadExcerpt(this); - }, - disconnect: function() { - if (g.VIEW !== 'thread' || !Conf['Thread Excerpt']) { - return; - } - return Thread.callbacks.disconnect('Thread Excerpt'); } }; @@ -9564,25 +9494,6 @@ ThreadStats.update(postCount, fileCount); return $.on(d, 'ThreadUpdate', ThreadStats.onUpdate); }, - disconnect: function() { - if (g.VIEW !== 'thread' || !Conf['Thread Stats']) { - return; - } - if (Conf['Updater and Stats in Header']) { - Header.rmShortcut(this.dialog); - } else { - $.rm(this.dialog); - } - clearTimeout(this.timeout); - delete this.timeout; - delete this.thread; - delete this.postCountEl; - delete this.fileCountEl; - delete this.pageCountEl; - delete this.dialog; - Thread.callbacks.disconnect('Thread Stats'); - return $.off(d, 'ThreadUpdate', ThreadStats.onUpdate); - }, onUpdate: function(e) { var fileCount, postCount, _ref; if (e.detail[404]) { @@ -9702,7 +9613,7 @@ subEntries.push({ el: this.settings }); - $.event('AddMenuEntry', this.entry = { + UI.addMenuEntry(this.entry = { type: 'header', el: $.el('span', { textContent: 'Updater' @@ -9715,45 +9626,6 @@ cb: this.node }); }, - disconnect: function() { - var el, entry, input, name, _i, _j, _len, _len1, _ref, _ref1; - if (g.VIEW !== 'thread' || !Conf['Thread Updater']) { - return; - } - $.off(this.timer, 'click', this.update); - $.off(this.status, 'click', this.update); - if (this.timeoutID) { - clearTimeout(this.timeoutID); - } - _ref = this.entry.subEntries; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - entry = _ref[_i]; - el = entry.el; - input = el.firstElementChild; - $.off(input, 'change', $.cb.checked); - $.off(input, 'change', this.cb.scrollBG); - $.off(input, 'change', this.cb.update); - } - $.off(this.settings, 'click', this.intervalShortcut); - $.off(window, 'online offline', this.cb.online); - $.off(d, 'QRPostSuccessful', this.cb.checkpost); - $.off(d, 'visibilitychange', this.cb.visibility); - this.set('timer', null); - this.set('status', 'Offline'); - $.event('rmMenuEntry', this.entry); - if (Conf['Updater and Stats in Header']) { - Header.rmShortcut(this.dialog); - } else { - $.rmClass(doc, 'float'); - $.rm(this.dialog); - } - _ref1 = ['checkPostCount', 'timer', 'status', 'isUpdating', 'entry', 'dialog', 'thread', 'root', 'lastPost', 'outdateCount', 'online', 'seconds', 'timeoutID']; - for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) { - name = _ref1[_j]; - delete this[name]; - } - return Thread.callbacks.disconnect('Thread Updater'); - }, node: function() { ThreadUpdater.thread = this; ThreadUpdater.root = this.OP.nodes.root.parentNode; @@ -9852,7 +9724,9 @@ ThreadUpdater.thread.kill(); $.event('ThreadUpdate', { 404: true, - thread: ThreadUpdater.thread + thread: { + fullID: ThreadUpdater.thread.fullID + } }); break; default: @@ -9978,12 +9852,18 @@ ID = +post.ID; if (__indexOf.call(index, ID) < 0) { post.kill(); - deletedPosts.push(post); + deletedPosts.push({ + ID: post.ID, + fullID: post.fullID + }); } else if (post.isDead) { post.resurrect(); } else if (post.file && !(post.file.isDead || __indexOf.call(files, ID) >= 0)) { post.kill(true); - deletedFiles.push(post); + deletedFiles.push({ + ID: post.ID, + fullID: post.fullID + }); } if (ThreadUpdater.postID && ThreadUpdater.postID === ID) { return ThreadUpdater.foundPost = true; @@ -10035,8 +9915,22 @@ } return $.event('ThreadUpdate', { 404: false, - thread: ThreadUpdater.thread, - newPosts: posts, + thread: { + ID: ThreadUpdater.thread.ID, + fullID: ThreadUpdater.thread.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, @@ -10065,9 +9959,6 @@ this.status = $('#watcher-status', this.dialog); this.list = this.dialog.lastElementChild; $.on(d, 'QRPostSuccessful', this.cb.post); - if (g.VIEW === 'thread') { - $.on(d, 'ThreadUpdate', this.cb.threadUpdate); - } $.on(sc, 'click', this.toggleWatcher); $.on($('.move>.close', ThreadWatcher.dialog), 'click', this.toggleWatcher); $.on(d, '4chanXInitFinished', this.ready); @@ -10183,7 +10074,7 @@ return $.set('AutoWatch', threadID); } } else if (Conf['Auto Watch Reply']) { - return ThreadWatcher.add(board.threads[threadID]); + return ThreadWatcher.add(g.boards[board.ID].threads[threadID]); } }, onIndexRefresh: function() { @@ -10213,7 +10104,7 @@ }, onThreadRefresh: function(e) { var thread; - thread = e.detail.thread; + thread = g.threads[e.detail.thread.fullID]; if (!(e.detail[404] && ThreadWatcher.db.get({ boardID: thread.board.ID, threadID: thread.ID @@ -10440,7 +10331,7 @@ entryEl = $.el('a', { href: 'javascript:;' }); - $.event('AddMenuEntry', { + UI.addMenuEntry({ type: 'header', el: entryEl, order: 60 @@ -10521,7 +10412,7 @@ if (refresh) { this.refreshers.push(refresh.bind(entry)); } - $.event('AddMenuEntry', entry); + UI.addMenuEntry(entry); } }, createSubEntry: function(name, desc) { @@ -10557,28 +10448,6 @@ cb: this.node }); }, - disconnect: function() { - var hr, name, _i, _len, _ref; - if (g.VIEW !== 'thread' || !Conf['Unread Count'] && !Conf['Unread Favicon'] && !Conf['Desktop Notifications']) { - return; - } - Unread.db.disconnect(); - if (hr = Unread.hr, Unread) { - $.rm(hr); - } - _ref = ['db', 'hr', 'posts', 'postsQuotingYou', 'thread', 'title', 'lastReadPost']; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - name = _ref[_i]; - delete this[name]; - } - $.off(d, '4chanXInitFinished', this.ready); - $.off(d, 'ThreadUpdate', this.onUpdate); - $.off(d, 'scroll visibilitychange', this.read); - if (Conf['Unread Line'] && !Conf['Quote Threading']) { - $.off(d, 'visibilitychange', this.setLine); - } - return Thread.callbacks.disconnect('Unread'); - }, node: function() { Unread.thread = this; Unread.title = d.title; @@ -10720,10 +10589,20 @@ }; }, onUpdate: function(e) { + var post; if (e.detail[404]) { return Unread.update(); } else if (!QuoteThreading.enabled) { - return Unread.addPosts(e.detail.newPosts); + return Unread.addPosts((function() { + var _i, _len, _ref, _results; + _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 { Unread.read(); return Unread.update(); @@ -10942,7 +10821,7 @@ return psa.hidden; } }; - $.event('AddMenuEntry', entry); + UI.addMenuEntry(entry); $.on(entry.el, 'click', PSAHiding.toggle); PSAHiding.btn = btn = $.el('span', { innerHTML: '[Dismiss]', @@ -11095,7 +10974,7 @@ input = $('input', el); $.on(input, 'change', this.toggle); $.sync('Header catalog links', CatalogLinks.set); - $.event('AddMenuEntry', { + UI.addMenuEntry({ type: 'header', el: el, order: 95 @@ -11593,7 +11472,7 @@ }); } if (board === 'sci') { - $.globalEval('window.addEventListener(\'jsmath\', function(e) {\n if (!jsMath) return;\n if (jsMath.loaded) {\n // process one post\n jsMath.ProcessBeforeShowing(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(\'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);'); return Post.callbacks.push({ name: 'Parse /sci/ math', cb: this.math @@ -11626,7 +11505,7 @@ }; })(this)), (function(_this) { return function() { - return $.event('jsmath', _this.nodes.post, window); + return $.event('jsmath', _this.ID, window); }; })(this)); }, @@ -12474,7 +12353,7 @@ Settings.dialog = dialog = $.el('div', { id: 'fourchanx-settings', className: 'dialog', - innerHTML: '
' + innerHTML: '
' }); $.on($('.export', Settings.dialog), 'click', Settings["export"]); $.on($('.import', Settings.dialog), 'click', Settings["import"]); @@ -13176,7 +13055,6 @@ }); } } - $.on(d, 'AddCallback', Main.addCallback); return $.ready(Main.initReady); }, initStyle: function() { @@ -13306,7 +13184,7 @@ } if (previousversion) { el = $.el('span', { - innerHTML: '4chan X has been updated to version 1.7.63.' + innerHTML: '4chan X has been updated to version 1.8.0.' }); new Notice('info', el, 15); } else { diff --git a/package.json b/package.json index 3a0a34816..7b3bb5296 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "4chan-X", - "version": "1.7.63", + "version": "1.8.0", "description": "Cross-browser userscript for maximum lurking on 4chan.", "meta": { "name": "4chan X",