Support captcha code copying on all forms.
This commit is contained in:
parent
720998721b
commit
a49580e6be
@ -8,8 +8,6 @@ Main =
|
|||||||
window['<%= meta.name %> antidup'] = true
|
window['<%= meta.name %> antidup'] = true
|
||||||
|
|
||||||
if location.hostname is 'www.google.com'
|
if location.hostname is 'www.google.com'
|
||||||
if location.pathname is '/recaptcha/api/fallback'
|
|
||||||
$.ready -> Captcha.v2.initFrame()
|
|
||||||
$.get 'Captcha Fixes', true, ({'Captcha Fixes': enabled}) ->
|
$.get 'Captcha Fixes', true, ({'Captcha Fixes': enabled}) ->
|
||||||
if enabled
|
if enabled
|
||||||
$.ready -> Captcha.fixes.init()
|
$.ready -> Captcha.fixes.init()
|
||||||
@ -353,7 +351,7 @@ Main =
|
|||||||
features: [
|
features: [
|
||||||
['Polyfill', Polyfill]
|
['Polyfill', Polyfill]
|
||||||
['Normalize URL', NormalizeURL]
|
['Normalize URL', NormalizeURL]
|
||||||
['Captcha Replacement', Captcha.replace]
|
['Captcha Configuration', Captcha.replace]
|
||||||
['Redirect', Redirect]
|
['Redirect', Redirect]
|
||||||
['Header', Header]
|
['Header', Header]
|
||||||
['Catalog Links', CatalogLinks]
|
['Catalog Links', CatalogLinks]
|
||||||
|
|||||||
@ -54,6 +54,9 @@ Captcha.fixes =
|
|||||||
$.on d, 'keydown', @keybinds.bind(@)
|
$.on d, 'keydown', @keybinds.bind(@)
|
||||||
|
|
||||||
initNoscript: ->
|
initNoscript: ->
|
||||||
|
data = if (token = $('.fbc-verification-token > textarea')?.value) then {token} else {working: true}
|
||||||
|
new Connection(window.parent, '*').send data
|
||||||
|
|
||||||
@noscript = true
|
@noscript = true
|
||||||
@images = $$ '.fbc-payload-imageselect > input'
|
@images = $$ '.fbc-payload-imageselect > input'
|
||||||
return unless @images.length is 9
|
return unless @images.length is 9
|
||||||
|
|||||||
@ -15,7 +15,7 @@ Captcha.replace =
|
|||||||
$.ready Captcha.replace.v1
|
$.ready Captcha.replace.v1
|
||||||
return
|
return
|
||||||
|
|
||||||
if Conf['captchaLanguage'].trim()
|
if Conf['captchaLanguage'].trim() or Conf['Captcha Fixes']
|
||||||
if location.hostname is 'boards.4chan.org'
|
if location.hostname is 'boards.4chan.org'
|
||||||
$.onExists doc, '#captchaFormPart', true, (node) -> $.onExists node, 'iframe', true, Captcha.replace.iframe
|
$.onExists doc, '#captchaFormPart', true, (node) -> $.onExists node, 'iframe', true, Captcha.replace.iframe
|
||||||
else
|
else
|
||||||
@ -54,11 +54,26 @@ Captcha.replace =
|
|||||||
script = $.el 'script',
|
script = $.el 'script',
|
||||||
src: url
|
src: url
|
||||||
$.add d.head, script
|
$.add d.head, script
|
||||||
|
$.onExists d.body, 'iframe', true, Captcha.replace.autocopy
|
||||||
|
|
||||||
iframe: (el) ->
|
iframe: (iframe) ->
|
||||||
return unless (lang = Conf['captchaLanguage'].trim())
|
if (lang = Conf['captchaLanguage'].trim())
|
||||||
src = if /[?&]hl=/.test el.src
|
src = if /[?&]hl=/.test iframe.src
|
||||||
el.src.replace(/([?&]hl=)[^&]*/, '$1' + encodeURIComponent lang)
|
iframe.src.replace(/([?&]hl=)[^&]*/, '$1' + encodeURIComponent lang)
|
||||||
else
|
else
|
||||||
el.src + "&hl=#{encodeURIComponent lang}"
|
iframe.src + "&hl=#{encodeURIComponent lang}"
|
||||||
el.src = src unless el.src is src
|
iframe.src = src unless iframe.src is src
|
||||||
|
Captcha.replace.autocopy iframe
|
||||||
|
|
||||||
|
autocopy: (iframe) ->
|
||||||
|
return unless Conf['Captcha Fixes'] and /^https:\/\/www\.google\.com\/recaptcha\/api\/fallback\?/.test(iframe.src)
|
||||||
|
new Connection iframe, 'https://www.google.com',
|
||||||
|
working: ->
|
||||||
|
if $.id('qr')?.contains iframe
|
||||||
|
$('#qr .captcha-container textarea')?.parentNode.hidden = true
|
||||||
|
token: (token) ->
|
||||||
|
node = iframe
|
||||||
|
while (node = node.parentNode)
|
||||||
|
break if (textarea = $ 'textarea', node)
|
||||||
|
textarea.value = token
|
||||||
|
$.event 'input', null, textarea
|
||||||
|
|||||||
@ -6,8 +6,6 @@ Captcha.v2 =
|
|||||||
return unless (@isEnabled = !!$ '#g-recaptcha, #captchaContainerAlt')
|
return unless (@isEnabled = !!$ '#g-recaptcha, #captchaContainerAlt')
|
||||||
|
|
||||||
if (@noscript = Conf['Force Noscript Captcha'] or not Main.jsEnabled)
|
if (@noscript = Conf['Force Noscript Captcha'] or not Main.jsEnabled)
|
||||||
@conn = new Connection null, "#{location.protocol}//www.google.com",
|
|
||||||
token: (token) => @save true, token
|
|
||||||
$.addClass QR.nodes.el, 'noscript-captcha'
|
$.addClass QR.nodes.el, 'noscript-captcha'
|
||||||
|
|
||||||
@captchas = []
|
@captchas = []
|
||||||
@ -37,16 +35,11 @@ Captcha.v2 =
|
|||||||
new MutationObserver(@watchBubbles.bind @).observe d.body,
|
new MutationObserver(@watchBubbles.bind @).observe d.body,
|
||||||
childList: true
|
childList: true
|
||||||
|
|
||||||
initFrame: ->
|
|
||||||
if (token = $('.fbc-verification-token > textarea')?.value)
|
|
||||||
conn = new Connection window.parent, "#{location.protocol}//boards.4chan.org"
|
|
||||||
conn.send {token}
|
|
||||||
|
|
||||||
timeouts: {}
|
timeouts: {}
|
||||||
postsCount: 0
|
postsCount: 0
|
||||||
|
|
||||||
noscriptURL: ->
|
noscriptURL: ->
|
||||||
url = '//www.google.com/recaptcha/api/fallback?k=<%= meta.recaptchaKey %>'
|
url = 'https://www.google.com/recaptcha/api/fallback?k=<%= meta.recaptchaKey %>'
|
||||||
if (lang = Conf['captchaLanguage'].trim())
|
if (lang = Conf['captchaLanguage'].trim())
|
||||||
url += "&hl=#{encodeURIComponent lang}"
|
url += "&hl=#{encodeURIComponent lang}"
|
||||||
url
|
url
|
||||||
@ -100,8 +93,10 @@ Captcha.v2 =
|
|||||||
iframe = $.el 'iframe',
|
iframe = $.el 'iframe',
|
||||||
id: 'qr-captcha-iframe'
|
id: 'qr-captcha-iframe'
|
||||||
src: @noscriptURL()
|
src: @noscriptURL()
|
||||||
$.add @nodes.container, iframe
|
div = $.el 'div'
|
||||||
@conn.target = iframe
|
textarea = $.el 'textarea'
|
||||||
|
$.add div, textarea
|
||||||
|
$.add @nodes.container, [iframe, div]
|
||||||
|
|
||||||
setupJS: ->
|
setupJS: ->
|
||||||
$.globalEval '''
|
$.globalEval '''
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user