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).
<!-- 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
*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.
<!-- 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
*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.
* https://github.com/ccd0/4chan-x/blob/master/LICENSE

Binary file not shown.

View File

@ -1,6 +1,6 @@
// ==UserScript==
// @name 4chan X beta
// @version 1.9.23.2
// @version 1.9.23.6
// @minGMVer 1.14
// @minFFVer 26
// @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==
// @name 4chan X
// @version 1.9.23.2
// @version 1.9.23.6
// @minGMVer 1.14
// @minFFVer 26
// @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'?>
<gupdate xmlns='http://www.google.com/update2/response' protocol='2.0'>
<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>
</gupdate>

View File

@ -1,7 +1,7 @@
<?xml version='1.0' encoding='UTF-8'?>
<gupdate xmlns='http://www.google.com/update2/response' protocol='2.0'>
<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>
</gupdate>

View File

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

View File

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

View File

@ -928,9 +928,31 @@ span.hide-announcement {
.fileThumb > .warning {
clear: both;
}
a.webm-title.ready {
/* WEBM Metadata */
.webm-title > a::before {
content: "title";
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"] {
width: 4em;
height: 1ex;

View File

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

View File

@ -1,4 +1,11 @@
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) ->
if el.nodeName is 'VIDEO'
el.currentTime = 0 if el.readyState >= el.HAVE_METADATA

View File

@ -143,7 +143,7 @@ ImageExpand =
$.off el, 'error', ImageExpand.error
ImageCommon.pushCache el
if file.isVideo
el.pause()
ImageCommon.pause el
for eventName, cb of ImageExpand.videoCB
$.off el, eventName, cb
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'
el.removeAttribute 'id'
else
isNew = true
el = file.fullImage = $.el (if isVideo then 'video' else 'img')
el.dataset.fullID = post.fullID
$.on el, 'error', ImageExpand.error
@ -192,7 +191,7 @@ ImageExpand =
thumb.parentNode.removeAttribute 'target'
el.loop = true
Volume.setup el, isNew
Volume.setup el
ImageExpand.setupVideoCB post
if !isVideo

View File

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

View File

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

View File

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

View File

@ -43,13 +43,22 @@ QuoteThreading =
node: ->
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
QuoteThreading.parent[@fullID] = parents[0]
parents = new Set()
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) ->
posts = [post]