Remove subtree argument from $.onExists.

This commit is contained in:
ccd0 2015-12-05 17:49:24 -08:00
parent 05b13d4fdd
commit b8082e3092
6 changed files with 15 additions and 15 deletions

View File

@ -120,25 +120,25 @@ $.asap = (test, cb) ->
else
setTimeout $.asap, 25, test, cb
$.onExists = (root, selector, subtree, cb) ->
$.onExists = (root, selector, cb) ->
if el = $ selector, root
return cb el
# XXX Edge doesn't notify MutationObservers of nodes added as document loads.
if $.engine is 'edge' and d.readyState is 'loading'
$.asap (-> d.readyState isnt 'loading' or $ selector, root), ->
$.onExists root, selector, subtree, cb
$.onExists root, selector, cb
return
observer = new MutationObserver ->
if el = $ selector, root
observer.disconnect()
cb el
observer.observe root, {childList: true, subtree}
observer.observe root, {childList: true, subtree: true}
$.addStyle = (css, id, test='head') ->
style = $.el 'style',
textContent: css
style.id = id if id?
$.onExists doc, test, true, ->
$.onExists doc, test, ->
$.add d.head, style
style

View File

@ -85,7 +85,7 @@ Main =
switch hostname
when 'www.4chan.org'
$.onExists doc, 'body', false, -> $.addStyle Main.cssWWW
$.onExists doc, 'body', -> $.addStyle Main.cssWWW
Captcha.replace.init()
return
when 'sys.4chan.org'
@ -132,7 +132,7 @@ Main =
g.posts = new SimpleDict()
# set up CSS when <head> is completely loaded
$.onExists doc, 'body', false, Main.initStyle
$.onExists doc, 'body', Main.initStyle
# c.time 'All initializations'
for [name, feature] in Main.features
@ -158,7 +158,7 @@ Main =
$.addClass doc, 'fourchan-x', 'seaweedchan'
$.addClass doc, if g.VIEW is 'thread' then 'thread-view' else g.VIEW
$.addClass doc, $.engine if $.engine
$.onExists doc, '.ad-cnt', true, (ad) -> $.onExists ad, 'img', true, -> $.addClass doc, 'ads-loaded'
$.onExists doc, '.ad-cnt', (ad) -> $.onExists ad, 'img', -> $.addClass doc, 'ads-loaded'
$.addStyle Main.css, 'fourchanx-css'
keyboard = false

View File

@ -28,7 +28,7 @@ Settings =
settings.disableAll = true
localStorage.setItem '4chan-settings', JSON.stringify settings
else
$.onExists doc, 'body', false, ->
$.onExists doc, 'body', ->
$.global -> window.Config.disableAll = true
open: (openSection) ->
@ -106,7 +106,7 @@ Settings =
Enable it on boards.4chan.org in your browser's privacy settings (may be listed as part of "local data" or "cookies").
"""
ads: (cb) ->
$.onExists doc, '.ad-cnt', true, (ad) -> $.onExists ad, 'img', true, ->
$.onExists doc, '.ad-cnt', (ad) -> $.onExists ad, 'img', ->
cb $.el 'li',
<%= html(
'To protect yourself from <a href="//boards.4chan.org/qa/thread/362590" target="_blank">malicious ads</a>,' +

View File

@ -39,13 +39,13 @@ Report =
Report.fit 'body'
if !Conf['Use Recaptcha v2 in Reports'] and Main.jsEnabled and d.cookie.indexOf('pass_enabled=1') < 0
$.onExists d.body, '#recaptcha_image', true, (image) ->
$.onExists d.body, '#recaptcha_image', (image) ->
# XXX Native reload-on-click breaks audio captcha.
$.global -> document.getElementById('recaptcha_image').removeEventListener 'click', window.onAltCaptchaClick, false
$.on image, 'click', ->
if $.id 'recaptcha_challenge_image'
$.global -> window.Recaptcha.reload()
$.onExists d.body, '#recaptcha_response_field', true, (field) ->
$.onExists d.body, '#recaptcha_response_field', (field) ->
$.on field, 'keydown', (e) ->
if e.keyCode is 8 and not field.value
$.global -> window.Recaptcha.reload()

View File

@ -49,7 +49,7 @@ Captcha.fixes =
when 'fallback' then @initNoscript()
initMain: ->
$.onExists d.body, '#recaptcha-anchor', true, (checkbox) ->
$.onExists d.body, '#recaptcha-anchor', (checkbox) ->
focus = ->
if d.hasFocus() and d.activeElement isnt checkbox
checkbox.focus()

View File

@ -18,9 +18,9 @@ Captcha.replace =
if Conf['captchaLanguage'].trim() or Conf['Captcha Fixes']
if location.hostname is 'boards.4chan.org'
$.onExists doc, '#captchaFormPart', true, (node) -> $.onExists node, 'iframe', true, Captcha.replace.iframe
$.onExists doc, '#captchaFormPart', (node) -> $.onExists node, 'iframe', Captcha.replace.iframe
else
$.onExists doc, 'iframe', true, Captcha.replace.iframe
$.onExists doc, 'iframe', Captcha.replace.iframe
noscript: ->
return unless (original = $ '#g-recaptcha, #captchaContainerAlt') and (noscript = $ 'noscript')
@ -61,7 +61,7 @@ Captcha.replace =
script = $.el 'script',
src: url
$.add d.head, script
$.onExists d.body, 'iframe', true, Captcha.replace.autocopy
$.onExists d.body, 'iframe', Captcha.replace.autocopy
iframe: (iframe) ->
if (lang = Conf['captchaLanguage'].trim())