Merge branch 'next' into multisite

This commit is contained in:
ccd0 2016-10-09 17:29:41 -07:00
commit b26a1806cf
21 changed files with 89 additions and 68 deletions

View File

@ -4,6 +4,9 @@
## v1.13.0 ## v1.13.0
**v1.13.0.9** *(2016-10-09)* - [[Userscript](https://raw.githubusercontent.com/ccd0/4chan-x/1.13.0.9/builds/4chan-X-noupdate.user.js)] [[Chrome extension](https://raw.githubusercontent.com/ccd0/4chan-x/1.13.0.9/builds/4chan-X-noupdate.crx)]
- Fix bug from v1.13.0.0 that broke Quote Inlining / Previewing of OPs on /f/.
**v1.13.0.8** *(2016-10-08)* - [[Userscript](https://raw.githubusercontent.com/ccd0/4chan-x/1.13.0.8/builds/4chan-X-noupdate.user.js)] [[Chrome extension](https://raw.githubusercontent.com/ccd0/4chan-x/1.13.0.8/builds/4chan-X-noupdate.crx)] **v1.13.0.8** *(2016-10-08)* - [[Userscript](https://raw.githubusercontent.com/ccd0/4chan-x/1.13.0.8/builds/4chan-X-noupdate.user.js)] [[Chrome extension](https://raw.githubusercontent.com/ccd0/4chan-x/1.13.0.8/builds/4chan-X-noupdate.crx)]
- (AchtBit) Add keybind for toggling custom cooldown (default: `Alt+Comma`). - (AchtBit) Add keybind for toggling custom cooldown (default: `Alt+Comma`).
- Add keybind to post file from URL (default: `Alt+l`). - Add keybind to post file from URL (default: `Alt+l`).

Binary file not shown.

View File

@ -1,6 +1,6 @@
// ==UserScript== // ==UserScript==
// @name 4chan X beta // @name 4chan X beta
// @version 1.13.0.8 // @version 1.13.0.9
// @minGMVer 1.14 // @minGMVer 1.14
// @minFFVer 26 // @minFFVer 26
// @namespace 4chan-X // @namespace 4chan-X

View File

@ -1,6 +1,6 @@
// ==UserScript== // ==UserScript==
// @name 4chan X beta // @name 4chan X beta
// @version 1.13.0.8 // @version 1.13.0.9
// @minGMVer 1.14 // @minGMVer 1.14
// @minFFVer 26 // @minFFVer 26
// @namespace 4chan-X // @namespace 4chan-X
@ -136,7 +136,7 @@ docSet = function() {
}; };
g = { g = {
VERSION: '1.13.0.8', VERSION: '1.13.0.9',
NAMESPACE: '4chan X.', NAMESPACE: '4chan X.',
boards: {} boards: {}
}; };
@ -6128,7 +6128,7 @@ Post = (function() {
_Class.prototype.isClone = true; _Class.prototype.isClone = true;
function _Class(origin, context, contractThumb) { function _Class(origin, context, contractThumb) {
var base, fileRoot, i, inline, inlined, j, k, key, l, len, len1, len2, len3, node, nodes, ref, ref1, ref2, ref3, ref4, root, val; var base, fileRoot, i, inline, inlined, j, k, key, l, len, len1, len2, len3, node, nodes, ref, ref1, ref2, ref3, ref4, ref5, root, val;
this.origin = origin; this.origin = origin;
this.context = context; this.context = context;
ref = ['ID', 'fullID', 'board', 'thread', 'info', 'quotes', 'isReply']; ref = ['ID', 'fullID', 'board', 'thread', 'info', 'quotes', 'isReply'];
@ -6178,7 +6178,7 @@ Post = (function() {
this.file.text = fileRoot.firstElementChild; this.file.text = fileRoot.firstElementChild;
this.file.link = $('.fileText > a, .fileText-original', fileRoot); this.file.link = $('.fileText > a, .fileText-original', fileRoot);
this.file.thumb = $('a.fileThumb > [data-md5]', fileRoot); this.file.thumb = $('a.fileThumb > [data-md5]', fileRoot);
this.file.thumbLink = this.file.thumb.parentNode; this.file.thumbLink = (ref5 = this.file.thumb) != null ? ref5.parentNode : void 0;
this.file.fullImage = $('.full-image', fileRoot); this.file.fullImage = $('.full-image', fileRoot);
this.file.videoControls = $('.video-controls', this.file.text); this.file.videoControls = $('.video-controls', this.file.text);
if (this.file.videoThumb) { if (this.file.videoThumb) {

Binary file not shown.

View File

@ -1,6 +1,6 @@
// ==UserScript== // ==UserScript==
// @name 4chan X // @name 4chan X
// @version 1.13.0.8 // @version 1.13.0.9
// @minGMVer 1.14 // @minGMVer 1.14
// @minFFVer 26 // @minFFVer 26
// @namespace 4chan-X // @namespace 4chan-X
@ -136,7 +136,7 @@ docSet = function() {
}; };
g = { g = {
VERSION: '1.13.0.8', VERSION: '1.13.0.9',
NAMESPACE: '4chan X.', NAMESPACE: '4chan X.',
boards: {} boards: {}
}; };
@ -6128,7 +6128,7 @@ Post = (function() {
_Class.prototype.isClone = true; _Class.prototype.isClone = true;
function _Class(origin, context, contractThumb) { function _Class(origin, context, contractThumb) {
var base, fileRoot, i, inline, inlined, j, k, key, l, len, len1, len2, len3, node, nodes, ref, ref1, ref2, ref3, ref4, root, val; var base, fileRoot, i, inline, inlined, j, k, key, l, len, len1, len2, len3, node, nodes, ref, ref1, ref2, ref3, ref4, ref5, root, val;
this.origin = origin; this.origin = origin;
this.context = context; this.context = context;
ref = ['ID', 'fullID', 'board', 'thread', 'info', 'quotes', 'isReply']; ref = ['ID', 'fullID', 'board', 'thread', 'info', 'quotes', 'isReply'];
@ -6178,7 +6178,7 @@ Post = (function() {
this.file.text = fileRoot.firstElementChild; this.file.text = fileRoot.firstElementChild;
this.file.link = $('.fileText > a, .fileText-original', fileRoot); this.file.link = $('.fileText > a, .fileText-original', fileRoot);
this.file.thumb = $('a.fileThumb > [data-md5]', fileRoot); this.file.thumb = $('a.fileThumb > [data-md5]', fileRoot);
this.file.thumbLink = this.file.thumb.parentNode; this.file.thumbLink = (ref5 = this.file.thumb) != null ? ref5.parentNode : void 0;
this.file.fullImage = $('.full-image', fileRoot); this.file.fullImage = $('.full-image', fileRoot);
this.file.videoControls = $('.video-controls', this.file.text); this.file.videoControls = $('.video-controls', this.file.text);
if (this.file.videoThumb) { if (this.file.videoThumb) {

Binary file not shown.

View File

@ -1,6 +1,6 @@
// ==UserScript== // ==UserScript==
// @name 4chan X // @name 4chan X
// @version 1.13.0.8 // @version 1.13.0.9
// @minGMVer 1.14 // @minGMVer 1.14
// @minFFVer 26 // @minFFVer 26
// @namespace 4chan-X // @namespace 4chan-X

View File

@ -1,6 +1,6 @@
// ==UserScript== // ==UserScript==
// @name 4chan X // @name 4chan X
// @version 1.13.0.8 // @version 1.13.0.9
// @minGMVer 1.14 // @minGMVer 1.14
// @minFFVer 26 // @minFFVer 26
// @namespace 4chan-X // @namespace 4chan-X
@ -136,7 +136,7 @@ docSet = function() {
}; };
g = { g = {
VERSION: '1.13.0.8', VERSION: '1.13.0.9',
NAMESPACE: '4chan X.', NAMESPACE: '4chan X.',
boards: {} boards: {}
}; };
@ -6128,7 +6128,7 @@ Post = (function() {
_Class.prototype.isClone = true; _Class.prototype.isClone = true;
function _Class(origin, context, contractThumb) { function _Class(origin, context, contractThumb) {
var base, fileRoot, i, inline, inlined, j, k, key, l, len, len1, len2, len3, node, nodes, ref, ref1, ref2, ref3, ref4, root, val; var base, fileRoot, i, inline, inlined, j, k, key, l, len, len1, len2, len3, node, nodes, ref, ref1, ref2, ref3, ref4, ref5, root, val;
this.origin = origin; this.origin = origin;
this.context = context; this.context = context;
ref = ['ID', 'fullID', 'board', 'thread', 'info', 'quotes', 'isReply']; ref = ['ID', 'fullID', 'board', 'thread', 'info', 'quotes', 'isReply'];
@ -6178,7 +6178,7 @@ Post = (function() {
this.file.text = fileRoot.firstElementChild; this.file.text = fileRoot.firstElementChild;
this.file.link = $('.fileText > a, .fileText-original', fileRoot); this.file.link = $('.fileText > a, .fileText-original', fileRoot);
this.file.thumb = $('a.fileThumb > [data-md5]', fileRoot); this.file.thumb = $('a.fileThumb > [data-md5]', fileRoot);
this.file.thumbLink = this.file.thumb.parentNode; this.file.thumbLink = (ref5 = this.file.thumb) != null ? ref5.parentNode : void 0;
this.file.fullImage = $('.full-image', fileRoot); this.file.fullImage = $('.full-image', fileRoot);
this.file.videoControls = $('.video-controls', this.file.text); this.file.videoControls = $('.video-controls', this.file.text);
if (this.file.videoThumb) { if (this.file.videoThumb) {

Binary file not shown.

View File

@ -1,7 +1,7 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<gupdate xmlns='http://www.google.com/update2/response' protocol='2.0'> <gupdate xmlns='http://www.google.com/update2/response' protocol='2.0'>
<app appid='lacclbnghgdicfifcamcmcnilckjamag'> <app appid='lacclbnghgdicfifcamcmcnilckjamag'>
<updatecheck codebase='https://www.4chan-x.net/builds/4chan-X-beta.crx' version='1.13.0.8' /> <updatecheck codebase='https://www.4chan-x.net/builds/4chan-X-beta.crx' version='1.13.0.9' />
</app> </app>
</gupdate> </gupdate>

View File

@ -1,7 +1,7 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<gupdate xmlns='http://www.google.com/update2/response' protocol='2.0'> <gupdate xmlns='http://www.google.com/update2/response' protocol='2.0'>
<app appid='lacclbnghgdicfifcamcmcnilckjamag'> <app appid='lacclbnghgdicfifcamcmcnilckjamag'>
<updatecheck codebase='https://www.4chan-x.net/builds/4chan-X.crx' version='1.13.0.8' /> <updatecheck codebase='https://www.4chan-x.net/builds/4chan-X.crx' version='1.13.0.9' />
</app> </app>
</gupdate> </gupdate>

View File

@ -83,8 +83,6 @@ Build =
html = html html = html
.replace(/<br\b[^<]*>/gi, '\n') .replace(/<br\b[^<]*>/gi, '\n')
.replace(/\n\n<span\b[^<]* class="abbr"[^]*$/i, '') # EXIF data (/p/) .replace(/\n\n<span\b[^<]* class="abbr"[^]*$/i, '') # EXIF data (/p/)
.replace(/^<b\b[^<]*>Rolled [^<]*<\/b>/i, '') # Rolls (/tg/)
.replace(/<span\b[^<]* class="fortune"[^]*$/i, '') # Fortunes (/s4s/)
.replace(/<[^>]*>/g, '') .replace(/<[^>]*>/g, '')
Build.unescape html Build.unescape html
@ -93,6 +91,9 @@ Build =
unless Conf['Remove Spoilers'] or Conf['Reveal Spoilers'] unless Conf['Remove Spoilers'] or Conf['Reveal Spoilers']
while (html2 = html.replace /<s>(?:(?!<\/?s>).)*<\/s>/g, '[spoiler]') isnt html while (html2 = html.replace /<s>(?:(?!<\/?s>).)*<\/s>/g, '[spoiler]') isnt html
html = html2 html = html2
html = html
.replace(/^<b\b[^<]*>Rolled [^<]*<\/b>/i, '') # Rolls (/tg/, /qst/)
.replace(/<span\b[^<]* class="fortune"[^]*$/i, '') # Fortunes (/s4s/)
# Remove preceding and following new lines, trailing spaces. # Remove preceding and following new lines, trailing spaces.
Build.parseComment(html).trim().replace(/\s+$/gm, '') Build.parseComment(html).trim().replace(/\s+$/gm, '')

View File

@ -3,9 +3,9 @@ Get =
{OP} = thread {OP} = thread
excerpt = ("/#{thread.board}/ - ") + ( excerpt = ("/#{thread.board}/ - ") + (
OP.info.subject?.trim() or OP.info.subject?.trim() or
OP.info.commentDisplay.replace(/\n+/g, ' // ') or OP.commentDisplay().replace(/\n+/g, ' // ') or
OP.file?.name or OP.file?.name or
OP.info.nameBlock) "No.#{OP}")
return "#{excerpt[...70]}..." if excerpt.length > 73 return "#{excerpt[...70]}..." if excerpt.length > 73
excerpt excerpt
threadFromRoot: (root) -> threadFromRoot: (root) ->

View File

@ -10,7 +10,7 @@ IDColor =
cb: @node cb: @node
node: -> node: ->
return if @isClone or !((uid = @info.uniqueID) and (span = $ 'span.hand', @nodes.uniqueID)) return if @isClone or !((uid = @info.uniqueID) and (span = @nodes.uniqueID))
rgb = IDColor.ids[uid] or IDColor.compute uid rgb = IDColor.ids[uid] or IDColor.compute uid

View File

@ -9,8 +9,8 @@ IDHighlight =
uniqueID: null uniqueID: null
node: -> node: ->
$.on @nodes.uniqueID, 'click', IDHighlight.click @ if @nodes.uniqueID $.on @nodes.uniqueIDRoot, 'click', IDHighlight.click @ if @nodes.uniqueIDRoot
$.on @nodes.capcode, 'click', IDHighlight.click @ if @nodes.capcode $.on @nodes.capcode, 'click', IDHighlight.click @ if @nodes.capcode
IDHighlight.set @ unless @isClone IDHighlight.set @ unless @isClone
set: (post) -> set: (post) ->

View File

@ -10,7 +10,7 @@ IDPostCount =
node: -> node: ->
if @nodes.uniqueID and @thread is IDPostCount.thread if @nodes.uniqueID and @thread is IDPostCount.thread
$.on $('span.hand', @nodes.uniqueID), 'mouseover', IDPostCount.count $.on @nodes.uniqueID, 'mouseover', IDPostCount.count
count: -> count: ->
{uniqueID} = Get.postFromNode(@).info {uniqueID} = Get.postFromNode(@).info

View File

@ -132,7 +132,7 @@ Unread =
openNotification: (post) -> openNotification: (post) ->
return unless Header.areNotificationsEnabled return unless Header.areNotificationsEnabled
notif = new Notification "#{post.info.nameBlock} replied to you", notif = new Notification "#{post.info.nameBlock} replied to you",
body: post.info.commentDisplay body: post.commentDisplay()
icon: Favicon.logo icon: Favicon.logo
notif.onclick = -> notif.onclick = ->
Header.scrollToIfNeeded post.nodes.root, true Header.scrollToIfNeeded post.nodes.root, true

View File

@ -48,7 +48,7 @@ Post.Clone = class extends Post
@file.text = fileRoot.firstElementChild @file.text = fileRoot.firstElementChild
@file.link = $ '.fileText > a, .fileText-original', fileRoot @file.link = $ '.fileText > a, .fileText-original', fileRoot
@file.thumb = $ 'a.fileThumb > [data-md5]', fileRoot @file.thumb = $ 'a.fileThumb > [data-md5]', fileRoot
@file.thumbLink = @file.thumb.parentNode @file.thumbLink = @file.thumb?.parentNode
@file.fullImage = $ '.full-image', fileRoot @file.fullImage = $ '.full-image', fileRoot
@file.videoControls = $ '.video-controls', @file.text @file.videoControls = $ '.video-controls', @file.text

View File

@ -24,17 +24,23 @@ class Post
@thread.kill() if @thread.isArchived @thread.kill() if @thread.isArchived
@info = @info =
nameBlock: if Conf['Anonymize'] then 'Anonymous' else @nodes.nameBlock.textContent.trim()
subject: @nodes.subject?.textContent or undefined subject: @nodes.subject?.textContent or undefined
name: @nodes.name?.textContent name: @nodes.name?.textContent
tripcode: @nodes.tripcode?.textContent tripcode: @nodes.tripcode?.textContent
uniqueID: @nodes.uniqueID?.firstElementChild.textContent uniqueID: @nodes.uniqueID?.textContent
capcode: @nodes.capcode?.textContent.replace '## ', '' capcode: @nodes.capcode?.textContent.replace '## ', ''
pass: @nodes.pass?.title.match(/\d*$/)[0] pass: @nodes.pass?.title.match(/\d*$/)[0]
flagCode: @nodes.flag?.className.match(/flag-(\w+)/)?[1].toUpperCase() flagCode: @nodes.flag?.className.match(/flag-(\w+)/)?[1].toUpperCase()
flag: @nodes.flag?.title flag: @nodes.flag?.title
date: if @nodes.date then new Date(@nodes.date.dataset.utc * 1000) date: if @nodes.date then new Date(@nodes.date.dataset.utc * 1000)
if Conf['Anonymize']
@info.nameBlock = 'Anonymous'
else
@info.nameBlock = "#{@info.name or ''} #{@info.tripcode or ''}".trim()
@info.nameBlock += " ## #{@info.capcode}" if @info.capcode
@info.nameBlock += " (ID: #{@info.uniqueID})" if @info.uniqueID
@parseComment() @parseComment()
@parseQuotes() @parseQuotes()
@parseFile() @parseFile()
@ -59,25 +65,25 @@ class Post
post = $ '.post', root post = $ '.post', root
info = $ '.postInfo', post info = $ '.postInfo', post
nodes = nodes =
root: root root: root
post: post post: post
info: info info: info
subject: $ '.subject', info subject: $ '.subject', info
name: $ '.name', info name: $ '.name', info
email: $ '.useremail', info email: $ '.useremail', info
tripcode: $ '.postertrip', info tripcode: $ '.postertrip', info
uniqueID: $ '.posteruid', info uniqueIDRoot: $ '.posteruid', info
capcode: $ '.capcode.hand', info uniqueID: $ '.posteruid > .hand', info
pass: $ '.n-pu', info capcode: $ '.capcode.hand', info
flag: $ '.flag, .countryFlag', info pass: $ '.n-pu', info
date: $ '.dateTime', info flag: $ '.flag, .countryFlag', info
nameBlock: $ '.nameBlock', info date: $ '.dateTime', info
quote: $ '.postNum > a:nth-of-type(2)', info nameBlock: $ '.nameBlock', info
reply: $ '.replylink', info quote: $ '.postNum > a:nth-of-type(2)', info
fileRoot: $ '.file', post reply: $ '.replylink', info
comment: $ '.postMessage', post fileRoot: $ '.file', post
links: [] comment: $ '.postMessage', post
quotelinks: [] quotelinks: []
archivelinks: [] archivelinks: []
# XXX Edge invalidates HTMLCollections when an ancestor node is inserted into another node. # XXX Edge invalidates HTMLCollections when an ancestor node is inserted into another node.
@ -101,29 +107,22 @@ class Post
# Remove: # Remove:
# 'Comment too long'... # 'Comment too long'...
# EXIF data. (/p/) # EXIF data. (/p/)
# Rolls. (/tg/) @nodes.commentClean = bq = @nodes.comment.cloneNode true
# Fortunes. (/s4s/) @cleanComment bq
bq = @nodes.comment.cloneNode true
for node in $$ '.abbr + br, .exif, b, .fortune', bq
$.rm node
if abbr = $ '.abbr', bq
$.rm abbr
@info.comment = @nodesToText bq @info.comment = @nodesToText bq
if abbr
@info.comment = @info.comment.replace /\n\n$/, ''
# Hide spoilers. commentDisplay: ->
# Remove: # Get the comment's text for display purposes (e.g. notifications, excerpts).
# In addition to what's done in generating `@info.comment`, remove:
# Spoilers. (filter to '[spoiler]')
# Rolls. (/tg/, /qst/)
# Fortunes. (/s4s/)
# Preceding and following new lines. # Preceding and following new lines.
# Trailing spaces. # Trailing spaces.
commentDisplay = @info.comment bq = @nodes.commentClean.cloneNode true
unless Conf['Remove Spoilers'] or Conf['Reveal Spoilers'] @cleanSpoilers bq unless Conf['Remove Spoilers'] or Conf['Reveal Spoilers']
spoilers = $$ 's', bq @cleanCommentDisplay bq
if spoilers.length @nodesToText(bq).trim().replace(/\s+$/gm, '')
for node in spoilers
$.replace node, $.tn '[spoiler]'
commentDisplay = @nodesToText bq
@info.commentDisplay = commentDisplay.trim().replace /\s+$/gm, ''
nodesToText: (bq) -> nodesToText: (bq) ->
text = "" text = ""
@ -133,6 +132,24 @@ class Post
text += node.data or '\n' text += node.data or '\n'
text text
cleanComment: (bq) ->
if (abbr = $ '.abbr', bq) # 'Comment too long' or 'EXIF data available'
for node in $$ '.abbr + br, .exif', bq
$.rm node
for i in [0...2]
$.rm br if (br = abbr.previousSibling) and br.nodeName is 'BR'
$.rm abbr
cleanSpoilers: (bq) ->
spoilers = $$ 's', bq
for node in spoilers
$.replace node, $.tn '[spoiler]'
return
cleanCommentDisplay: (bq) ->
$.rm b if (b = $ 'b', bq) and /^Rolled /.test(b.textContent)
$.rm $('.fortune', bq)
parseQuotes: -> parseQuotes: ->
@quotes = [] @quotes = []
# XXX https://github.com/4chan/4chan-JS/issues/77 # XXX https://github.com/4chan/4chan-JS/issues/77

View File

@ -1,4 +1,4 @@
{ {
"version": "1.13.0.8", "version": "1.13.0.9",
"date": "2016-10-08T19:18:35.432Z" "date": "2016-10-09T10:48:46.406Z"
} }