From bbe93eb475a956c46b6d9b6f225b03e2f40317f8 Mon Sep 17 00:00:00 2001 From: Mayhem Date: Wed, 7 Aug 2013 15:24:21 +0200 Subject: [PATCH 1/8] Shave a line. --- src/Monitoring/Unread.coffee | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Monitoring/Unread.coffee b/src/Monitoring/Unread.coffee index c31c63b56..da1419be5 100644 --- a/src/Monitoring/Unread.coffee +++ b/src/Monitoring/Unread.coffee @@ -125,9 +125,8 @@ Unread = break if bottom > height # post is not completely read return unless i - Unread.lastReadPost = Unread.posts[i - 1].ID + Unread.lastReadPost = Unread.posts.splice(0, i)[i - 1].ID Unread.saveLastReadPost() - Unread.posts.splice 0, i Unread.readArray Unread.postsQuotingYou Unread.update() if e From 39f30c1d0edbec684c03d199a4466f26ba7a84a2 Mon Sep 17 00:00:00 2001 From: Mayhem Date: Wed, 7 Aug 2013 19:55:25 +0200 Subject: [PATCH 2/8] Slightly simplify $.ajax. --- lib/$.coffee | 14 +++----------- src/General/Main.coffee | 2 +- src/Menu/DeleteLink.coffee | 2 +- src/Posting/QR.coffee | 8 ++++---- 4 files changed, 9 insertions(+), 17 deletions(-) diff --git a/lib/$.coffee b/lib/$.coffee index 59e08cbbd..306eba722 100644 --- a/lib/$.coffee +++ b/lib/$.coffee @@ -36,23 +36,15 @@ $.extend = (object, properties) -> for key, val of properties object[key] = val return -$.ajax = (url, callbacks, opts={}) -> - {type, cred, headers, upCallbacks, form, sync} = opts +$.ajax = (url, options, extra={}) -> + {type, headers, upCallbacks, form, sync} = extra r = new XMLHttpRequest() type or= form and 'post' or 'get' r.open type, url, !sync for key, val of headers r.setRequestHeader key, val - $.extend r, callbacks + $.extend r, options $.extend r.upload, upCallbacks - try - # Firefox throws an error if you try - # to set this on a synchronous XHR. - # Only cookies from the remote domain - # are used in a request withCredentials. - r.withCredentials = cred - catch err - # do nothing r.send form r $.cache = do -> diff --git a/src/General/Main.coffee b/src/General/Main.coffee index 0105d43f6..a1dd45ae4 100644 --- a/src/General/Main.coffee +++ b/src/General/Main.coffee @@ -345,7 +345,7 @@ Main = <% } %> ).join '\n' return unless errors - $.ajax '<%= meta.page %>errors', {}, + $.ajax '<%= meta.page %>errors', null, sync: true form: $.formData n: "<%= meta.name %> v#{g.VERSION}" diff --git a/src/Menu/DeleteLink.coffee b/src/Menu/DeleteLink.coffee index 7f71d7f6e..b7678e48a 100644 --- a/src/Menu/DeleteLink.coffee +++ b/src/Menu/DeleteLink.coffee @@ -55,10 +55,10 @@ DeleteLink = link = @ $.ajax $.id('delform').action.replace("/#{g.BOARD}/", "/#{post.board}/"), + withCredentials: true onload: -> DeleteLink.load link, post, fileOnly, @response onerror: -> DeleteLink.error link , - cred: true form: $.formData form load: (link, post, fileOnly, html) -> tmpDoc = d.implementation.createHTMLDocument '' diff --git a/src/Posting/QR.coffee b/src/Posting/QR.coffee index 791e7ded0..6a1d339d9 100644 --- a/src/Posting/QR.coffee +++ b/src/Posting/QR.coffee @@ -959,7 +959,8 @@ QR = recaptcha_challenge_field: challenge recaptcha_response_field: response - callbacks = + options = + withCredentials: true onload: QR.response onerror: -> # Connection error, or @@ -973,8 +974,7 @@ QR = Connection error. You may have been banned. [FAQ] """ - opts = - cred: true + extra = form: $.formData postData upCallbacks: onload: -> @@ -988,7 +988,7 @@ QR = QR.req.progress = "#{Math.round e.loaded / e.total * 100}%" QR.status() - QR.req = $.ajax $.id('postForm').parentNode.action, callbacks, opts + QR.req = $.ajax $.id('postForm').parentNode.action, options, extra # Starting to upload might take some time. # Provide some feedback that we're starting to submit. QR.req.uploadStartTime = Date.now() From 773f2cfe0fadb90ff31b9b703bbccc529e19905b Mon Sep 17 00:00:00 2001 From: Mayhem Date: Wed, 7 Aug 2013 20:04:47 +0200 Subject: [PATCH 3/8] Use xhr.responseType = 'document'. --- src/Menu/DeleteLink.coffee | 11 +++++------ src/Posting/QR.coffee | 26 +++++++++++++++----------- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/src/Menu/DeleteLink.coffee b/src/Menu/DeleteLink.coffee index b7678e48a..1912733c6 100644 --- a/src/Menu/DeleteLink.coffee +++ b/src/Menu/DeleteLink.coffee @@ -55,21 +55,20 @@ DeleteLink = link = @ $.ajax $.id('delform').action.replace("/#{g.BOARD}/", "/#{post.board}/"), + responseType: 'document' withCredentials: true onload: -> DeleteLink.load link, post, fileOnly, @response onerror: -> DeleteLink.error link , form: $.formData form - load: (link, post, fileOnly, html) -> - tmpDoc = d.implementation.createHTMLDocument '' - tmpDoc.documentElement.innerHTML = html - if tmpDoc.title is '4chan - Banned' # Ban/warn check + load: (link, post, fileOnly, resDoc) -> + if resDoc.title is '4chan - Banned' # Ban/warn check s = 'Banned!' - else if msg = tmpDoc.getElementById 'errmsg' # error! + else if msg = resDoc.getElementById 'errmsg' # error! s = msg.textContent $.on link, 'click', DeleteLink.delete else - if tmpDoc.title is 'Updating index...' + if resDoc.title is 'Updating index...' # We're 100% sure. (post.origin or post).kill fileOnly s = 'Deleted' diff --git a/src/Posting/QR.coffee b/src/Posting/QR.coffee index 6a1d339d9..fc7b0357b 100644 --- a/src/Posting/QR.coffee +++ b/src/Posting/QR.coffee @@ -960,6 +960,7 @@ QR = recaptcha_response_field: response options = + responseType: 'document' withCredentials: true onload: QR.response onerror: -> @@ -1002,20 +1003,23 @@ QR = post = QR.posts[0] post.unlock() - tmpDoc = d.implementation.createHTMLDocument '' - tmpDoc.documentElement.innerHTML = req.response - if ban = $ '.banType', tmpDoc # banned/warning - board = $('.board', tmpDoc).innerHTML + resDoc = req.response + if ban = $ '.banType', resDoc # banned/warning + board = $('.board', resDoc).innerHTML err = $.el 'span', innerHTML: if ban.textContent.toLowerCase() is 'banned' - "You are banned on #{board}! ;_;
" + - "Click here to see the reason." + """ + You are banned on #{board}! ;_;
+ Click here to see the reason. + """ else - "You were issued a warning on #{board} as #{$('.nameBlock', tmpDoc).innerHTML}.
" + - "Reason: #{$('.reason', tmpDoc).innerHTML}" - else if err = tmpDoc.getElementById 'errmsg' # error! + """ + You were issued a warning on #{board} as #{$('.nameBlock', resDoc).innerHTML}.
+ Reason: #{$('.reason', resDoc).innerHTML} + """ + else if err = resDoc.getElementById 'errmsg' # error! $('a', err)?.target = '_blank' # duplicate image link - else if tmpDoc.title isnt 'Post successful!' + else if resDoc.title isnt 'Post successful!' err = 'Connection error with sys.4chan.org.' else if req.status isnt 200 err = "Error #{req.statusText} (#{req.status})" @@ -1049,7 +1053,7 @@ QR = QR.error err return - h1 = $ 'h1', tmpDoc + h1 = $ 'h1', resDoc QR.cleanNotifications() QR.notifications.push new Notification 'success', h1.textContent, 5 From ce6e317c98c7de912b614b4db877e237fa55f580 Mon Sep 17 00:00:00 2001 From: Zixaphir Date: Wed, 7 Aug 2013 20:55:23 -0700 Subject: [PATCH 4/8] Time to stop being silly. --- builds/4chan-X.user.js | 53 +++++++++-------------------- builds/crx/script.js | 53 +++++++++-------------------- src/General/lib/$.coffee | 18 ---------- src/Monitoring/Unread.coffee | 19 ++++++++--- src/Quotelinks/QuoteBacklink.coffee | 2 +- 5 files changed, 49 insertions(+), 96 deletions(-) diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index 41c542a2f..373cd2533 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -336,15 +336,6 @@ return this.indexOf(string) > -1; }; - Array.prototype.add = function(object, position) { - var keep; - - keep = this.slice(position); - this.length = position; - this.push(object); - return this.pushArrays(keep); - }; - Array.prototype.contains = function(object) { return this.indexOf(object) > -1; }; @@ -361,27 +352,6 @@ return i; }; - Array.prototype.pushArrays = function() { - var arg, args, _i, _len; - - args = arguments; - for (_i = 0, _len = args.length; _i < _len; _i++) { - arg = args[_i]; - this.push.apply(this, arg); - } - return this; - }; - - Array.prototype.remove = function(object) { - var index; - - if ((index = this.indexOf(object)) > -1) { - return this.splice(index, 1); - } else { - return false; - } - }; - $ = function(selector, root) { if (root == null) { root = d.body; @@ -3683,7 +3653,7 @@ if (Conf['Quote Inlining']) { $.on(link, 'click', QuoteInline.toggle); if (Conf['Quote Hash Navigation']) { - frag.pushArrays(QuoteInline.qiQuote(link, $.hasClass(link, 'filtered'))); + frag.push.apply(frag, QuoteInline.qiQuote(link, $.hasClass(link, 'filtered'))); } } $.add(container, frag); @@ -7992,17 +7962,28 @@ height = doc.clientHeight; posts = Unread.posts; i = 0; - while (post = posts[i++]) { + while (post = posts[i]) { bottom = post.nodes.root.getBoundingClientRect().bottom; - if (bottom < height) { - ID = post.ID; - posts.remove(post); + if (bottom > height) { + i++; + continue; } + ID = post.ID; + if (Conf['Quote Threading']) { + posts.splice(i, 1); + continue; + } else { + posts.splice(0, i); + break; + } + i++; } if (!ID) { return; } - Unread.lastReadPost = ID; + if (Unread.lastReadPost < ID || !Unread.lastReadPost) { + Unread.lastReadPost = ID; + } Unread.saveLastReadPost(); Unread.readArray(Unread.postsQuotingYou); return Unread.update(); diff --git a/builds/crx/script.js b/builds/crx/script.js index e88002f09..304eb227a 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -317,15 +317,6 @@ return this.indexOf(string) > -1; }; - Array.prototype.add = function(object, position) { - var keep; - - keep = this.slice(position); - this.length = position; - this.push(object); - return this.pushArrays(keep); - }; - Array.prototype.contains = function(object) { return this.indexOf(object) > -1; }; @@ -342,27 +333,6 @@ return i; }; - Array.prototype.pushArrays = function() { - var arg, args, _i, _len; - - args = arguments; - for (_i = 0, _len = args.length; _i < _len; _i++) { - arg = args[_i]; - this.push.apply(this, arg); - } - return this; - }; - - Array.prototype.remove = function(object) { - var index; - - if ((index = this.indexOf(object)) > -1) { - return this.splice(index, 1); - } else { - return false; - } - }; - $ = function(selector, root) { if (root == null) { root = d.body; @@ -3688,7 +3658,7 @@ if (Conf['Quote Inlining']) { $.on(link, 'click', QuoteInline.toggle); if (Conf['Quote Hash Navigation']) { - frag.pushArrays(QuoteInline.qiQuote(link, $.hasClass(link, 'filtered'))); + frag.push.apply(frag, QuoteInline.qiQuote(link, $.hasClass(link, 'filtered'))); } } $.add(container, frag); @@ -7973,17 +7943,28 @@ height = doc.clientHeight; posts = Unread.posts; i = 0; - while (post = posts[i++]) { + while (post = posts[i]) { bottom = post.nodes.root.getBoundingClientRect().bottom; - if (bottom < height) { - ID = post.ID; - posts.remove(post); + if (bottom > height) { + i++; + continue; } + ID = post.ID; + if (Conf['Quote Threading']) { + posts.splice(i, 1); + continue; + } else { + posts.splice(0, i); + break; + } + i++; } if (!ID) { return; } - Unread.lastReadPost = ID; + if (Unread.lastReadPost < ID || !Unread.lastReadPost) { + Unread.lastReadPost = ID; + } Unread.saveLastReadPost(); Unread.readArray(Unread.postsQuotingYou); return Unread.update(); diff --git a/src/General/lib/$.coffee b/src/General/lib/$.coffee index 1569f960e..34a0e8af7 100644 --- a/src/General/lib/$.coffee +++ b/src/General/lib/$.coffee @@ -4,12 +4,6 @@ String::capitalize = -> String::contains = (string) -> @indexOf(string) > -1 -Array::add = (object, position) -> - keep = @slice position - @length = position - @push object - @pushArrays keep - Array::contains = (object) -> @indexOf(object) > -1 @@ -19,18 +13,6 @@ Array::indexOf = (object) -> return i if @[i] is object return i -Array::pushArrays = -> - args = arguments - for arg in args - @push.apply @, arg - return @ - -Array::remove = (object) -> - if (index = @indexOf object) > -1 - @splice index, 1 - else - false - # loosely follows the jquery api: # http://api.jquery.com/ # not chainable diff --git a/src/Monitoring/Unread.coffee b/src/Monitoring/Unread.coffee index 1979f3bbb..788b41753 100644 --- a/src/Monitoring/Unread.coffee +++ b/src/Monitoring/Unread.coffee @@ -121,14 +121,23 @@ Unread = {posts} = Unread i = 0 - while post = posts[i++] + while post = posts[i] {bottom} = post.nodes.root.getBoundingClientRect() - if (bottom < height) # post is completely read - {ID} = post - posts.remove post + if bottom > height # post isnt completely read + i++ + continue + + {ID} = post + if Conf['Quote Threading'] + posts.splice i, 1 + continue + else + posts.splice 0, i + break + i++ return unless ID - Unread.lastReadPost = ID + Unread.lastReadPost = ID if Unread.lastReadPost < ID or !Unread.lastReadPost Unread.saveLastReadPost() Unread.readArray Unread.postsQuotingYou Unread.update() diff --git a/src/Quotelinks/QuoteBacklink.coffee b/src/Quotelinks/QuoteBacklink.coffee index 91bbb6e84..ae4a4b433 100644 --- a/src/Quotelinks/QuoteBacklink.coffee +++ b/src/Quotelinks/QuoteBacklink.coffee @@ -41,7 +41,7 @@ QuoteBacklink = $.on link, 'mouseover', QuotePreview.mouseover if Conf['Quote Inlining'] $.on link, 'click', QuoteInline.toggle - frag.pushArrays QuoteInline.qiQuote link, $.hasClass link, 'filtered' if Conf['Quote Hash Navigation'] + frag.push.apply frag, QuoteInline.qiQuote link, $.hasClass link, 'filtered' if Conf['Quote Hash Navigation'] $.add container, frag return secondNode: -> From ee4ece2574edd7b01d244f34653f32665978a0e5 Mon Sep 17 00:00:00 2001 From: Zixaphir Date: Thu, 8 Aug 2013 14:18:44 -0700 Subject: [PATCH 5/8] Fix a few features identifying themselves incorrectly A few refactors to ColorUserIDs --- LICENSE | 2 +- builds/4chan-X.user.js | 23 +++--- builds/crx/script.js | 23 +++--- src/General/Main.coffee | 110 +++++++++++++------------- src/Miscellaneous/ColorUserIDs.coffee | 12 ++- 5 files changed, 79 insertions(+), 91 deletions(-) diff --git a/LICENSE b/LICENSE index c83c43ea3..8986054f8 100644 --- a/LICENSE +++ b/LICENSE @@ -1,5 +1,5 @@ /* -* 4chan X - Version 1.2.25 - 2013-08-07 +* 4chan X - Version 1.2.25 - 2013-08-08 * * Licensed under the MIT license. * https://github.com/seaweedchan/4chan-x/blob/master/LICENSE diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index 373cd2533..1d6dcd0c3 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -19,7 +19,7 @@ // @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAgMAAAAqbBEUAAAACVBMVEUAAGcAAABmzDNZt9VtAAAAAXRSTlMAQObYZgAAAHFJREFUKFOt0LENACEIBdBv4Qju4wgWanEj3D6OcIVMKaitYHEU/jwTCQj8W75kiVCSBvdQ5/AvfVHBin11BgdRq3ysBgfwBDRrj3MCIA+oAQaku/Q1cNctrAmyDl577tOThYt/Y1RBM4DgOHzM0HFTAyLukH/cmRnqAAAAAElFTkSuQmCC // ==/UserScript== /* -* 4chan X - Version 1.2.25 - 2013-08-07 +* 4chan X - Version 1.2.25 - 2013-08-08 * * Licensed under the MIT license. * https://github.com/seaweedchan/4chan-x/blob/master/LICENSE @@ -8355,20 +8355,18 @@ return; } return Post.prototype.callbacks.push({ - name: 'Reveal Spoilers', + name: 'Color User IDs', cb: this.node }); }, node: function(post) { - var str, uid; + var str, _ref; - if (!(uid = $('.hand', this.nodes.uniqueID))) { + if (((_ref = $('.hand', this.nodes.uniqueID)) != null ? _ref.nodeName : void 0) !== 'SPAN') { return; } str = this.info.uniqueID; - if (uid.nodeName === 'SPAN') { - return uid.style.cssText = IDColor.apply.call(str); - } + return uid.style.cssText = IDColor.css(IDColor.ids[str] || IDColor.compute(str)); }, ids: {}, compute: function(str) { @@ -8380,11 +8378,8 @@ this.ids[str] = rgb; return rgb; }, - apply: function() { - var rgb; - - rgb = IDColor.ids[this] || IDColor.compute(this); - return ("background-color: rgb(" + rgb[0] + "," + rgb[1] + "," + rgb[2] + "); color: ") + (rgb[3] ? "black; border-radius: 3px; padding: 0px 2px;" : "white; border-radius: 3px; padding: 0px 2px;"); + css: function(rgb) { + return "background-color: rgb(" + rgb[0] + "," + rgb[1] + "," + rgb[2] + "); color: " + (rgb[3] ? "black;" : "white;") + " border-radius: 3px; padding: 0px 2px;"; }, hash: function(str) { var i, j, msg; @@ -10347,7 +10342,7 @@ 'Fourchan thingies': Fourchan, 'Emoji': Emoji, 'Color User IDs': IDColor, - 'Remove Spoilers': RemoveSpoilers, + 'Reveal Spoilers': RemoveSpoilers, 'Custom CSS': CustomCSS, 'Linkify': Linkify, 'Resurrect Quotes': Quotify, @@ -10379,7 +10374,7 @@ 'Sauce': Sauce, 'Image Expansion': ImageExpand, 'Image Expansion (Menu)': ImageExpand.menu, - 'Reveal Spoilers': RevealSpoilers, + 'Reveal Spoiler Thumbnails': RevealSpoilers, 'Image Loading': ImageLoader, 'Image Hover': ImageHover, 'Comment Expansion': ExpandComment, diff --git a/builds/crx/script.js b/builds/crx/script.js index 304eb227a..016dac3df 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -1,6 +1,6 @@ // Generated by CoffeeScript /* -* 4chan X - Version 1.2.25 - 2013-08-07 +* 4chan X - Version 1.2.25 - 2013-08-08 * * Licensed under the MIT license. * https://github.com/seaweedchan/4chan-x/blob/master/LICENSE @@ -8341,20 +8341,18 @@ return; } return Post.prototype.callbacks.push({ - name: 'Reveal Spoilers', + name: 'Color User IDs', cb: this.node }); }, node: function(post) { - var str, uid; + var str, _ref; - if (!(uid = $('.hand', this.nodes.uniqueID))) { + if (((_ref = $('.hand', this.nodes.uniqueID)) != null ? _ref.nodeName : void 0) !== 'SPAN') { return; } str = this.info.uniqueID; - if (uid.nodeName === 'SPAN') { - return uid.style.cssText = IDColor.apply.call(str); - } + return uid.style.cssText = IDColor.css(IDColor.ids[str] || IDColor.compute(str)); }, ids: {}, compute: function(str) { @@ -8366,11 +8364,8 @@ this.ids[str] = rgb; return rgb; }, - apply: function() { - var rgb; - - rgb = IDColor.ids[this] || IDColor.compute(this); - return ("background-color: rgb(" + rgb[0] + "," + rgb[1] + "," + rgb[2] + "); color: ") + (rgb[3] ? "black; border-radius: 3px; padding: 0px 2px;" : "white; border-radius: 3px; padding: 0px 2px;"); + css: function(rgb) { + return "background-color: rgb(" + rgb[0] + "," + rgb[1] + "," + rgb[2] + "); color: " + (rgb[3] ? "black;" : "white;") + " border-radius: 3px; padding: 0px 2px;"; }, hash: function(str) { var i, j, msg; @@ -10331,7 +10326,7 @@ 'Fourchan thingies': Fourchan, 'Emoji': Emoji, 'Color User IDs': IDColor, - 'Remove Spoilers': RemoveSpoilers, + 'Reveal Spoilers': RemoveSpoilers, 'Custom CSS': CustomCSS, 'Linkify': Linkify, 'Resurrect Quotes': Quotify, @@ -10363,7 +10358,7 @@ 'Sauce': Sauce, 'Image Expansion': ImageExpand, 'Image Expansion (Menu)': ImageExpand.menu, - 'Reveal Spoilers': RevealSpoilers, + 'Reveal Spoiler Thumbnails': RevealSpoilers, 'Image Loading': ImageLoader, 'Image Hover': ImageHover, 'Comment Expansion': ExpandComment, diff --git a/src/General/Main.coffee b/src/General/Main.coffee index 41b2679ce..aeedede7d 100644 --- a/src/General/Main.coffee +++ b/src/General/Main.coffee @@ -73,61 +73,61 @@ Main = # c.time 'All initializations' init - 'Polyfill': Polyfill - 'Redirect': Redirect - 'Header': Header - 'Catalog Links': CatalogLinks - 'Settings': Settings - 'Announcement Hiding': PSAHiding - 'Fourchan thingies': Fourchan - 'Emoji': Emoji - 'Color User IDs': IDColor - 'Remove Spoilers': RemoveSpoilers - 'Custom CSS': CustomCSS - 'Linkify': Linkify - 'Resurrect Quotes': Quotify - 'Filter': Filter - 'Thread Hiding Buttons': ThreadHiding - 'Reply Hiding Buttons': PostHiding - 'Recursive': Recursive - 'Strike-through Quotes': QuoteStrikeThrough - 'Quick Reply': QR - 'Menu': Menu - 'Report Link': ReportLink - 'Thread Hiding (Menu)': ThreadHiding.menu - 'Reply Hiding (Menu)': PostHiding.menu - 'Delete Link': DeleteLink - 'Filter (Menu)': Filter.menu - 'Download Link': DownloadLink - 'Archive Link': ArchiveLink - 'Quote Inlining': QuoteInline - 'Quote Previewing': QuotePreview - 'Quote Backlinks': QuoteBacklink - 'Mark Quotes of You': QuoteYou - 'Mark OP Quotes': QuoteOP - 'Mark Cross-thread Quotes': QuoteCT - 'Anonymize': Anonymize - 'Time Formatting': Time - 'Relative Post Dates': RelativeDates - 'File Info Formatting': FileInfo - 'Fappe Tyme': FappeTyme - 'Sauce': Sauce - 'Image Expansion': ImageExpand - 'Image Expansion (Menu)': ImageExpand.menu - 'Reveal Spoilers': RevealSpoilers - 'Image Loading': ImageLoader - 'Image Hover': ImageHover - 'Comment Expansion': ExpandComment - 'Thread Expansion': ExpandThread - 'Thread Excerpt': ThreadExcerpt - 'Favicon': Favicon - 'Unread': Unread - 'Quote Threading': QuoteThreading - 'Thread Stats': ThreadStats - 'Thread Updater': ThreadUpdater - 'Thread Watcher': ThreadWatcher - 'Index Navigation': Nav - 'Keybinds': Keybinds + 'Polyfill': Polyfill + 'Redirect': Redirect + 'Header': Header + 'Catalog Links': CatalogLinks + 'Settings': Settings + 'Announcement Hiding': PSAHiding + 'Fourchan thingies': Fourchan + 'Emoji': Emoji + 'Color User IDs': IDColor + 'Reveal Spoilers': RemoveSpoilers + 'Custom CSS': CustomCSS + 'Linkify': Linkify + 'Resurrect Quotes': Quotify + 'Filter': Filter + 'Thread Hiding Buttons': ThreadHiding + 'Reply Hiding Buttons': PostHiding + 'Recursive': Recursive + 'Strike-through Quotes': QuoteStrikeThrough + 'Quick Reply': QR + 'Menu': Menu + 'Report Link': ReportLink + 'Thread Hiding (Menu)': ThreadHiding.menu + 'Reply Hiding (Menu)': PostHiding.menu + 'Delete Link': DeleteLink + 'Filter (Menu)': Filter.menu + 'Download Link': DownloadLink + 'Archive Link': ArchiveLink + 'Quote Inlining': QuoteInline + 'Quote Previewing': QuotePreview + 'Quote Backlinks': QuoteBacklink + 'Mark Quotes of You': QuoteYou + 'Mark OP Quotes': QuoteOP + 'Mark Cross-thread Quotes': QuoteCT + 'Anonymize': Anonymize + 'Time Formatting': Time + 'Relative Post Dates': RelativeDates + 'File Info Formatting': FileInfo + 'Fappe Tyme': FappeTyme + 'Sauce': Sauce + 'Image Expansion': ImageExpand + 'Image Expansion (Menu)': ImageExpand.menu + 'Reveal Spoiler Thumbnails': RevealSpoilers + 'Image Loading': ImageLoader + 'Image Hover': ImageHover + 'Comment Expansion': ExpandComment + 'Thread Expansion': ExpandThread + 'Thread Excerpt': ThreadExcerpt + 'Favicon': Favicon + 'Unread': Unread + 'Quote Threading': QuoteThreading + 'Thread Stats': ThreadStats + 'Thread Updater': ThreadUpdater + 'Thread Watcher': ThreadWatcher + 'Index Navigation': Nav + 'Keybinds': Keybinds # c.timeEnd 'All initializations' diff --git a/src/Miscellaneous/ColorUserIDs.coffee b/src/Miscellaneous/ColorUserIDs.coffee index ba7647686..b4b72e7dc 100644 --- a/src/Miscellaneous/ColorUserIDs.coffee +++ b/src/Miscellaneous/ColorUserIDs.coffee @@ -3,14 +3,13 @@ IDColor = return unless Conf['Color User IDs'] Post::callbacks.push - name: 'Reveal Spoilers' + name: 'Color User IDs' cb: @node node: (post) -> - return unless uid = $ '.hand', @nodes.uniqueID + return unless $('.hand', @nodes.uniqueID)?.nodeName is 'SPAN' str = @info.uniqueID - if uid.nodeName is 'SPAN' - uid.style.cssText = IDColor.apply.call str + uid.style.cssText = IDColor.css IDColor.ids[str] or IDColor.compute str ids: {} @@ -22,14 +21,13 @@ IDColor = (hash >> 16) & 0xFF (hash >> 8) & 0xFF ] + rgb[3] = ((rgb[0] * 0.299) + (rgb[1] * 0.587) + (rgb[2] * 0.114)) > 125 @ids[str] = rgb rgb - apply: -> - rgb = IDColor.ids[@] or IDColor.compute @ - "background-color: rgb(#{rgb[0]},#{rgb[1]},#{rgb[2]}); color: " + if rgb[3] then "black; border-radius: 3px; padding: 0px 2px;" else "white; border-radius: 3px; padding: 0px 2px;" + css: (rgb) -> "background-color: rgb(#{rgb[0]},#{rgb[1]},#{rgb[2]}); color: #{if rgb[3] then "black;" else "white;"} border-radius: 3px; padding: 0px 2px;" hash: (str) -> msg = 0 From 254fa9959b4229fdb5f51344be89eb727de10cd6 Mon Sep 17 00:00:00 2001 From: Zixaphir Date: Thu, 8 Aug 2013 14:27:19 -0700 Subject: [PATCH 6/8] And a couple more fixes #136 --- builds/4chan-X.user.js | 9 +++++---- builds/crx/script.js | 9 +++++---- src/Miscellaneous/ColorUserIDs.coffee | 5 +++-- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index 1d6dcd0c3..b797c7a69 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -8359,13 +8359,14 @@ cb: this.node }); }, - node: function(post) { - var str, _ref; + node: function() { + var str, uid; - if (((_ref = $('.hand', this.nodes.uniqueID)) != null ? _ref.nodeName : void 0) !== 'SPAN') { + str = this.info.uniqueID; + uid = $('.hand', this.nodes.uniqueID); + if (!(str && uid && uid.nodeName === 'SPAN')) { return; } - str = this.info.uniqueID; return uid.style.cssText = IDColor.css(IDColor.ids[str] || IDColor.compute(str)); }, ids: {}, diff --git a/builds/crx/script.js b/builds/crx/script.js index 016dac3df..fdae8541e 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -8345,13 +8345,14 @@ cb: this.node }); }, - node: function(post) { - var str, _ref; + node: function() { + var str, uid; - if (((_ref = $('.hand', this.nodes.uniqueID)) != null ? _ref.nodeName : void 0) !== 'SPAN') { + str = this.info.uniqueID; + uid = $('.hand', this.nodes.uniqueID); + if (!(str && uid && uid.nodeName === 'SPAN')) { return; } - str = this.info.uniqueID; return uid.style.cssText = IDColor.css(IDColor.ids[str] || IDColor.compute(str)); }, ids: {}, diff --git a/src/Miscellaneous/ColorUserIDs.coffee b/src/Miscellaneous/ColorUserIDs.coffee index b4b72e7dc..a0b442a17 100644 --- a/src/Miscellaneous/ColorUserIDs.coffee +++ b/src/Miscellaneous/ColorUserIDs.coffee @@ -6,9 +6,10 @@ IDColor = name: 'Color User IDs' cb: @node - node: (post) -> - return unless $('.hand', @nodes.uniqueID)?.nodeName is 'SPAN' + node: -> str = @info.uniqueID + uid = $ '.hand', @nodes.uniqueID + return unless str and uid and uid.nodeName is 'SPAN' uid.style.cssText = IDColor.css IDColor.ids[str] or IDColor.compute str ids: {} From bd1dc8cb532587347421679ebda194a4a9981881 Mon Sep 17 00:00:00 2001 From: Zixaphir Date: Thu, 8 Aug 2013 14:35:26 -0700 Subject: [PATCH 7/8] Fix #298 --- builds/4chan-X.user.js | 6 +++++- builds/crx/script.js | 6 +++++- src/General/Header.coffee | 5 ++++- src/Miscellaneous/CatalogLinks.coffee | 2 +- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index b797c7a69..758523ea7 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -1616,7 +1616,11 @@ a.dataset.only = m[1]; a.href = "//boards.4chan.org/" + board + "/"; if (m[1] === 'catalog') { - a.href += 'catalog'; + if (Conf['External Catalog']) { + a.href = CatalogLinks.external(board); + } else { + a.href += 'catalog'; + } $.addClass(a, 'catalog'); } } diff --git a/builds/crx/script.js b/builds/crx/script.js index fdae8541e..2c5f99ebd 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -1628,7 +1628,11 @@ a.dataset.only = m[1]; a.href = "//boards.4chan.org/" + board + "/"; if (m[1] === 'catalog') { - a.href += 'catalog'; + if (Conf['External Catalog']) { + a.href = CatalogLinks.external(board); + } else { + a.href += 'catalog'; + } $.addClass(a, 'catalog'); } } diff --git a/src/General/Header.coffee b/src/General/Header.coffee index c1cea716a..d08b8cd99 100644 --- a/src/General/Header.coffee +++ b/src/General/Header.coffee @@ -169,7 +169,10 @@ Header = a.dataset.only = m[1] a.href = "//boards.4chan.org/#{board}/" if m[1] is 'catalog' - a.href += 'catalog' + if Conf['External Catalog'] + a.href = CatalogLinks.external board + else + a.href += 'catalog' $.addClass a, 'catalog' $.addClass a, 'navSmall' if board is '@' diff --git a/src/Miscellaneous/CatalogLinks.coffee b/src/Miscellaneous/CatalogLinks.coffee index b92983ce5..cb1e84535 100644 --- a/src/Miscellaneous/CatalogLinks.coffee +++ b/src/Miscellaneous/CatalogLinks.coffee @@ -35,7 +35,7 @@ CatalogLinks = continue if ['f', 'status', '4chan'].contains(board) or !board if Conf['External Catalog'] a.href = if useCatalog - CatalogLinks.external(board) + CatalogLinks.external board else "//boards.4chan.org/#{board}/" else From 73250fcc3d9e3571a8748a357318dddc971b5d30 Mon Sep 17 00:00:00 2001 From: Zixaphir Date: Thu, 8 Aug 2013 14:49:31 -0700 Subject: [PATCH 8/8] Fix #378 --- builds/4chan-X.user.js | 6 +++--- builds/crx/script.js | 6 +++--- src/Quotelinks/QuoteInline.coffee | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index 758523ea7..f1fcb88a2 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -3733,9 +3733,6 @@ if (g.VIEW === 'catalog' || !Conf['Quote Inlining']) { return; } - if (Conf['Comment Expansion']) { - ExpandComment.callbacks.push(this.node); - } if (Conf['Quote Hash Navigation']) { this.node = function() { var link, _i, _len, _ref; @@ -3760,6 +3757,9 @@ } }; } + if (Conf['Comment Expansion']) { + ExpandComment.callbacks.push(this.node); + } return Post.prototype.callbacks.push({ name: 'Quote Inlining', cb: this.node diff --git a/builds/crx/script.js b/builds/crx/script.js index 2c5f99ebd..2785e07e9 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -3738,9 +3738,6 @@ if (g.VIEW === 'catalog' || !Conf['Quote Inlining']) { return; } - if (Conf['Comment Expansion']) { - ExpandComment.callbacks.push(this.node); - } if (Conf['Quote Hash Navigation']) { this.node = function() { var link, _i, _len, _ref; @@ -3765,6 +3762,9 @@ } }; } + if (Conf['Comment Expansion']) { + ExpandComment.callbacks.push(this.node); + } return Post.prototype.callbacks.push({ name: 'Quote Inlining', cb: this.node diff --git a/src/Quotelinks/QuoteInline.coffee b/src/Quotelinks/QuoteInline.coffee index 723f0c53b..95a225e38 100644 --- a/src/Quotelinks/QuoteInline.coffee +++ b/src/Quotelinks/QuoteInline.coffee @@ -2,9 +2,6 @@ QuoteInline = init: -> return if g.VIEW is 'catalog' or !Conf['Quote Inlining'] - if Conf['Comment Expansion'] - ExpandComment.callbacks.push @node - if Conf['Quote Hash Navigation'] @node = -> for link in @nodes.quotelinks.concat [@nodes.backlinks...] @@ -18,6 +15,9 @@ QuoteInline = $.on link, 'click', QuoteInline.toggle return + if Conf['Comment Expansion'] + ExpandComment.callbacks.push @node + Post::callbacks.push name: 'Quote Inlining' cb: @node