Recheck site properties every load.

This commit is contained in:
ccd0 2018-12-05 10:26:32 -08:00
parent 929fac05ca
commit d49fbd3b0b
2 changed files with 19 additions and 12 deletions

View File

@ -44,7 +44,7 @@ SW.tinyboard =
detect: -> detect: ->
for script in $$ 'script:not([src])', d.head for script in $$ 'script:not([src])', d.head
return true if /\bvar configRoot=".*?"/.test(script.textContent) return {} if /\bvar configRoot=".*?"/.test(script.textContent)
false false
urls: urls:

View File

@ -5,19 +5,26 @@ Site =
hostname = hostname.replace(/^[^.]*\.?/, '') hostname = hostname.replace(/^[^.]*\.?/, '')
hostname = '4chan.org' if hostname is '4channel.org' hostname = '4chan.org' if hostname is '4channel.org'
if hostname and Conf['siteProperties'][hostname].software of SW if hostname and Conf['siteProperties'][hostname].software of SW
@set hostname, Conf['siteProperties'][hostname] @set hostname
cb() cb()
else $.onExists doc, 'body', =>
$.onExists doc, 'body', => for software of SW when (changes = SW[software].detect?())
for software of SW changes.software = software
if SW[software].detect?() hostname = location.hostname.replace(/^www\./, '')
properties = {software} properties = (Conf['siteProperties'][hostname] or= {})
@set location.hostname.replace(/^www\./, ''), properties changed = 0
Conf['siteProperties'][@hostname] = properties for key of changes when properties[key] isnt changes[key]
$.set 'siteProperties', Conf['siteProperties'] properties[key] = changes[key]
cb() changed++
if changed
$.set 'siteProperties', Conf['siteProperties']
unless @hostname
@set hostname
cb()
return return
return
set: (@hostname, @properties) -> set: (@hostname) ->
@properties = Conf['siteProperties'][@hostname]
@software = @properties.software @software = @properties.software
$.extend @, SW[@software] $.extend @, SW[@software]