Merge branch 'bstable'

This commit is contained in:
ccd0 2018-01-24 16:58:51 -08:00
commit ecc6fa452e
3 changed files with 10 additions and 20 deletions

View File

@ -21,6 +21,10 @@
### v1.13.15 ### v1.13.15
**v1.13.15.6** *(2018-01-25)* - [[Userscript](https://raw.githubusercontent.com/ccd0/4chan-x/1.13.15.6/builds/4chan-X-noupdate.user.js)] [[Chrome extension](https://raw.githubusercontent.com/ccd0/4chan-x/1.13.15.6/builds/4chan-X-noupdate.crx)]
- Bugfix to captcha opening logic. Don't ask user for new captchas when we have a bypass cookie or at least one captcha, even when many posts are queued.
- Don't save captchas to disk or share them between tabs. They are too short-lived to be worth it now. This should reduce associated I/O errors.
**v1.13.15.5** *(2018-01-23)* - [[Userscript](https://raw.githubusercontent.com/ccd0/4chan-x/1.13.15.5/builds/4chan-X-noupdate.user.js)] [[Chrome extension](https://raw.githubusercontent.com/ccd0/4chan-x/1.13.15.5/builds/4chan-X-noupdate.crx)] **v1.13.15.5** *(2018-01-23)* - [[Userscript](https://raw.githubusercontent.com/ccd0/4chan-x/1.13.15.5/builds/4chan-X-noupdate.user.js)] [[Chrome extension](https://raw.githubusercontent.com/ccd0/4chan-x/1.13.15.5/builds/4chan-X-noupdate.crx)]
- Add link in settings to captcha FAQ. - Add link in settings to captcha FAQ.

View File

@ -1,9 +1,5 @@
Captcha.cache = Captcha.cache =
init: -> init: ->
$.get 'captchas', [], ({captchas}) =>
@sync captchas
@clear()
$.sync 'captchas', @sync.bind(@)
$.on d, 'SaveCaptcha', (e) => $.on d, 'SaveCaptcha', (e) =>
@save e.detail @save e.detail
@ -13,44 +9,34 @@ Captcha.cache =
@captchas.length @captchas.length
needed: -> needed: ->
captchaCount = @captchas.length not (
captchaCount++ if QR.req or /\b_ct=/.test(d.cookie) /\b_ct=/.test(d.cookie) or @captchas.length or QR.req
postsCount = QR.posts.length ) and (
postsCount = 0 if postsCount is 1 and !Conf['Auto-load captcha'] and !QR.posts[0].com and !QR.posts[0].file QR.posts.length > 1 or Conf['Auto-load captcha'] or QR.posts[0].com or QR.posts[0].file
captchaCount < postsCount )
sync: (captchas=[]) ->
captchas = [] unless captchas instanceof Array
@captchas = captchas
@count()
getOne: (isReply) -> getOne: (isReply) ->
@clear() @clear()
i = @captchas.findIndex((x) -> isReply or !x.challenge?) i = @captchas.findIndex((x) -> isReply or !x.challenge?)
if i >= 0 if i >= 0
captcha = @captchas.splice(i, 1)[0] captcha = @captchas.splice(i, 1)[0]
$.set 'captchas', @captchas
@count() @count()
captcha captcha
else else
null null
save: (captcha) -> save: (captcha) ->
$.forceSync 'captchas'
@captchas.push captcha @captchas.push captcha
@captchas.sort (a, b) -> a.timeout - b.timeout @captchas.sort (a, b) -> a.timeout - b.timeout
$.set 'captchas', @captchas
@count() @count()
clear: -> clear: ->
$.forceSync 'captchas'
if @captchas.length if @captchas.length
now = Date.now() now = Date.now()
for captcha, i in @captchas for captcha, i in @captchas
break if captcha.timeout > now break if captcha.timeout > now
if i if i
@captchas = @captchas[i..] @captchas = @captchas[i..]
$.set 'captchas', @captchas
@count() @count()
count: -> count: ->

View File

@ -671,7 +671,7 @@ else
# XXX https://github.com/greasemonkey/greasemonkey/issues/2033 # XXX https://github.com/greasemonkey/greasemonkey/issues/2033
# Also support case where GM_listValues is not defined. # Also support case where GM_listValues is not defined.
$.delete Object.keys(Conf) $.delete Object.keys(Conf)
$.delete ['previousversion', 'QR Size', 'captchas', 'QR.persona', 'hiddenPSA'] $.delete ['previousversion', 'QR Size', 'QR.persona', 'hiddenPSA']
try try
$.delete $.listValues().map (key) -> key.replace g.NAMESPACE, '' $.delete $.listValues().map (key) -> key.replace g.NAMESPACE, ''
cb?() cb?()