From ee4ece2574edd7b01d244f34653f32665978a0e5 Mon Sep 17 00:00:00 2001 From: Zixaphir Date: Thu, 8 Aug 2013 14:18:44 -0700 Subject: [PATCH] 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