Update for 4channel.org

This commit is contained in:
ccd0 2018-11-23 14:11:00 -08:00
parent 244d41bb1e
commit a1a084acca
16 changed files with 55 additions and 32 deletions

View File

@ -27,12 +27,18 @@
"*://boards.4chan.org/*",
"*://sys.4chan.org/*",
"*://www.4chan.org/*",
"*://boards.4channel.org/*",
"*://sys.4channel.org/*",
"*://www.4channel.org/*",
"*://i.4cdn.org/*",
"*://is.4chan.org/*",
"*://is2.4chan.org/*"
"*://is2.4chan.org/*",
"*://is.4channel.org/*",
"*://is2.4channel.org/*"
],
"matches_only": [
"*://*.4chan.org/*",
"*://*.4channel.org/*",
"*://*.4cdn.org/*"
],
"matches": [
@ -48,7 +54,13 @@
"*://www.4chan.org/advertise",
"*://www.4chan.org/advertise?*",
"*://www.4chan.org/donate",
"*://www.4chan.org/donate?*"
"*://www.4chan.org/donate?*",
"*://www.4channel.org/pass",
"*://www.4channel.org/pass?*",
"*://www.4channel.org/advertise",
"*://www.4channel.org/advertise?*",
"*://www.4channel.org/donate",
"*://www.4channel.org/donate?*"
],
"grants": [
"GM_getValue",

View File

@ -42,6 +42,12 @@ BoardConfig =
sfwBoards: (sfw) ->
board for board, data of (@boards or Conf['boardConfig'].boards) when !!data.ws_board is sfw
isSFW: (board) ->
!!(@boards or Conf['boardConfig'].boards)[board]?.ws_board
domain: (board) ->
"boards.#{if BoardConfig.isSFW(board) then '4channel' else '4chan'}.org"
noAudio: (boardID) ->
return false unless Site.software is 'yotsuba'
boards = @boards or Conf['boardConfig'].boards

View File

@ -24,7 +24,7 @@ Build.Test =
$.rm el
for el in $$ 'a[href]', root2
href = el.href
href = href.replace /(^\w+:\/\/boards.4chan.org\/[^\/]+\/thread\/\d+)\/.*/, '$1'
href = href.replace /(^\w+:\/\/boards\.4chan(?:nel)?\.org\/[^\/]+\/thread\/\d+)\/.*/, '$1'
el.setAttribute 'href', href
ImageHost.fixLinks $$('.fileText > a, a.fileThumb', root2)
for el in $$ 'img[src]', root2

View File

@ -227,7 +227,7 @@ Header =
boardID = t.split('-')[0]
if boardID is 'current'
if location.hostname is 'boards.4chan.org'
if location.hostname in ['boards.4chan.org', 'boards.4channel.org']
boardID = g.BOARD.ID
else
a = $.el 'a',
@ -246,7 +246,7 @@ Header =
textContent: '@'
a = $.el 'a',
href: "//boards.4chan.org/#{boardID}/"
href: "//#{BoardConfig.domain(boardID)}/#{boardID}/"
textContent: boardID
title: BoardConfig.title(boardID)
a.href += g.VIEW if g.VIEW in ['catalog', 'archive']
@ -270,7 +270,7 @@ Header =
if Conf['JSON Index'] and indexOptions
a.dataset.indexOptions = indexOptions
if a.hostname is 'boards.4chan.org' and a.pathname.split('/')[2] is ''
if a.hostname in ['boards.4chan.org', 'boards.4channel.org'] and a.pathname.split('/')[2] is ''
a.href += (if a.hash then '/' else '#') + indexOptions
if /-archive/.test t
@ -281,7 +281,7 @@ Header =
if /-expired/.test t
if boardID not in ['b', 'f', 'trash', 'bant']
a.href = "//boards.4chan.org/#{boardID}/archive"
a.href = "//#{BoardConfig.domain(boardID)}/#{boardID}/archive"
else
return a.firstChild # Its text node.

View File

@ -110,7 +110,7 @@ Settings =
cb $.el 'li',
textContent: """
<%= meta.name %> needs local storage to #{why}.
Enable it on boards.4chan.org in your browser's privacy settings (may be listed as part of "local data" or "cookies").
Enable it on boards.#{location.hostname.split('.')[1]}.org in your browser's privacy settings (may be listed as part of "local data" or "cookies").
"""
ads: (cb) ->
$.onExists doc, '.adg-rects > .desktop', (ad) -> $.onExists ad, 'iframe', ->
@ -456,6 +456,9 @@ Settings =
if compareString < '00001.00014.00003.00002'
if data['sauces']?
set 'sauces', data['sauces'].replace(/^(#?\s*)https:\/\/whatanime\.ga\//mg, '$1https://trace.moe/')
if compareString < '00001.00014.00004.00004'
if data['siteSoftware']? and !/^4channel\.org yotsuba$/m.test(data['siteSoftware'])
set 'siteSoftware', data['siteSoftware'] + '\n4channel.org yotsuba'
changes
loadSettings: (data, cb) ->

View File

@ -14,7 +14,7 @@ ImageHost =
test: (hostname) ->
hostname is 'i.4cdn.org' or ImageHost.regex.test(hostname)
regex: /^is\d*\.4chan\.org$/
regex: /^is\d*\.4chan(?:nel)?\.org$/
node: ->
return if @isClone

View File

@ -12,7 +12,7 @@ ReportLink =
el: a
order: 10
open: (post) ->
ReportLink.url = "//sys.4chan.org/#{post.board}/imgboard.php?mode=report&no=#{post}"
ReportLink.url = "//sys.#{location.hostname.split('.')[1]}.org/#{post.board}/imgboard.php?mode=report&no=#{post}"
if d.cookie.indexOf('pass_enabled=1') >= 0
ReportLink.dims = 'width=350,height=275'
else

View File

@ -37,8 +37,8 @@ CatalogLinks =
node: ->
for a in $$ 'a', @nodes.comment
if m = a.href.match /^https?:\/\/boards\.4chan\.org\/([^\/]+)\/catalog(#s=.*)?/
a.href = "//boards.4chan.org/#{m[1]}/#{m[2] or '#catalog'}"
if m = a.href.match /^https?:\/\/boards\.4chan(?:nel)?\.org\/([^\/]+)\/catalog(#s=.*)?/
a.href = "//boards.4chan(?:nel)?.org/#{m[1]}/#{m[2] or '#catalog'}"
return
toggle: ->
@ -59,7 +59,7 @@ CatalogLinks =
for a in $$('a:not([data-only])', list)
continue if (
a.hostname not in ['boards.4chan.org', 'catalog.neet.tv'] or
a.hostname not in ['boards.4chan.org', 'boards.4channel.org', 'catalog.neet.tv'] or
!(board = a.pathname.split('/')[1]) or
board in ['f', 'status', '4chan'] or
a.pathname.split('/')[2] is 'archive' or
@ -68,9 +68,9 @@ CatalogLinks =
# Href is easier than pathname because then we don't have
# conditions where External Catalog has been disabled between switches.
a.href = if Conf['Header catalog links'] then CatalogLinks.catalog(board) else "//boards.4chan.org/#{board}/"
a.href = if Conf['Header catalog links'] then CatalogLinks.catalog(board) else "//#{BoardConfig.domain(board)}/#{board}/"
if a.dataset.indexOptions and a.hostname is 'boards.4chan.org' and a.pathname.split('/')[2] is ''
if a.dataset.indexOptions and a.hostname in ['boards.4chan.org', 'boards.4channel.org'] and a.pathname.split('/')[2] is ''
a.href += (if a.hash then '/' else '#') + a.dataset.indexOptions
return
@ -78,12 +78,12 @@ CatalogLinks =
if Conf['External Catalog'] and board in ['a', 'c', 'g', 'biz', 'k', 'm', 'o', 'p', 'v', 'vg', 'vr', 'w', 'wg', 'cm', '3', 'adv', 'an', 'asp', 'cgl', 'ck', 'co', 'diy', 'fa', 'fit', 'gd', 'int', 'jp', 'lit', 'mlp', 'mu', 'n', 'out', 'po', 'sci', 'sp', 'tg', 'toy', 'trv', 'tv', 'vp', 'wsg', 'x', 'f', 'pol', 's4s', 'lgbt']
"//catalog.neet.tv/#{board}/"
else if Conf['JSON Index'] and Conf['Use <%= meta.name %> Catalog']
if location.hostname is 'boards.4chan.org' and g.BOARD.ID is board and g.VIEW is 'index' then '#catalog' else "//boards.4chan.org/#{board}/#catalog"
if location.hostname in ['boards.4chan.org', 'boards.4channel.org'] and g.BOARD.ID is board and g.VIEW is 'index' then '#catalog' else "//#{BoardConfig.domain(board)}/#{board}/#catalog"
else
"//boards.4chan.org/#{board}/catalog"
"//#{BoardConfig.domain(board)}/#{board}/catalog"
index: (board=g.BOARD.ID) ->
if Conf['JSON Index'] and board isnt 'f'
if location.hostname is 'boards.4chan.org' and g.BOARD.ID is board and g.VIEW is 'index' then '#index' else "//boards.4chan.org/#{board}/#index"
if location.hostname in ['boards.4chan.org', 'boards.4channel.org'] and g.BOARD.ID is board and g.VIEW is 'index' then '#index' else "//#{BoardConfig.domain(board)}/#{board}/#index"
else
"//boards.4chan.org/#{board}/"
"//#{BoardConfig.domain(board)}/#{board}/"

View File

@ -7,7 +7,7 @@ Captcha.replace =
return
if Conf['captchaLanguage'].trim() or Conf['Captcha Fixes']
if location.hostname is 'boards.4chan.org'
if location.hostname in ['boards.4chan.org', 'boards.4channel.org']
$.onExists doc, '#captchaFormPart', (node) -> $.onExists node, 'iframe', Captcha.replace.iframe
else
$.onExists doc, 'iframe', Captcha.replace.iframe

View File

@ -10,7 +10,7 @@ PassLink =
className: 'brackets-wrap pass-link-container'
$.extend passLink, <%= html('<a href="javascript:;">4chan Pass</a>') %>
$.on passLink.firstElementChild, 'click', ->
window.open '//sys.4chan.org/auth',
window.open "//sys.#{location.hostname.split('.')[1]}.org/auth",
Date.now()
'width=500,height=280,toolbar=0'
$.before styleSelector.previousSibling, [passLink, $.tn('\u00A0\u00A0')]

View File

@ -740,7 +740,7 @@ QR =
extra.form.append 'recaptcha_response_field', response.response
else
extra.form.append 'g-recaptcha-response', response.response
QR.req = $.ajax "https://sys.4chan.org/#{g.BOARD}/post", options, extra
QR.req = $.ajax "https://sys.#{location.hostname.split('.')[1]}.org/#{g.BOARD}/post", options, extra
QR.req.progress = '...'
if typeof captcha is 'function'

View File

@ -23,7 +23,7 @@ Quotify =
parseArchivelink: (link) ->
return if not (m = link.pathname.match /^\/([^/]+)\/thread\/S?(\d+)\/?$/)
return if link.hostname is 'boards.4chan.org'
return if link.hostname in ['boards.4chan.org', 'boards.4channel.org']
boardID = m[1]
threadID = m[2]
postID = link.hash.match(/^#[pq]?(\d+)$|$/)[1] or threadID

View File

@ -1138,5 +1138,6 @@ Config =
siteSoftware: """
4chan.org yotsuba
4channel.org yotsuba
4cdn.org yotsuba
"""

View File

@ -45,7 +45,7 @@ Main =
return
# XXX Remove document-breaking ad
if location.hostname is 'boards.4chan.org'
if location.hostname in ['boards.4chan.org', 'boards.4channel.org']
$.global ->
fromCharCode0 = String.fromCharCode
String.fromCharCode = ->
@ -78,7 +78,7 @@ Main =
Conf['Toggleable Thread Watcher'] = true
# Enforce JS whitelist
if /\.4chan\.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
($.getSync or $.get) {'jsWhitelist': Conf['jsWhitelist']}, ({jsWhitelist}) ->
$.addCSP "script-src #{jsWhitelist.replace(/^#.*$/mg, '').replace(/[\s;]+/g, ' ').trim()}"
@ -87,7 +87,7 @@ Main =
items[key] = undefined for key of Conf
items['previousversion'] = undefined
($.getSync or $.get) items, (items) ->
if !$.perProtocolSettings and /\.4chan\.org$/.test(location.hostname) and (items['Redirect to HTTPS'] ? Conf['Redirect to HTTPS']) and location.protocol isnt 'https:'
if !$.perProtocolSettings and /\.4chan(?:nel)?\.org$/.test(location.hostname) and (items['Redirect to HTTPS'] ? Conf['Redirect to HTTPS']) and location.protocol isnt 'https:'
location.replace('https://' + location.host + location.pathname + location.search + location.hash)
return
$.asap docSet, ->
@ -125,7 +125,7 @@ Main =
initFeatures: ->
{hostname, search} = location
pathname = location.pathname.split /\/+/
g.BOARD = new Board pathname[1] unless hostname is 'www.4chan.org'
g.BOARD = new Board pathname[1] unless hostname in ['www.4chan.org', 'www.4channel.org']
$.global ->
document.documentElement.classList.add 'js-enabled'
@ -133,11 +133,11 @@ Main =
Main.jsEnabled = $.hasClass doc, 'js-enabled'
switch hostname
when 'www.4chan.org'
when 'www.4chan.org', 'www.4channel.org'
$.onExists doc, 'body', -> $.addStyle CSS.www
Captcha.replace.init()
return
when 'sys.4chan.org'
when 'sys.4chan.org', 'sys.4channel.org'
if pathname[2] is 'imgboard.php'
if /\bmode=report\b/.test search
Report.init()

View File

@ -35,6 +35,7 @@
})()
%>
// @connect 4chan.org
// @connect 4channel.org
// @connect 4cdn.org
// @connect mayhemydg.github.io
<%=

View File

@ -47,7 +47,7 @@ SW.yotsuba =
regexp:
quotelink:
///
^https?://boards\.4chan\.org/+
^https?://boards\.4chan(?:nel)?\.org/+
([^/]+) # boardID
/+thread/+
(\d+) # threadID
@ -63,7 +63,7 @@ SW.yotsuba =
isThisPageLegit: ->
# not 404 error page or similar.
location.hostname is 'boards.4chan.org' and
location.hostname in ['boards.4chan.org', 'boards.4channel.org'] and
d.doctype and
!$('link[href*="favicon-status.ico"]', d.head) and
d.title not in ['4chan - Temporarily Offline', '4chan - Error', '504 Gateway Time-out', 'MathJax Equation Source']
@ -76,7 +76,7 @@ SW.yotsuba =
return g.VIEW in ['index', 'thread'] and not $('.board + *')
isAuxiliaryPage: ->
location.hostname isnt 'boards.4chan.org'
location.hostname not in ['boards.4chan.org', 'boards.4channel.org']
scriptData: ->
for script in $$ 'script:not([src])', d.head