From 9ba7f2c3f2080072be52e198128f8fcd9fc2961d Mon Sep 17 00:00:00 2001 From: Zixaphir Date: Tue, 30 Apr 2013 17:22:08 -0700 Subject: [PATCH 1/2] Small indexOf optimization. --- LICENSE | 2 +- builds/4chan-X.js | 5 +++-- builds/4chan-X.user.js | 5 +++-- builds/crx/script.js | 5 +++-- src/General/lib/$.coffee | 4 ++-- 5 files changed, 12 insertions(+), 9 deletions(-) diff --git a/LICENSE b/LICENSE index c3a953a51..d8174a263 100644 --- a/LICENSE +++ b/LICENSE @@ -1,5 +1,5 @@ /* -* 4chan X - Version 1.1.3 - 2013-04-28 +* 4chan X - Version 1.1.3 - 2013-04-30 * * Licensed under the MIT license. * https://github.com/seaweedchan/4chan-x/blob/master/LICENSE diff --git a/builds/4chan-X.js b/builds/4chan-X.js index 935cc190e..757285a8b 100644 --- a/builds/4chan-X.js +++ b/builds/4chan-X.js @@ -18,7 +18,7 @@ // @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAgMAAAAqbBEUAAAACVBMVEUAAGcAAABmzDNZt9VtAAAAAXRSTlMAQObYZgAAAHFJREFUKFOt0LENACEIBdBv4Qju4wgWanEj3D6OcIVMKaitYHEU/jwTCQj8W75kiVCSBvdQ5/AvfVHBin11BgdRq3ysBgfwBDRrj3MCIA+oAQaku/Q1cNctrAmyDl577tOThYt/Y1RBM4DgOHzM0HFTAyLukH/cmRnqAAAAAElFTkSuQmCC // ==/UserScript== /* -* 4chan X - Version 1.1.3 - 2013-04-28 +* 4chan X - Version 1.1.3 - 2013-04-30 * * Licensed under the MIT license. * https://github.com/seaweedchan/4chan-x/blob/master/LICENSE @@ -335,7 +335,7 @@ i = this.length; while (i--) { if (this[i] === object) { - break; + return i; } } return i; @@ -349,6 +349,7 @@ arg = args[_i]; this.push.apply(this, arg); } + return this; }; Array.prototype.remove = function(object) { diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index a58c32940..2466ac03f 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -18,7 +18,7 @@ // @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAgMAAAAqbBEUAAAACVBMVEUAAGcAAABmzDNZt9VtAAAAAXRSTlMAQObYZgAAAHFJREFUKFOt0LENACEIBdBv4Qju4wgWanEj3D6OcIVMKaitYHEU/jwTCQj8W75kiVCSBvdQ5/AvfVHBin11BgdRq3ysBgfwBDRrj3MCIA+oAQaku/Q1cNctrAmyDl577tOThYt/Y1RBM4DgOHzM0HFTAyLukH/cmRnqAAAAAElFTkSuQmCC // ==/UserScript== /* -* 4chan X - Version 1.1.3 - 2013-04-28 +* 4chan X - Version 1.1.3 - 2013-04-30 * * Licensed under the MIT license. * https://github.com/seaweedchan/4chan-x/blob/master/LICENSE @@ -332,7 +332,7 @@ i = this.length; while (i--) { if (this[i] === object) { - break; + return i; } } return i; @@ -346,6 +346,7 @@ arg = args[_i]; this.push.apply(this, arg); } + return this; }; Array.prototype.remove = function(object) { diff --git a/builds/crx/script.js b/builds/crx/script.js index 5905614b9..f35257445 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -1,5 +1,5 @@ /* -* 4chan X - Version 1.1.3 - 2013-04-28 +* 4chan X - Version 1.1.3 - 2013-04-30 * * Licensed under the MIT license. * https://github.com/seaweedchan/4chan-x/blob/master/LICENSE @@ -314,7 +314,7 @@ i = this.length; while (i--) { if (this[i] === object) { - break; + return i; } } return i; @@ -328,6 +328,7 @@ arg = args[_i]; this.push.apply(this, arg); } + return this; }; Array.prototype.remove = function(object) { diff --git a/src/General/lib/$.coffee b/src/General/lib/$.coffee index f5cccad99..8c8d4713e 100644 --- a/src/General/lib/$.coffee +++ b/src/General/lib/$.coffee @@ -16,14 +16,14 @@ Array::contains = (object) -> Array::indexOf = (object) -> i = @length while i-- - break if @[i] is object + return i if @[i] is object return i Array::pushArrays = -> args = arguments for arg in args @push.apply @, arg - return + return @ Array::remove = (object) -> if (index = @indexOf object) > -1 From fb3d995b11bc8c24fc79b2f554c9261e8eb9ba9d Mon Sep 17 00:00:00 2001 From: Zixaphir Date: Tue, 30 Apr 2013 18:41:38 -0700 Subject: [PATCH 2/2] gist title link --- builds/4chan-X.js | 15 +++++++++++++++ builds/4chan-X.user.js | 15 +++++++++++++++ builds/crx/script.js | 15 +++++++++++++++ src/Linkification/Linkify.coffee | 5 +++++ 4 files changed, 50 insertions(+) diff --git a/builds/4chan-X.js b/builds/4chan-X.js index 859464b2b..776cf06fa 100644 --- a/builds/4chan-X.js +++ b/builds/4chan-X.js @@ -4326,6 +4326,21 @@ return div = $.el('iframe', { src: "http://www.purplegene.com/script?url=https://gist.github.com/" + this.name + ".js" }); + }, + title: { + api: function() { + return "https://api.github.com/gists/" + this.name; + }, + text: function() { + var file, response; + + response = JSON.parse(this.responseText).files; + for (file in response) { + if (response.hasOwnProperty(file)) { + return file; + } + } + } } } }, diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index bddcd36e2..ad0702e7f 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -4322,6 +4322,21 @@ return div = $.el('iframe', { src: "http://www.purplegene.com/script?url=https://gist.github.com/" + this.name + ".js" }); + }, + title: { + api: function() { + return "https://api.github.com/gists/" + this.name; + }, + text: function() { + var file, response; + + response = JSON.parse(this.responseText).files; + for (file in response) { + if (response.hasOwnProperty(file)) { + return file; + } + } + } } } }, diff --git a/builds/crx/script.js b/builds/crx/script.js index 309c3fb93..b57c17c6e 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -4325,6 +4325,21 @@ return div = $.el('iframe', { src: "http://www.purplegene.com/script?url=https://gist.github.com/" + this.name + ".js" }); + }, + title: { + api: function() { + return "https://api.github.com/gists/" + this.name; + }, + text: function() { + var file, response; + + response = JSON.parse(this.responseText).files; + for (file in response) { + if (response.hasOwnProperty(file)) { + return file; + } + } + } } } }, diff --git a/src/Linkification/Linkify.coffee b/src/Linkification/Linkify.coffee index 356ebad0f..2fc8ed524 100644 --- a/src/Linkification/Linkify.coffee +++ b/src/Linkification/Linkify.coffee @@ -212,6 +212,11 @@ Linkify = div = $.el 'iframe', # Github doesn't allow embedding straight from the site, so we use an external site to bypass that. src: "http://www.purplegene.com/script?url=https://gist.github.com/#{@name}.js" + title: + api: -> "https://api.github.com/gists/#{@name}" + text: -> + response = JSON.parse(@responseText).files + return file for file of response when response.hasOwnProperty file embedder: (a) -> return [a] unless Conf['Link Title']