Merge branch 'master' into quotify

This commit is contained in:
Nicolas Stepien 2012-03-07 21:11:18 +01:00
commit 0fc9c5dea1
5 changed files with 62 additions and 34 deletions

View File

@ -1,6 +1,6 @@
// ==UserScript==
// @name 4chan x
// @version 2.28.0
// @version 2.28.1
// @namespace aeosynth
// @description Adds various features.
// @copyright 2009-2011 James Campos <james.r.campos@gmail.com>
@ -20,7 +20,7 @@
* Copyright (c) 2009-2011 James Campos <james.r.campos@gmail.com>
* Copyright (c) 2012 Nicolas Stepien <stepien.nicolas@gmail.com>
* http://mayhemydg.github.com/4chan-x/
* 4chan X 2.28.0
* 4chan X 2.28.1
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
@ -212,7 +212,7 @@
NAMESPACE = '4chan_x.';
VERSION = '2.28.0';
VERSION = '2.28.1';
SECOND = 1000;
@ -676,8 +676,9 @@
return text.join('');
},
filename: function(post) {
var file;
if (file = $('span', post.filesize)) return file.title;
var file, filesize;
filesize = post.filesize;
if (filesize && (file = $('span', filesize))) return file.title;
return false;
},
dimensions: function(post) {
@ -889,22 +890,21 @@
ReplyHiding = {
init: function() {
return g.callbacks.push(this.node);
},
node: function(post) {
var a, dd, id, reply;
if (post["class"]) return;
dd = $('.doubledash', post.root);
dd.className = 'replyhider';
a = $.el('a', {
this.a = $.el('a', {
textContent: '[ - ]',
href: 'javascript:;'
});
return g.callbacks.push(this.node);
},
node: function(post) {
var a, dd;
if (post["class"]) return;
dd = post.el.previousSibling;
dd.className = 'replyhider';
a = ReplyHiding.a.cloneNode(true);
$.on(a, 'click', ReplyHiding.cb.hide);
$.replace(dd.firstChild, a);
reply = dd.nextSibling;
id = reply.id;
if (id in g.hiddenReplies) return ReplyHiding.hide(reply);
if (post.id in g.hiddenReplies) return ReplyHiding.hide(post.el);
},
cb: {
hide: function() {
@ -1315,8 +1315,10 @@
return $.rm(script);
});
if (conf['Persistent QR']) {
qr.dialog();
if (conf['Auto Hide QR']) qr.hide();
setTimeout(function() {
qr.dialog();
if (conf['Auto Hide QR']) return qr.hide();
});
}
$.on(d, 'dragover', qr.dragOver);
$.on(d, 'drop', qr.dropFile);
@ -2813,6 +2815,7 @@
},
node: function(post) {
var name, node;
if (post["class"] === 'inline') return;
name = $('.commentpostername, .postername', post.el);
name.textContent = 'Anonymous';
node = name.nextElementSibling;
@ -3536,11 +3539,22 @@
Unread.replies = Unread.replies.slice(i);
return Unread.update();
},
setTitle: function(count) {
if (this.scheduled) {
clearTimeout(this.scheduled);
delete Unread.scheduled;
this.setTitle(count);
return;
}
return this.scheduled = setTimeout((function() {
return d.title = "(" + count + ") " + Unread.title;
}), 5);
},
update: function(forceUpdate) {
var count;
if (!g.REPLY) return;
count = this.replies.length;
if (conf['Unread Count']) d.title = "(" + count + ") " + this.title;
if (conf['Unread Count']) this.setTitle(count);
if (!(conf['Unread Favicon'] && (count < 2 || forceUpdate))) return;
Favicon.el.href = g.dead ? count ? Favicon.unreadDead : Favicon.dead : count ? Favicon.unread : Favicon["default"];
return $.add(d.head, Favicon.el);

View File

@ -2,7 +2,7 @@
{exec} = require 'child_process'
fs = require 'fs'
VERSION = '2.28.0'
VERSION = '2.28.1'
HEADER = """
// ==UserScript==

View File

@ -1,4 +1,6 @@
master
2.28.1
- Mayhem
General performance improvements.
Threads will now be updated instantly after posting through the QR.

View File

@ -1 +1 @@
postMessage({version:'2.28.0'},'*')
postMessage({version:'2.28.1'},'*')

View File

@ -172,7 +172,7 @@ conf = {}
) null, config
NAMESPACE = '4chan_x.'
VERSION = '2.28.0'
VERSION = '2.28.1'
SECOND = 1000
MINUTE = 60*SECOND
HOUR = 60*MINUTE
@ -594,7 +594,8 @@ Filter =
text.push if data = nodes.snapshotItem(i).data then data else '\n'
text.join ''
filename: (post) ->
if file = $ 'span', post.filesize
{filesize} = post
if filesize and file = $ 'span', filesize
return file.title
false
dimensions: (post) ->
@ -748,22 +749,21 @@ ExpandThread =
ReplyHiding =
init: ->
@a = $.el 'a',
textContent: '[ - ]'
href: 'javascript:;'
g.callbacks.push @node
node: (post) ->
return if post.class
dd = $ '.doubledash', post.root
dd = post.el.previousSibling
dd.className = 'replyhider'
a = $.el 'a',
textContent: '[ - ]'
href: 'javascript:;'
a = ReplyHiding.a.cloneNode true
$.on a, 'click', ReplyHiding.cb.hide
$.replace dd.firstChild, a
reply = dd.nextSibling
id = reply.id
if id of g.hiddenReplies
ReplyHiding.hide reply
if post.id of g.hiddenReplies
ReplyHiding.hide post.el
cb:
hide: ->
@ -1071,8 +1071,9 @@ qr =
$.rm script
if conf['Persistent QR']
qr.dialog()
qr.hide() if conf['Auto Hide QR']
setTimeout ->
qr.dialog()
qr.hide() if conf['Auto Hide QR']
$.on d, 'dragover', qr.dragOver
$.on d, 'drop', qr.dropFile
$.on d, 'dragstart', qr.drag
@ -2368,6 +2369,7 @@ Anonymize =
init: ->
g.callbacks.push @node
node: (post) ->
return if post.class is 'inline'
name = $ '.commentpostername, .postername', post.el
name.textContent = 'Anonymous'
node = name.nextElementSibling
@ -2909,13 +2911,23 @@ Unread =
Unread.replies = Unread.replies[i..]
Unread.update()
setTitle: (count) ->
if @scheduled
clearTimeout @scheduled
delete Unread.scheduled
@setTitle count
return
@scheduled = setTimeout (->
d.title = "(#{count}) #{Unread.title}"
), 5
update: (forceUpdate) ->
return unless g.REPLY
count = @replies.length
if conf['Unread Count']
d.title = "(#{count}) #{@title}"
@setTitle count
unless conf['Unread Favicon'] and (count < 2 or forceUpdate)
return