From e29c806268aa66f7c34ff31645644b6683673e4f Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Tue, 26 Jun 2012 17:51:02 +0200 Subject: [PATCH 1/4] =?UTF-8?q?Replace=20×=20and=20\u00d7=20by=20?= =?UTF-8?q?=C3=97.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 4chan_x.user.js | 14 +++++++------- script.coffee | 17 +++++++---------- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index af4c43ba5..d4edfc025 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -846,13 +846,13 @@ a = $('.summary', thread); switch (a.textContent[0]) { case '+': - a.textContent = a.textContent.replace('+', '\u00d7 Loading...'); + a.textContent = a.textContent.replace('+', '× Loading...'); $.cache(pathname, function() { return ExpandThread.parse(this, thread, a); }); break; - case '\u00d7': - a.textContent = a.textContent.replace('\u00d7 Loading...', '+'); + case '×': + a.textContent = a.textContent.replace('× Loading...', '+'); $.cache.requests[pathname].abort(); break; case '-': @@ -883,7 +883,7 @@ $.off(a, 'click', ExpandThread.cb.toggle); return; } - a.textContent = a.textContent.replace('\u00d7 Loading...', '-'); + a.textContent = a.textContent.replace('× Loading...', '-'); doc = d.implementation.createHTMLDocument(''); doc.documentElement.innerHTML = req.response; threadID = thread.id.slice(1); @@ -1693,7 +1693,7 @@ className: 'thumbnail', draggable: true, href: 'javascript:;', - innerHTML: '×' + innerHTML: '×' }); $('input', this.el).checked = this.spoiler; $.on(this.el, 'click', function() { @@ -1975,7 +1975,7 @@ QR.el = UI.dialog('qr', 'top:0;right:0;', '\
\ Quick Reply \ - ×\ + ×\
\
\
\ @@ -2757,7 +2757,7 @@ for (id in _ref) { props = _ref[id]; x = $.el('a', { - textContent: '\u00d7', + textContent: '×', href: 'javascript:;' }); $.on(x, 'click', Watcher.cb.x); diff --git a/script.coffee b/script.coffee index faf99c37e..72085076b 100644 --- a/script.coffee +++ b/script.coffee @@ -646,15 +646,13 @@ ExpandThread = pathname = "/#{g.BOARD}/res/#{thread.id[1..]}" a = $ '.summary', thread - # \u00d7 is × - switch a.textContent[0] when '+' - a.textContent = a.textContent.replace '+', '\u00d7 Loading...' + a.textContent = a.textContent.replace '+', '× Loading...' $.cache pathname, -> ExpandThread.parse @, thread, a - when '\u00d7' - a.textContent = a.textContent.replace '\u00d7 Loading...', '+' + when '×' + a.textContent = a.textContent.replace '× Loading...', '+' $.cache.requests[pathname].abort() when '-' @@ -676,7 +674,7 @@ ExpandThread = $.off a, 'click', ExpandThread.cb.toggle return - a.textContent = a.textContent.replace '\u00d7 Loading...', '-' + a.textContent = a.textContent.replace '× Loading...', '-' doc = d.implementation.createHTMLDocument '' doc.documentElement.innerHTML = req.response @@ -1261,7 +1259,7 @@ QR = className: 'thumbnail' draggable: true href: 'javascript:;' - innerHTML: '×' + innerHTML: '×' $('input', @el).checked = @spoiler $.on @el, 'click', => @select() $.on $('.remove', @el), 'click', (e) => @@ -1466,7 +1464,7 @@ QR = QR.el = UI.dialog 'qr', 'top:0;right:0;', '
Quick Reply - × + ×
@@ -2166,8 +2164,7 @@ Watcher = for board of watched for id, props of watched[board] x = $.el 'a', - # \u00d7 is × - textContent: '\u00d7' + textContent: '×' href: 'javascript:;' $.on x, 'click', Watcher.cb.x link = $.el 'a', props From 39ccd42729b7ce7472ef1d86a97d57601bc9726f Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Wed, 27 Jun 2012 18:19:14 +0200 Subject: [PATCH 2/4] Close #567 --- 4chan_x.user.js | 10 ++++++++-- script.coffee | 18 ++++++++---------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index d4edfc025..4b78c72ad 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -4160,10 +4160,13 @@ } url = "//images.4chan.org/" + src[3] + "/src/" + src[5] + "?" + (Date.now()); } + if ($.engine !== 'webkit' && url.split('/')[2] === 'images.4chan.org') { + return; + } timeoutID = setTimeout((function() { return _this.src = url; }), 3000); - if (!($.engine === 'webkit' && src[2] === 'images.4chan.org')) { + if ($.engine !== 'webkit' || url.split('/')[2] !== 'images.4chan.org') { return; } return $.ajax(url, { @@ -4345,8 +4348,11 @@ } url = "//images.4chan.org/" + src[3] + "/src/" + src[5] + "?" + (Date.now()); } + if ($.engine !== 'webkit' && url.split('/')[2] === 'images.4chan.org') { + return; + } timeoutID = setTimeout(ImageExpand.expand, 10000, thumb, url); - if (!($.engine === 'webkit' && url.split('/')[2] === 'images.4chan.org')) { + if ($.engine !== 'webkit' || url.split('/')[2] !== 'images.4chan.org') { return; } return $.ajax(url, { diff --git a/script.coffee b/script.coffee index 72085076b..8d6bd53c1 100644 --- a/script.coffee +++ b/script.coffee @@ -3228,14 +3228,13 @@ ImageHover = src = @src.replace(/\?\d+$/, '').split '/' unless src[2] is 'images.4chan.org' and url = Redirect.image src[3], src[5] return if g.dead - # CloudFlare may cache banned pages instead of images. # This will fool CloudFlare's cache. url = "//images.4chan.org/#{src[3]}/src/#{src[5]}?#{Date.now()}" - # navigator.online is not x-browser/os yet + return if $.engine isnt 'webkit' and url.split('/')[2] is 'images.4chan.org' timeoutID = setTimeout (=> @src = url), 3000 - # Only Chrome let userscript break through cross domain requests. - # Don't check it 404s in the archivers. - return unless $.engine is 'webkit' and src[2] is 'images.4chan.org' + # Only Chrome let userscripts do cross domain requests. + # Don't check for 404'd status in the archivers. + return if $.engine isnt 'webkit' or url.split('/')[2] isnt 'images.4chan.org' $.ajax url, onreadystatechange: (-> clearTimeout timeoutID if @status is 404), type: 'head' mouseout: -> @@ -3349,14 +3348,13 @@ ImageExpand = src = @src.replace(/\?\d+$/, '').split '/' unless src[2] is 'images.4chan.org' and url = Redirect.image src[3], src[5] return if g.dead - # CloudFlare may cache banned pages instead of images. # This will fool CloudFlare's cache. url = "//images.4chan.org/#{src[3]}/src/#{src[5]}?#{Date.now()}" - #navigator.online is not x-browser/os yet + return if $.engine isnt 'webkit' and url.split('/')[2] is 'images.4chan.org' timeoutID = setTimeout ImageExpand.expand, 10000, thumb, url - # Only Chrome let userscript break through cross domain requests. - # Don't check it 404s in the archivers. - return unless $.engine is 'webkit' and url.split('/')[2] is 'images.4chan.org' + # Only Chrome let userscripts do cross domain requests. + # Don't check for 404'd status in the archivers. + return if $.engine isnt 'webkit' or url.split('/')[2] isnt 'images.4chan.org' $.ajax url, onreadystatechange: (-> clearTimeout timeoutID if @status is 404), type: 'head' From f4f13449dc8875089925cb6d3571b50b9a4ce5f8 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Thu, 28 Jun 2012 23:06:35 +0200 Subject: [PATCH 3/4] Add /sp/ archive redirection. Update /u/ archive redirection. --- 4chan_x.user.js | 20 +++++++++++++++----- changelog | 2 ++ script.coffee | 14 +++++++++++--- 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 4b78c72ad..87a3b757a 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -4013,10 +4013,12 @@ case 'a': case 'jp': case 'm': + case 'sp': case 'tg': - case 'u': case 'vg': return "//archive.foolz.us/" + board + "/full_image/" + filename; + case 'u': + return "//nsfw.foolz.us/" + board + "/full_image/" + filename; } }, post: function(board, postID) { @@ -4025,15 +4027,17 @@ case 'co': case 'jp': case 'm': + case 'sp': case 'tg': case 'tv': - case 'u': case 'v': case 'vg': case 'dev': case 'foolz': - case 'kuku': return "//archive.foolz.us/api/chan/post/board/" + board + "/num/" + postID + "/format/json"; + case 'u': + case 'kuku': + return "//nsfw.foolz.us/api/chan/post/board/" + board + "/num/" + postID + "/format/json"; } }, thread: function(board, threadID, postID) { @@ -4047,19 +4051,25 @@ case 'co': case 'jp': case 'm': + case 'sp': case 'tg': case 'tv': - case 'u': case 'v': case 'vg': case 'dev': case 'foolz': - case 'kuku': url = "//archive.foolz.us/" + path + "/"; if (threadID && postID) { url += "#" + postID; } break; + case 'u': + case 'kuku': + url = "//nsfw.foolz.us/" + path + "/"; + if (threadID && postID) { + url += "#" + postID; + } + break; case 'lit': url = "//fuuka.warosu.org/" + path; if (threadID && postID) { diff --git a/changelog b/changelog index 1723e3b25..5af3e760e 100644 --- a/changelog +++ b/changelog @@ -1,4 +1,6 @@ master +- Mayhem + Add /sp/ archive redirection. 2.33.4 - Mayhem diff --git a/script.coffee b/script.coffee index 8d6bd53c1..316e66c3f 100644 --- a/script.coffee +++ b/script.coffee @@ -3141,8 +3141,10 @@ Redirect = image: (board, filename) -> # Do not use g.BOARD, the image url can originate from a cross-quote. switch board - when 'a', 'jp', 'm', 'tg', 'u', 'vg' + when 'a', 'jp', 'm', 'sp', 'tg', 'vg' "//archive.foolz.us/#{board}/full_image/#{filename}" + when 'u' + "//nsfw.foolz.us/#{board}/full_image/#{filename}" # these will work whenever https://github.com/eksopl/fuuka/issues/23 is done # when 'cgl', 'g', 'w' # "//archive.rebeccablacktech.com/#{board}/full_image/#{filename}" @@ -3152,8 +3154,10 @@ Redirect = # "https://md401.homelinux.net/4chan/cgi-board.pl/#{board}/full_image/#{filename}" post: (board, postID) -> switch board - when 'a', 'co', 'jp', 'm', 'tg', 'tv', 'u', 'v', 'vg', 'dev', 'foolz', 'kuku' + when 'a', 'co', 'jp', 'm', 'sp', 'tg', 'tv', 'v', 'vg', 'dev', 'foolz' "//archive.foolz.us/api/chan/post/board/#{board}/num/#{postID}/format/json" + when 'u', 'kuku' + "//nsfw.foolz.us/api/chan/post/board/#{board}/num/#{postID}/format/json" thread: (board, threadID, postID) -> # keep the number only if the location.hash was sent f.e. postID = postID.match(/\d+/)[0] if postID @@ -3163,10 +3167,14 @@ Redirect = else "#{board}/post/#{postID}" switch board - when 'a', 'co', 'jp', 'm', 'tg', 'tv', 'u', 'v', 'vg', 'dev', 'foolz', 'kuku' + when 'a', 'co', 'jp', 'm', 'sp', 'tg', 'tv', 'v', 'vg', 'dev', 'foolz' url = "//archive.foolz.us/#{path}/" if threadID and postID url += "##{postID}" + when 'u', 'kuku' + url = "//nsfw.foolz.us/#{path}/" + if threadID and postID + url += "##{postID}" when 'lit' url = "//fuuka.warosu.org/#{path}" if threadID and postID From 52043d63eeb8fbbc6cbfb75fc91298e6bb196513 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Thu, 28 Jun 2012 23:06:49 +0200 Subject: [PATCH 4/4] Release 2.33.5. --- 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 87a3b757a..786b12a00 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1,6 +1,6 @@ // ==UserScript== // @name 4chan x -// @version 2.33.4 +// @version 2.33.5 // @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.33.4 + * 4chan X 2.33.5 * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation @@ -4734,7 +4734,7 @@ return $.globalEval(("(" + code + ")()").replace('_id_', bq.id)); }, namespace: '4chan_x.', - version: '2.33.4', + version: '2.33.5', callbacks: [], css: '\ /* dialog styling */\ diff --git a/Cakefile b/Cakefile index b5fb8a767..92703dfe7 100644 --- a/Cakefile +++ b/Cakefile @@ -2,7 +2,7 @@ {exec} = require 'child_process' fs = require 'fs' -VERSION = '2.33.4' +VERSION = '2.33.5' HEADER = """ // ==UserScript== diff --git a/changelog b/changelog index 5af3e760e..3b0e81854 100644 --- a/changelog +++ b/changelog @@ -1,4 +1,6 @@ master + +2.33.5 - Mayhem Add /sp/ archive redirection. diff --git a/latest.js b/latest.js index d8e552e0c..59d319320 100644 --- a/latest.js +++ b/latest.js @@ -1 +1 @@ -postMessage({version:'2.33.4'},'*') \ No newline at end of file +postMessage({version:'2.33.5'},'*') \ No newline at end of file diff --git a/script.coffee b/script.coffee index 316e66c3f..e6d5f6411 100644 --- a/script.coffee +++ b/script.coffee @@ -3654,7 +3654,7 @@ Main = $.globalEval "(#{code})()".replace '_id_', bq.id namespace: '4chan_x.' - version: '2.33.4' + version: '2.33.5' callbacks: [] css: ' /* dialog styling */