From b5baa3a67b0f99064034542fccab9f250e74bf02 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Wed, 5 Sep 2012 20:17:32 +0200 Subject: [PATCH 01/37] MOOOOOOOT --- 4chan_x.user.js | 7 +++---- changelog | 2 ++ script.coffee | 7 +++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 8bec9e11a..82b13957d 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -2541,7 +2541,7 @@ Options = { init: function() { var a, el, settings, _i, _len, _ref; - _ref = ['navtopr', 'navbotr']; + _ref = ['navtopright', 'navbotright']; for (_i = 0, _len = _ref.length; _i < _len; _i++) { settings = _ref[_i]; a = $.el('a', { @@ -2551,8 +2551,7 @@ }); $.on(a, 'click', Options.dialog); el = $.id(settings).firstElementChild; - el.hidden = true; - $.before(el, a); + $.before(el, [a, $.tn('] ')]); } if (!$.get('firstrun')) { if (!Favicon.el) { @@ -5086,7 +5085,7 @@ } return; } - if (!$.id('navtopr')) { + if (!$.id('navtopright')) { return; } $.addClass(d.body, $.engine); diff --git a/changelog b/changelog index 487c03dab..239fabe6b 100644 --- a/changelog +++ b/changelog @@ -1,4 +1,6 @@ master +- Mayhem + Fix 4chan X. Blame moot. 2.34.9 - Mayhem diff --git a/script.coffee b/script.coffee index 151cdf1ec..341aa7bc2 100644 --- a/script.coffee +++ b/script.coffee @@ -1995,15 +1995,14 @@ QR = Options = init: -> - for settings in ['navtopr', 'navbotr'] + for settings in ['navtopright', 'navbotright'] a = $.el 'a', href: 'javascript:;' className: 'settingsWindowLink' textContent: '4chan X Settings' $.on a, 'click', Options.dialog el = $.id(settings).firstElementChild - el.hidden = true - $.before el, a + $.before el, [a, $.tn('] ')] unless $.get 'firstrun' # Prevent race conditions Favicon.init() unless Favicon.el @@ -3981,7 +3980,7 @@ Main = if Conf['404 Redirect'] and /^\d+$/.test g.THREAD_ID location.href = Redirect.thread g.BOARD, g.THREAD_ID, location.hash return - unless $.id 'navtopr' + unless $.id 'navtopright' return $.addClass d.body, $.engine $.addClass d.body, 'fourchan_x' From f2b1c25848414840505c56630a13e7df3be94b68 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Wed, 5 Sep 2012 20:17:52 +0200 Subject: [PATCH 02/37] Release 2.34.10. --- 4chan_x.user.js | 6 +++--- Cakefile | 2 +- changelog | 2 ++ latest.js | 2 +- script.coffee | 2 +- 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 82b13957d..9995cf96a 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1,6 +1,6 @@ // ==UserScript== // @name 4chan x -// @version 2.34.9 +// @version 2.34.10 // @namespace aeosynth // @description Adds various features. // @copyright 2009-2011 James Campos @@ -23,7 +23,7 @@ * Copyright (c) 2009-2011 James Campos * Copyright (c) 2012 Nicolas Stepien * http://mayhemydg.github.com/4chan-x/ - * 4chan X 2.34.9 + * 4chan X 2.34.10 * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation @@ -5284,7 +5284,7 @@ return $.globalEval(("(" + code + ")()").replace('_id_', bq.id)); }, namespace: '4chan_x.', - version: '2.34.9', + version: '2.34.10', callbacks: [], css: '\ /* dialog styling */\ diff --git a/Cakefile b/Cakefile index 8b7d81e0e..e7c0ee80e 100644 --- a/Cakefile +++ b/Cakefile @@ -2,7 +2,7 @@ {exec} = require 'child_process' fs = require 'fs' -VERSION = '2.34.9' +VERSION = '2.34.10' HEADER = """ // ==UserScript== diff --git a/changelog b/changelog index 239fabe6b..bb5cac57a 100644 --- a/changelog +++ b/changelog @@ -1,4 +1,6 @@ master + +2.34.10 - Mayhem Fix 4chan X. Blame moot. diff --git a/latest.js b/latest.js index 0335ecfb8..d90eff7b7 100644 --- a/latest.js +++ b/latest.js @@ -1 +1 @@ -postMessage({version:'2.34.9'},'*') \ No newline at end of file +postMessage({version:'2.34.10'},'*') \ No newline at end of file diff --git a/script.coffee b/script.coffee index 341aa7bc2..6c9a6fa1e 100644 --- a/script.coffee +++ b/script.coffee @@ -4124,7 +4124,7 @@ Main = $.globalEval "(#{code})()".replace '_id_', bq.id namespace: '4chan_x.' - version: '2.34.9' + version: '2.34.10' callbacks: [] css: ' /* dialog styling */ From ad95f332c26808df955f04a11dadde13f90800bb Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Wed, 5 Sep 2012 21:36:14 +0200 Subject: [PATCH 03/37] Tiny fix. Don't cut off the [ on Settings. --- 4chan_x.user.js | 5 ++--- script.coffee | 3 +-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 9995cf96a..1ec1c1bfc 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -2540,7 +2540,7 @@ Options = { init: function() { - var a, el, settings, _i, _len, _ref; + var a, settings, _i, _len, _ref; _ref = ['navtopright', 'navbotright']; for (_i = 0, _len = _ref.length; _i < _len; _i++) { settings = _ref[_i]; @@ -2550,8 +2550,7 @@ textContent: '4chan X Settings' }); $.on(a, 'click', Options.dialog); - el = $.id(settings).firstElementChild; - $.before(el, [a, $.tn('] ')]); + $.prepend($.id(settings), [$.tn('['), a, $.tn('] ')]); } if (!$.get('firstrun')) { if (!Favicon.el) { diff --git a/script.coffee b/script.coffee index 6c9a6fa1e..49fbf2ab6 100644 --- a/script.coffee +++ b/script.coffee @@ -2001,8 +2001,7 @@ Options = className: 'settingsWindowLink' textContent: '4chan X Settings' $.on a, 'click', Options.dialog - el = $.id(settings).firstElementChild - $.before el, [a, $.tn('] ')] + $.prepend $.id(settings), [$.tn('['), a, $.tn('] ')] unless $.get 'firstrun' # Prevent race conditions Favicon.init() unless Favicon.el From 9805572fe0ff93c481ef2e5d91544000971fdcc2 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Thu, 6 Sep 2012 17:00:37 +0200 Subject: [PATCH 04/37] Fix regression: don't stop auto-posting because of a captcha error. --- 4chan_x.user.js | 2 +- script.coffee | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 1ec1c1bfc..6a3487b9c 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -2485,7 +2485,7 @@ err = 'Connection error with sys.4chan.org.'; } if (err) { - if (/captcha|verification/i.test(err) || err === 'Connection error with sys.4chan.org.') { + if (/captcha|verification/i.test(err.textContent) || err === 'Connection error with sys.4chan.org.') { QR.cooldown.auto = !!$.get('captchas', []).length; QR.cooldown.set(2); } else { diff --git a/script.coffee b/script.coffee index 49fbf2ab6..8f8a34812 100644 --- a/script.coffee +++ b/script.coffee @@ -1940,7 +1940,7 @@ QR = err = 'Connection error with sys.4chan.org.' if err - if /captcha|verification/i.test(err) or err is 'Connection error with sys.4chan.org.' + if /captcha|verification/i.test(err.textContent) or err is 'Connection error with sys.4chan.org.' # Enable auto-post if we have some cached captchas. QR.cooldown.auto = !!$.get('captchas', []).length # Too many frequent mistyped captchas will auto-ban you! From 44f25dea0ccbd880945b5dbf39bf7da4701ddb97 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Fri, 7 Sep 2012 18:47:06 +0200 Subject: [PATCH 05/37] Fetch posts using 4chan's API for Quote Previewing and Quote Inlining --- 4chan_x.user.js | 407 ++++++++++++++++++++++------------------- script.coffee | 467 +++++++++++++++++++++++++++++------------------- 2 files changed, 508 insertions(+), 366 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 6a3487b9c..a5f5f3455 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -77,7 +77,7 @@ */ (function() { - var $, $$, Anonymize, ArchiveLink, AutoGif, Conf, Config, DeleteLink, DownloadLink, ExpandComment, ExpandThread, Favicon, FileInfo, Filter, Get, ImageExpand, ImageHover, Keybinds, Main, Menu, Nav, Options, QR, QuoteBacklink, QuoteCT, QuoteInline, QuoteOP, QuotePreview, Quotify, Redirect, ReplyHiding, ReportLink, RevealSpoilers, Sauce, StrikethroughQuotes, ThreadHiding, ThreadStats, Time, TitlePost, UI, Unread, Updater, Watcher, d, g, _base; + var $, $$, Anonymize, ArchiveLink, AutoGif, Build, Conf, Config, DeleteLink, DownloadLink, ExpandComment, ExpandThread, Favicon, FileInfo, Filter, Get, ImageExpand, ImageHover, Keybinds, Main, Menu, Nav, Options, QR, QuoteBacklink, QuoteCT, QuoteInline, QuoteOP, QuotePreview, Quotify, Redirect, ReplyHiding, ReportLink, RevealSpoilers, Sauce, StrikethroughQuotes, ThreadHiding, ThreadStats, Time, TitlePost, UI, Unread, Updater, Watcher, d, g, _base; Config = { main: { @@ -487,15 +487,6 @@ $.add(d.head, script); return $.rm(script); }, - shortenFilename: function(filename, isOP) { - var threshold; - threshold = 30 + 10 * isOP; - if (filename.replace(/\.\w+$/, '').length > threshold) { - return "" + filename.slice(0, threshold - 5) + "(...)" + (filename.match(/\.\w+$/)); - } else { - return filename; - } - }, bytesToString: function(size) { var unit; unit = 0; @@ -3398,7 +3389,7 @@ unit: alt.match(/\w+$/)[0], resolution: node.textContent.match(/\d+x\d+|PDF/)[0], fullname: filename, - shortname: $.shortenFilename(filename, post.ID === post.threadID) + shortname: Build.shortFilename(filename, post.ID === post.threadID) }; node.setAttribute('data-filename', filename); return node.innerHTML = FileInfo.funk(FileInfo); @@ -3490,7 +3481,7 @@ } root.textContent = "Loading post No." + postID + "..."; if (threadID) { - return $.cache("/" + board + "/res/" + threadID, function() { + return $.cache("//api.4chan.org/" + board + "/res/" + threadID + ".json", function() { return Get.parsePost(this, board, threadID, postID, root, cb); }); } else if (url = Redirect.post(board, postID)) { @@ -3500,7 +3491,7 @@ } }, parsePost: function(req, board, threadID, postID, root, cb) { - var doc, href, link, pc, quote, status, url, _i, _len, _ref; + var post, posts, status, url, _i, _len; status = req.status; if (status !== 200) { if (url = Redirect.post(board, postID)) { @@ -3508,166 +3499,44 @@ return Get.parseArchivedPost(this, board, postID, root, cb); }); } else { + $.addClass(root, 'warning'); root.textContent = status === 404 ? "Thread No." + threadID + " has not been found." : "Error " + req.status + ": " + req.statusText + "."; } return; } - doc = d.implementation.createHTMLDocument(''); - doc.documentElement.innerHTML = req.response; - if (!(pc = doc.getElementById("pc" + postID))) { - if (url = Redirect.post(board, postID)) { - $.cache(url, function() { - return Get.parseArchivedPost(this, board, postID, root, cb); - }); - } else { - root.textContent = "Post No." + postID + " has not been found."; + posts = JSON.parse(req.response).posts; + postID = +postID; + for (_i = 0, _len = posts.length; _i < _len; _i++) { + post = posts[_i]; + if (post.no === postID) { + break; } - return; - } - pc = Get.cleanPost(d.importNode(pc, true)); - _ref = $$('.quotelink', pc); - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - quote = _ref[_i]; - href = quote.getAttribute('href'); - if (href[0] === '/') { - continue; + if (post.no > postID) { + if (url = Redirect.post(board, postID)) { + $.cache(url, function() { + return Get.parseArchivedPost(this, board, postID, root, cb); + }); + } else { + $.addClass(root, 'warning'); + root.textContent = "Post No." + postID + " has not been found."; + } + return; } - quote.href = "/" + board + "/res/" + href; } - link = $('a[title="Highlight this post"]', pc); - link.href = "/" + board + "/res/" + threadID + "#p" + postID; - link.nextSibling.href = "/" + board + "/res/" + threadID + "#q" + postID; - $.replace(root.firstChild, pc); + $.replace(root.firstChild, Get.cleanPost(Build.postFromObject(post, board))); if (cb) { return cb(); } }, parseArchivedPost: function(req, board, postID, root, cb) { - var bq, br, capcode, data, email, file, filename, filesize, isOP, name, nameBlock, pc, pi, piM, span, spoiler, subject, threadID, thumb_src, timestamp, trip, userID; + var bq, comment, data, o; data = JSON.parse(req.response); - $.addClass(root, 'archivedPost'); if (data.error) { + $.addClass(root, 'warning'); root.textContent = data.error; return; } - threadID = data.thread_num; - isOP = postID === threadID; - name = data.name, trip = data.trip, timestamp = data.timestamp; - subject = data.title; - userID = data.poster_hash; - piM = $.el('div', { - id: "pim" + postID, - className: 'postInfoM mobile', - innerHTML: "
" + data.fourchan_date + "
No." + postID + "
" - }); - $('.name', piM).textContent = name; - $('.subject', piM).textContent = subject; - br = $('br', piM); - if (trip) { - $.before(br, [ - $.tn(' '), $.el('span', { - className: 'postertrip', - textContent: trip - }) - ]); - } - capcode = data.capcode; - if (capcode !== 'N') { - $.addClass(br.parentNode, capcode === 'A' ? 'capcodeAdmin' : 'capcodeMod'); - $.before(br, [ - $.tn(' '), $.el('strong', { - className: 'capcode', - textContent: capcode === 'A' ? '## Admin' : '## Mod' - }), $.tn(' '), $.el('img', { - src: capcode === 'A' ? '//static.4chan.org/image/adminicon.gif' : '//static.4chan.org/image/modicon.gif', - alt: capcode === 'A' ? 'This user is the 4chan Administrator.' : 'This user is a 4chan Moderator.', - title: capcode === 'A' ? 'This user is the 4chan Administrator.' : 'This user is a 4chan Moderator.', - className: 'identityIcon' - }) - ]); - } - pi = $.el('div', { - id: "pi" + postID, - className: 'postInfo desktop', - innerHTML: " data.fourchan_date No." + postID + "" - }); - $('.subject', pi).textContent = subject; - nameBlock = $('.nameBlock', pi); - if (data.email) { - email = $.el('a', { - className: 'useremail', - href: "mailto:" + data.email - }); - $.add(nameBlock, email); - nameBlock = email; - } - $.add(nameBlock, $.el('span', { - className: 'name', - textContent: data.name - })); - if (userID) { - $.add(nameBlock, [ - $.tn(' '), $.el('span', { - className: "posteruid id_" + userID, - innerHTML: "(ID: " + userID + ")" - }) - ]); - } - if (trip) { - $.add(nameBlock, [ - $.tn(' '), $.el('span', { - className: 'postertrip', - textContent: trip - }) - ]); - } - nameBlock = $('.nameBlock', pi); - switch (capcode) { - case 'A': - $.addClass(nameBlock, 'capcodeAdmin'); - $.add(nameBlock, [ - $.tn(' '), $.el('strong', { - className: 'capcode', - textContent: '## Admin' - }), $.tn(' '), $.el('img', { - src: '//static.4chan.org/image/adminicon.gif', - alt: 'This user is the 4chan Administrator.', - title: 'This user is the 4chan Administrator.', - className: 'identityIcon' - }) - ]); - break; - case 'M': - $.addClass(nameBlock, 'capcodeMod'); - $.add(nameBlock, [ - $.tn(' '), $.el('strong', { - className: 'capcode', - textContent: '## Mod' - }), $.tn(' '), $.el('img', { - src: '//static.4chan.org/image/modicon.gif', - alt: 'This user is a 4chan Moderator.', - title: 'This user is a 4chan Moderator.', - className: 'identityIcon' - }) - ]); - break; - case 'D': - $.addClass(nameBlock, 'capcodeDeveloper'); - $.add(nameBlock, [ - $.tn(' '), $.el('strong', { - className: 'capcode', - textContent: '## Developer' - }), $.tn(' '), $.el('img', { - src: '//static.4chan.org/image/developericon.gif', - alt: 'This user is a 4chan Developer.', - title: 'title="This user is a 4chan Developer.', - className: 'identityIcon' - }) - ]); - } bq = $.el('blockquote', { - id: "m" + postID, - className: 'postMessage', textContent: data.comment }); bq.innerHTML = bq.innerHTML.replace(/\n|\[\/?b\]|\[\/?spoiler\]|\[\/?code\]|\[\/?moot\]|\[\/?banned\]/g, function(text) { @@ -3696,37 +3565,47 @@ return ''; } }); - bq.innerHTML = bq.innerHTML.replace(/(^|>)(>[^<$]+)(<|$)/g, '$1$2$3'); - pc = $.el('div', { - id: "pc" + postID, - className: "postContainer " + (isOP ? 'op' : 'reply') + "Container", - innerHTML: "
" - }); - $.add(pc.firstChild, [piM, pi, bq]); - if (filename = data.media_filename) { - file = $.el('div', { - id: "f" + postID, - className: 'file' - }); - spoiler = data.spoiler === '1'; - filesize = $.bytesToString(data.media_size); - $.add(file, $.el('div', { - className: 'fileInfo', - innerHTML: "File: " + data.media_orig + "-(" + (spoiler ? 'Spoiler Image, ' : '') + filesize + ", " + data.media_w + "x" + data.media_h + ", )" - })); - span = $('span[title]', file); - span.title = filename; - span.textContent = $.shortenFilename(filename, isOP); - thumb_src = data.media_status === 'available' ? "src=" + data.thumb_link : ''; - $.add(file, $.el('a', { - className: spoiler ? 'fileThumb imgspoiler' : 'fileThumb', - href: data.media_link || data.remote_media_link, - target: '_blank', - innerHTML: "" + (data.media_status !== " - })); - $.after((isOP ? piM : pi), file); + comment = bq.innerHTML.replace(/(^|>)(>[^<$]+)(<|$)/g, '$1$2$3'); + o = { + postID: postID, + threadID: data.thread_num, + board: board, + name: data.name_processed, + capcode: (function() { + switch (data.capcode) { + case 'M': + return 'mod'; + case 'A': + return 'admin'; + case 'D': + return 'developer'; + } + })(), + tripcode: data.trip, + uniqueID: data.poster_hash, + email: encodeURIComponent(data.email), + subject: data.title_processed, + flagCode: data.poster_country, + date: data.fourchan_date, + dateUTC: data.timestamp, + comment: comment + }; + if (data.media_filename) { + o.file = { + name: data.media_filename_processed, + timestamp: data.media_orig, + url: data.media_link || data.remote_media_link, + height: data.media_h, + width: data.media_w, + MD5: data.media_hash, + size: data.media_size, + turl: data.thumb_link || ("//thumbs.4chan.org/" + board + "/thumb/" + data.preview_orig), + theight: data.preview_h, + twidth: data.preview_w, + isSpoiler: data.spoiler === '1' + }; } - $.replace(root.firstChild, Get.cleanPost(pc)); + $.replace(root.firstChild, Get.cleanPost(Build.post(o, true))); if (cb) { return cb(); } @@ -3782,6 +3661,164 @@ } }; + Build = { + shortFilename: function(filename, isOP) { + var threshold; + threshold = isOP ? 40 : 30; + if (filename.length - 4 > threshold) { + return "" + filename.slice(0, threshold - 5) + "(...)." + filename.slice(-3); + } else { + return filename; + } + }, + postFromObject: function(data, board) { + var o; + o = { + postID: data.no, + threadID: data.resto || data.no, + board: board, + name: data.name, + capcode: data.capcode, + tripcode: data.trip, + uniqueID: data.id, + email: data.email.replace(/\s/g, '%20'), + subject: data.sub, + flagCode: data.country, + flagName: data.country_name, + date: data.now, + dateUTC: data.time, + comment: data.com + }; + if (data.ext) { + o.file = { + name: data.filename + data.ext, + timestamp: "" + data.tim + data.ext, + url: "//images.4chan.org/" + board + "/src/" + data.tim + data.ext, + height: data.h, + width: data.w, + MD5: data.md5, + size: data.fsize, + turl: "//thumbs.4chan.org/" + board + "/thumb/" + data.tim + "s.jpg", + theight: data.tn_h, + twidth: data.tn_w, + isSpoiler: !!data.spoiler, + isDeleted: !!data.filedeleted + }; + } + return Build.post(o); + }, + post: function(o, isArchived) { + /* + This function contains code from 4chan-JS (https://github.com/4chan/4chan-JS). + @license: https://github.com/4chan/4chan-JS/blob/master/LICENSE + */ + + var board, capcode, capcodeClass, capcodeStart, comment, container, date, dateUTC, email, emailEnd, emailStart, ext, file, fileDims, fileHTML, fileInfo, fileSize, fileThumb, flag, flagCode, flagName, href, imgSrc, isOP, name, postID, quote, staticPath, subject, threadID, tripcode, uniqueID, userID, _i, _len, _ref; + postID = o.postID, threadID = o.threadID, board = o.board, name = o.name, capcode = o.capcode, tripcode = o.tripcode, uniqueID = o.uniqueID, email = o.email, subject = o.subject, flagCode = o.flagCode, flagName = o.flagName, date = o.date, dateUTC = o.dateUTC, comment = o.comment, file = o.file; + isOP = postID === threadID; + staticPath = '//static.4chan.org'; + if (email) { + emailStart = ''; + emailEnd = ''; + } else { + emailStart = ''; + emailEnd = ''; + } + userID = !capcode && uniqueID ? (" (ID: ") + ("" + uniqueID + ") ") : ''; + switch (capcode) { + case 'admin': + case 'admin_highlight': + capcodeClass = " capcodeAdmin"; + capcodeStart = " ## Admin"; + capcode = (" "; + break; + case 'mod': + capcodeClass = " capcodeMod"; + capcodeStart = " ## Moderator"; + capcode = (" "; + break; + case 'developer': + capcodeClass = " capcodeDeveloper"; + capcodeStart = " ## Developer"; + capcode = (" "; + break; + default: + capcodeClass = ''; + capcodeStart = ''; + capcode = ''; + } + flag = flagCode ? ("  + flagCode + ") : ''; + if (file != null ? file.isDeleted : void 0) { + fileHTML = isOP ? ("
") + ("File deleted.") + "
" : ("
") + ("File deleted.") + "
"; + } else if (file) { + ext = file.name.slice(-3); + if (!file.twidth && !file.theight && ext === 'gif') { + file.twidth = file.width; + file.theight = file.height; + } + fileSize = $.bytesToString(file.size); + fileThumb = file.turl; + if (file.isSpoiler) { + fileSize = "Spoiler Image, " + fileSize; + if (!isArchived) { + fileThumb = '//thumbs.4chan.org/image/spoiler'; + fileThumb += (function() { + switch (board) { + case 'a': + return '-a'; + case 'co': + return '-co'; + case 'jp': + return '-jp'; + case 'lit': + return 'lit'; + case 'm': + return '-m2'; + case 'mlp': + return '-mlp'; + case 'tg': + return '-tg2'; + case 'tv': + return '-tv5'; + case 'v': + case 'vg': + return '-v'; + case 'vp': + return '-vp'; + default: + return ''; + } + })(); + fileThumb += '.png'; + file.twidth = file.theight = 100; + } + } + imgSrc = ("") + ("" + fileSize + ""); + fileDims = ext === 'pdf' ? 'PDF' : "" + file.width + "x" + file.height; + fileInfo = ("File: " + file.timestamp + "") + ("-(" + fileSize + ", " + fileDims + (file.isSpoiler ? '' : ", " + (Build.shortFilename(file.name)) + "'")) + ")"; + fileHTML = "
" + fileInfo + "
" + imgSrc + "
"; + } else { + fileHTML = ''; + } + tripcode = tripcode ? " " + tripcode + "" : ''; + container = $.el('div', { + className: "postContainer " + (isOP ? 'op' : 'reply') + "Container", + id: "pc" + postID, + innerHTML: (isOP ? '' : "
>>
") + ("
") + ("' + (isOP ? fileHTML : '') + ("' + (isOP ? '' : fileHTML) + ("
" + comment + "
") + '
' + }); + _ref = $$('.quotelink', container); + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + quote = _ref[_i]; + href = quote.getAttribute('href'); + if (href[0] === '/') { + continue; + } + quote.href = "/" + board + "/res/" + href; + } + return container; + } + }; + TitlePost = { init: function() { return d.title = Get.title(); diff --git a/script.coffee b/script.coffee index 8f8a34812..2be1f4181 100644 --- a/script.coffee +++ b/script.coffee @@ -368,15 +368,6 @@ $.extend $, script = $.el 'script', textContent: code $.add d.head, script $.rm script - shortenFilename: (filename, isOP) -> - # FILENAME SHORTENING SCIENCE: - # OPs have a +10 characters threshold. - # The file extension is not taken into account. - threshold = 30 + 10 * isOP - if filename.replace(/\.\w+$/, '').length > threshold - "#{filename[...threshold - 5]}(...)#{filename.match(/\.\w+$/)}" - else - filename bytesToString: (size) -> unit = 0 # Bytes while size >= 1024 @@ -1977,7 +1968,7 @@ QR = # Enable auto-posting if we have stuff to post, disable it otherwise. QR.cooldown.auto = QR.replies.length > 1 QR.cooldown.set if g.BOARD is 'q' or /sage/i.test reply.email then 60 else 30 - if Conf['Open Reply in New Tab'] && !g.REPLY && !QR.cooldown.auto + if Conf['Open Reply in New Tab'] and !g.REPLY and !QR.cooldown.auto $.open "//boards.4chan.org/#{g.BOARD}/res/#{threadID}#p#{postID}" if Conf['Persistent QR'] or QR.cooldown.auto @@ -2410,7 +2401,7 @@ Updater = Updater.unsuccessfulFetchCount = 0 Updater.set 'timer', -Updater.getInterval() - scroll = Conf['Scrolling'] && Updater.scrollBG() && + scroll = Conf['Scrolling'] and Updater.scrollBG() and lastPost.getBoundingClientRect().bottom - d.documentElement.clientHeight < 25 $.add Updater.thread, nodes.reverse() if scroll @@ -2689,7 +2680,7 @@ FileInfo = unit: alt.match(/\w+$/)[0] resolution: node.textContent.match(/\d+x\d+|PDF/)[0] fullname: filename - shortname: $.shortenFilename filename, post.ID is post.threadID + shortname: Build.shortFilename filename, post.ID is post.threadID # XXX GM/Scriptish node.setAttribute 'data-filename', filename node.innerHTML = FileInfo.funk FileInfo @@ -2738,7 +2729,7 @@ Get = root.textContent = "Loading post No.#{postID}..." if threadID - $.cache "/#{board}/res/#{threadID}", -> + $.cache "//api.4chan.org/#{board}/res/#{threadID}.json", -> Get.parsePost @, board, threadID, postID, root, cb else if url = Redirect.post board, postID $.cache url, -> @@ -2751,6 +2742,7 @@ Get = $.cache url, -> Get.parseArchivedPost @, board, postID, root, cb else + $.addClass root, 'warning' root.textContent = if status is 404 "Thread No.#{threadID} has not been found." @@ -2758,153 +2750,31 @@ Get = "Error #{req.status}: #{req.statusText}." return - doc = d.implementation.createHTMLDocument '' - doc.documentElement.innerHTML = req.response + posts = JSON.parse(req.response).posts + postID = +postID + for post in posts + break if post.no is postID # we found it! + if post.no > postID + # The post can be deleted by the time we check a quote. + if url = Redirect.post board, postID + $.cache url, -> + Get.parseArchivedPost @, board, postID, root, cb + else + $.addClass root, 'warning' + root.textContent = "Post No.#{postID} has not been found." + return - unless pc = doc.getElementById "pc#{postID}" - # The post can be deleted by the time we check a quote. - if url = Redirect.post board, postID - $.cache url, -> - Get.parseArchivedPost @, board, postID, root, cb - else - root.textContent = "Post No.#{postID} has not been found." - return - pc = Get.cleanPost d.importNode pc, true - - for quote in $$ '.quotelink', pc - href = quote.getAttribute 'href' - continue if href[0] is '/' # Cross-board quote, or board link - quote.href = "/#{board}/res/#{href}" # Fix pathnames - link = $ 'a[title="Highlight this post"]', pc - link.href = "/#{board}/res/#{threadID}#p#{postID}" - link.nextSibling.href = "/#{board}/res/#{threadID}#q#{postID}" - - $.replace root.firstChild, pc + $.replace root.firstChild, Get.cleanPost Build.postFromObject post, board cb() if cb parseArchivedPost: (req, board, postID, root, cb) -> data = JSON.parse req.response - $.addClass root, 'archivedPost' if data.error + $.addClass root, 'warning' root.textContent = data.error return - threadID = data.thread_num - isOP = postID is threadID - {name, trip, timestamp} = data - subject = data.title - userID = data.poster_hash - - # post info (mobile) - piM = $.el 'div', - id: "pim#{postID}" - className: 'postInfoM mobile' - innerHTML: "
#{data.fourchan_date}
No.#{postID}
" - $('.name', piM).textContent = name - $('.subject', piM).textContent = subject - br = $ 'br', piM - if trip - $.before br, [$.tn(' '), $.el 'span', - className: 'postertrip' - textContent: trip - ] - {capcode} = data - if capcode isnt 'N' # 'A'dmin or 'M'od - $.addClass br.parentNode, if capcode is 'A' then 'capcodeAdmin' else 'capcodeMod' - $.before br, [ - $.tn(' '), - $.el('strong', - className: 'capcode', - textContent: if capcode is 'A' then '## Admin' else '## Mod' - ), - $.tn(' '), - $.el('img', - src: if capcode is 'A' then '//static.4chan.org/image/adminicon.gif' else '//static.4chan.org/image/modicon.gif', - alt: if capcode is 'A' then 'This user is the 4chan Administrator.' else 'This user is a 4chan Moderator.', - title: if capcode is 'A' then 'This user is the 4chan Administrator.' else 'This user is a 4chan Moderator.', - className: 'identityIcon' - ) - ] - - # post info - pi = $.el 'div', - id: "pi#{postID}" - className: 'postInfo desktop' - innerHTML: " data.fourchan_date No.#{postID}" - # subject - $('.subject', pi).textContent = subject - nameBlock = $ '.nameBlock', pi - if data.email - email = $.el 'a', - className: 'useremail' - href: "mailto:#{data.email}" - $.add nameBlock, email - nameBlock = email - $.add nameBlock, $.el 'span', - className: 'name' - textContent: data.name - if userID - $.add nameBlock, [$.tn(' '), $.el('span', - className: "posteruid id_#{userID}" - innerHTML: "(ID: #{userID})" - )] - if trip - $.add nameBlock, [$.tn(' '), $.el('span', className: 'postertrip', textContent: trip)] - nameBlock = $ '.nameBlock', pi - switch capcode # 'A'dmin or 'M'od or 'D'eveloper - when 'A' - $.addClass nameBlock, 'capcodeAdmin' - $.add nameBlock, [ - $.tn(' '), - $.el('strong', - className: 'capcode' - textContent: '## Admin' - ), - $.tn(' '), - $.el('img', - src: '//static.4chan.org/image/adminicon.gif' - alt: 'This user is the 4chan Administrator.' - title: 'This user is the 4chan Administrator.' - className: 'identityIcon' - ) - ] - when 'M' - $.addClass nameBlock, 'capcodeMod' - $.add nameBlock, [ - $.tn(' '), - $.el('strong', - className: 'capcode' - textContent: '## Mod' - ), - $.tn(' '), - $.el('img', - src: '//static.4chan.org/image/modicon.gif' - alt: 'This user is a 4chan Moderator.' - title: 'This user is a 4chan Moderator.' - className: 'identityIcon' - ) - ] - when 'D' - $.addClass nameBlock, 'capcodeDeveloper' - $.add nameBlock, [ - $.tn(' '), - $.el('strong', - className: 'capcode' - textContent: '## Developer' - ), - $.tn(' '), - $.el('img', - src: '//static.4chan.org/image/developericon.gif' - alt: 'This user is a 4chan Developer.' - title: 'title="This user is a 4chan Developer.' - className: 'identityIcon' - ) - ] - - # comment - bq = $.el 'blockquote', - id: "m#{postID}" - className: 'postMessage' - textContent: data.comment # set this first to convert text to HTML entities + # convert comment to html + bq = $.el 'blockquote', textContent: data.comment # set this first to convert text to HTML entities # https://github.com/eksopl/fuuka/blob/master/Board/Yotsuba.pm#L413-452 # https://github.com/eksopl/asagi/blob/master/src/main/java/net/easymodo/asagi/Yotsuba.java#L109-138 bq.innerHTML = bq.innerHTML.replace /// @@ -2939,37 +2809,44 @@ Get = when '[/banned]' '' # greentext - bq.innerHTML = bq.innerHTML.replace /(^|>)(>[^<$]+)(<|$)/g, '$1$2$3' + comment = bq.innerHTML.replace /(^|>)(>[^<$]+)(<|$)/g, '$1$2$3' - # post container - pc = $.el 'div', - id: "pc#{postID}" - className: "postContainer #{if isOP then 'op' else 'reply'}Container" - innerHTML: "
" - $.add pc.firstChild, [piM, pi, bq] + o = + # id + postID: postID + threadID: data.thread_num + board: board + # info + name: data.name_processed + capcode: switch data.capcode + when 'M' then 'mod' + when 'A' then 'admin' + when 'D' then 'developer' + tripcode: data.trip + uniqueID: data.poster_hash + email: encodeURIComponent data.email + subject: data.title_processed + flagCode: data.poster_country + # XXX flagName: data.???_processed + date: data.fourchan_date + dateUTC: data.timestamp + comment: comment + # file + if data.media_filename + o.file = + name: data.media_filename_processed + timestamp: data.media_orig + url: data.media_link or data.remote_media_link + height: data.media_h + width: data.media_w + MD5: data.media_hash + size: data.media_size + turl: data.thumb_link or "//thumbs.4chan.org/#{board}/thumb/#{data.preview_orig}" + theight: data.preview_h + twidth: data.preview_w + isSpoiler: data.spoiler is '1' - # file - if filename = data.media_filename - file = $.el 'div', - id: "f#{postID}" - className: 'file' - spoiler = data.spoiler is '1' - filesize = $.bytesToString data.media_size - $.add file, $.el 'div', - className: 'fileInfo' - innerHTML: "File: #{data.media_orig}-(#{if spoiler then 'Spoiler Image, ' else ''}#{filesize}, #{data.media_w}x#{data.media_h}, )" - span = $ 'span[title]', file - span.title = filename - span.textContent = $.shortenFilename filename, isOP - thumb_src = if data.media_status is 'available' then "src=#{data.thumb_link}" else '' - $.add file, $.el 'a', - className: if spoiler then 'fileThumb imgspoiler' else 'fileThumb' - href: data.media_link or data.remote_media_link - target: '_blank' - innerHTML: "#{if data.media_status isnt " - $.after (if isOP then piM else pi), file - - $.replace root.firstChild, Get.cleanPost pc + $.replace root.firstChild, Get.cleanPost Build.post o, true cb() if cb cleanPost: (root) -> post = $ '.post', root @@ -3006,6 +2883,234 @@ Get = span = $.el 'span', innerHTML: el.innerHTML.replace /
/g, ' ' "/#{g.BOARD}/ - #{span.textContent.trim()}" +Build = + shortFilename: (filename, isOP) -> + # FILENAME SHORTENING SCIENCE: + # OPs have a +10 characters threshold. + # The file extension is not taken into account. + threshold = if isOP then 40 else 30 + if filename.length - 4 > threshold + "#{filename[...threshold - 5]}(...).#{filename[-3..]}" + else + filename + postFromObject: (data, board) -> + o = + # id + postID: data.no + threadID: data.resto or data.no + board: board + # info + name: data.name + capcode: data.capcode + tripcode: data.trip + uniqueID: data.id + email: data.email.replace /\s/g, '%20' # UGH + subject: data.sub + flagCode: data.country + flagName: data.country_name + date: data.now + dateUTC: data.time + comment: data.com + # file + if data.ext + o.file = + name: data.filename + data.ext + timestamp: "#{data.tim}#{data.ext}" + url: "//images.4chan.org/#{board}/src/#{data.tim}#{data.ext}" + height: data.h + width: data.w + MD5: data.md5 + size: data.fsize + turl: "//thumbs.4chan.org/#{board}/thumb/#{data.tim}s.jpg" + theight: data.tn_h + twidth: data.tn_w + isSpoiler: !!data.spoiler + isDeleted: !!data.filedeleted + Build.post o + post: (o, isArchived) -> + ### + This function contains code from 4chan-JS (https://github.com/4chan/4chan-JS). + @license: https://github.com/4chan/4chan-JS/blob/master/LICENSE + ### + { + postID, threadID, board + name, capcode, tripcode, uniqueID, email, subject, flagCode, flagName, date, dateUTC + comment + file + } = o + isOP = postID is threadID + + staticPath = '//static.4chan.org' + + if email + emailStart = '' + emailEnd = '' + else + emailStart = '' + emailEnd = '' + + userID = + if !capcode and uniqueID + " (ID: " + + "#{uniqueID}) " + else + '' + + switch capcode + when 'admin', 'admin_highlight' + capcodeClass = " capcodeAdmin" + capcodeStart = " ## Admin" + capcode = " " + when 'mod' + capcodeClass = " capcodeMod" + capcodeStart = " ## Moderator" + capcode = " " + when 'developer' + capcodeClass = " capcodeDeveloper" + capcodeStart = " ## Developer" + capcode = " " + else + capcodeClass = '' + capcodeStart = '' + capcode = '' + + flag = + if flagCode + " #{flagCode}" + else + '' + + if file?.isDeleted + fileHTML = + if isOP + "
" + + "File deleted." + + "
" + else + "
" + + "File deleted." + + "
" + else if file + ext = file.name[-3..] + if !file.twidth and !file.theight and ext is 'gif' # wtf ? + file.twidth = file.width + file.theight = file.height + + fileSize = $.bytesToString file.size + + fileThumb = file.turl + if file.isSpoiler + fileSize = "Spoiler Image, #{fileSize}" + unless isArchived + fileThumb = '//thumbs.4chan.org/image/spoiler' + fileThumb += switch board + # UGGH, I can't wait to maintain this crap. + # Sup desuwa? + when 'a' then '-a' + when 'co' then '-co' + when 'jp' then '-jp' + when 'lit' then 'lit' + when 'm' then '-m2' + when 'mlp' then '-mlp' + when 'tg' then '-tg2' + when 'tv' then '-tv5' + when 'v', 'vg' then '-v' + when 'vp' then '-vp' + else '' + fileThumb += '.png' + file.twidth = file.theight = 100 + + imgSrc = "" + + "#{fileSize}" + + fileDims = if ext is 'pdf' then 'PDF' else "#{file.width}x#{file.height}" + fileInfo = "File: #{file.timestamp}" + + "-(#{fileSize}, #{fileDims}#{ + if file.isSpoiler + '' + else + ", #{Build.shortFilename file.name}'" + }" + ")" + + fileHTML = "
#{fileInfo}
#{imgSrc}
" + else + fileHTML = '' + + tripcode = + if tripcode + " #{tripcode}" + else + '' + + container = $.el 'div', + className: "postContainer #{if isOP then 'op' else 'reply'}Container" + id: "pc#{postID}" + innerHTML: \ + (if isOP then '' else "
>>
") + + "
" + + + "' + + + (if isOP then fileHTML else '') + + + "' + + + (if isOP then '' else fileHTML) + + + "
#{comment}
" + + + '
' + + for quote in $$ '.quotelink', container + href = quote.getAttribute 'href' + continue if href[0] is '/' # Cross-board quote, or board link + quote.href = "/#{board}/res/#{href}" # Fix pathnames + + container TitlePost = init: -> d.title = Get.title() From 8d1a1ca6dddfdc62ffc86e4c47e4a217931d91e9 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Fri, 7 Sep 2012 18:48:59 +0200 Subject: [PATCH 06/37] Changelog --- changelog | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/changelog b/changelog index bb5cac57a..168492998 100644 --- a/changelog +++ b/changelog @@ -1,4 +1,8 @@ master +- Mayhem + Use 4chan's API to fetch posts for: + - Quote Inlining. + - Quote Previewing. 2.34.10 - Mayhem From fe2a6641687f8680c02d40b4cb8e05e680af7b0e Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Fri, 7 Sep 2012 18:51:19 +0200 Subject: [PATCH 07/37] Don't strike-through deadlinks. --- 4chan_x.user.js | 3 +++ script.coffee | 3 +++ 2 files changed, 6 insertions(+) diff --git a/4chan_x.user.js b/4chan_x.user.js index a5f5f3455..842e70a71 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -5766,6 +5766,9 @@ body.unscroll {\ .qphl {\ outline: 2px solid rgba(216, 94, 49, .7);\ }\ +.quotelink.deadlink {\ + text-decoration: underline !important;\ +}\ .inlined {\ opacity: .5;\ }\ diff --git a/script.coffee b/script.coffee index 2be1f4181..99763ca6a 100644 --- a/script.coffee +++ b/script.coffee @@ -4674,6 +4674,9 @@ body.unscroll { .qphl { outline: 2px solid rgba(216, 94, 49, .7); } +.quotelink.deadlink { + text-decoration: underline !important; +} .inlined { opacity: .5; } From 946daebac9aca6d2161edac56d5c3b184db5a1dc Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Fri, 7 Sep 2012 20:20:48 +0200 Subject: [PATCH 08/37] Fix for deleted files. --- 4chan_x.user.js | 4 ++-- script.coffee | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 842e70a71..03f854597 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -3689,7 +3689,7 @@ dateUTC: data.time, comment: data.com }; - if (data.ext) { + if (data.ext || data.filedeleted) { o.file = { name: data.filename + data.ext, timestamp: "" + data.tim + data.ext, @@ -3802,8 +3802,8 @@ } tripcode = tripcode ? " " + tripcode + "" : ''; container = $.el('div', { - className: "postContainer " + (isOP ? 'op' : 'reply') + "Container", id: "pc" + postID, + className: "postContainer " + (isOP ? 'op' : 'reply') + "Container", innerHTML: (isOP ? '' : "
>>
") + ("
") + ("' + (isOP ? fileHTML : '') + ("' + (isOP ? '' : fileHTML) + ("
" + comment + "
") + '
' }); _ref = $$('.quotelink', container); diff --git a/script.coffee b/script.coffee index 99763ca6a..f0d1e0c71 100644 --- a/script.coffee +++ b/script.coffee @@ -2912,7 +2912,7 @@ Build = dateUTC: data.time comment: data.com # file - if data.ext + if data.ext or data.filedeleted o.file = name: data.filename + data.ext timestamp: "#{data.tim}#{data.ext}" @@ -3053,8 +3053,8 @@ Build = '' container = $.el 'div', - className: "postContainer #{if isOP then 'op' else 'reply'}Container" id: "pc#{postID}" + className: "postContainer #{if isOP then 'op' else 'reply'}Container" innerHTML: \ (if isOP then '' else "
>>
") + "
" + From 37933050a9634296daa4a9adca8d3108d6fd1dfb Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Fri, 7 Sep 2012 20:31:26 +0200 Subject: [PATCH 09/37] Add sticky and closed. --- 4chan_x.user.js | 12 ++++++++---- script.coffee | 19 +++++++++++++++++-- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 03f854597..c1fb119eb 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -3687,7 +3687,9 @@ flagName: data.country_name, date: data.now, dateUTC: data.time, - comment: data.com + comment: data.com, + isSticky: !!data.sticky, + isClosed: !!data.closed }; if (data.ext || data.filedeleted) { o.file = { @@ -3713,8 +3715,8 @@ @license: https://github.com/4chan/4chan-JS/blob/master/LICENSE */ - var board, capcode, capcodeClass, capcodeStart, comment, container, date, dateUTC, email, emailEnd, emailStart, ext, file, fileDims, fileHTML, fileInfo, fileSize, fileThumb, flag, flagCode, flagName, href, imgSrc, isOP, name, postID, quote, staticPath, subject, threadID, tripcode, uniqueID, userID, _i, _len, _ref; - postID = o.postID, threadID = o.threadID, board = o.board, name = o.name, capcode = o.capcode, tripcode = o.tripcode, uniqueID = o.uniqueID, email = o.email, subject = o.subject, flagCode = o.flagCode, flagName = o.flagName, date = o.date, dateUTC = o.dateUTC, comment = o.comment, file = o.file; + var board, capcode, capcodeClass, capcodeStart, closed, comment, container, date, dateUTC, email, emailEnd, emailStart, ext, file, fileDims, fileHTML, fileInfo, fileSize, fileThumb, flag, flagCode, flagName, href, imgSrc, isClosed, isOP, isSticky, name, postID, quote, staticPath, sticky, subject, threadID, tripcode, uniqueID, userID, _i, _len, _ref; + postID = o.postID, threadID = o.threadID, board = o.board, name = o.name, capcode = o.capcode, tripcode = o.tripcode, uniqueID = o.uniqueID, email = o.email, subject = o.subject, flagCode = o.flagCode, flagName = o.flagName, date = o.date, dateUTC = o.dateUTC, isSticky = o.isSticky, isClosed = o.isClosed, comment = o.comment, file = o.file; isOP = postID === threadID; staticPath = '//static.4chan.org'; if (email) { @@ -3801,10 +3803,12 @@ fileHTML = ''; } tripcode = tripcode ? " " + tripcode + "" : ''; + sticky = isSticky ? ' Sticky' : ''; + closed = isClosed ? ' Closed' : ''; container = $.el('div', { id: "pc" + postID, className: "postContainer " + (isOP ? 'op' : 'reply') + "Container", - innerHTML: (isOP ? '' : "
>>
") + ("
") + ("' + (isOP ? fileHTML : '') + ("' + (isOP ? '' : fileHTML) + ("
" + comment + "
") + '
' + innerHTML: (isOP ? '' : "
>>
") + ("
") + ("' + (isOP ? fileHTML : '') + ("' + (isOP ? '' : fileHTML) + ("
" + comment + "
") + '
' }); _ref = $$('.quotelink', container); for (_i = 0, _len = _ref.length; _i < _len; _i++) { diff --git a/script.coffee b/script.coffee index f0d1e0c71..43b986ebf 100644 --- a/script.coffee +++ b/script.coffee @@ -2911,6 +2911,9 @@ Build = date: data.now dateUTC: data.time comment: data.com + # thread status + isSticky: !!data.sticky + isClosed: !!data.closed # file if data.ext or data.filedeleted o.file = @@ -2935,6 +2938,7 @@ Build = { postID, threadID, board name, capcode, tripcode, uniqueID, email, subject, flagCode, flagName, date, dateUTC + isSticky, isClosed comment file } = o @@ -3052,6 +3056,17 @@ Build = else '' + sticky = + if isSticky + ' Sticky' + else + '' + closed = + if isClosed + ' Closed' + else + '' + container = $.el 'div', id: "pc#{postID}" className: "postContainer #{if isOP then 'op' else 'reply'}Container" @@ -3063,7 +3078,7 @@ Build = "" + emailStart + "#{name}" + tripcode + - emailEnd + capcodeStart + capcode + userID + flag + + emailEnd + capcodeStart + capcode + userID + flag + sticky + closed + "
#{subject}" + "
#{date}" + '
' + @@ -3085,7 +3100,7 @@ Build = "" + emailStart + "#{name}" + tripcode + - emailEnd + capcodeStart + capcode + userID + flag + + emailEnd + capcodeStart + capcode + userID + flag + sticky + closed + ' ' + "#{date} " + "" + From c7bfdecb2e47643207961b3a181069eea48ed816 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Fri, 7 Sep 2012 20:33:12 +0200 Subject: [PATCH 10/37] Add admin_highlight hl class. --- 4chan_x.user.js | 8 ++++++-- script.coffee | 4 +++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index c1fb119eb..fe33c44e4 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -3715,7 +3715,7 @@ @license: https://github.com/4chan/4chan-JS/blob/master/LICENSE */ - var board, capcode, capcodeClass, capcodeStart, closed, comment, container, date, dateUTC, email, emailEnd, emailStart, ext, file, fileDims, fileHTML, fileInfo, fileSize, fileThumb, flag, flagCode, flagName, href, imgSrc, isClosed, isOP, isSticky, name, postID, quote, staticPath, sticky, subject, threadID, tripcode, uniqueID, userID, _i, _len, _ref; + var board, capcode, capcodeClass, capcodeStart, closed, comment, container, date, dateUTC, email, emailEnd, emailStart, ext, file, fileDims, fileHTML, fileInfo, fileSize, fileThumb, flag, flagCode, flagName, highlight, href, imgSrc, isClosed, isOP, isSticky, name, postID, quote, staticPath, sticky, subject, threadID, tripcode, uniqueID, userID, _i, _len, _ref; postID = o.postID, threadID = o.threadID, board = o.board, name = o.name, capcode = o.capcode, tripcode = o.tripcode, uniqueID = o.uniqueID, email = o.email, subject = o.subject, flagCode = o.flagCode, flagName = o.flagName, date = o.date, dateUTC = o.dateUTC, isSticky = o.isSticky, isClosed = o.isClosed, comment = o.comment, file = o.file; isOP = postID === threadID; staticPath = '//static.4chan.org'; @@ -3730,6 +3730,9 @@ switch (capcode) { case 'admin': case 'admin_highlight': + if (capcode === 'admin_highlight') { + highlight = ' highlightPost'; + } capcodeClass = " capcodeAdmin"; capcodeStart = " ## Admin"; capcode = (" "; @@ -3745,6 +3748,7 @@ capcode = (" "; break; default: + highlight = ''; capcodeClass = ''; capcodeStart = ''; capcode = ''; @@ -3808,7 +3812,7 @@ container = $.el('div', { id: "pc" + postID, className: "postContainer " + (isOP ? 'op' : 'reply') + "Container", - innerHTML: (isOP ? '' : "
>>
") + ("
") + ("' + (isOP ? fileHTML : '') + ("' + (isOP ? '' : fileHTML) + ("
" + comment + "
") + '
' + innerHTML: (isOP ? '' : "
>>
") + ("
") + ("' + (isOP ? fileHTML : '') + ("' + (isOP ? '' : fileHTML) + ("
" + comment + "
") + '
' }); _ref = $$('.quotelink', container); for (_i = 0, _len = _ref.length; _i < _len; _i++) { diff --git a/script.coffee b/script.coffee index 43b986ebf..c40851dd7 100644 --- a/script.coffee +++ b/script.coffee @@ -2962,6 +2962,7 @@ Build = switch capcode when 'admin', 'admin_highlight' + highlight = ' highlightPost' if capcode is 'admin_highlight' capcodeClass = " capcodeAdmin" capcodeStart = " ## Admin" @@ -2983,6 +2984,7 @@ Build = "alt='This user is a 4chan Developer.' " + "title='This user is a 4chan Developer.' class=identityIcon>" else + highlight = '' capcodeClass = '' capcodeStart = '' capcode = '' @@ -3072,7 +3074,7 @@ Build = className: "postContainer #{if isOP then 'op' else 'reply'}Container" innerHTML: \ (if isOP then '' else "
>>
") + - "
" + + "
" + "