Transition from siteSoftware to extensible siteProperties.
This commit is contained in:
parent
2b59c9e380
commit
929fac05ca
@ -467,6 +467,12 @@ Settings =
|
||||
delete data[db].boards
|
||||
delete data[db].lastChecked
|
||||
set db, data[db]
|
||||
if data['siteSoftware']? and not data['siteProperties']?
|
||||
siteProperties = {}
|
||||
for line in data['siteSoftware'].split('\n')
|
||||
[hostname, software] = line.split(' ')
|
||||
siteProperties[hostname] = {software}
|
||||
set 'siteProperties', siteProperties
|
||||
changes
|
||||
|
||||
loadSettings: (data, cb) ->
|
||||
|
||||
@ -308,7 +308,7 @@ ThreadWatcher =
|
||||
excerpt or= "/#{boardID}/ - No.#{threadID}"
|
||||
|
||||
link = $.el 'a',
|
||||
href: SW[Site.swDict[siteID]].urls.thread({siteID, boardID, threadID})
|
||||
href: SW[Conf['siteProperties'][siteID]?.software]?.urls.thread({siteID, boardID, threadID}) or ''
|
||||
title: excerpt
|
||||
className: 'watcher-link'
|
||||
|
||||
|
||||
@ -1135,9 +1135,3 @@ Config =
|
||||
'updater.position': 'bottom: 0px; left: 0px;'
|
||||
'thread-watcher.position': 'top: 50px; left: 0px;'
|
||||
'qr.position': 'top: 50px; right: 0px;'
|
||||
|
||||
siteSoftware: """
|
||||
4chan.org yotsuba
|
||||
4channel.org yotsuba
|
||||
4cdn.org yotsuba
|
||||
"""
|
||||
|
||||
@ -67,6 +67,10 @@ Main =
|
||||
Conf['cooldowns'] = {}
|
||||
Conf['Index Sort'] = {}
|
||||
Conf["Last Long Reply Thresholds #{i}"] = {} for i in [0...2]
|
||||
Conf['siteProperties'] =
|
||||
'4chan.org': {software: 'yotsuba'}
|
||||
'4channel.org': {software: 'yotsuba'}
|
||||
'4cdn.org': {software: 'yotsuba'}
|
||||
|
||||
# XXX old key names
|
||||
Conf['Except Archives from Encryption'] = false
|
||||
@ -76,6 +80,11 @@ Main =
|
||||
Conf['QR Shortcut'] = true
|
||||
Conf['Bottom QR Link'] = true
|
||||
Conf['Toggleable Thread Watcher'] = true
|
||||
Conf['siteSoftware'] = """
|
||||
4chan.org yotsuba
|
||||
4channel.org yotsuba
|
||||
4cdn.org yotsuba
|
||||
"""
|
||||
|
||||
# Enforce JS whitelist
|
||||
if /\.4chan(?:nel)?\.org$/.test(location.hostname) and !$$('script:not([src])', d).filter((s) -> /this\[/.test(s.textContent)).length
|
||||
|
||||
@ -1,25 +1,23 @@
|
||||
Site =
|
||||
init: (cb) ->
|
||||
@swDict = {}
|
||||
for line in Conf['siteSoftware'].split('\n') when line[0] isnt '#'
|
||||
[hostname, software] = line.split(' ')
|
||||
@swDict[hostname] = software if software of SW
|
||||
{hostname} = location
|
||||
while hostname and hostname not of @swDict
|
||||
while hostname and hostname not of Conf['siteProperties']
|
||||
hostname = hostname.replace(/^[^.]*\.?/, '')
|
||||
hostname = '4chan.org' if hostname is '4channel.org'
|
||||
if hostname
|
||||
@set hostname, @swDict[hostname]
|
||||
if hostname and Conf['siteProperties'][hostname].software of SW
|
||||
@set hostname, Conf['siteProperties'][hostname]
|
||||
cb()
|
||||
else
|
||||
$.onExists doc, 'body', =>
|
||||
for software of SW
|
||||
if SW[software].detect?()
|
||||
@set location.hostname.replace(/^www\./, ''), software
|
||||
Conf['siteSoftware'] += "\n#{@hostname} #{@software}"
|
||||
$.set 'siteSoftware', Conf['siteSoftware']
|
||||
properties = {software}
|
||||
@set location.hostname.replace(/^www\./, ''), properties
|
||||
Conf['siteProperties'][@hostname] = properties
|
||||
$.set 'siteProperties', Conf['siteProperties']
|
||||
cb()
|
||||
return
|
||||
|
||||
set: (@hostname, @software) ->
|
||||
set: (@hostname, @properties) ->
|
||||
@software = @properties.software
|
||||
$.extend @, SW[@software]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user