diff --git a/src/General/Settings.coffee b/src/General/Settings.coffee index 40013583e..8953ebc62 100644 --- a/src/General/Settings.coffee +++ b/src/General/Settings.coffee @@ -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) -> diff --git a/src/Monitoring/ThreadWatcher.coffee b/src/Monitoring/ThreadWatcher.coffee index 707db7296..7916ea31b 100644 --- a/src/Monitoring/ThreadWatcher.coffee +++ b/src/Monitoring/ThreadWatcher.coffee @@ -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' diff --git a/src/config/Config.coffee b/src/config/Config.coffee index b3eb5efcf..51dcb2a41 100644 --- a/src/config/Config.coffee +++ b/src/config/Config.coffee @@ -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 - """ diff --git a/src/main/Main.coffee b/src/main/Main.coffee index dfcee73dc..77216b6cd 100644 --- a/src/main/Main.coffee +++ b/src/main/Main.coffee @@ -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 diff --git a/src/site/Site.coffee b/src/site/Site.coffee index 5c79ea4cf..a95b470d0 100644 --- a/src/site/Site.coffee +++ b/src/site/Site.coffee @@ -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]