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.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)]
- Add link in settings to captcha FAQ.

View File

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

View File

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