Reduce code duplication with Get.scriptData.

This commit is contained in:
ccd0 2014-12-20 12:31:15 -08:00
parent f1ef4b6c3c
commit 5fc2e7946f
3 changed files with 4 additions and 3 deletions

View File

@ -66,6 +66,8 @@ Get =
quotelinks.filter (quotelink) ->
{boardID, postID} = Get.postDataFromLink quotelink
boardID is post.board.ID and postID is post.ID
scriptData: ->
$('script:not([src])', d.head)?.textContent or ''
postClone: (boardID, threadID, postID, root, context) ->
if post = g.posts["#{boardID}.#{postID}"]
Get.insert post, root, context

View File

@ -193,7 +193,7 @@ Main =
Main.handleErrors errors if errors
if g.VIEW is 'thread'
scriptData = $('script:not([src])', d.head)?.textContent or ''
scriptData = Get.scriptData()
threads[0].postLimit = /\bbumplimit *= *1\b/.test scriptData
threads[0].fileLimit = /\bimagelimit *= *1\b/.test scriptData
threads[0].ipCount = if m = scriptData.match /\bunique_ips *= *(\d+)\b/ then +m[1]

View File

@ -5,8 +5,7 @@ QR.cooldown =
return unless Conf['Cooldown']
# Read cooldown times
scriptData = $('script:not([src])', d.head)?.textContent or ''
QR.cooldown.delays = if m = scriptData.match /\bcooldowns *= *({[^}]+})/
QR.cooldown.delays = if m = Get.scriptData().match /\bcooldowns *= *({[^}]+})/
JSON.parse m[1]
else
{thread: 0, reply: 0, image: 0, reply_intra: 0, image_intra: 0}