Move 'Use Recaptcha v2 in Reports' into Captcha.replace.
This commit is contained in:
parent
5dec400267
commit
12e44e0ca5
@ -3,15 +3,13 @@ Report =
|
|||||||
|
|
||||||
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+)/
|
||||||
Captcha.replace.init() unless Conf['Use Recaptcha v2 in Reports']
|
Captcha.replace.init()
|
||||||
@postID = +match[1]
|
@postID = +match[1]
|
||||||
$.ready @ready
|
$.ready @ready
|
||||||
|
|
||||||
ready: ->
|
ready: ->
|
||||||
$.addStyle Report.css
|
$.addStyle Report.css
|
||||||
Report.archive() if Conf['Archive Report']
|
Report.archive() if Conf['Archive Report']
|
||||||
if Conf['Use Recaptcha v2 in Reports']
|
|
||||||
Report.captchaV2()
|
|
||||||
if Conf['Use Recaptcha v2 in Reports'] and $.hasClass doc, 'js-enabled'
|
if Conf['Use Recaptcha v2 in Reports'] and $.hasClass doc, 'js-enabled'
|
||||||
new MutationObserver(-> Report.fit '.gc-bubbleDefault').observe d.body,
|
new MutationObserver(-> Report.fit '.gc-bubbleDefault').observe d.body,
|
||||||
childList: true
|
childList: true
|
||||||
@ -20,19 +18,6 @@ Report =
|
|||||||
else
|
else
|
||||||
Report.fit 'body'
|
Report.fit 'body'
|
||||||
|
|
||||||
captchaV2: ->
|
|
||||||
return unless old = $.id 'captchaContainerAlt'
|
|
||||||
container = $.el 'div',
|
|
||||||
className: 'g-recaptcha'
|
|
||||||
container.dataset.sitekey = '<%= meta.recaptchaKey %>'
|
|
||||||
$.replace old, container
|
|
||||||
url = 'https://www.google.com/recaptcha/api.js'
|
|
||||||
if lang = Conf['captchaLanguage'].trim()
|
|
||||||
url += "?hl=#{encodeURIComponent lang}"
|
|
||||||
script = $.el 'script',
|
|
||||||
src: url
|
|
||||||
$.add d.head, script
|
|
||||||
|
|
||||||
fit: (selector) ->
|
fit: (selector) ->
|
||||||
return unless el = $ selector, doc
|
return unless el = $ selector, doc
|
||||||
dy = el.getBoundingClientRect().bottom - doc.clientHeight + 8
|
dy = el.getBoundingClientRect().bottom - doc.clientHeight + 8
|
||||||
|
|||||||
@ -3,12 +3,29 @@ Captcha.replace =
|
|||||||
return unless d.cookie.indexOf('pass_enabled=1') < 0
|
return unless d.cookie.indexOf('pass_enabled=1') < 0
|
||||||
return if location.hostname is 'boards.4chan.org' and Conf['Hide Original Post Form']
|
return if location.hostname is 'boards.4chan.org' and Conf['Hide Original Post Form']
|
||||||
|
|
||||||
|
if location.hostname is 'sys.4chan.org' and Conf['Use Recaptcha v2 in Reports']
|
||||||
|
$.ready Captcha.replace.v2
|
||||||
|
return
|
||||||
|
|
||||||
if Conf['captchaLanguage'].trim()
|
if Conf['captchaLanguage'].trim()
|
||||||
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
|
||||||
$.onExists doc, 'iframe', true, Captcha.replace.iframe
|
$.onExists doc, 'iframe', true, Captcha.replace.iframe
|
||||||
|
|
||||||
|
v2: ->
|
||||||
|
return unless old = $.id 'captchaContainerAlt'
|
||||||
|
container = $.el 'div',
|
||||||
|
className: 'g-recaptcha'
|
||||||
|
container.dataset.sitekey = '<%= meta.recaptchaKey %>'
|
||||||
|
$.replace old, container
|
||||||
|
url = 'https://www.google.com/recaptcha/api.js'
|
||||||
|
if lang = Conf['captchaLanguage'].trim()
|
||||||
|
url += "?hl=#{encodeURIComponent lang}"
|
||||||
|
script = $.el 'script',
|
||||||
|
src: url
|
||||||
|
$.add d.head, script
|
||||||
|
|
||||||
iframe: (el) ->
|
iframe: (el) ->
|
||||||
return unless lang = Conf['captchaLanguage'].trim()
|
return unless lang = Conf['captchaLanguage'].trim()
|
||||||
src = if /[?&]hl=/.test el.src
|
src = if /[?&]hl=/.test el.src
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user