Fix a few features identifying themselves incorrectly

A few refactors to ColorUserIDs
This commit is contained in:
Zixaphir 2013-08-08 14:18:44 -07:00
parent ce6e317c98
commit ee4ece2574
5 changed files with 79 additions and 91 deletions

View File

@ -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

View File

@ -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,

View File

@ -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,

View File

@ -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'

View File

@ -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