From a1a084acca639321dffe0f8bea5d782276db25c3 Mon Sep 17 00:00:00 2001 From: ccd0 Date: Fri, 23 Nov 2018 14:11:00 -0800 Subject: [PATCH] Update for 4channel.org --- package.json | 16 ++++++++++++++-- src/General/BoardConfig.coffee | 6 ++++++ src/General/Build.Test.coffee | 2 +- src/General/Header.coffee | 8 ++++---- src/General/Settings.coffee | 5 ++++- src/Images/ImageHost.coffee | 2 +- src/Menu/ReportLink.coffee | 2 +- src/Miscellaneous/CatalogLinks.coffee | 18 +++++++++--------- src/Posting/Captcha.replace.coffee | 2 +- src/Posting/PassLink.coffee | 2 +- src/Posting/QR.coffee | 2 +- src/Quotelinks/Quotify.coffee | 2 +- src/config/Config.coffee | 1 + src/main/Main.coffee | 12 ++++++------ src/meta/metadata.js | 1 + src/site/SW.yotsuba.coffee | 6 +++--- 16 files changed, 55 insertions(+), 32 deletions(-) diff --git a/package.json b/package.json index 0b89ad010..1d43838c4 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/General/BoardConfig.coffee b/src/General/BoardConfig.coffee index 32f6d3f73..fb8ee4f06 100644 --- a/src/General/BoardConfig.coffee +++ b/src/General/BoardConfig.coffee @@ -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 diff --git a/src/General/Build.Test.coffee b/src/General/Build.Test.coffee index 9ff50cceb..cc015ac11 100644 --- a/src/General/Build.Test.coffee +++ b/src/General/Build.Test.coffee @@ -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 diff --git a/src/General/Header.coffee b/src/General/Header.coffee index 13c2255e0..981acaad7 100644 --- a/src/General/Header.coffee +++ b/src/General/Header.coffee @@ -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. diff --git a/src/General/Settings.coffee b/src/General/Settings.coffee index c0ba5e0e2..0f23da52e 100644 --- a/src/General/Settings.coffee +++ b/src/General/Settings.coffee @@ -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) -> diff --git a/src/Images/ImageHost.coffee b/src/Images/ImageHost.coffee index 05d0e5906..126994b56 100644 --- a/src/Images/ImageHost.coffee +++ b/src/Images/ImageHost.coffee @@ -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 diff --git a/src/Menu/ReportLink.coffee b/src/Menu/ReportLink.coffee index c354b8def..8cee54a6d 100644 --- a/src/Menu/ReportLink.coffee +++ b/src/Menu/ReportLink.coffee @@ -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 diff --git a/src/Miscellaneous/CatalogLinks.coffee b/src/Miscellaneous/CatalogLinks.coffee index 819991261..751fff099 100644 --- a/src/Miscellaneous/CatalogLinks.coffee +++ b/src/Miscellaneous/CatalogLinks.coffee @@ -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}/" diff --git a/src/Posting/Captcha.replace.coffee b/src/Posting/Captcha.replace.coffee index 6326bc0bf..d849f3184 100644 --- a/src/Posting/Captcha.replace.coffee +++ b/src/Posting/Captcha.replace.coffee @@ -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 diff --git a/src/Posting/PassLink.coffee b/src/Posting/PassLink.coffee index a95ca92d5..a1a448bd5 100644 --- a/src/Posting/PassLink.coffee +++ b/src/Posting/PassLink.coffee @@ -10,7 +10,7 @@ PassLink = className: 'brackets-wrap pass-link-container' $.extend passLink, <%= html('4chan Pass') %> $.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')] diff --git a/src/Posting/QR.coffee b/src/Posting/QR.coffee index 249b97417..e37874824 100644 --- a/src/Posting/QR.coffee +++ b/src/Posting/QR.coffee @@ -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' diff --git a/src/Quotelinks/Quotify.coffee b/src/Quotelinks/Quotify.coffee index a7d4f7f0f..b088ea6c6 100644 --- a/src/Quotelinks/Quotify.coffee +++ b/src/Quotelinks/Quotify.coffee @@ -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 diff --git a/src/config/Config.coffee b/src/config/Config.coffee index 25083eb0c..b3eb5efcf 100644 --- a/src/config/Config.coffee +++ b/src/config/Config.coffee @@ -1138,5 +1138,6 @@ Config = siteSoftware: """ 4chan.org yotsuba + 4channel.org yotsuba 4cdn.org yotsuba """ diff --git a/src/main/Main.coffee b/src/main/Main.coffee index 5d740808e..dfcee73dc 100644 --- a/src/main/Main.coffee +++ b/src/main/Main.coffee @@ -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() diff --git a/src/meta/metadata.js b/src/meta/metadata.js index 3baf7650c..29db302f3 100644 --- a/src/meta/metadata.js +++ b/src/meta/metadata.js @@ -35,6 +35,7 @@ })() %> // @connect 4chan.org +// @connect 4channel.org // @connect 4cdn.org // @connect mayhemydg.github.io <%= diff --git a/src/site/SW.yotsuba.coffee b/src/site/SW.yotsuba.coffee index c22058342..e80200011 100644 --- a/src/site/SW.yotsuba.coffee +++ b/src/site/SW.yotsuba.coffee @@ -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