diff --git a/4chan_x.user.js b/4chan_x.user.js index b7f0c9731..821400d70 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -43,7 +43,7 @@ */ (function() { - var $, $$, AutoGIF, Board, Build, Clone, Conf, Config, FileInfo, Get, ImageHover, Main, Post, QuoteBacklink, QuoteCT, QuoteInline, QuoteOP, QuotePreview, Quotify, Redirect, RevealSpoilers, Sauce, Thread, ThreadUpdater, Time, UI, d, g, + var $, $$, Anonymize, AutoGIF, Board, Build, Clone, Conf, Config, FileInfo, Get, ImageHover, Main, Post, QuoteBacklink, QuoteCT, QuoteInline, QuoteOP, QuotePreview, Quotify, Redirect, RevealSpoilers, Sauce, Thread, ThreadUpdater, Time, UI, d, g, __hasProp = {}.hasOwnProperty, __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; @@ -170,6 +170,22 @@ imageFit: 'fit width' }; + if (!/^(boards|images|sys)\.4chan\.org$/.test(location.hostname)) { + return; + } + + Conf = {}; + + d = document; + + g = { + VERSION: '3.0.0', + NAMESPACE: "4chan_X_Alpha.", + boards: {}, + threads: {}, + posts: {} + }; + UI = (function() { var dialog, drag, dragend, dragstart, hover, hoverend, hoverstart, touchend, touchmove; dialog = function(id, position, html) { @@ -656,22 +672,6 @@ } }); - if (!/^(boards|images|sys)\.4chan\.org$/.test(location.hostname)) { - return; - } - - Conf = {}; - - d = document; - - g = { - VERSION: '3.0.0', - NAMESPACE: "4chan_X_Alpha.", - boards: {}, - threads: {}, - posts: {} - }; - Redirect = { image: function(board, filename) { switch (board) { @@ -1560,6 +1560,37 @@ } }; + Anonymize = { + init: function() { + return Post.prototype.callbacks.push({ + name: 'Anonymize', + cb: this.node + }); + }, + node: function() { + var email, name, tripcode, _ref; + if (this.info.capcode || this.isClone) { + return; + } + _ref = this.nodes, name = _ref.name, tripcode = _ref.tripcode, email = _ref.email; + if (this.info.name !== 'Anonymous') { + name.textContent = 'Anonymous'; + } + if (tripcode) { + $.rm(tripcode); + delete this.nodes.tripcode; + } + if (this.info.email) { + if (/sage/i.test(this.info.email)) { + return email.href = 'mailto:sage'; + } else { + $.replace(email, name); + return delete this.nodes.email; + } + } + } + }; + Time = { init: function() { this.funk = this.createFunc(Conf['time']); @@ -2647,6 +2678,13 @@ $.log(err, 'Indicate Cross-thread Quotes'); } } + if (Conf['Anonymize']) { + try { + Anonymize.init(); + } catch (e) { + $.log(err, 'Anonymize'); + } + } if (Conf['Time Formatting']) { try { Time.init(); diff --git a/grunt.js b/grunt.js index 07b8a788f..ab74c94a5 100644 --- a/grunt.js +++ b/grunt.js @@ -16,9 +16,9 @@ module.exports = function(grunt) { coffee: { src: [ '', + '', '', '', - '', '', '' ], diff --git a/src/features.coffee b/src/features.coffee index a731dc74d..774a6f5ee 100644 --- a/src/features.coffee +++ b/src/features.coffee @@ -846,6 +846,26 @@ QuoteCT = $.add quote, $.tn QuoteCT.text return +Anonymize = + init: -> + Post::callbacks.push + name: 'Anonymize' + cb: @node + node: -> + return if @info.capcode or @isClone + {name, tripcode, email} = @nodes + if @info.name isnt 'Anonymous' + name.textContent = 'Anonymous' + if tripcode + $.rm tripcode + delete @nodes.tripcode + if @info.email + if /sage/i.test @info.email + email.href = 'mailto:sage' + else + $.replace email, name + delete @nodes.email + Time = init: -> @funk = @createFunc Conf['time'] diff --git a/src/main.coffee b/src/main.coffee index dacccfebd..699b8d5b1 100644 --- a/src/main.coffee +++ b/src/main.coffee @@ -362,6 +362,13 @@ Main = # XXX handle error $.log err, 'Indicate Cross-thread Quotes' + if Conf['Anonymize'] + try + Anonymize.init() + catch e + # XXX handle error + $.log err, 'Anonymize' + if Conf['Time Formatting'] try Time.init()