Merge branch 'bstable'
Conflicts: builds/4chan-X-beta.crx builds/4chan-X-beta.meta.js builds/4chan-X-beta.user.js builds/4chan-X-noupdate.crx builds/4chan-X-noupdate.user.js builds/4chan-X.crx builds/4chan-X.meta.js builds/4chan-X.user.js builds/4chan-X.zip builds/updates-beta.xml builds/updates.xml package.json
This commit is contained in:
commit
69c882f9bf
@ -19,6 +19,9 @@ The links to individual versions below are to copies of the script with the upda
|
|||||||
|
|
||||||
### v1.10.14
|
### v1.10.14
|
||||||
|
|
||||||
|
**v1.10.14.4** *(2015-06-19)* - [[Firefox](https://raw.githubusercontent.com/ccd0/4chan-x/1.10.14.4/builds/4chan-X-noupdate.user.js "Firefox version")] [[Chromium](https://raw.githubusercontent.com/ccd0/4chan-x/1.10.14.4/builds/4chan-X-noupdate.crx "Chromium version")]
|
||||||
|
- Update script for new non-Javascript captcha using image selection.
|
||||||
|
|
||||||
**v1.10.14.3** *(2015-06-16)* - [[Firefox](https://raw.githubusercontent.com/ccd0/4chan-x/1.10.14.3/builds/4chan-X-noupdate.user.js "Firefox version")] [[Chromium](https://raw.githubusercontent.com/ccd0/4chan-x/1.10.14.3/builds/4chan-X-noupdate.crx "Chromium version")]
|
**v1.10.14.3** *(2015-06-16)* - [[Firefox](https://raw.githubusercontent.com/ccd0/4chan-x/1.10.14.3/builds/4chan-X-noupdate.user.js "Firefox version")] [[Chromium](https://raw.githubusercontent.com/ccd0/4chan-x/1.10.14.3/builds/4chan-X-noupdate.crx "Chromium version")]
|
||||||
- Fix words being cut off in non-Javascript captcha.
|
- Fix words being cut off in non-Javascript captcha.
|
||||||
|
|
||||||
|
|||||||
@ -1,3 +1,9 @@
|
|||||||
noscript div:first-child, noscript iframe {
|
noscript > div, noscript > div > div {
|
||||||
height: 422px !important;
|
height: 545px !important;
|
||||||
|
}
|
||||||
|
noscript > div > div > div:first-child, noscript iframe {
|
||||||
|
height: 423px !important;
|
||||||
|
}
|
||||||
|
:root:not(.js-enabled) #g-recaptcha {
|
||||||
|
height: auto;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,3 +0,0 @@
|
|||||||
:root:not(.js-enabled) #g-recaptcha {
|
|
||||||
height: auto;
|
|
||||||
}
|
|
||||||
@ -1222,24 +1222,7 @@ input.field.tripped:not(:hover):not(:focus) {
|
|||||||
top: 2px;
|
top: 2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Noscript Recaptcha */
|
/* Captcha */
|
||||||
.captcha-img {
|
|
||||||
margin: 0px;
|
|
||||||
text-align: center;
|
|
||||||
background-image: #fff;
|
|
||||||
font-size: 0px;
|
|
||||||
min-height: 59px;
|
|
||||||
min-width: 302px;
|
|
||||||
}
|
|
||||||
.captcha-input{
|
|
||||||
width: 100%;
|
|
||||||
margin: 1px 0 0;
|
|
||||||
}
|
|
||||||
#qr-captcha-iframe {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Recaptcha v2 */
|
|
||||||
#qr .captcha-root {
|
#qr .captcha-root {
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
@ -1263,6 +1246,13 @@ input.field.tripped:not(:hover):not(:focus) {
|
|||||||
display: block;
|
display: block;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
#qr-captcha-iframe {
|
||||||
|
width: 302px;
|
||||||
|
height: 423px;
|
||||||
|
max-width: 100vw;
|
||||||
|
max-height: calc(100vh - 210px);
|
||||||
|
overflow: auto;
|
||||||
|
}
|
||||||
.goog-bubble-content {
|
.goog-bubble-content {
|
||||||
max-width: 100vw;
|
max-width: 100vw;
|
||||||
max-height: 100vh;
|
max-height: 100vh;
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
Report =
|
Report =
|
||||||
css: `<%= importCSS('noscript', 'report') %>`
|
css: `<%= importCSS('noscript') %>`
|
||||||
|
|
||||||
init: ->
|
init: ->
|
||||||
return unless /\bmode=report\b/.test(location.search) and match = location.search.match /\bno=(\d+)/
|
return unless /\bmode=report\b/.test(location.search) and match = location.search.match /\bno=(\d+)/
|
||||||
|
|||||||
@ -1,44 +1,4 @@
|
|||||||
Captcha.noscript =
|
Captcha.noscript =
|
||||||
lifetime: 2 * $.MINUTE
|
|
||||||
iframeURL: '//www.google.com/recaptcha/api/fallback?k=<%= meta.recaptchaKey %>'
|
|
||||||
|
|
||||||
init: ->
|
|
||||||
return if d.cookie.indexOf('pass_enabled=1') >= 0
|
|
||||||
return unless @isEnabled = !!$.id 'g-recaptcha'
|
|
||||||
|
|
||||||
container = $.el 'div',
|
|
||||||
className: 'captcha-img'
|
|
||||||
title: 'Reload reCAPTCHA'
|
|
||||||
|
|
||||||
input = $.el 'input',
|
|
||||||
className: 'captcha-input field'
|
|
||||||
title: 'Verification'
|
|
||||||
autocomplete: 'off'
|
|
||||||
spellcheck: false
|
|
||||||
@nodes = {container, input}
|
|
||||||
|
|
||||||
$.on input, 'keydown', @keydown.bind @
|
|
||||||
$.on @nodes.container, 'click', =>
|
|
||||||
@reload()
|
|
||||||
@nodes.input.focus()
|
|
||||||
|
|
||||||
@conn = new Connection null, "#{location.protocol}//www.google.com",
|
|
||||||
challenge: @load.bind @
|
|
||||||
token: @save.bind @
|
|
||||||
error: @error.bind @
|
|
||||||
|
|
||||||
$.addClass QR.nodes.el, 'has-captcha'
|
|
||||||
$.after QR.nodes.com.parentNode, [container, input]
|
|
||||||
|
|
||||||
@captchas = []
|
|
||||||
$.get 'captchas', [], ({captchas}) ->
|
|
||||||
QR.captcha.sync captchas
|
|
||||||
QR.captcha.clear()
|
|
||||||
$.sync 'captchas', @sync
|
|
||||||
|
|
||||||
@beforeSetup()
|
|
||||||
@setup()
|
|
||||||
|
|
||||||
initFrame: ->
|
initFrame: ->
|
||||||
conn = new Connection window.parent, "#{location.protocol}//boards.4chan.org",
|
conn = new Connection window.parent, "#{location.protocol}//boards.4chan.org",
|
||||||
response: (response) ->
|
response: (response) ->
|
||||||
@ -58,169 +18,3 @@ Captcha.noscript =
|
|||||||
cb()
|
cb()
|
||||||
else
|
else
|
||||||
$.on img, 'load', cb
|
$.on img, 'load', cb
|
||||||
|
|
||||||
timers: {}
|
|
||||||
|
|
||||||
cb:
|
|
||||||
focus: -> QR.captcha.setup false, true
|
|
||||||
|
|
||||||
beforeSetup: ->
|
|
||||||
{container, input} = @nodes
|
|
||||||
container.hidden = true
|
|
||||||
input.value = ''
|
|
||||||
input.placeholder = 'Focus to load reCAPTCHA'
|
|
||||||
@count()
|
|
||||||
$.on input, 'focus click', @cb.focus
|
|
||||||
|
|
||||||
needed: ->
|
|
||||||
captchaCount = @captchas.length
|
|
||||||
captchaCount++ if QR.req
|
|
||||||
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
|
|
||||||
|
|
||||||
onNewPost: ->
|
|
||||||
|
|
||||||
onPostChange: ->
|
|
||||||
|
|
||||||
setup: (focus, force) ->
|
|
||||||
return unless @isEnabled and (@needed() or force)
|
|
||||||
if !@nodes.iframe
|
|
||||||
@nodes.iframe = $.el 'iframe',
|
|
||||||
id: 'qr-captcha-iframe'
|
|
||||||
src: @iframeURL
|
|
||||||
$.add d.body, @nodes.iframe
|
|
||||||
@conn.target = @nodes.iframe.contentWindow
|
|
||||||
else if !@occupied or force
|
|
||||||
@nodes.iframe.src = @iframeURL
|
|
||||||
@occupied = true
|
|
||||||
@nodes.input.focus() if focus
|
|
||||||
|
|
||||||
afterSetup: ->
|
|
||||||
{container, input} = @nodes
|
|
||||||
container.hidden = false
|
|
||||||
input.placeholder = 'Verification'
|
|
||||||
@count()
|
|
||||||
$.off input, 'focus click', @cb.focus
|
|
||||||
|
|
||||||
if QR.nodes.el.getBoundingClientRect().bottom > doc.clientHeight
|
|
||||||
QR.nodes.el.style.top = ''
|
|
||||||
QR.nodes.el.style.bottom = '0px'
|
|
||||||
|
|
||||||
destroy: ->
|
|
||||||
return unless @isEnabled
|
|
||||||
$.rm @nodes.img if @nodes.img
|
|
||||||
delete @nodes.img
|
|
||||||
$.rm @nodes.iframe if @nodes.iframe
|
|
||||||
delete @nodes.iframe
|
|
||||||
delete @occupied
|
|
||||||
@beforeSetup()
|
|
||||||
|
|
||||||
sync: (captchas=[]) ->
|
|
||||||
QR.captcha.captchas = captchas
|
|
||||||
QR.captcha.count()
|
|
||||||
|
|
||||||
getOne: ->
|
|
||||||
@clear()
|
|
||||||
if captcha = @captchas.shift()
|
|
||||||
@count()
|
|
||||||
$.set 'captchas', @captchas
|
|
||||||
captcha.response
|
|
||||||
else if /\S/.test @nodes.input.value
|
|
||||||
(cb) =>
|
|
||||||
@submitCB = cb
|
|
||||||
@sendResponse()
|
|
||||||
else
|
|
||||||
null
|
|
||||||
|
|
||||||
sendResponse: ->
|
|
||||||
response = @nodes.input.value
|
|
||||||
if /\S/.test response
|
|
||||||
@conn.send {response}
|
|
||||||
|
|
||||||
save: (token) ->
|
|
||||||
delete @occupied
|
|
||||||
@nodes.input.value = ''
|
|
||||||
if @submitCB
|
|
||||||
@submitCB token
|
|
||||||
delete @submitCB
|
|
||||||
if @needed() then @reload() else @destroy()
|
|
||||||
else
|
|
||||||
$.forceSync 'captchas'
|
|
||||||
@captchas.push
|
|
||||||
response: token
|
|
||||||
timeout: @timeout
|
|
||||||
@count()
|
|
||||||
$.set 'captchas', @captchas
|
|
||||||
@reload()
|
|
||||||
|
|
||||||
error: (message) ->
|
|
||||||
@occupied = true
|
|
||||||
@nodes.input.value = ''
|
|
||||||
if @submitCB
|
|
||||||
@submitCB()
|
|
||||||
delete @submitCB
|
|
||||||
QR.error "Captcha Error: #{message}"
|
|
||||||
|
|
||||||
clear: ->
|
|
||||||
return unless @captchas.length
|
|
||||||
$.forceSync 'captchas'
|
|
||||||
now = Date.now()
|
|
||||||
for captcha, i in @captchas
|
|
||||||
break if captcha.timeout > now
|
|
||||||
return unless i
|
|
||||||
@captchas = @captchas[i..]
|
|
||||||
@count()
|
|
||||||
$.set 'captchas', @captchas
|
|
||||||
|
|
||||||
load: (src) ->
|
|
||||||
{container, input, img} = @nodes
|
|
||||||
@occupied = true
|
|
||||||
@timeout = Date.now() + @lifetime
|
|
||||||
unless img
|
|
||||||
img = @nodes.img = new Image()
|
|
||||||
$.one img, 'load', @afterSetup.bind @
|
|
||||||
$.on img, 'load', -> @hidden = false
|
|
||||||
$.add container, img
|
|
||||||
img.src = src
|
|
||||||
input.value = ''
|
|
||||||
@clear()
|
|
||||||
clearTimeout @timers.expire
|
|
||||||
@timers.expire = setTimeout @expire.bind(@), @lifetime
|
|
||||||
|
|
||||||
count: ->
|
|
||||||
count = if @captchas then @captchas.length else 0
|
|
||||||
placeholder = @nodes.input.placeholder.replace /\ \(.*\)$/, ''
|
|
||||||
placeholder += switch count
|
|
||||||
when 0
|
|
||||||
if placeholder is 'Verification' then ' (Shift + Enter to cache)' else ''
|
|
||||||
when 1
|
|
||||||
' (1 cached captcha)'
|
|
||||||
else
|
|
||||||
" (#{count} cached captchas)"
|
|
||||||
@nodes.input.placeholder = placeholder
|
|
||||||
@nodes.input.alt = count # For XTRM RICE.
|
|
||||||
clearTimeout @timers.clear
|
|
||||||
if @captchas.length
|
|
||||||
@timers.clear = setTimeout @clear.bind(@), @captchas[0].timeout - Date.now()
|
|
||||||
|
|
||||||
expire: ->
|
|
||||||
return unless @nodes.iframe
|
|
||||||
if not d.hidden and (@needed() or d.activeElement is @nodes.input)
|
|
||||||
@reload()
|
|
||||||
else
|
|
||||||
@destroy()
|
|
||||||
|
|
||||||
reload: ->
|
|
||||||
@nodes.iframe.src = @iframeURL
|
|
||||||
@occupied = true
|
|
||||||
@nodes.img?.hidden = true
|
|
||||||
|
|
||||||
keydown: (e) ->
|
|
||||||
if e.keyCode is 8 and not @nodes.input.value
|
|
||||||
if @nodes.iframe then @reload() else @setup()
|
|
||||||
else if e.keyCode is 13 and e.shiftKey
|
|
||||||
@sendResponse()
|
|
||||||
else
|
|
||||||
return
|
|
||||||
e.preventDefault()
|
|
||||||
|
|||||||
@ -1,10 +1,15 @@
|
|||||||
Captcha.v2 =
|
Captcha.v2 =
|
||||||
lifetime: 2 * $.MINUTE
|
lifetime: 2 * $.MINUTE
|
||||||
|
noscriptURL: '//www.google.com/recaptcha/api/fallback?k=<%= meta.recaptchaKey %>'
|
||||||
|
|
||||||
init: ->
|
init: ->
|
||||||
return if d.cookie.indexOf('pass_enabled=1') >= 0
|
return if d.cookie.indexOf('pass_enabled=1') >= 0
|
||||||
return unless @isEnabled = !!$.id 'g-recaptcha'
|
return unless @isEnabled = !!$.id 'g-recaptcha'
|
||||||
|
|
||||||
|
if @noscript = Conf['Force Noscript Captcha'] or not $.hasClass doc, 'js-enabled'
|
||||||
|
@conn = new Connection null, "#{location.protocol}//www.google.com",
|
||||||
|
token: (token) => @save true, token
|
||||||
|
|
||||||
@captchas = []
|
@captchas = []
|
||||||
$.get 'captchas', [], ({captchas}) ->
|
$.get 'captchas', [], ({captchas}) ->
|
||||||
QR.captcha.sync captchas
|
QR.captcha.sync captchas
|
||||||
@ -70,6 +75,19 @@ Captcha.v2 =
|
|||||||
childList: true
|
childList: true
|
||||||
subtree: true
|
subtree: true
|
||||||
|
|
||||||
|
if @noscript
|
||||||
|
@setupNoscript()
|
||||||
|
else
|
||||||
|
@setupJS()
|
||||||
|
|
||||||
|
setupNoscript: ->
|
||||||
|
iframe = $.el 'iframe',
|
||||||
|
id: 'qr-captcha-iframe'
|
||||||
|
src: @noscriptURL
|
||||||
|
$.add @nodes.container, iframe
|
||||||
|
@conn.target = iframe.contentWindow
|
||||||
|
|
||||||
|
setupJS: ->
|
||||||
$.globalEval '''
|
$.globalEval '''
|
||||||
(function() {
|
(function() {
|
||||||
function render() {
|
function render() {
|
||||||
@ -139,11 +157,11 @@ Captcha.v2 =
|
|||||||
else
|
else
|
||||||
null
|
null
|
||||||
|
|
||||||
save: (pasted) ->
|
save: (pasted, token) ->
|
||||||
$.forceSync 'captchas'
|
$.forceSync 'captchas'
|
||||||
@captchas.push
|
@captchas.push
|
||||||
response: $('textarea', @nodes.container).value
|
response: token or $('textarea', @nodes.container).value
|
||||||
timeout: (if pasted then @setupTime else Date.now()) + @lifetime
|
timeout: Date.now() + @lifetime
|
||||||
$.set 'captchas', @captchas
|
$.set 'captchas', @captchas
|
||||||
@count()
|
@count()
|
||||||
|
|
||||||
@ -183,9 +201,12 @@ Captcha.v2 =
|
|||||||
@timeouts.clear = setTimeout @clear.bind(@), @captchas[0].timeout - Date.now()
|
@timeouts.clear = setTimeout @clear.bind(@), @captchas[0].timeout - Date.now()
|
||||||
|
|
||||||
reload: ->
|
reload: ->
|
||||||
$.globalEval '''
|
if @noscript
|
||||||
(function() {
|
$('iframe', @nodes.container).src = @noscriptURL
|
||||||
var container = document.querySelector("#qr .captcha-container");
|
else
|
||||||
window.grecaptcha.reset(container.dataset.widgetID);
|
$.globalEval '''
|
||||||
})();
|
(function() {
|
||||||
'''
|
var container = document.querySelector("#qr .captcha-container");
|
||||||
|
window.grecaptcha.reset(container.dataset.widgetID);
|
||||||
|
})();
|
||||||
|
'''
|
||||||
|
|||||||
@ -9,8 +9,7 @@ QR =
|
|||||||
|
|
||||||
return if g.VIEW is 'archive'
|
return if g.VIEW is 'archive'
|
||||||
|
|
||||||
noscript = Conf['Force Noscript Captcha'] or not $.hasClass doc, 'js-enabled'
|
@captcha = Captcha.v2
|
||||||
@captcha = Captcha[if noscript then 'noscript' else 'v2']
|
|
||||||
|
|
||||||
$.on d, '4chanXInitFinished', @initReady
|
$.on d, '4chanXInitFinished', @initReady
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user