diff --git a/CHANGELOG.md b/CHANGELOG.md index 2ed9212e6..d173b098e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,5 @@ +- Fix resurrecting dead quotelinks on HTTP. + ### 3.0.6 - *2013-04-14* - Fix regression concerning thread selection when quoting on the index. diff --git a/Gruntfile.coffee b/Gruntfile.coffee index 63c0b2ea0..eb9723650 100644 --- a/Gruntfile.coffee +++ b/Gruntfile.coffee @@ -1,15 +1,16 @@ module.exports = (grunt) -> pkg = grunt.file.readJSON 'package.json' + concatOptions = + process: + data: pkg # Project configuration. grunt.initConfig pkg: pkg concat: coffee: - options: - process: - data: pkg + options: concatOptions src: [ 'src/config.coffee' 'src/globals.coffee' @@ -27,9 +28,7 @@ module.exports = (grunt) -> dest: 'tmp/script.coffee' crx: - options: - process: - data: pkg + options: concatOptions files: 'builds/crx/manifest.json': 'src/manifest.json' 'builds/crx/script.js': [ @@ -38,9 +37,7 @@ module.exports = (grunt) -> ] userjs: - options: - process: - data: pkg + options: concatOptions src: [ 'src/metadata.js' 'src/banner.js' @@ -49,9 +46,7 @@ module.exports = (grunt) -> dest: 'builds/<%= pkg.name %>.js' userscript: - options: - process: - data: pkg + options: concatOptions files: 'builds/<%= pkg.name %>.meta.js': 'src/metadata.js' 'builds/<%= pkg.name %>.user.js': [ @@ -170,22 +165,29 @@ module.exports = (grunt) -> grunt.registerTask 'patch', [ 'bump' + 'reloadPkh' 'updcl:3' ] grunt.registerTask 'minor', [ 'bump:minor' + 'reloadPkh' 'updcl:2' ] grunt.registerTask 'major', [ 'bump:major' + 'reloadPkh' 'updcl:1' ] - grunt.registerTask 'updcl', 'Update the changelog', (i) -> + grunt.registerTask 'reloadPkg', 'Reload the package', -> # Update the `pkg` object with the new version. - pkg = grunt.file.readJSON('package.json'); + pkg = grunt.file.readJSON('package.json') + concatOptions.process.data = pkg + grunt.log.ok('pkg reloaded.') + + grunt.registerTask 'updcl', 'Update the changelog', (i) -> # i is the number of #s for markdown. version = [] version.length = +i + 1 diff --git a/builds/4chan-X.js b/builds/4chan-X.js index 4808b20b3..e67bad09d 100644 --- a/builds/4chan-X.js +++ b/builds/4chan-X.js @@ -865,6 +865,13 @@ }; } })(), + rmAll: function(root) { + var node; + + while (node = root.firstChild) { + $.rm(node); + } + }, tn: function(s) { return d.createTextNode(s); }, @@ -1224,7 +1231,7 @@ var as, list, nodes; list = $('#custom-board-list', Header.nav); - list.innerHTML = null; + $.rmAll(list); if (!text) { return; } @@ -1603,7 +1610,7 @@ } $.addClass($(".tab-" + this.hyphenatedTitle, Settings.dialog), 'tab-selected'); section = $('section', Settings.dialog); - section.innerHTML = null; + $.rmAll(section); section.className = "section-" + this.hyphenatedTitle; this.open(section, g); return section.scrollTop = 0; @@ -1732,7 +1739,7 @@ return; } p = $('.imp-exp-result', Settings.dialog); - p.innerHTML = null; + $.rmAll(p); return $.add(p, a); }, "import": function() { @@ -1873,7 +1880,7 @@ div = this.nextElementSibling; if ((name = this.value) !== 'guide') { - div.innerHTML = null; + $.rmAll(div); ta = $.el('textarea', { name: name, className: 'field', @@ -3753,9 +3760,9 @@ case 'vp': case 'vr': case 'wsg': - return "//archive.foolz.us/_/api/chan/post/?board=" + boardID + "&num=" + postID; + return "https://archive.foolz.us/_/api/chan/post/?board=" + boardID + "&num=" + postID; case 'u': - return "//nsfw.foolz.us/_/api/chan/post/?board=" + boardID + "&num=" + postID; + return "https://nsfw.foolz.us/_/api/chan/post/?board=" + boardID + "&num=" + postID; case 'c': case 'int': case 'out': @@ -3795,10 +3802,10 @@ case 's4s': return Redirect.path('//fuuka.warosu.org', 'fuuka', data); case 'diy': + case 'g': case 'sci': return Redirect.path('//archive.installgentoo.net', 'fuuka', data); case 'cgl': - case 'g': case 'mu': case 'w': return Redirect.path('//rbt.asia', 'fuuka', data); @@ -4110,9 +4117,9 @@ clone = post.addClone(context); Main.callbackNodes(Post, [clone]); nodes = clone.nodes; - nodes.root.innerHTML = null; + $.rmAll(nodes.root); $.add(nodes.root, nodes.post); - root.innerHTML = null; + $.rmAll(root); return $.add(root, nodes.root); }, fetchedPost: function(req, boardID, threadID, postID, root, context) { @@ -6513,7 +6520,7 @@ nodes.push(div); } } - ThreadWatcher.dialog.innerHTML = ''; + $.rmAll(ThreadWatcher.dialog); $.add(ThreadWatcher.dialog, nodes); watched = watched[g.BOARD] || {}; _ref1 = g.BOARD.threads; diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index e19634182..ba9acbf00 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -862,6 +862,13 @@ }; } })(), + rmAll: function(root) { + var node; + + while (node = root.firstChild) { + $.rm(node); + } + }, tn: function(s) { return d.createTextNode(s); }, @@ -1215,7 +1222,7 @@ var as, list, nodes; list = $('#custom-board-list', Header.nav); - list.innerHTML = null; + $.rmAll(list); if (!text) { return; } @@ -1594,7 +1601,7 @@ } $.addClass($(".tab-" + this.hyphenatedTitle, Settings.dialog), 'tab-selected'); section = $('section', Settings.dialog); - section.innerHTML = null; + $.rmAll(section); section.className = "section-" + this.hyphenatedTitle; this.open(section, g); return section.scrollTop = 0; @@ -1723,7 +1730,7 @@ return; } p = $('.imp-exp-result', Settings.dialog); - p.innerHTML = null; + $.rmAll(p); return $.add(p, a); }, "import": function() { @@ -1864,7 +1871,7 @@ div = this.nextElementSibling; if ((name = this.value) !== 'guide') { - div.innerHTML = null; + $.rmAll(div); ta = $.el('textarea', { name: name, className: 'field', @@ -3744,9 +3751,9 @@ case 'vp': case 'vr': case 'wsg': - return "//archive.foolz.us/_/api/chan/post/?board=" + boardID + "&num=" + postID; + return "https://archive.foolz.us/_/api/chan/post/?board=" + boardID + "&num=" + postID; case 'u': - return "//nsfw.foolz.us/_/api/chan/post/?board=" + boardID + "&num=" + postID; + return "https://nsfw.foolz.us/_/api/chan/post/?board=" + boardID + "&num=" + postID; case 'c': case 'int': case 'out': @@ -3786,10 +3793,10 @@ case 's4s': return Redirect.path('//fuuka.warosu.org', 'fuuka', data); case 'diy': + case 'g': case 'sci': return Redirect.path('//archive.installgentoo.net', 'fuuka', data); case 'cgl': - case 'g': case 'mu': case 'w': return Redirect.path('//rbt.asia', 'fuuka', data); @@ -4101,9 +4108,9 @@ clone = post.addClone(context); Main.callbackNodes(Post, [clone]); nodes = clone.nodes; - nodes.root.innerHTML = null; + $.rmAll(nodes.root); $.add(nodes.root, nodes.post); - root.innerHTML = null; + $.rmAll(root); return $.add(root, nodes.root); }, fetchedPost: function(req, boardID, threadID, postID, root, context) { @@ -6504,7 +6511,7 @@ nodes.push(div); } } - ThreadWatcher.dialog.innerHTML = ''; + $.rmAll(ThreadWatcher.dialog); $.add(ThreadWatcher.dialog, nodes); watched = watched[g.BOARD] || {}; _ref1 = g.BOARD.threads; diff --git a/builds/crx/script.js b/builds/crx/script.js index e84675638..5e23abee6 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -839,6 +839,13 @@ }; } })(), + rmAll: function(root) { + var node; + + while (node = root.firstChild) { + $.rm(node); + } + }, tn: function(s) { return d.createTextNode(s); }, @@ -1159,7 +1166,7 @@ var as, list, nodes; list = $('#custom-board-list', Header.nav); - list.innerHTML = null; + $.rmAll(list); if (!text) { return; } @@ -1538,7 +1545,7 @@ } $.addClass($(".tab-" + this.hyphenatedTitle, Settings.dialog), 'tab-selected'); section = $('section', Settings.dialog); - section.innerHTML = null; + $.rmAll(section); section.className = "section-" + this.hyphenatedTitle; this.open(section, g); return section.scrollTop = 0; @@ -1667,7 +1674,7 @@ return; } p = $('.imp-exp-result', Settings.dialog); - p.innerHTML = null; + $.rmAll(p); return $.add(p, a); }, "import": function() { @@ -1808,7 +1815,7 @@ div = this.nextElementSibling; if ((name = this.value) !== 'guide') { - div.innerHTML = null; + $.rmAll(div); ta = $.el('textarea', { name: name, className: 'field', @@ -3688,9 +3695,9 @@ case 'vp': case 'vr': case 'wsg': - return "//archive.foolz.us/_/api/chan/post/?board=" + boardID + "&num=" + postID; + return "https://archive.foolz.us/_/api/chan/post/?board=" + boardID + "&num=" + postID; case 'u': - return "//nsfw.foolz.us/_/api/chan/post/?board=" + boardID + "&num=" + postID; + return "https://nsfw.foolz.us/_/api/chan/post/?board=" + boardID + "&num=" + postID; case 'c': case 'int': case 'out': @@ -3730,10 +3737,10 @@ case 's4s': return Redirect.path('//fuuka.warosu.org', 'fuuka', data); case 'diy': + case 'g': case 'sci': return Redirect.path('//archive.installgentoo.net', 'fuuka', data); case 'cgl': - case 'g': case 'mu': case 'w': return Redirect.path('//rbt.asia', 'fuuka', data); @@ -4045,9 +4052,9 @@ clone = post.addClone(context); Main.callbackNodes(Post, [clone]); nodes = clone.nodes; - nodes.root.innerHTML = null; + $.rmAll(nodes.root); $.add(nodes.root, nodes.post); - root.innerHTML = null; + $.rmAll(root); return $.add(root, nodes.root); }, fetchedPost: function(req, boardID, threadID, postID, root, context) { @@ -6453,7 +6460,7 @@ nodes.push(div); } } - ThreadWatcher.dialog.innerHTML = ''; + $.rmAll(ThreadWatcher.dialog); $.add(ThreadWatcher.dialog, nodes); watched = watched[g.BOARD] || {}; _ref1 = g.BOARD.threads; diff --git a/lib/$.coffee b/lib/$.coffee index ec67c6f17..5a27dfd28 100644 --- a/lib/$.coffee +++ b/lib/$.coffee @@ -143,6 +143,11 @@ $.extend $, (el) -> el.remove() else (el) -> el.parentNode?.removeChild el + rmAll: (root) -> + # jsperf.com/emptify-element + while node = root.firstChild + $.rm node + return tn: (s) -> d.createTextNode s frag: -> diff --git a/src/features.coffee b/src/features.coffee index 4a5b811da..cb9ad0cb3 100644 --- a/src/features.coffee +++ b/src/features.coffee @@ -88,7 +88,7 @@ Header = generateBoardList: (text) -> list = $ '#custom-board-list', Header.nav - list.innerHTML = null + $.rmAll list return unless text as = $$('#full-board-list a', Header.nav)[0...-2] # ignore the Settings and Home links nodes = text.match(/[\w@]+(-(all|title|full|index|catalog|text:"[^"]+"))*|[^\w@]+/g).map (t) -> @@ -387,7 +387,7 @@ Settings = $.rmClass selected, 'tab-selected' $.addClass $(".tab-#{@hyphenatedTitle}", Settings.dialog), 'tab-selected' section = $ 'section', Settings.dialog - section.innerHTML = null + $.rmAll section section.className = "section-#{@hyphenatedTitle}" @open section, g section.scrollTop = 0 @@ -473,7 +473,7 @@ Settings = return # XXX Firefox won't let us download automatically. p = $ '.imp-exp-result', Settings.dialog - p.innerHTML = null + $.rmAll p $.add p, a import: -> @nextElementSibling.click() @@ -595,7 +595,7 @@ Settings = selectFilter: -> div = @nextElementSibling if (name = @value) isnt 'guide' - div.innerHTML = null + $.rmAll div ta = $.el 'textarea', name: name className: 'field' @@ -2084,11 +2084,13 @@ Redirect = when 'c' "//archive.nyafuu.org/#{boardID}/full_image/#{filename}" post: (boardID, postID) -> + # XXX foolz had HSTS set for 120 days, which broke XHR+CORS+Redirection when on HTTP. + # Remove necessary HTTPS procotol in September 2013. switch boardID when 'a', 'co', 'gd', 'jp', 'm', 'q', 'sp', 'tg', 'tv', 'v', 'vg', 'vp', 'vr', 'wsg' - "//archive.foolz.us/_/api/chan/post/?board=#{boardID}&num=#{postID}" + "https://archive.foolz.us/_/api/chan/post/?board=#{boardID}&num=#{postID}" when 'u' - "//nsfw.foolz.us/_/api/chan/post/?board=#{boardID}&num=#{postID}" + "https://nsfw.foolz.us/_/api/chan/post/?board=#{boardID}&num=#{postID}" when 'c', 'int', 'out', 'po' "//archive.thedarkcave.org/_/api/chan/post/?board=#{boardID}&num=#{postID}" # for fuuka-based archives: @@ -2104,9 +2106,9 @@ Redirect = Redirect.path '//archive.thedarkcave.org', 'foolfuuka', data when 'ck', 'fa', 'lit', 's4s' Redirect.path '//fuuka.warosu.org', 'fuuka', data - when 'diy', 'sci' + when 'diy', 'g', 'sci' Redirect.path '//archive.installgentoo.net', 'fuuka', data - when 'cgl', 'g', 'mu', 'w' + when 'cgl', 'mu', 'w' Redirect.path '//rbt.asia', 'fuuka', data when 'an', 'fit', 'k', 'mlp', 'r9k', 'toy', 'x' Redirect.path 'http://archive.heinessen.com', 'fuuka', data @@ -2479,10 +2481,10 @@ Get = # Get rid of the side arrows. {nodes} = clone - nodes.root.innerHTML = null + $.rmAll nodes.root $.add nodes.root, nodes.post - root.innerHTML = null + $.rmAll root $.add root, nodes.root fetchedPost: (req, boardID, threadID, postID, root, context) -> # In case of multiple callbacks for the same request, @@ -4337,7 +4339,7 @@ ThreadWatcher = $.add div, [x, $.tn(' '), link] nodes.push div - ThreadWatcher.dialog.innerHTML = '' + $.rmAll ThreadWatcher.dialog $.add ThreadWatcher.dialog, nodes watched = watched[g.BOARD] or {}