Add option to set captcha language.
This commit is contained in:
parent
a50eb04ccc
commit
fc90b895ef
@ -25,7 +25,7 @@
|
||||
"*://www.4chan.org/feedback",
|
||||
"https://www.google.com/recaptcha/api2/anchor?k=6Ldp2bsSAAAAAAJ5uyx_lx34lJeEpTLVkP5k04qc*",
|
||||
"https://www.google.com/recaptcha/api2/frame?*&k=6Ldp2bsSAAAAAAJ5uyx_lx34lJeEpTLVkP5k04qc*",
|
||||
"*://www.google.com/recaptcha/api/fallback?k=6Ldp2bsSAAAAAAJ5uyx_lx34lJeEpTLVkP5k04qc"
|
||||
"*://www.google.com/recaptcha/api/fallback?k=6Ldp2bsSAAAAAAJ5uyx_lx34lJeEpTLVkP5k04qc*"
|
||||
],
|
||||
"suffix": {
|
||||
"stable": "",
|
||||
|
||||
@ -741,6 +741,8 @@ Config =
|
||||
#options:"sage";boards:jp;always
|
||||
"""
|
||||
|
||||
captchaLanguage: ''
|
||||
|
||||
time: '%m/%d/%y(%a)%H:%M:%S'
|
||||
|
||||
backlink: '>>%id'
|
||||
|
||||
@ -10,6 +10,10 @@ Main =
|
||||
|
||||
if location.hostname is 'www.4chan.org'
|
||||
$.onExists d.documentElement, 'body', false, -> $.addStyle Main.cssWWW
|
||||
Conf = {'captchaLanguage': Config.captchaLanguage}
|
||||
$.get Conf, (items) ->
|
||||
$.extend Conf, items
|
||||
Captcha.language.fixPage()
|
||||
return
|
||||
|
||||
g.threads = new SimpleDict()
|
||||
@ -310,6 +314,7 @@ Main =
|
||||
|
||||
features: [
|
||||
['Polyfill', Polyfill]
|
||||
['Captcha Language', Captcha.language]
|
||||
['Redirect', Redirect]
|
||||
['Header', Header]
|
||||
['Catalog Links', CatalogLinks]
|
||||
|
||||
@ -315,7 +315,7 @@ Settings =
|
||||
|
||||
items = {}
|
||||
inputs = {}
|
||||
for name in ['boardnav', 'time', 'backlink', 'fileInfo', 'favicon', 'usercss', 'customCooldown']
|
||||
for name in ['captchaLanguage', 'boardnav', 'time', 'backlink', 'fileInfo', 'favicon', 'usercss', 'customCooldown']
|
||||
input = $ "[name='#{name}']", section
|
||||
items[name] = Conf[name]
|
||||
inputs[name] = input
|
||||
@ -324,9 +324,9 @@ Settings =
|
||||
else if name is 'favicon'
|
||||
$.on input, 'change', $.cb.value
|
||||
$.on input, 'change', Settings[name]
|
||||
else
|
||||
else
|
||||
$.on input, 'input', $.cb.value
|
||||
$.on input, 'input', Settings[name]
|
||||
$.on input, 'input', Settings[name] if name of Settings
|
||||
|
||||
# Quick Reply Personas
|
||||
ta = $ '.personafield', section
|
||||
@ -339,8 +339,8 @@ Settings =
|
||||
for key, val of items
|
||||
input = inputs[key]
|
||||
input.value = val
|
||||
continue if key in ['usercss', 'customCooldown']
|
||||
Settings[key].call input
|
||||
if key of Settings and key isnt 'usercss'
|
||||
Settings[key].call input
|
||||
return
|
||||
|
||||
interval = $ 'input[name="Interval"]', section
|
||||
|
||||
@ -12,6 +12,12 @@
|
||||
</table>
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
<legend>Captcha Language</legend>
|
||||
<div>Choose from <a href="https://developers.google.com/recaptcha/docs/language">list of language codes</a>. Leave blank to autoselect.</div>
|
||||
<div><input name="captchaLanguage" class="field" spellcheck="false"></div>
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
<legend>Custom Board Navigation</legend>
|
||||
<div><textarea name="boardnav" class="field" spellcheck="false"></textarea></div>
|
||||
|
||||
@ -3,6 +3,7 @@ Report =
|
||||
|
||||
init: ->
|
||||
return unless /\bmode=report\b/.test(location.search) and match = location.search.match /\bno=(\d+)/
|
||||
Captcha.language.fixPage()
|
||||
@postID = +match[1]
|
||||
$.ready @ready
|
||||
|
||||
|
||||
17
src/Posting/Captcha.language.coffee
Normal file
17
src/Posting/Captcha.language.coffee
Normal file
@ -0,0 +1,17 @@
|
||||
Captcha.language =
|
||||
init: ->
|
||||
return unless Conf['captchaLanguage'].trim() and d.cookie.indexOf('pass_enabled=1') < 0 and !Conf['Hide Original Post Form']
|
||||
$.onExists doc, '#captchaFormPart', true, (node) ->
|
||||
$.onExists node, 'iframe', true, Captcha.language.fixIframe
|
||||
|
||||
fixPage: ->
|
||||
return unless Conf['captchaLanguage'].trim() and d.cookie.indexOf('pass_enabled=1') < 0
|
||||
$.onExists doc, 'iframe', true, Captcha.language.fixIframe
|
||||
|
||||
fixIframe: (el) ->
|
||||
return unless lang = Conf['captchaLanguage'].trim()
|
||||
src = if /[?&]hl=/.test el.src
|
||||
el.src.replace(/([?&]hl=)[^&]*/, '$1' + encodeURIComponent lang)
|
||||
else
|
||||
el.src + "&hl=#{encodeURIComponent lang}"
|
||||
el.src = src unless el.src is src
|
||||
@ -1,6 +1,5 @@
|
||||
Captcha.v2 =
|
||||
lifetime: 2 * $.MINUTE
|
||||
noscriptURL: '//www.google.com/recaptcha/api/fallback?k=<%= meta.recaptchaKey %>'
|
||||
|
||||
init: ->
|
||||
return if d.cookie.indexOf('pass_enabled=1') >= 0
|
||||
@ -34,6 +33,12 @@ Captcha.v2 =
|
||||
timeouts: {}
|
||||
postsCount: 0
|
||||
|
||||
noscriptURL: ->
|
||||
url = '//www.google.com/recaptcha/api/fallback?k=<%= meta.recaptchaKey %>'
|
||||
if lang = Conf['captchaLanguage'].trim()
|
||||
url += "&hl=#{encodeURIComponent lang}"
|
||||
url
|
||||
|
||||
needed: ->
|
||||
captchaCount = @captchas.length
|
||||
captchaCount++ if QR.req
|
||||
@ -83,7 +88,7 @@ Captcha.v2 =
|
||||
setupNoscript: ->
|
||||
iframe = $.el 'iframe',
|
||||
id: 'qr-captcha-iframe'
|
||||
src: @noscriptURL
|
||||
src: @noscriptURL()
|
||||
$.add @nodes.container, iframe
|
||||
@conn.target = iframe.contentWindow
|
||||
|
||||
@ -120,7 +125,7 @@ Captcha.v2 =
|
||||
return
|
||||
|
||||
setupIFrame: (iframe) ->
|
||||
@setupTime = Date.now()
|
||||
Captcha.language.fixIframe iframe
|
||||
$.addClass QR.nodes.el, 'captcha-open'
|
||||
if QR.nodes.el.getBoundingClientRect().bottom > doc.clientHeight
|
||||
QR.nodes.el.style.top = null
|
||||
@ -202,7 +207,7 @@ Captcha.v2 =
|
||||
|
||||
reload: ->
|
||||
if @noscript
|
||||
$('iframe', @nodes.container).src = @noscriptURL
|
||||
$('iframe', @nodes.container).src = @noscriptURL()
|
||||
else
|
||||
$.globalEval '''
|
||||
(function() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user