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