diff --git a/4chan_x.user.js b/4chan_x.user.js index 637a8bdc8..3d5f79048 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1,5 +1,6 @@ // ==UserScript== // @name 4chan x +// @version 2.21.0 // @namespace aeosynth // @description Adds various features. // @copyright 2009-2011 James Campos @@ -13,7 +14,8 @@ /* LICENSE * * Copyright (c) 2009-2011 James Campos - * http://aeosynth.github.com/4chan-x/ + * http://mayhemydg.github.com/4chan-x/ + * 4chan x 2.21.0 * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation @@ -64,7 +66,7 @@ */ (function() { - var $, $$, DAY, Favicon, HOUR, MINUTE, Main, NAMESPACE, Recaptcha, SECOND, Time, anonymize, conf, config, cooldown, d, expandComment, expandThread, filter, flatten, g, getTitle, imgExpand, imgGif, imgHover, key, keybinds, log, nav, options, qr, quoteBacklink, quoteInline, quoteOP, quotePreview, redirect, replyHiding, reportButton, revealSpoilers, sauce, strikethroughQuotes, threadHiding, threadStats, threading, titlePost, ui, unread, updater, val, watcher; + var $, $$, DAY, Favicon, HOUR, MINUTE, Main, NAMESPACE, Recaptcha, SECOND, Time, VERSION, anonymize, conf, config, cooldown, d, expandComment, expandThread, filter, flatten, g, getTitle, imgExpand, imgGif, imgHover, key, keybinds, log, nav, options, qr, quoteBacklink, quoteInline, quoteOP, quotePreview, redirect, replyHiding, reportButton, revealSpoilers, sauce, strikethroughQuotes, threadHiding, threadStats, threading, titlePost, ui, unread, updater, val, watcher; var __slice = Array.prototype.slice; config = { @@ -77,7 +79,8 @@ 'Comment Expansion': [true, 'Expand too long comments'], 'Thread Expansion': [true, 'View all replies'], 'Index Navigation': [true, 'Navigate to previous / next thread'], - 'Reply Navigation': [false, 'Navigate to top / bottom of thread'] + 'Reply Navigation': [false, 'Navigate to top / bottom of thread'], + 'Check for Updates': [true, 'Check for updated versions of 4chan X'] }, Filtering: { 'Anonymize': [false, 'Make everybody anonymous'], @@ -208,6 +211,8 @@ NAMESPACE = '4chan_x.'; + VERSION = '2.21.0'; + SECOND = 1000; MINUTE = 60 * SECOND; @@ -2963,6 +2968,11 @@ $.addStyle(Main.css); threading.init(); Favicon.init(); + if (Main.reqUpdate && conf['Check for Updates']) { + $.add(d.head, $.el('script', { + src: 'https://raw.github.com/mayhemydg/4chan-x/master/latest.js' + })); + } if ((form = $('form[name=post]')) && (canPost = !!$('#recaptcha_response_field'))) { Recaptcha.init(); if (g.REPLY && conf['Auto Watch Reply'] && conf['Thread Watcher']) { @@ -3013,9 +3023,13 @@ return options.init(); }, message: function(e) { - var data, origin; + var data, location, origin; origin = e.origin, data = e.data; - if (origin === 'http://sys.4chan.org') return qr.message(data); + if (origin === 'http://sys.4chan.org') { + return qr.message(data); + } else if (data.version !== VERSION && confirm('An updated version of 4chan X is available, would you like to install it now?')) { + return location = "https://raw.github.com/mayhemydg/4chan-x/" + data.version + "/4chan_x.user.js"; + } }, node: function(e) { var callback, target, _i, _len, _ref, _results; diff --git a/Cakefile b/Cakefile index ecdfdada0..95a9112c1 100644 --- a/Cakefile +++ b/Cakefile @@ -2,9 +2,12 @@ {exec} = require 'child_process' fs = require 'fs' +VERSION = '2.21.0' + HEADER = """ // ==UserScript== // @name 4chan x +// @version #{VERSION} // @namespace aeosynth // @description Adds various features. // @copyright 2009-2011 James Campos @@ -18,7 +21,8 @@ HEADER = """ /* LICENSE * * Copyright (c) 2009-2011 James Campos - * http://aeosynth.github.com/4chan-x/ + * http://mayhemydg.github.com/4chan-x/ + * 4chan x #{VERSION} * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation diff --git a/changelog b/changelog index 5e4949c76..2ba9d2244 100644 --- a/changelog +++ b/changelog @@ -1,4 +1,6 @@ master + +2.21.0 - mayhem initiate 4chan X earlier performance improvements @@ -7,8 +9,6 @@ master automatically reload expanded pictures on error handle bans with the thread updater use unread favicons by ferongr -- aeosynth - quick reply redesign 2.20.3 - mayhem diff --git a/script.coffee b/script.coffee index c591d7dd9..7f2a580cd 100644 --- a/script.coffee +++ b/script.coffee @@ -9,6 +9,7 @@ config = 'Thread Expansion': [true, 'View all replies'] 'Index Navigation': [true, 'Navigate to previous / next thread'] 'Reply Navigation': [false, 'Navigate to top / bottom of thread'] + 'Check for Updates': [true, 'Check for updated versions of 4chan X'] Filtering: 'Anonymize': [false, 'Make everybody anonymous'] 'Filter': [false, 'Self-moderation placebo'] @@ -121,6 +122,7 @@ conf = {} ) null, config NAMESPACE = '4chan_x.' +VERSION = '2.21.0' SECOND = 1000 MINUTE = 60*SECOND HOUR = 60*MINUTE @@ -2319,6 +2321,9 @@ Main = threading.init() Favicon.init() + if Main.reqUpdate and conf['Check for Updates'] + $.add d.head, $.el 'script', src: 'https://raw.github.com/mayhemydg/4chan-x/master/latest.js' + #recaptcha may be blocked, eg by noscript if (form = $ 'form[name=post]') and (canPost = !!$ '#recaptcha_response_field') Recaptcha.init() @@ -2397,6 +2402,8 @@ Main = {origin, data} = e if origin is 'http://sys.4chan.org' qr.message data + else if data.version isnt VERSION and confirm 'An updated version of 4chan X is available, would you like to install it now?' + location = "https://raw.github.com/mayhemydg/4chan-x/#{data.version}/4chan_x.user.js" node: (e) -> {target} = e