diff --git a/src/Filtering/PostHiding.coffee b/src/Filtering/PostHiding.coffee
index ebabee867..52c662ed1 100644
--- a/src/Filtering/PostHiding.coffee
+++ b/src/Filtering/PostHiding.coffee
@@ -26,7 +26,7 @@ PostHiding =
return unless Conf['Reply Hiding Buttons']
button = PostHiding.makeButton @, 'hide'
- if (sa = Site.selectors.sideArrows)
+ if (sa = g.SITE.selectors.sideArrows)
sideArrows = $ sa, @nodes.root
$.replace sideArrows.firstChild, button
sideArrows.removeAttribute 'class'
diff --git a/src/Filtering/ThreadHiding.coffee b/src/Filtering/ThreadHiding.coffee
index b5352fc80..80f930f13 100644
--- a/src/Filtering/ThreadHiding.coffee
+++ b/src/Filtering/ThreadHiding.coffee
@@ -12,7 +12,7 @@ ThreadHiding =
cb: @node
catalogSet: (board) ->
- return unless $.hasStorage and Site.software is 'yotsuba'
+ return unless $.hasStorage and g.SITE.software is 'yotsuba'
hiddenThreads = ThreadHiding.db.get
boardID: board.ID
defaultValue: {}
@@ -20,7 +20,7 @@ ThreadHiding =
localStorage.setItem "4chan-hide-t-#{board}", JSON.stringify hiddenThreads
catalogWatch: ->
- return unless $.hasStorage and Site.software is 'yotsuba'
+ return unless $.hasStorage and g.SITE.software is 'yotsuba'
@hiddenThreads = JSON.parse(localStorage.getItem "4chan-hide-t-#{g.BOARD}") or {}
Main.ready ->
# 4chan's catalog sets the style to "display: none;" when hiding or unhiding a thread.
diff --git a/src/General/BoardConfig.coffee b/src/General/BoardConfig.coffee
index 842cd84da..d02b027b5 100644
--- a/src/General/BoardConfig.coffee
+++ b/src/General/BoardConfig.coffee
@@ -54,7 +54,7 @@ BoardConfig =
!data or data.is_archived
noAudio: (boardID) ->
- return false unless Site.software is 'yotsuba'
+ return false unless g.SITE.software is 'yotsuba'
boards = @boards or Conf['boardConfig'].boards
boards and boards[boardID] and !boards[boardID].webm_audio
diff --git a/src/General/Build.coffee b/src/General/Build.coffee
index 1bde00fa7..267902d97 100644
--- a/src/General/Build.coffee
+++ b/src/General/Build.coffee
@@ -42,7 +42,7 @@ Build =
ID: data.no
threadID: data.resto or data.no
boardID: boardID
- siteID: siteID or Site.hostname
+ siteID: siteID or g.SITE.ID
isReply: !!data.resto
# thread status
isSticky: !!data.sticky
diff --git a/src/General/Get.coffee b/src/General/Get.coffee
index 92a5ecbe7..b2438e5e7 100644
--- a/src/General/Get.coffee
+++ b/src/General/Get.coffee
@@ -13,20 +13,20 @@ Get =
{board} = root.dataset
g.threads["#{if board then encodeURIComponent(board) else g.BOARD.ID}.#{root.id.match(/\d*$/)[0]}"]
threadFromNode: (node) ->
- Get.threadFromRoot $.x "ancestor-or-self::#{Site.xpath.thread}", node
+ Get.threadFromRoot $.x "ancestor-or-self::#{g.SITE.xpath.thread}", node
postFromRoot: (root) ->
return null unless root?
post = g.posts[root.dataset.fullID]
index = root.dataset.clone
if index then post.clones[index] else post
postFromNode: (root) ->
- Get.postFromRoot $.x "ancestor-or-self::#{Site.xpath.postContainer}[1]", root
+ Get.postFromRoot $.x "ancestor-or-self::#{g.SITE.xpath.postContainer}[1]", root
postDataFromLink: (link) ->
if link.dataset.postID # resurrected quote
{boardID, threadID, postID} = link.dataset
threadID or= 0
else
- match = link.href.match Site.regexp.quotelink
+ match = link.href.match g.SITE.regexp.quotelink
[boardID, threadID, postID] = match[1..]
postID or= threadID
return {
diff --git a/src/General/Header.coffee b/src/General/Header.coffee
index 2cd3060f2..a19b2e072 100644
--- a/src/General/Header.coffee
+++ b/src/General/Header.coffee
@@ -92,7 +92,7 @@ Header =
$.add d.body, Header.hover
@setBarPosition Conf['Bottom Header']
- $.onExists doc, "#{Site.selectors.boardList} + *", Header.generateFullBoardList
+ $.onExists doc, "#{g.SITE.selectors.boardList} + *", Header.generateFullBoardList
Main.ready ->
if not (footer = $.id 'boardNavDesktopFoot')
@@ -165,7 +165,7 @@ Header =
generateFullBoardList: ->
nodes = []
spacer = -> $.el 'span', className: 'spacer'
- items = $.X './/a|.//text()[not(ancestor::a)]', $(Site.selectors.boardList)
+ items = $.X './/a|.//text()[not(ancestor::a)]', $(g.SITE.selectors.boardList)
i = 0
while node = items.snapshotItem i++
switch node.nodeName
diff --git a/src/General/Index.coffee b/src/General/Index.coffee
index 6f72b0c92..99bf91638 100644
--- a/src/General/Index.coffee
+++ b/src/General/Index.coffee
@@ -592,7 +592,7 @@ Index =
return
Index.req = $.whenModified(
- Site.urls.catalogJSON({boardID: g.BOARD.ID}),
+ g.SITE.urls.catalogJSON({boardID: g.BOARD.ID}),
'Index',
Index.load
)
diff --git a/src/General/Settings.coffee b/src/General/Settings.coffee
index 535a3022e..2a04731d5 100644
--- a/src/General/Settings.coffee
+++ b/src/General/Settings.coffee
@@ -199,7 +199,7 @@ Settings =
$.on button, 'click', ->
@textContent = 'Hidden: 0'
$.get 'hiddenThreads', {}, ({hiddenThreads}) ->
- if $.hasStorage and Site.software is 'yotsuba'
+ if $.hasStorage and g.SITE.software is 'yotsuba'
for boardID of hiddenThreads.boards
localStorage.removeItem "4chan-hide-t-#{boardID}"
($.delete ['hiddenThreads', 'hiddenPosts'])
diff --git a/src/General/Test.coffee b/src/General/Test.coffee
index 8aefef9e4..60b1ddd87 100644
--- a/src/General/Test.coffee
+++ b/src/General/Test.coffee
@@ -65,7 +65,7 @@ Test =
testOne: (post) ->
Test.postsRemaining++
- $.cache Site.urls.threadJSON({boardID: post.boardID, threadID: post.threadID}), ->
+ $.cache g.SITE.urls.threadJSON({boardID: post.boardID, threadID: post.threadID}), ->
return unless @response
{posts} = @response
Build.spoilerRange[post.board.ID] = posts[0].custom_spoiler
diff --git a/src/Images/Gallery.coffee b/src/Images/Gallery.coffee
index cbd881282..d5c681d65 100644
--- a/src/Images/Gallery.coffee
+++ b/src/Images/Gallery.coffee
@@ -82,7 +82,7 @@ Gallery =
$.on window, 'resize', Gallery.cb.setHeight
- for postThumb in $$ Site.selectors.file.thumb
+ for postThumb in $$ g.SITE.selectors.file.thumb
continue unless (post = Get.postFromNode postThumb)
continue unless post.file?.thumb
Gallery.generateThumb post
diff --git a/src/Images/ImageCommon.coffee b/src/Images/ImageCommon.coffee
index b7e0b7242..2a42d4b8c 100644
--- a/src/Images/ImageCommon.coffee
+++ b/src/Images/ImageCommon.coffee
@@ -54,7 +54,7 @@ ImageCommon =
clearTimeout timeoutID if delay?
cb URL
- $.ajax Site.urls.threadJSON({boardID: post.boardID, threadID: post.threadID}), onloadend: ->
+ $.ajax g.SITE.urls.threadJSON({boardID: post.boardID, threadID: post.threadID}), onloadend: ->
post.kill !post.isClone if @status is 404
return redirect() if @status isnt 200
for postObj in @response.posts
diff --git a/src/Images/ImageHover.coffee b/src/Images/ImageHover.coffee
index d9cd67149..0dbdc4e12 100644
--- a/src/Images/ImageHover.coffee
+++ b/src/Images/ImageHover.coffee
@@ -23,7 +23,7 @@ ImageHover =
return unless doc.contains @
{file} = post
{isVideo} = file
- return if file.isExpanding or file.isExpanded or Site.isThumbExpanded?(file)
+ return if file.isExpanding or file.isExpanded or g.SITE.isThumbExpanded?(file)
error = ImageHover.error post
if ImageCommon.cache?.dataset.fullID is post.fullID
el = ImageCommon.popCache()
diff --git a/src/Miscellaneous/CatalogLinks.coffee b/src/Miscellaneous/CatalogLinks.coffee
index 8fed1ede7..91c91a8c3 100644
--- a/src/Miscellaneous/CatalogLinks.coffee
+++ b/src/Miscellaneous/CatalogLinks.coffee
@@ -1,6 +1,6 @@
CatalogLinks =
init: ->
- if Site.software is 'yotsuba' and (Conf['External Catalog'] or Conf['JSON Index']) and !(Conf['JSON Index'] and g.VIEW is 'index')
+ if g.SITE.software is 'yotsuba' and (Conf['External Catalog'] or Conf['JSON Index']) and !(Conf['JSON Index'] and g.VIEW is 'index')
selector = switch g.VIEW
when 'thread', 'archive' then '.navLinks.desktop > a'
when 'catalog' then '.navLinks > :first-child > a'
@@ -20,7 +20,7 @@ CatalogLinks =
$.after link.parentNode, [$.tn(' '), catalogLink]
return
- if Site.software is 'yotsuba' and Conf['JSON Index'] and Conf['Use <%= meta.name %> Catalog']
+ if g.SITE.software is 'yotsuba' and Conf['JSON Index'] and Conf['Use <%= meta.name %> Catalog']
Callbacks.Post.push
name: 'Catalog Link Rewrite'
cb: @node
diff --git a/src/Miscellaneous/ExpandComment.coffee b/src/Miscellaneous/ExpandComment.coffee
index 6fbf847e0..3bbbd3d7b 100644
--- a/src/Miscellaneous/ExpandComment.coffee
+++ b/src/Miscellaneous/ExpandComment.coffee
@@ -23,7 +23,7 @@ ExpandComment =
return
return if not (a = $ '.abbr > a', post.nodes.comment)
a.textContent = "Post No.#{post} Loading..."
- $.cache Site.urls.threadJSON({boardID: post.boardID, threadID: post.threadID}), -> ExpandComment.parse @, a, post
+ $.cache g.SITE.urls.threadJSON({boardID: post.boardID, threadID: post.threadID}), -> ExpandComment.parse @, a, post
contract: (post) ->
return unless post.nodes.shortComment
diff --git a/src/Miscellaneous/ExpandThread.coffee b/src/Miscellaneous/ExpandThread.coffee
index cf525d00e..9a270a62d 100644
--- a/src/Miscellaneous/ExpandThread.coffee
+++ b/src/Miscellaneous/ExpandThread.coffee
@@ -54,7 +54,7 @@ ExpandThread =
expand: (thread, a) ->
ExpandThread.statuses[thread] = status = {}
a.textContent = Build.summaryText '...', a.textContent.match(/\d+/g)...
- status.req = $.cache Site.urls.threadJSON({boardID: thread.board.ID, threadID: thread.ID}), ->
+ status.req = $.cache g.SITE.urls.threadJSON({boardID: thread.board.ID, threadID: thread.ID}), ->
return if @ isnt status.req # aborted
delete status.req
ExpandThread.parse @, thread, a
diff --git a/src/Miscellaneous/Fourchan.coffee b/src/Miscellaneous/Fourchan.coffee
index 7fba2af7f..186576ec4 100644
--- a/src/Miscellaneous/Fourchan.coffee
+++ b/src/Miscellaneous/Fourchan.coffee
@@ -1,6 +1,6 @@
Fourchan =
init: ->
- return unless Site.software is 'yotsuba' and g.VIEW in ['index', 'thread', 'archive']
+ return unless g.SITE.software is 'yotsuba' and g.VIEW in ['index', 'thread', 'archive']
BoardConfig.ready @initBoard
Main.ready @initReady
diff --git a/src/Miscellaneous/Tinyboard.coffee b/src/Miscellaneous/Tinyboard.coffee
index b4865bdb1..7d0b3e512 100644
--- a/src/Miscellaneous/Tinyboard.coffee
+++ b/src/Miscellaneous/Tinyboard.coffee
@@ -1,6 +1,6 @@
Tinyboard =
init: ->
- return unless Site.software is 'tinyboard'
+ return unless g.SITE.software is 'tinyboard'
if g.VIEW is 'thread'
Main.ready ->
$.global ->
diff --git a/src/Monitoring/ThreadStats.coffee b/src/Monitoring/ThreadStats.coffee
index 014cd8a67..1acc3cc5e 100644
--- a/src/Monitoring/ThreadStats.coffee
+++ b/src/Monitoring/ThreadStats.coffee
@@ -76,7 +76,7 @@ ThreadStats =
return
ThreadStats.timeout = setTimeout ThreadStats.fetchPage, 2 * $.MINUTE
$.whenModified(
- Site.urls.threadsListJSON({boardID: ThreadStats.thread.board}),
+ g.SITE.urls.threadsListJSON({boardID: ThreadStats.thread.board}),
'ThreadStats',
ThreadStats.onThreadsLoad
)
diff --git a/src/Monitoring/ThreadUpdater.coffee b/src/Monitoring/ThreadUpdater.coffee
index 99e16b8d3..74925d5e7 100644
--- a/src/Monitoring/ThreadUpdater.coffee
+++ b/src/Monitoring/ThreadUpdater.coffee
@@ -138,7 +138,7 @@ ThreadUpdater =
ThreadUpdater.setInterval()
when 404
# XXX workaround for 4chan sending false 404s
- $.ajax Site.urls.catalogJSON({boardID: ThreadUpdater.thread.board.ID}), onloadend: ->
+ $.ajax g.SITE.urls.catalogJSON({boardID: ThreadUpdater.thread.board.ID}), onloadend: ->
if @status is 200
confirmed = true
for page in @response
@@ -234,7 +234,7 @@ ThreadUpdater =
delete ThreadUpdater.req
oldReq.abort()
ThreadUpdater.req = $.whenModified(
- Site.urls.threadJSON({boardID: ThreadUpdater.thread.board.ID, threadID: ThreadUpdater.thread.ID}),
+ g.SITE.urls.threadJSON({boardID: ThreadUpdater.thread.board.ID, threadID: ThreadUpdater.thread.ID}),
'ThreadUpdater',
ThreadUpdater.cb.load,
{timeout: $.MINUTE}
diff --git a/src/Monitoring/ThreadWatcher.coffee b/src/Monitoring/ThreadWatcher.coffee
index 53cdbe12f..ae376ac98 100644
--- a/src/Monitoring/ThreadWatcher.coffee
+++ b/src/Monitoring/ThreadWatcher.coffee
@@ -93,7 +93,7 @@ ThreadWatcher =
href: 'javascript:;'
className: 'watch-thread-link'
$.before $('input', @nodes.info), toggler
- siteID = Site.hostname
+ siteID = g.SITE.ID
boardID = @board.ID
threadID = @thread.ID
data = ThreadWatcher.db.get {siteID, boardID, threadID}
@@ -148,7 +148,7 @@ ThreadWatcher =
ThreadWatcher.add g.threads[boardID + '.' + threadID] or new Thread(threadID, g.boards[boardID] or new Board(boardID))
onIndexUpdate: (e) ->
{db} = ThreadWatcher
- siteID = Site.hostname
+ siteID = g.SITE.ID
boardID = g.BOARD.ID
nKilled = 0
for threadID, data of db.data[siteID].boards[boardID] when not data?.isDead and "#{boardID}.#{threadID}" not in e.detail.threads
@@ -185,7 +185,7 @@ ThreadWatcher =
else
ThreadWatcher.status.textContent = "#{Math.round(ThreadWatcher.fetched / ThreadWatcher.requests.length * 100)}%"
cb.apply @, args
- ajax = if siteID is Site.hostname then $.ajax else CrossOrigin.ajax
+ ajax = if siteID is g.SITE.ID then $.ajax else CrossOrigin.ajax
if force
delete $.lastModified.ThreadWatcher?[url]
req = $.whenModified(
@@ -382,7 +382,7 @@ ThreadWatcher =
all = []
for siteID, boards of ThreadWatcher.db.data
for boardID, threads of boards.boards
- if Conf['Current Board'] and (siteID isnt Site.hostname or boardID isnt g.BOARD.ID)
+ if Conf['Current Board'] and (siteID isnt g.SITE.ID or boardID isnt g.BOARD.ID)
continue
if groupByBoard
all.push (cont = [])
@@ -466,7 +466,7 @@ ThreadWatcher =
ThreadWatcher.setPrefixes threads
for {siteID, boardID, threadID, data} in threads
# Add missing excerpt for threads added by Auto Watch
- if not data.excerpt? and siteID is Site.hostname and (thread = g.threads["#{boardID}.#{threadID}"]) and thread.OP
+ if not data.excerpt? and siteID is g.SITE.ID and (thread = g.threads["#{boardID}.#{threadID}"]) and thread.OP
ThreadWatcher.db.extend {boardID, threadID, val: {excerpt: Get.threadExcerpt thread}}
nodes.push ThreadWatcher.makeLine siteID, boardID, threadID, data
{list} = ThreadWatcher
@@ -522,7 +522,7 @@ ThreadWatcher =
ThreadWatcher.db.extend {boardID, threadID, val: {isDead: true, page: undefined, lastPage: undefined, unread: undefined, quotingYou: undefined}}, cb
toggle: (thread) ->
- siteID = Site.hostname
+ siteID = g.SITE.ID
boardID = thread.board.ID
threadID = thread.ID
if ThreadWatcher.db.get {boardID, threadID}
@@ -532,7 +532,7 @@ ThreadWatcher =
add: (thread) ->
data = {}
- siteID = Site.hostname
+ siteID = g.SITE.ID
boardID = thread.board.ID
threadID = thread.ID
if thread.isDead
@@ -546,7 +546,7 @@ ThreadWatcher =
addRaw: (boardID, threadID, data) ->
ThreadWatcher.db.set {boardID, threadID, val: data}
ThreadWatcher.refresh()
- thread = {siteID: Site.hostname, boardID, threadID, data, force: true}
+ thread = {siteID: g.SITE.ID, boardID, threadID, data, force: true}
if Conf['Show Page'] and !data.isDead
ThreadWatcher.fetchBoard [thread]
else if ThreadWatcher.unreadEnabled and Conf['Show Unread Count']
diff --git a/src/Monitoring/Unread.coffee b/src/Monitoring/Unread.coffee
index 2f39d0775..33e3ee0c2 100644
--- a/src/Monitoring/Unread.coffee
+++ b/src/Monitoring/Unread.coffee
@@ -34,7 +34,7 @@ Unread =
textContent: 'Test Post Order'
$.on testLink, 'click', ->
list1 = (x.ID for x in Unread.order.order())
- list2 = (+x.id.match(/\d*$/)[0] for x in $$ (if Site.isOPContainerThread then "#{Site.selectors.thread}, " else '') + Site.selectors.postContainer)
+ list2 = (+x.id.match(/\d*$/)[0] for x in $$ (if g.SITE.isOPContainerThread then "#{g.SITE.selectors.thread}, " else '') + g.SITE.selectors.postContainer)
pass = do ->
return false unless list1.length is list2.length
for i in [0...list1.length] by 1
@@ -223,7 +223,7 @@ Unread =
Unread.saveThreadWatcherCount()
- if Conf['Unread Favicon'] and Site.software is 'yotsuba'
+ if Conf['Unread Favicon'] and g.SITE.software is 'yotsuba'
{isDead} = Unread.thread
Favicon.el.href =
if countQuotingYou
@@ -238,7 +238,7 @@ Unread =
saveThreadWatcherCount: $.debounce 2 * $.SECOND, ->
$.forceSync 'Remember Last Read Post'
if Conf['Remember Last Read Post'] and (!Unread.thread.isDead or Unread.thread.isArchived)
- ThreadWatcher.update Site.hostname, Unread.thread.board.ID, Unread.thread.ID,
+ ThreadWatcher.update g.SITE.ID, Unread.thread.board.ID, Unread.thread.ID,
isDead: Unread.thread.isDead
unread: Unread.posts.size
quotingYou: !!(if !Conf['Require OP Quote Link'] and QuoteYou.isYou(Unread.thread.OP) then Unread.posts.size else Unread.postsQuotingYou.size)
diff --git a/src/Monitoring/UnreadIndex.coffee b/src/Monitoring/UnreadIndex.coffee
index 4d2878352..1ca6c489c 100644
--- a/src/Monitoring/UnreadIndex.coffee
+++ b/src/Monitoring/UnreadIndex.coffee
@@ -64,7 +64,7 @@ UnreadIndex =
firstUnread = post
hr = UnreadIndex.hr[thread.fullID]
- if firstUnread and (repliesRead or (lastReadPost is thread.OP.ID and (!$(Site.selectors.summary, thread.nodes.root) or thread.ID of ExpandThread.statuses)))
+ if firstUnread and (repliesRead or (lastReadPost is thread.OP.ID and (!$(g.SITE.selectors.summary, thread.nodes.root) or thread.ID of ExpandThread.statuses)))
if !hr
hr = UnreadIndex.hr[thread.fullID] = $.el 'hr',
className: 'unread-line'
@@ -87,7 +87,7 @@ UnreadIndex =
href: 'javascript:;'
textContent: 'Mark Read'
$.on link, 'click', UnreadIndex.markRead
- if (divider = $ Site.selectors.threadDivider, thread.nodes.root) # divider inside thread as in Tinyboard
+ if (divider = $ g.SITE.selectors.threadDivider, thread.nodes.root) # divider inside thread as in Tinyboard
$.before divider, link
else
$.add thread.nodes.root, link
@@ -105,6 +105,6 @@ UnreadIndex =
val: lastPost
$.rm UnreadIndex.hr[thread.fullID]
thread.nodes.root.classList.remove 'unread-thread'
- ThreadWatcher.update Site.hostname, thread.board.ID, thread.ID,
+ ThreadWatcher.update g.SITE.ID, thread.board.ID, thread.ID,
unread: 0
quotingYou: false
diff --git a/src/Posting/QR.coffee b/src/Posting/QR.coffee
index 20a340de8..4db04e286 100644
--- a/src/Posting/QR.coffee
+++ b/src/Posting/QR.coffee
@@ -317,7 +317,7 @@ QR =
$.replace node, $.tn '\n'
for node in $$ 'br', frag
$.replace node, $.tn '\n>' unless node is frag.lastChild
- Site.insertTags?(frag)
+ g.SITE.insertTags?(frag)
for node in $$ '.linkify[data-original]', frag
$.replace node, $.tn node.dataset.original
for node in $$ '.embedder', frag
diff --git a/src/classes/DataBoard.coffee b/src/classes/DataBoard.coffee
index ddb7c621f..219c525f5 100644
--- a/src/classes/DataBoard.coffee
+++ b/src/classes/DataBoard.coffee
@@ -19,7 +19,7 @@ class DataBoard
@data['4chan.org'] = {boards, lastChecked}
delete @data.boards
delete @data.lastChecked
- @data[Site.hostname] or= boards: {}
+ @data[g.SITE.ID] or= boards: {}
changes: []
@@ -47,7 +47,7 @@ class DataBoard
cb?()
delete: ({siteID, boardID, threadID, postID}) ->
- siteID or= Site.hostname
+ siteID or= g.SITE.ID
return unless @data[siteID]
@save =>
if postID
@@ -76,7 +76,7 @@ class DataBoard
, cb
setUnsafe: ({siteID, boardID, threadID, postID, val}) ->
- siteID or= Site.hostname
+ siteID or= g.SITE.ID
@data[siteID] or= boards: {}
if postID isnt undefined
((@data[siteID].boards[boardID] or= {})[threadID] or= {})[postID] = val
@@ -101,7 +101,7 @@ class DataBoard
@data[key] = Date.now()
get: ({siteID, boardID, threadID, postID, defaultValue}) ->
- siteID or= Site.hostname
+ siteID or= g.SITE.ID
if board = @data[siteID]?.boards[boardID]
unless threadID?
if postID?
@@ -119,7 +119,7 @@ class DataBoard
val or defaultValue
clean: ->
- siteID = Site.hostname
+ siteID = g.SITE.ID
for boardID, val of @data[siteID].boards
@deleteIfEmpty {siteID, boardID}
now = Date.now()
@@ -131,12 +131,12 @@ class DataBoard
ajaxClean: (boardID) ->
that = @
- siteID = Site.hostname
- threadsList = Site.urls.threadsListJSON?({siteID, boardID})
+ siteID = g.SITE.ID
+ threadsList = g.SITE.urls.threadsListJSON?({siteID, boardID})
return unless threadsList
$.cache threadsList, ->
return unless @status is 200
- archiveList = Site.urls.archiveListJSON?({siteID, boardID})
+ archiveList = g.SITE.urls.archiveListJSON?({siteID, boardID})
return that.ajaxCleanParse(boardID, @response) unless archiveList
response1 = @response
$.cache archiveList, ->
@@ -144,7 +144,7 @@ class DataBoard
that.ajaxCleanParse(boardID, response1, @response)
ajaxCleanParse: (boardID, response1, response2) ->
- siteID = Site.hostname
+ siteID = g.SITE.ID
return if not (board = @data[siteID].boards[boardID])
threads = {}
if response1
diff --git a/src/classes/Fetcher.coffee b/src/classes/Fetcher.coffee
index 693fb2856..d61e50d96 100644
--- a/src/classes/Fetcher.coffee
+++ b/src/classes/Fetcher.coffee
@@ -16,7 +16,7 @@ class Fetcher
@root.textContent = "Loading post No.#{@postID}..."
if @threadID
that = @
- $.cache Site.urls.threadJSON({boardID: @boardID, threadID: @threadID}), ({isCached}) ->
+ $.cache g.SITE.urls.threadJSON({boardID: @boardID, threadID: @threadID}), ({isCached}) ->
that.fetchedPost @, isCached
else
@archivedPost()
@@ -81,7 +81,7 @@ class Fetcher
if post.no isnt @postID
# Cached requests can be stale and must be rechecked.
if isCached
- api = Site.urls.threadJSON({boardID: @boardID, threadID: @threadID})
+ api = g.SITE.urls.threadJSON({boardID: @boardID, threadID: @threadID})
$.cleanCache (url) -> url is api
that = @
$.cache api, ->
diff --git a/src/classes/Post.Clone.coffee b/src/classes/Post.Clone.coffee
index 1fd0c9a66..873eba202 100644
--- a/src/classes/Post.Clone.coffee
+++ b/src/classes/Post.Clone.coffee
@@ -44,7 +44,7 @@ Post.Clone = class extends Post
@file = {}
for key, val of @origin.file
@file[key] = val
- for key, selector of Site.selectors.file
+ for key, selector of g.SITE.selectors.file
@file[key] = $ selector, @nodes.root
@file.thumbLink = @file.thumb?.parentNode
@file.fullImage = $ '.full-image', @file.thumbLink if @file.thumbLink
diff --git a/src/classes/Post.coffee b/src/classes/Post.coffee
index 58d89ebfc..58d927b37 100644
--- a/src/classes/Post.coffee
+++ b/src/classes/Post.coffee
@@ -9,7 +9,7 @@ class Post
@ID = +root.id.match(/\d*$/)[0]
@threadID = @thread.ID
@boardID = @board.ID
- @siteID = Site.hostname
+ @siteID = g.SITE.ID
@fullID = "#{@board}.#{@ID}"
@context = @
@isReply = (@ID isnt @threadID)
@@ -21,7 +21,7 @@ class Post
if not @isReply
@thread.OP = @
for key in ['isSticky', 'isClosed', 'isArchived']
- @thread[key] = if (selector = Site.selectors.icons[key]) then !!$(selector, @nodes.info) else false
+ @thread[key] = if (selector = g.SITE.selectors.icons[key]) then !!$(selector, @nodes.info) else false
if @thread.isArchived
@thread.isClosed = true
@thread.kill()
@@ -67,12 +67,12 @@ class Post
g.posts.push @fullID, @
parseNodes: (root) ->
- s = Site.selectors
+ s = g.SITE.selectors
post = $(s.post, root) or root
info = $ s.infoRoot, post
nodes =
root: root
- bottom: if @isReply or !Site.isOPContainerThread then root else $(s.opBottom, root)
+ bottom: if @isReply or !g.SITE.isOPContainerThread then root else $(s.opBottom, root)
post: post
info: info
comment: $ s.comment, post
@@ -81,7 +81,7 @@ class Post
embedlinks: []
for key, selector of s.info
nodes[key] = $ selector, info
- Site.parseNodes?(@, nodes)
+ g.SITE.parseNodes?(@, nodes)
nodes.uniqueIDRoot or= nodes.uniqueID
# XXX Edge invalidates HTMLCollections when an ancestor node is inserted into another node.
@@ -106,7 +106,7 @@ class Post
# 'Comment too long'...
# EXIF data. (/p/)
@nodes.commentClean = bq = @nodes.comment.cloneNode true
- Site.cleanComment?(bq)
+ g.SITE.cleanComment?(bq)
@info.comment = @nodesToText bq
commentDisplay: ->
@@ -119,13 +119,13 @@ class Post
# Trailing spaces.
bq = @nodes.commentClean.cloneNode true
@cleanSpoilers bq unless Conf['Remove Spoilers'] or Conf['Reveal Spoilers']
- Site.cleanCommentDisplay?(bq)
+ g.SITE.cleanCommentDisplay?(bq)
@nodesToText(bq).trim().replace(/\s+$/gm, '')
commentOrig: ->
# Get the comment's text for reposting purposes.
bq = @nodes.commentClean.cloneNode true
- Site.insertTags?(bq)
+ g.SITE.insertTags?(bq)
@nodesToText bq
nodesToText: (bq) ->
@@ -137,14 +137,14 @@ class Post
text
cleanSpoilers: (bq) ->
- spoilers = $$ Site.selectors.spoiler, bq
+ spoilers = $$ g.SITE.selectors.spoiler, bq
for node in spoilers
$.replace node, $.tn '[spoiler]'
return
parseQuotes: ->
@quotes = []
- for quotelink in $$ Site.selectors.quotelink, @nodes.comment
+ for quotelink in $$ g.SITE.selectors.quotelink, @nodes.comment
@parseQuote quotelink
return
@@ -155,7 +155,7 @@ class Post
# - catalog links. (>>>/b/catalog or >>>/b/search)
# - rules links. (>>>/a/rules)
# - text-board quotelinks. (>>>/img/1234)
- match = quotelink.href.match Site.regexp.quotelink
+ match = quotelink.href.match g.SITE.regexp.quotelink
return unless match or (@isClone and quotelink.dataset.postID) # normal or resurrected quote
@nodes.quotelinks.push quotelink
@@ -168,12 +168,12 @@ class Post
parseFile: ->
file = {}
- for key, selector of Site.selectors.file
+ for key, selector of g.SITE.selectors.file
file[key] = $ selector, @nodes.root
file.thumbLink = file.thumb?.parentNode
return if not (file.text and file.link)
- return if not Site.parseFile @, file
+ return if not g.SITE.parseFile @, file
$.extend file,
url: file.link.href
diff --git a/src/globals/globals.js b/src/globals/globals.js
index 993d572f1..f8398488d 100644
--- a/src/globals/globals.js
+++ b/src/globals/globals.js
@@ -13,6 +13,7 @@ docSet = function() {
g = {
VERSION: '<%= readJSON('/version.json').version %>',
NAMESPACE: '<%= meta.name %>.',
+ sites: {},
boards: {}
};
diff --git a/src/main/Main.coffee b/src/main/Main.coffee
index d292c25af..f5a492330 100644
--- a/src/main/Main.coffee
+++ b/src/main/Main.coffee
@@ -157,7 +157,7 @@ Main =
if ImageHost.test hostname
return unless pathname[2] and not /[sm]\.jpg$/.test(pathname[2])
$.asap (-> d.readyState isnt 'loading'), ->
- if Conf['404 Redirect'] and Site.is404?()
+ if Conf['404 Redirect'] and g.SITE.is404?()
Redirect.navigate 'file', {
boardID: g.BOARD.ID
filename: pathname[pathname.length - 1]
@@ -172,7 +172,7 @@ Main =
ImageCommon.addControls video
return
- return if Site.isAuxiliaryPage?()
+ return if g.SITE.isAuxiliaryPage?()
if pathname[2] in ['thread', 'res']
g.VIEW = 'thread'
@@ -192,7 +192,7 @@ Main =
# c.time 'All initializations'
for [name, feature] in Main.features
- continue if Site.disabledFeatures and name in Site.disabledFeatures
+ continue if g.SITE.disabledFeatures and name in g.SITE.disabledFeatures
# c.time "#{name} initialization"
try
feature.init()
@@ -213,7 +213,7 @@ Main =
# disable the mobile layout
$('link[href*=mobile]', d.head)?.disabled = true
doc.dataset.host = location.host
- $.addClass doc, "sw-#{Site.software}"
+ $.addClass doc, "sw-#{g.SITE.software}"
$.addClass doc, if g.VIEW is 'thread' then 'thread-view' else g.VIEW
$.onExists doc, '.ad-cnt, .adg-rects > .desktop', (ad) -> $.onExists ad, 'img, iframe', -> $.addClass doc, 'ads-loaded'
$.addClass doc, 'autohiding-scrollbar' if Conf['Autohiding Scrollbar']
@@ -235,7 +235,7 @@ Main =
setClass: ->
knownStyles = ['yotsuba', 'yotsuba-b', 'futaba', 'burichan', 'photon', 'tomorrow', 'spooky']
- if Site.software is 'yotsuba' and g.VIEW is 'catalog'
+ if g.SITE.software is 'yotsuba' and g.VIEW is 'catalog'
if (mainStyleSheet = $.id('base-css'))
style = mainStyleSheet.href.match(/catalog_(\w+)/)?[1].replace('_new', '').replace(/_+/g, '-')
if style in knownStyles
@@ -246,7 +246,7 @@ Main =
setStyle = ->
# Use preconfigured CSS for 4chan's default themes.
- if Site.software is 'yotsuba'
+ if g.SITE.software is 'yotsuba'
$.rmClass doc, style
style = null
for styleSheet in styleSheets
@@ -261,7 +261,7 @@ Main =
return
# Determine proper dialog background color for other themes.
- div = Site.bgColoredEl()
+ div = g.SITE.bgColoredEl()
div.style.position = 'absolute';
div.style.visibility = 'hidden';
$.add d.body, div
@@ -282,9 +282,9 @@ Main =
"""
$.after $.id('fourchanx-css'), Main.bgColorStyle
- $.onExists d.head, Site.selectors.styleSheet, (el) ->
+ $.onExists d.head, g.SITE.selectors.styleSheet, (el) ->
mainStyleSheet = el
- if Site.software is 'yotsuba'
+ if g.SITE.software is 'yotsuba'
styleSheets = $$ 'link[rel="alternate stylesheet"]', d.head
new MutationObserver(setStyle).observe mainStyleSheet, {
attributes: true
@@ -296,7 +296,7 @@ Main =
setStyle()
initReady: ->
- if Site.is404?()
+ if g.SITE.is404?()
if g.VIEW is 'thread'
ThreadWatcher.set404 g.BOARD.ID, g.THREADID, ->
if Conf['404 Redirect']
@@ -308,7 +308,7 @@ Main =
return
- if Site.isIncomplete?()
+ if g.SITE.isIncomplete?()
msg = $.el 'div',
<%= html('The page didn't load completely.
Some features may not work unless you reload.') %>
$.on $('a', msg), 'click', -> location.reload()
@@ -322,7 +322,7 @@ Main =
$.event '4chanXInitFinished'
initThread: ->
- s = Site.selectors
+ s = g.SITE.selectors
if (board = $ s.board)
threads = []
posts = []
@@ -336,7 +336,7 @@ Main =
Main.handleErrors errors if errors.length
if g.VIEW is 'thread'
- Site.parseThreadMetadata?(threads[0])
+ g.SITE.parseThreadMetadata?(threads[0])
Main.callbackNodes 'Thread', threads
Main.callbackNodesDB 'Post', posts, ->
@@ -360,13 +360,13 @@ Main =
thread = new Thread threadID, boardObj
thread.nodes.root = threadRoot
threads.push thread
- postRoots = $$ Site.selectors.postContainer, threadRoot
- postRoots.unshift threadRoot if Site.isOPContainerThread
+ postRoots = $$ g.SITE.selectors.postContainer, threadRoot
+ postRoots.unshift threadRoot if g.SITE.isOPContainerThread
Main.parsePosts postRoots, thread, posts, errors
Main.addPostsObserver.observe threadRoot, {childList: true}
parsePosts: (postRoots, thread, posts, errors) ->
- for postRoot in postRoots when !postRoot.dataset.fullID and $(Site.selectors.comment, postRoot)
+ for postRoot in postRoots when !postRoot.dataset.fullID and $(g.SITE.selectors.comment, postRoot)
try
posts.push new Post postRoot, thread, thread.board
catch err
@@ -379,7 +379,7 @@ Main =
addThreads: (records) ->
threadRoots = []
for record in records
- for node in record.addedNodes when node.nodeType is Node.ELEMENT_NODE and node.matches(Site.selectors.thread)
+ for node in record.addedNodes when node.nodeType is Node.ELEMENT_NODE and node.matches(g.SITE.selectors.thread)
threadRoots.push node
return unless threadRoots.length
threads = []
@@ -400,7 +400,7 @@ Main =
thread = Get.threadFromRoot record.target
postRoots = []
for node in record.addedNodes when node.nodeType is Node.ELEMENT_NODE
- if node.matches(Site.selectors.postContainer) or (node = $(Site.selectors.postContainer, node))
+ if node.matches(g.SITE.selectors.postContainer) or (node = $(g.SITE.selectors.postContainer, node))
postRoots.push node
n = posts.length
Main.parsePosts postRoots, thread, posts, errors
@@ -512,8 +512,8 @@ Main =
isThisPageLegit: ->
# not 404 error page or similar.
unless 'thisPageIsLegit' of Main
- Main.thisPageIsLegit = if Site.isThisPageLegit
- Site.isThisPageLegit()
+ Main.thisPageIsLegit = if g.SITE.isThisPageLegit
+ g.SITE.isThisPageLegit()
else
!/^[45]\d\d\b/.test(document.title)
Main.thisPageIsLegit
diff --git a/src/site/SW.tinyboard.coffee b/src/site/SW.tinyboard.coffee
index 307614a99..715cde595 100644
--- a/src/site/SW.tinyboard.coffee
+++ b/src/site/SW.tinyboard.coffee
@@ -134,7 +134,7 @@ SW.tinyboard =
parseFile: (post, file) ->
{text, link, thumb} = file
- return false if $.x("ancestor::#{Site.xpath.postContainer}[1]", text) isnt post.nodes.root # file belongs to a reply
+ return false if $.x("ancestor::#{@xpath.postContainer}[1]", text) isnt post.nodes.root # file belongs to a reply
return false if not (infoNode = if '(' in link.nextSibling?.textContent then link.nextSibling else link.nextElementSibling)
return false if not (info = infoNode.textContent.match /\((Spoiler Image, )?([\d.]+ [KMG]?B).*\)/)
nameNode = $ '.postfilename', text
diff --git a/src/site/SW.yotsuba.coffee b/src/site/SW.yotsuba.coffee
index cb25f01c9..a54d9f20c 100644
--- a/src/site/SW.yotsuba.coffee
+++ b/src/site/SW.yotsuba.coffee
@@ -100,7 +100,7 @@ SW.yotsuba =
if g.BOARD.ID is 'f' and thread.OP.file
{file} = thread.OP
- $.ajax Site.urls.threadJSON({boardID: 'f', threadID: thread.ID}),
+ $.ajax @urls.threadJSON({boardID: 'f', threadID: thread.ID}),
timeout: $.MINUTE
onloadend: ->
if @response
diff --git a/src/site/Site.coffee b/src/site/Site.coffee
index 52165d8a1..830c4a7df 100644
--- a/src/site/Site.coffee
+++ b/src/site/Site.coffee
@@ -25,13 +25,17 @@ Site =
changed++
if changed
$.set 'siteProperties', Conf['siteProperties']
- unless @hostname
+ unless g.SITE
@set hostname
cb()
return
return
- set: (@hostname) ->
- @properties = Conf['siteProperties'][@hostname]
- @software = @properties.software
- $.extend @, SW[@software]
+ set: (hostname) ->
+ for ID, properties of Conf['siteProperties']
+ continue if properties.canonical
+ software = properties.software
+ continue unless software and SW[software]
+ g.sites[ID] = site = Object.create SW[software]
+ $.extend site, {ID, properties, software}
+ g.SITE = g.sites[hostname]