diff --git a/src/Archive/Redirect.coffee b/src/Archive/Redirect.coffee
index c7ec71f3d..683398a39 100644
--- a/src/Archive/Redirect.coffee
+++ b/src/Archive/Redirect.coffee
@@ -127,7 +127,7 @@ Redirect =
url
file: (archive, {boardID, filename}) ->
- filename = encodeURIComponent Build.unescape decodeURIComponent filename if boardID is 'f'
+ filename = encodeURIComponent $.unescape decodeURIComponent filename if boardID is 'f'
"#{Redirect.protocol archive}#{archive.domain}/#{boardID}/full_image/#{filename}"
board: (archive, {boardID}) ->
diff --git a/src/Filtering/Filter.coffee b/src/Filtering/Filter.coffee
index 43ceeabc1..d0cb2ce64 100644
--- a/src/Filtering/Filter.coffee
+++ b/src/Filtering/Filter.coffee
@@ -103,10 +103,9 @@ Filter =
for boardID in boardsRaw.split(',')
if ':' in boardID
[siteFilter, boardID] = boardID.split(':')[-2..]
- for siteID, siteProperties of Conf['siteProperties']
- continue if siteProperties.canonical or siteID[...siteFilter.length] isnt siteFilter
+ for siteID, site of g.sites when siteID[...siteFilter.length] is siteFilter
if boardID in ['nsfw', 'sfw']
- for boardID2 in SW[siteProperties.software]?.sfwBoards?(boardID is 'sfw') or []
+ for boardID2 in site.sfwBoards?(boardID is 'sfw') or []
boards["#{siteID}/#{boardID2}"] = true
else
boards["#{siteID}/#{encodeURIComponent boardID}"] = true
diff --git a/src/General/Build.coffee b/src/General/Build.coffee
index 267902d97..282c428a3 100644
--- a/src/General/Build.coffee
+++ b/src/General/Build.coffee
@@ -3,11 +3,6 @@ Build =
gifIcon: if window.devicePixelRatio >= 2 then '@2x.gif' else '.gif'
spoilerRange: {}
- unescape: (text) ->
- return text unless text?
- text.replace(/<[^>]*>/g, '').replace /&(amp|#039|quot|lt|gt|#44);/g, (c) ->
- (({'&': '&', ''': "'", '"': '"', '<': '<', '>': '>', ',': ','})[c])
-
shortFilename: (filename) ->
ext = filename.match(/\.?[^\.]*$/)[0]
if filename.length - ext.length > 30
@@ -51,15 +46,15 @@ Build =
# file status
fileDeleted: !!data.filedeleted
o.info =
- subject: Build.unescape data.sub
- email: Build.unescape data.email
- name: Build.unescape(data.name) or ''
+ subject: $.unescape data.sub
+ email: $.unescape data.email
+ name: $.unescape(data.name) or ''
tripcode: data.trip
pass: if data.since4pass? then "#{data.since4pass}" else undefined
uniqueID: data.id
flagCode: data.country
flagCodeTroll: data.troll_country
- flag: Build.unescape data.country_name
+ flag: $.unescape data.country_name
dateUTC: data.time
dateText: data.now
commentHTML: {innerHTML: data.com or ''}
@@ -69,7 +64,7 @@ Build =
delete o.info.uniqueID
if data.ext
o.file =
- name: (Build.unescape data.filename) + data.ext
+ name: ($.unescape data.filename) + data.ext
url: if boardID is 'f'
"#{location.protocol}//#{ImageHost.flashHost()}/#{boardID}/#{encodeURIComponent data.filename}#{data.ext}"
else
@@ -95,7 +90,7 @@ Build =
.replace(/
/gi, '\n')
.replace(/\n\n]*>/g, '')
- Build.unescape html
+ $.unescape html
parseCommentDisplay: (html) ->
# Hide spoilers.
@@ -252,9 +247,9 @@ Build =
if data.com
excerpt = Build.parseCommentDisplay(data.com).replace(/>>\d+/g, '').trim().replace(/\n+/g, ' // ')
if data.ext
- excerpt or= "#{Build.unescape data.filename}#{data.ext}"
+ excerpt or= "#{$.unescape data.filename}#{data.ext}"
if data.com
- excerpt or= Build.unescape data.com.replace(/
/gi, ' // ')
+ excerpt or= $.unescape data.com.replace(/
/gi, ' // ')
excerpt or= '\xA0'
excerpt = "#{excerpt[...70]}..." if excerpt.length > 73
diff --git a/src/Monitoring/ThreadWatcher.coffee b/src/Monitoring/ThreadWatcher.coffee
index 3cdbe7815..991f32536 100644
--- a/src/Monitoring/ThreadWatcher.coffee
+++ b/src/Monitoring/ThreadWatcher.coffee
@@ -264,16 +264,16 @@ ThreadWatcher =
return unless board.some (thread) -> !thread.data.isDead
force = Conf['Show Page'] and board.some((thread) -> !thread.data.page? and !thread.data.isDead and thread.data.last isnt -1)
{siteID, boardID} = board[0]
- software = Conf['siteProperties'][siteID]?.software
- urlF = if deep and software is 'tinyboard' then 'catalogJSON' else 'threadsListJSON'
- url = SW[software]?.urls[urlF]?({siteID, boardID})
+ site = g.sites[siteID]
+ return unless site
+ urlF = if deep and site.software is 'tinyboard' then 'catalogJSON' else 'threadsListJSON'
+ url = site.urls[urlF]?({siteID, boardID})
return unless url
ThreadWatcher.fetch url, {siteID, force}, [board, url], ThreadWatcher.parseBoard
parseBoard: (board, url) ->
return unless @status is 200
{siteID, boardID} = board[0]
- software = Conf['siteProperties'][siteID]?.software
lmDate = @getResponseHeader('Last-Modified')
ThreadWatcher.dbLM.extend {siteID, boardID, val: $.item(url, lmDate)}
threads = {}
@@ -300,7 +300,7 @@ ThreadWatcher =
if threads[threadID]
{page, index, modified, replies} = threads[threadID]
if Conf['Show Page']
- lastPage = if SW[software]?.isPrunedByAge?({siteID, boardID})
+ lastPage = if g.sites[siteID].isPrunedByAge?({siteID, boardID})
threadID is oldest
else
index >= nThreads - pageLength
@@ -318,16 +318,13 @@ ThreadWatcher =
fetchStatus: (thread) ->
{siteID, boardID, threadID, data, force} = thread
- software = Conf['siteProperties'][siteID]?.software
- url = SW[software]?.urls.threadJSON?({siteID, boardID, threadID})
+ url = g.sites[siteID]?.urls.threadJSON?({siteID, boardID, threadID})
return unless url
return if data.isDead and not force
return if data.last is -1 # 404 or no JSON API
ThreadWatcher.fetch url, {siteID, force}, [thread], ThreadWatcher.parseStatus
parseStatus: ({siteID, boardID, threadID, data, newData}) ->
- software = Conf['siteProperties'][siteID]?.software
-
if @status is 200 and @response
last = @response.posts[@response.posts.length-1].no
replies = @response.posts.length-1
@@ -356,7 +353,7 @@ ThreadWatcher =
continue unless !quotingYou and QuoteYou.db and postObj.com
quotesYou = false
- regexp = SW[software].regexp.quotelinkHTML
+ regexp = g.sites[siteID].regexp.quotelinkHTML
regexp.lastIndex = 0
while match = regexp.exec postObj.com
if QuoteYou.db.get {
@@ -375,7 +372,7 @@ ThreadWatcher =
ThreadWatcher.update siteID, boardID, threadID, newData
else if @status is 404
- if SW[software].mayLackJSON and !data.last?
+ if g.sites[siteID].mayLackJSON and !data.last?
ThreadWatcher.update siteID, boardID, threadID, {last: -1}
else
ThreadWatcher.update siteID, boardID, threadID, {isDead: true}
@@ -393,8 +390,6 @@ ThreadWatcher =
all
makeLine: (siteID, boardID, threadID, data) ->
- software = Conf['siteProperties'][siteID]?.software
-
x = $.el 'a',
className: 'fa fa-times'
href: 'javascript:;'
@@ -405,7 +400,7 @@ ThreadWatcher =
excerpt = ThreadWatcher.prefixes[siteID] + excerpt if Conf['Show Site Prefix']
link = $.el 'a',
- href: SW[software]?.urls.thread({siteID, boardID, threadID}) or ''
+ href: g.sites[siteID]?.urls.thread({siteID, boardID, threadID}) or ''
title: excerpt
className: 'watcher-link'
diff --git a/src/platform/$.coffee b/src/platform/$.coffee
index 3d13c7ee9..356e552be 100644
--- a/src/platform/$.coffee
+++ b/src/platform/$.coffee
@@ -463,6 +463,11 @@ $.hasAudio = (video) ->
$.luma = (rgb) ->
rgb[0] * 0.299 + rgb[1] * 0.587 + rgb[2] * 0.114
+$.unescape = (text) ->
+ return text unless text?
+ text.replace(/<[^>]*>/g, '').replace /&(amp|#039|quot|lt|gt|#44);/g, (c) ->
+ (({'&': '&', ''': "'", '"': '"', '<': '<', '>': '>', ',': ','})[c])
+
$.engine = do ->
return 'edge' if /Edge\//.test navigator.userAgent
return 'blink' if /Chrome\//.test navigator.userAgent