Merge branch 'master' into zixaphir-merge

This commit is contained in:
ccd0 2015-02-04 15:18:49 -08:00
commit 7c32cb37c9
23 changed files with 406 additions and 316 deletions

View File

@ -3,6 +3,26 @@ Sometimes the changelog has notes (not comprehensive) acknowledging people's wor
The links to individual versions below are to copies of the script with the update URL removed. If you want automatic updates, install the script from the links on the [main page](https://github.com/ccd0/4chan-x). The links to individual versions below are to copies of the script with the update URL removed. If you want automatic updates, install the script from the links on the [main page](https://github.com/ccd0/4chan-x).
<!-- v1.9.23.x --> <!-- v1.9.23.x -->
### v1.9.23.6
*2015-02-04* - [[Firefox](https://raw.githubusercontent.com/ccd0/4chan-x/1.9.23.6/builds/4chan-X-noupdate.user.js "Firefox version")] [[Chromium](https://raw.githubusercontent.com/ccd0/4chan-x/1.9.23.6/builds/4chan-X-noupdate.crx "Chromium version")]
- Mute videos when removing them to work around a bug where the sound kept playing for some videos.
### v1.9.23.5
*2015-02-03* - [[Firefox](https://raw.githubusercontent.com/ccd0/4chan-x/1.9.23.5/builds/4chan-X-noupdate.user.js "Firefox version")] [[Chromium](https://raw.githubusercontent.com/ccd0/4chan-x/1.9.23.5/builds/4chan-X-noupdate.crx "Chromium version")]
- WEBM Metadata: Show the WebM title on mouseover instead of toggling with a click.
### v1.9.23.4
*2015-02-03* - [[Firefox](https://raw.githubusercontent.com/ccd0/4chan-x/1.9.23.4/builds/4chan-X-noupdate.user.js "Firefox version")] [[Chromium](https://raw.githubusercontent.com/ccd0/4chan-x/1.9.23.4/builds/4chan-X-noupdate.crx "Chromium version")]
- Quote Threading improvement: Thread posts with multiple quotes provided all of them are ancestors of the last.
### v1.9.23.3
*2015-02-03* - [[Firefox](https://raw.githubusercontent.com/ccd0/4chan-x/1.9.23.3/builds/4chan-X-noupdate.user.js "Firefox version")] [[Chromium](https://raw.githubusercontent.com/ccd0/4chan-x/1.9.23.3/builds/4chan-X-noupdate.crx "Chromium version")]
- Merge v1.9.22.7: `Pin Watched Threads` (in header menu -> `Index Navigation`) is now off by default.
### v1.9.23.2 ### v1.9.23.2
*2015-02-03* - [[Firefox](https://raw.githubusercontent.com/ccd0/4chan-x/1.9.23.2/builds/4chan-X-noupdate.user.js "Firefox version")] [[Chromium](https://raw.githubusercontent.com/ccd0/4chan-x/1.9.23.2/builds/4chan-X-noupdate.crx "Chromium version")] *2015-02-03* - [[Firefox](https://raw.githubusercontent.com/ccd0/4chan-x/1.9.23.2/builds/4chan-X-noupdate.user.js "Firefox version")] [[Chromium](https://raw.githubusercontent.com/ccd0/4chan-x/1.9.23.2/builds/4chan-X-noupdate.crx "Chromium version")]
@ -19,6 +39,11 @@ The links to individual versions below are to copies of the script with the upda
- `WEBM Metadata` option (on by default): Adds a link to display the title in the WebM metadata. - `WEBM Metadata` option (on by default): Adds a link to display the title in the WebM metadata.
<!-- v1.9.22.x --> <!-- v1.9.22.x -->
### v1.9.22.7
*2015-02-03* - [[Firefox](https://raw.githubusercontent.com/ccd0/4chan-x/1.9.22.7/builds/4chan-X-noupdate.user.js "Firefox version")] [[Chromium](https://raw.githubusercontent.com/ccd0/4chan-x/1.9.22.7/builds/4chan-X-noupdate.crx "Chromium version")]
- `Pin Watched Threads` (in header menu -> `Index Navigation`) is now off by default.
### v1.9.22.6 ### v1.9.22.6
*2015-02-02* - [[Firefox](https://raw.githubusercontent.com/ccd0/4chan-x/1.9.22.6/builds/4chan-X-noupdate.user.js "Firefox version")] [[Chromium](https://raw.githubusercontent.com/ccd0/4chan-x/1.9.22.6/builds/4chan-X-noupdate.crx "Chromium version")] *2015-02-02* - [[Firefox](https://raw.githubusercontent.com/ccd0/4chan-x/1.9.22.6/builds/4chan-X-noupdate.user.js "Firefox version")] [[Chromium](https://raw.githubusercontent.com/ccd0/4chan-x/1.9.22.6/builds/4chan-X-noupdate.crx "Chromium version")]

View File

@ -1,5 +1,5 @@
/* /*
* 4chan X - Version 1.9.23.2 * 4chan X - Version 1.9.23.6
* *
* Licensed under the MIT license. * Licensed under the MIT license.
* https://github.com/ccd0/4chan-x/blob/master/LICENSE * https://github.com/ccd0/4chan-x/blob/master/LICENSE

Binary file not shown.

View File

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

File diff suppressed because one or more lines are too long

Binary file not shown.

File diff suppressed because one or more lines are too long

Binary file not shown.

View File

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

File diff suppressed because one or more lines are too long

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://ccd0.github.io/4chan-x/builds/4chan-X-beta.crx' version='1.9.23.2' /> <updatecheck codebase='https://ccd0.github.io/4chan-x/builds/4chan-X-beta.crx' version='1.9.23.6' />
</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://ccd0.github.io/4chan-x/builds/4chan-X.crx' version='1.9.23.2' /> <updatecheck codebase='https://ccd0.github.io/4chan-x/builds/4chan-X.crx' version='1.9.23.6' />
</app> </app>
</gupdate> </gupdate>

View File

@ -3,7 +3,7 @@
"description": "Cross-browser userscript for maximum lurking on 4chan.", "description": "Cross-browser userscript for maximum lurking on 4chan.",
"meta": { "meta": {
"name": "4chan X", "name": "4chan X",
"version": "1.9.23.2", "version": "1.9.23.6",
"repo": "https://github.com/ccd0/4chan-x/", "repo": "https://github.com/ccd0/4chan-x/",
"page": "https://github.com/ccd0/4chan-x", "page": "https://github.com/ccd0/4chan-x",
"downloads": "https://ccd0.github.io/4chan-x/builds/", "downloads": "https://ccd0.github.io/4chan-x/builds/",

View File

@ -682,7 +682,7 @@ Config =
'Index Sort': 'bump' 'Index Sort': 'bump'
'Index Size': 'small' 'Index Size': 'small'
'Show Replies': true 'Show Replies': true
'Pin Watched Threads': true 'Pin Watched Threads': false
'Anchor Hidden Threads': true 'Anchor Hidden Threads': true
'Refreshed Navigation': false 'Refreshed Navigation': false

View File

@ -928,9 +928,31 @@ span.hide-announcement {
.fileThumb > .warning { .fileThumb > .warning {
clear: both; clear: both;
} }
a.webm-title.ready { /* WEBM Metadata */
.webm-title > a::before {
content: "title";
text-decoration: underline; text-decoration: underline;
} }
.webm-title.loading > a::after {
content: "...";
}
.webm-title.error > a:hover::before,
.webm-title.error > a:focus::before {
content: "error";
text-decoration: none;
}
.webm-title > span {
cursor: text;
}
.webm-title.not-found > span::before {
content: "not found";
}
.webm-title:not(:hover):not(:focus) > span,
.webm-title:hover > span + a,
.webm-title:focus > span + a {
display: none;
}
/* Volume control */
input[name="Default Volume"] { input[name="Default Volume"] {
width: 4em; width: 4em;
height: 1ex; height: 1ex;

View File

@ -147,12 +147,12 @@ Gallery =
$[if elType is 'iframe' then 'addClass' else 'rmClass'] doc, 'gal-pdf' $[if elType is 'iframe' then 'addClass' else 'rmClass'] doc, 'gal-pdf'
file = $.el elType, file = $.el elType,
title: name.download = name.textContent = thumb.title title: name.download = name.textContent = thumb.title
$.on file, 'error', => $.extend file.dataset, thumb.dataset
Gallery.error file, thumb $.on file, 'error', Gallery.error
file.src = name.href = thumb.href file.src = name.href = thumb.href
$.extend file.dataset, thumb.dataset $.off nodes.current, 'error', Gallery.error
nodes.current.pause?() unless nodes.current.error ImageCommon.pause nodes.current
$.replace nodes.current, file $.replace nodes.current, file
if elType is 'video' if elType is 'video'
file.loop = true file.loop = true
@ -175,14 +175,14 @@ Gallery =
# Center selected thumbnail # Center selected thumbnail
nodes.thumbs.scrollTop = thumb.offsetTop + thumb.offsetHeight/2 - nodes.thumbs.clientHeight/2 nodes.thumbs.scrollTop = thumb.offsetTop + thumb.offsetHeight/2 - nodes.thumbs.clientHeight/2
error: (file, thumb) -> error: ->
if file.error?.code is MediaError.MEDIA_ERR_DECODE if @error?.code is MediaError.MEDIA_ERR_DECODE
return new Notice 'error', 'Corrupt or unplayable video', 30 return new Notice 'error', 'Corrupt or unplayable video', 30
return unless file.src.split('/')[2] is 'i.4cdn.org' return unless @src.split('/')[2] is 'i.4cdn.org'
ImageCommon.error file, g.posts[file.dataset.post], null, (URL) -> ImageCommon.error @, g.posts[@dataset.post], null, (url) =>
return unless URL return unless url
thumb.href = URL Gallery.images[@dataset.id].href = url
file.src = URL if Gallery.nodes.current is file @src = url if Gallery.nodes.current is @
cleanupTimer: -> cleanupTimer: ->
clearTimeout Gallery.timeoutID clearTimeout Gallery.timeoutID
@ -281,7 +281,8 @@ Gallery =
Gallery.slideshow = false Gallery.slideshow = false
close: -> close: ->
Gallery.nodes.current.pause?() $.off Gallery.nodes.current, 'error', Gallery.error
ImageCommon.pause Gallery.nodes.current
$.rm Gallery.nodes.el $.rm Gallery.nodes.el
$.rmClass doc, 'gallery-open' $.rmClass doc, 'gallery-open'
if Conf['Fullscreen Gallery'] if Conf['Fullscreen Gallery']

View File

@ -1,4 +1,11 @@
ImageCommon = ImageCommon =
# Pause and mute video in preparation for removing the element from the document.
pause: (video) ->
return unless video.nodeName is 'VIDEO'
video.pause()
$.off video, 'volumechange', Volume.change
video.muted = true
rewind: (el) -> rewind: (el) ->
if el.nodeName is 'VIDEO' if el.nodeName is 'VIDEO'
el.currentTime = 0 if el.readyState >= el.HAVE_METADATA el.currentTime = 0 if el.readyState >= el.HAVE_METADATA

View File

@ -143,7 +143,7 @@ ImageExpand =
$.off el, 'error', ImageExpand.error $.off el, 'error', ImageExpand.error
ImageCommon.pushCache el ImageCommon.pushCache el
if file.isVideo if file.isVideo
el.pause() ImageCommon.pause el
for eventName, cb of ImageExpand.videoCB for eventName, cb of ImageExpand.videoCB
$.off el, eventName, cb $.off el, eventName, cb
ImageCommon.rewind file.thumb if Conf['Restart when Opened'] ImageCommon.rewind file.thumb if Conf['Restart when Opened']
@ -172,7 +172,6 @@ ImageExpand =
ImageCommon.rewind el if Conf['Restart when Opened'] and el.id isnt 'ihover' ImageCommon.rewind el if Conf['Restart when Opened'] and el.id isnt 'ihover'
el.removeAttribute 'id' el.removeAttribute 'id'
else else
isNew = true
el = file.fullImage = $.el (if isVideo then 'video' else 'img') el = file.fullImage = $.el (if isVideo then 'video' else 'img')
el.dataset.fullID = post.fullID el.dataset.fullID = post.fullID
$.on el, 'error', ImageExpand.error $.on el, 'error', ImageExpand.error
@ -192,7 +191,7 @@ ImageExpand =
thumb.parentNode.removeAttribute 'target' thumb.parentNode.removeAttribute 'target'
el.loop = true el.loop = true
Volume.setup el, isNew Volume.setup el
ImageExpand.setupVideoCB post ImageExpand.setupVideoCB post
if !isVideo if !isVideo

View File

@ -31,7 +31,6 @@ ImageHover =
el = ImageCommon.popCache() el = ImageCommon.popCache()
$.on el, 'error', error $.on el, 'error', error
else else
isNew = true
el = $.el (if isVideo then 'video' else 'img') el = $.el (if isVideo then 'video' else 'img')
el.dataset.fullID = post.fullID el.dataset.fullID = post.fullID
$.on el, 'error', error $.on el, 'error', error
@ -45,7 +44,7 @@ ImageHover =
if isVideo if isVideo
el.loop = true el.loop = true
el.controls = false el.controls = false
Volume.setup el, isNew Volume.setup el
el.play() if Conf['Autoplay'] el.play() if Conf['Autoplay']
[width, height] = (+x for x in file.dimensions.split 'x') [width, height] = (+x for x in file.dimensions.split 'x')
{left, right} = @getBoundingClientRect() {left, right} = @getBoundingClientRect()
@ -66,7 +65,7 @@ ImageHover =
cb: -> cb: ->
$.off el, 'error', error $.off el, 'error', error
ImageCommon.pushCache el ImageCommon.pushCache el
el.pause() if isVideo ImageCommon.pause el
$.rm el $.rm el
el.removeAttribute 'style' el.removeAttribute 'style'

View File

@ -9,26 +9,32 @@ Metadata =
node: -> node: ->
return unless @file and /webm$/i.test @file.URL return unless @file and /webm$/i.test @file.URL
if @isClone if @isClone
link = $ '.webm-title', @file.text el = $ '.webm-title', @file.text
else else
link = $.el 'a', el = $.el 'span',
className: 'webm-title ready' className: 'webm-title'
href: 'javascript:;' $.extend el,
textContent: 'title' <%= html('<a href="javascript:;"></a>') %>
$.add @file.text, [$.tn('\u00A0'), link] $.add @file.text, [$.tn('\u00A0'), el]
$.on link, 'click', Metadata[if link.dataset.title? then 'toggle' else 'load'] $.one el.lastElementChild, 'mouseover focus', Metadata.load if el.children.length is 1
load: -> load: ->
$.off @, 'click', Metadata.load $.rmClass @parentNode, 'error'
$.rmClass @, 'ready' $.addClass @parentNode, 'loading'
@textContent = '...'
CrossOrigin.binary Get.postFromNode(@).file.URL, (data) => CrossOrigin.binary Get.postFromNode(@).file.URL, (data) =>
$.rmClass @parentNode, 'loading'
if data? if data?
Metadata.parse.call @, data title = Metadata.parse data
$.on @, 'click', Metadata.toggle output = $.el 'span',
textContent: title or ''
$.addClass @parentNode, 'not-found' unless title?
$.before @, output
@parentNode.tabIndex = 0
@parentNode.focus() if d.activeElement is @
@tabIndex = -1
else else
@textContent = 'error' $.addClass @parentNode, 'error'
$.on @, 'click', Metadata.load $.one @, 'click', Metadata.load
, ,
Range: 'bytes=0-9999' Range: 'bytes=0-9999'
@ -50,15 +56,7 @@ Metadata =
title = '' title = ''
while size-- and i < data.length while size-- and i < data.length
title += String.fromCharCode data[i++] title += String.fromCharCode data[i++]
@textContent = @dataset.title = decodeURIComponent escape title # UTF-8 decoding return decodeURIComponent escape title # UTF-8 decoding
return
else unless element in [0x8538067, 0x549A966] # Segment, Info else unless element in [0x8538067, 0x549A966] # Segment, Info
i += size i += size
@textContent = 'not found' null
toggle: ->
@textContent = if $.hasClass @, 'ready'
@dataset.title or 'not found'
else
'title'
$.toggleClass @, 'ready'

View File

@ -31,10 +31,10 @@ Volume =
Header.menu.addEntry {el: unmuteEntry, order: 200} Header.menu.addEntry {el: unmuteEntry, order: 200}
Header.menu.addEntry {el: volumeEntry, order: 201} Header.menu.addEntry {el: volumeEntry, order: 201}
setup: (video, isNew=true) -> setup: (video) ->
video.muted = !Conf['Allow Sound'] video.muted = !Conf['Allow Sound']
video.volume = Conf['Default Volume'] video.volume = Conf['Default Volume']
$.on video, 'volumechange', Volume.change if isNew $.on video, 'volumechange', Volume.change
change: -> change: ->
{muted, volume} = @ {muted, volume} = @

View File

@ -43,13 +43,22 @@ QuoteThreading =
node: -> node: ->
return if @isFetchedQuote or @isClone or !@isReply return if @isFetchedQuote or @isClone or !@isReply
{thread} = QuoteThreading
parents = (parent for quote in @quotes when (parent = g.posts[quote]) and
not parent.isFetchedQuote and parent.isReply and parent.ID < @ID
)
if parents.length is 1 parents = new Set()
QuoteThreading.parent[@fullID] = parents[0] lastParent = null
for quote in @quotes when parent = g.posts[quote]
if not parent.isFetchedQuote and parent.isReply and parent.ID < @ID
parents.add parent.ID
lastParent = parent if not lastParent or parent.ID > lastParent.ID
return unless lastParent
ancestor = lastParent
while ancestor = QuoteThreading.parent[ancestor.fullID]
parents.delete ancestor.ID
if parents.size is 1
QuoteThreading.parent[@fullID] = lastParent
descendants: (post) -> descendants: (post) ->
posts = [post] posts = [post]