diff --git a/src/Archive/Redirect.coffee b/src/Archive/Redirect.coffee index 4d77be1a8..5eb934fa9 100644 --- a/src/Archive/Redirect.coffee +++ b/src/Archive/Redirect.coffee @@ -18,6 +18,7 @@ Redirect = thread: {} post: {} file: {} + report: {} archives = {} for data in Conf['archives'] @@ -30,6 +31,7 @@ Redirect = o.thread[boardID] = data unless boardID of o.thread o.post[boardID] = data unless boardID of o.post or software isnt 'foolfuuka' o.file[boardID] = data unless boardID of o.file or boardID not in files + o.report[boardID] = data if name is 'fgts' for boardID, record of Conf['selectedArchives'] for type, id of record when (archive = archives[JSON.stringify id]) @@ -152,6 +154,9 @@ Redirect = "#{boardID}/?task=search2&search_#{type}=#{value}" "#{Redirect.protocol archive}#{archive.domain}/#{path}" + report: (archive, {boardID, postID}) -> + "https://so.fgts.jp/report/?board=#{boardID}&no=#{postID}" + securityCheck: (url) -> /^https:\/\//.test(url) or location.protocol is 'http:' or diff --git a/src/Menu/ReportLink.coffee b/src/Menu/ReportLink.coffee index 3255ded7d..cb666a535 100644 --- a/src/Menu/ReportLink.coffee +++ b/src/Menu/ReportLink.coffee @@ -19,6 +19,10 @@ ReportLink = ReportLink.dims = 'width=350,height=275' else ReportLink.dims = 'width=400,height=550' + else if Conf['Archive Report'] + a.textContent = 'Report to archive' + ReportLink.url = Redirect.to 'report', {boardID: post.board.ID, postID: post.ID} + ReportLink.dims = 'width=700,height=475' else ReportLink.url = '' !!ReportLink.url diff --git a/src/Miscellaneous/Report.coffee b/src/Miscellaneous/Report.coffee index 79b21d58c..c170f4e7c 100644 --- a/src/Miscellaneous/Report.coffee +++ b/src/Miscellaneous/Report.coffee @@ -8,6 +8,8 @@ Report = ready: -> $.addStyle CSS.report + Report.archive() if Conf['Archive Report'] + if not Conf['Use Recaptcha v1 in Reports'] and not Conf['Force Noscript Captcha'] and Main.jsEnabled new MutationObserver(-> Report.fit 'iframe[src^="https://www.google.com/recaptcha/api2/frame"]' @@ -23,3 +25,26 @@ Report = return if not ((el = $ selector, doc) and getComputedStyle(el).visibility isnt 'hidden') dy = el.getBoundingClientRect().bottom - doc.clientHeight + 8 window.resizeBy 0, dy if dy > 0 + + archive: -> + Redirect.init() + return unless (url = Redirect.to 'report', {boardID: g.BOARD.ID, postID: Report.postID}) + + if (message = $ 'h3') and /Report submitted!/.test(message.textContent) + if location.hash is '#redirect' + $.globalEval 'self.close = function(){};' + window.resizeTo 700, 475 + location.replace url + return + + link = $.el 'a', + href: url + textContent: 'Report to archive' + $.on link, 'click', (e) -> + unless e.shiftKey or e.altKey or e.ctrlKey or e.metaKey or e.button isnt 0 + window.resizeTo 700, 475 + $.add d.body, [$.tn(' ['), link, $.tn(']')] + + if types = $.id('reportTypes') + $.on types, 'change', (e) -> + $('form').action = if e.target.value is 'illegal' then '#redirect' else '' diff --git a/src/config/Config.coffee b/src/config/Config.coffee index 09cffe243..2bc61816d 100644 --- a/src/config/Config.coffee +++ b/src/config/Config.coffee @@ -39,6 +39,10 @@ Config = true 'Redirect dead threads and images to the archives.' ] + 'Archive Report': [ + true + 'Enable reporting posts to supported archives.' + ] 'Exempt Archives from Encryption': [ true 'Permit loading content from, and warningless redirects to, HTTP-only archives from HTTPS pages.'