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

View File

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

View File

@ -28,7 +28,7 @@ Settings =
settings.disableAll = true settings.disableAll = true
localStorage.setItem '4chan-settings', JSON.stringify settings localStorage.setItem '4chan-settings', JSON.stringify settings
else else
$.onExists doc, 'body', false, -> $.onExists doc, 'body', ->
$.global -> window.Config.disableAll = true $.global -> window.Config.disableAll = true
open: (openSection) -> 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"). Enable it on boards.4chan.org in your browser's privacy settings (may be listed as part of "local data" or "cookies").
""" """
ads: (cb) -> ads: (cb) ->
$.onExists doc, '.ad-cnt', true, (ad) -> $.onExists ad, 'img', true, -> $.onExists doc, '.ad-cnt', (ad) -> $.onExists ad, 'img', ->
cb $.el 'li', cb $.el 'li',
<%= html( <%= html(
'To protect yourself from <a href="//boards.4chan.org/qa/thread/362590" target="_blank">malicious ads</a>,' + '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' Report.fit 'body'
if !Conf['Use Recaptcha v2 in Reports'] and Main.jsEnabled and d.cookie.indexOf('pass_enabled=1') < 0 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. # XXX Native reload-on-click breaks audio captcha.
$.global -> document.getElementById('recaptcha_image').removeEventListener 'click', window.onAltCaptchaClick, false $.global -> document.getElementById('recaptcha_image').removeEventListener 'click', window.onAltCaptchaClick, false
$.on image, 'click', -> $.on image, 'click', ->
if $.id 'recaptcha_challenge_image' if $.id 'recaptcha_challenge_image'
$.global -> window.Recaptcha.reload() $.global -> window.Recaptcha.reload()
$.onExists d.body, '#recaptcha_response_field', true, (field) -> $.onExists d.body, '#recaptcha_response_field', (field) ->
$.on field, 'keydown', (e) -> $.on field, 'keydown', (e) ->
if e.keyCode is 8 and not field.value if e.keyCode is 8 and not field.value
$.global -> window.Recaptcha.reload() $.global -> window.Recaptcha.reload()

View File

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

View File

@ -18,9 +18,9 @@ Captcha.replace =
if Conf['captchaLanguage'].trim() or Conf['Captcha Fixes'] 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', (node) -> $.onExists node, 'iframe', Captcha.replace.iframe
else else
$.onExists doc, 'iframe', true, Captcha.replace.iframe $.onExists doc, 'iframe', Captcha.replace.iframe
noscript: -> noscript: ->
return unless (original = $ '#g-recaptcha, #captchaContainerAlt') and (noscript = $ 'noscript') return unless (original = $ '#g-recaptcha, #captchaContainerAlt') and (noscript = $ 'noscript')
@ -61,7 +61,7 @@ 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 $.onExists d.body, 'iframe', Captcha.replace.autocopy
iframe: (iframe) -> iframe: (iframe) ->
if (lang = Conf['captchaLanguage'].trim()) if (lang = Conf['captchaLanguage'].trim())