From 250323d304dece37c55fffdd5922fbe165318f14 Mon Sep 17 00:00:00 2001 From: Zixaphir Date: Mon, 5 Aug 2013 12:19:26 -0700 Subject: [PATCH] Vine --- builds/4chan-X.user.js | 155 ++++++++++++++++--------------- builds/crx/script.js | 155 ++++++++++++++++--------------- src/Linkification/Linkify.coffee | 123 ++++++++++++++---------- 3 files changed, 236 insertions(+), 197 deletions(-) diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index f5ce94ae5..71277dcf5 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -4532,55 +4532,6 @@ } }, types: { - YouTube: { - regExp: /.*(?:youtu.be\/|youtube.*v=|youtube.*\/embed\/|youtube.*\/v\/|youtube.*videos\/)([^#\&\?]*)\??(t\=.*)?/, - el: function() { - return $.el('iframe', { - src: "//www.youtube.com/embed/" + this.name + (this.option ? '#' + this.option : '') + "?wmode=opaque" - }); - }, - title: { - api: function(uid) { - return "https://gdata.youtube.com/feeds/api/videos/" + uid + "?alt=json&fields=title/text(),yt:noembed,app:control/yt:state/@reasonCode"; - }, - text: function() { - return JSON.parse(this.responseText).entry.title.$t; - } - } - }, - Vocaroo: { - regExp: /.*(?:vocaroo.com\/)([^#\&\?]*).*/, - style: 'border: 0; width: 150px; height: 45px;', - el: function() { - return $.el('object', { - innerHTML: "" - }); - } - }, - Vimeo: { - regExp: /.*(?:vimeo.com\/)([^#\&\?]*).*/, - el: function() { - return $.el('iframe', { - src: "//player.vimeo.com/video/" + this.name + "?wmode=opaque" - }); - }, - title: { - api: function(uid) { - return "https://vimeo.com/api/oembed.json?url=http://vimeo.com/" + uid; - }, - text: function() { - return JSON.parse(this.responseText).title; - } - } - }, - LiveLeak: { - regExp: /.*(?:liveleak.com\/view.+i=)([0-9a-z_]+)/, - el: function() { - return $.el('object', { - innerHTML: "" - }); - } - }, audio: { regExp: /(.*\.(mp3|ogg|wav))$/, el: function() { @@ -4591,6 +4542,31 @@ }); } }, + gist: { + regExp: /.*(?:gist.github.com.*\/)([^\/][^\/]*)$/, + el: function() { + var div; + + return div = $.el('iframe', { + src: "http://www.purplegene.com/script?url=https://gist.github.com/" + this.name + ".js" + }); + }, + title: { + api: function(uid) { + return "https://api.github.com/gists/" + uid; + }, + text: function() { + var file, response; + + response = JSON.parse(this.responseText).files; + for (file in response) { + if (response.hasOwnProperty(file)) { + return file; + } + } + } + } + }, image: { regExp: /(http|www).*\.(gif|png|jpg|jpeg|bmp)$/, style: 'border: 0; width: auto; height: auto;', @@ -4600,6 +4576,32 @@ }); } }, + InstallGentoo: { + regExp: /.*(?:paste.installgentoo.com\/view\/)([0-9a-z_]+)/, + el: function() { + return $.el('iframe', { + src: "http://paste.installgentoo.com/view/embed/" + this.name + }); + } + }, + LiveLeak: { + regExp: /.*(?:liveleak.com\/view.+i=)([0-9a-z_]+)/, + el: function() { + return $.el('object', { + innerHTML: "" + }); + } + }, + pastebin: { + regExp: /.*(?:pastebin.com\/(?!u\/))([^#\&\?]*).*/, + el: function() { + var div; + + return div = $.el('iframe', { + src: "http://pastebin.com/embed_iframe.php?i=" + this.name + }); + } + }, SoundCloud: { regExp: /.*(?:soundcloud.com\/|snd.sc\/)([^#\&\?]*).*/, style: 'height: auto; width: 500px; display: inline-block;', @@ -4627,48 +4629,55 @@ } } }, - pastebin: { - regExp: /.*(?:pastebin.com\/(?!u\/))([^#\&\?]*).*/, + Vocaroo: { + regExp: /.*(?:vocaroo.com\/)([^#\&\?]*).*/, + style: 'border: 0; width: 150px; height: 45px;', el: function() { - var div; - - return div = $.el('iframe', { - src: "http://pastebin.com/embed_iframe.php?i=" + this.name + return $.el('object', { + innerHTML: "" }); } }, - gist: { - regExp: /.*(?:gist.github.com.*\/)([^\/][^\/]*)$/, + Vimeo: { + regExp: /.*(?:vimeo.com\/)([^#\&\?]*).*/, el: function() { - var div; - - return div = $.el('iframe', { - src: "http://www.purplegene.com/script?url=https://gist.github.com/" + this.name + ".js" + return $.el('iframe', { + src: "//player.vimeo.com/video/" + this.name + "?wmode=opaque" }); }, title: { api: function(uid) { - return "https://api.github.com/gists/" + uid; + return "https://vimeo.com/api/oembed.json?url=http://vimeo.com/" + uid; }, text: function() { - var file, response; - - response = JSON.parse(this.responseText).files; - for (file in response) { - if (response.hasOwnProperty(file)) { - return file; - } - } + return JSON.parse(this.responseText).title; } } }, - InstallGentoo: { - regExp: /.*(?:paste.installgentoo.com\/view\/)([0-9a-z_]+)/, + Vine: { + regExp: /.*(?:vine.co\/)([^#\&\?]*).*/, + style: 'border: none; width: 500px; height: 500px;', el: function() { return $.el('iframe', { - src: "http://paste.installgentoo.com/view/embed/" + this.name + src: "https://vine.co/" + this.name + "/card" }); } + }, + YouTube: { + regExp: /.*(?:youtu.be\/|youtube.*v=|youtube.*\/embed\/|youtube.*\/v\/|youtube.*videos\/)([^#\&\?]*)\??(t\=.*)?/, + el: function() { + return $.el('iframe', { + src: "//www.youtube.com/embed/" + this.name + (this.option ? '#' + this.option : '') + "?wmode=opaque" + }); + }, + title: { + api: function(uid) { + return "https://gdata.youtube.com/feeds/api/videos/" + uid + "?alt=json&fields=title/text(),yt:noembed,app:control/yt:state/@reasonCode"; + }, + text: function() { + return JSON.parse(this.responseText).entry.title.$t; + } + } } } }; diff --git a/builds/crx/script.js b/builds/crx/script.js index 8fd0d325e..7fe3cdbf8 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -4537,55 +4537,6 @@ } }, types: { - YouTube: { - regExp: /.*(?:youtu.be\/|youtube.*v=|youtube.*\/embed\/|youtube.*\/v\/|youtube.*videos\/)([^#\&\?]*)\??(t\=.*)?/, - el: function() { - return $.el('iframe', { - src: "//www.youtube.com/embed/" + this.name + (this.option ? '#' + this.option : '') + "?wmode=opaque" - }); - }, - title: { - api: function(uid) { - return "https://gdata.youtube.com/feeds/api/videos/" + uid + "?alt=json&fields=title/text(),yt:noembed,app:control/yt:state/@reasonCode"; - }, - text: function() { - return JSON.parse(this.responseText).entry.title.$t; - } - } - }, - Vocaroo: { - regExp: /.*(?:vocaroo.com\/)([^#\&\?]*).*/, - style: 'border: 0; width: 150px; height: 45px;', - el: function() { - return $.el('object', { - innerHTML: "" - }); - } - }, - Vimeo: { - regExp: /.*(?:vimeo.com\/)([^#\&\?]*).*/, - el: function() { - return $.el('iframe', { - src: "//player.vimeo.com/video/" + this.name + "?wmode=opaque" - }); - }, - title: { - api: function(uid) { - return "https://vimeo.com/api/oembed.json?url=http://vimeo.com/" + uid; - }, - text: function() { - return JSON.parse(this.responseText).title; - } - } - }, - LiveLeak: { - regExp: /.*(?:liveleak.com\/view.+i=)([0-9a-z_]+)/, - el: function() { - return $.el('object', { - innerHTML: "" - }); - } - }, audio: { regExp: /(.*\.(mp3|ogg|wav))$/, el: function() { @@ -4596,6 +4547,31 @@ }); } }, + gist: { + regExp: /.*(?:gist.github.com.*\/)([^\/][^\/]*)$/, + el: function() { + var div; + + return div = $.el('iframe', { + src: "http://www.purplegene.com/script?url=https://gist.github.com/" + this.name + ".js" + }); + }, + title: { + api: function(uid) { + return "https://api.github.com/gists/" + uid; + }, + text: function() { + var file, response; + + response = JSON.parse(this.responseText).files; + for (file in response) { + if (response.hasOwnProperty(file)) { + return file; + } + } + } + } + }, image: { regExp: /(http|www).*\.(gif|png|jpg|jpeg|bmp)$/, style: 'border: 0; width: auto; height: auto;', @@ -4605,6 +4581,32 @@ }); } }, + InstallGentoo: { + regExp: /.*(?:paste.installgentoo.com\/view\/)([0-9a-z_]+)/, + el: function() { + return $.el('iframe', { + src: "http://paste.installgentoo.com/view/embed/" + this.name + }); + } + }, + LiveLeak: { + regExp: /.*(?:liveleak.com\/view.+i=)([0-9a-z_]+)/, + el: function() { + return $.el('object', { + innerHTML: "" + }); + } + }, + pastebin: { + regExp: /.*(?:pastebin.com\/(?!u\/))([^#\&\?]*).*/, + el: function() { + var div; + + return div = $.el('iframe', { + src: "http://pastebin.com/embed_iframe.php?i=" + this.name + }); + } + }, SoundCloud: { regExp: /.*(?:soundcloud.com\/|snd.sc\/)([^#\&\?]*).*/, style: 'height: auto; width: 500px; display: inline-block;', @@ -4632,48 +4634,55 @@ } } }, - pastebin: { - regExp: /.*(?:pastebin.com\/(?!u\/))([^#\&\?]*).*/, + Vocaroo: { + regExp: /.*(?:vocaroo.com\/)([^#\&\?]*).*/, + style: 'border: 0; width: 150px; height: 45px;', el: function() { - var div; - - return div = $.el('iframe', { - src: "http://pastebin.com/embed_iframe.php?i=" + this.name + return $.el('object', { + innerHTML: "" }); } }, - gist: { - regExp: /.*(?:gist.github.com.*\/)([^\/][^\/]*)$/, + Vimeo: { + regExp: /.*(?:vimeo.com\/)([^#\&\?]*).*/, el: function() { - var div; - - return div = $.el('iframe', { - src: "http://www.purplegene.com/script?url=https://gist.github.com/" + this.name + ".js" + return $.el('iframe', { + src: "//player.vimeo.com/video/" + this.name + "?wmode=opaque" }); }, title: { api: function(uid) { - return "https://api.github.com/gists/" + uid; + return "https://vimeo.com/api/oembed.json?url=http://vimeo.com/" + uid; }, text: function() { - var file, response; - - response = JSON.parse(this.responseText).files; - for (file in response) { - if (response.hasOwnProperty(file)) { - return file; - } - } + return JSON.parse(this.responseText).title; } } }, - InstallGentoo: { - regExp: /.*(?:paste.installgentoo.com\/view\/)([0-9a-z_]+)/, + Vine: { + regExp: /.*(?:vine.co\/)([^#\&\?]*).*/, + style: 'border: none; width: 500px; height: 500px;', el: function() { return $.el('iframe', { - src: "http://paste.installgentoo.com/view/embed/" + this.name + src: "https://vine.co/" + this.name + "/card" }); } + }, + YouTube: { + regExp: /.*(?:youtu.be\/|youtube.*v=|youtube.*\/embed\/|youtube.*\/v\/|youtube.*videos\/)([^#\&\?]*)\??(t\=.*)?/, + el: function() { + return $.el('iframe', { + src: "//www.youtube.com/embed/" + this.name + (this.option ? '#' + this.option : '') + "?wmode=opaque" + }); + }, + title: { + api: function(uid) { + return "https://gdata.youtube.com/feeds/api/videos/" + uid + "?alt=json&fields=title/text(),yt:noembed,app:control/yt:state/@reasonCode"; + }, + text: function() { + return JSON.parse(this.responseText).entry.title.$t; + } + } } } }; diff --git a/src/Linkification/Linkify.coffee b/src/Linkification/Linkify.coffee index c32ec484e..48dbb705a 100644 --- a/src/Linkification/Linkify.coffee +++ b/src/Linkification/Linkify.coffee @@ -233,52 +233,51 @@ Linkify = "[#{key}] #{@status}'d" types: - YouTube: - regExp: /.*(?:youtu.be\/|youtube.*v=|youtube.*\/embed\/|youtube.*\/v\/|youtube.*videos\/)([^#\&\?]*)\??(t\=.*)?/ - el: -> - $.el 'iframe', - src: "//www.youtube.com/embed/#{@name}#{if @option then '#' + @option else ''}?wmode=opaque" - title: - api: (uid) -> "https://gdata.youtube.com/feeds/api/videos/#{uid}?alt=json&fields=title/text(),yt:noembed,app:control/yt:state/@reasonCode" - text: -> JSON.parse(@responseText).entry.title.$t - - Vocaroo: - regExp: /.*(?:vocaroo.com\/)([^#\&\?]*).*/ - style: 'border: 0; width: 150px; height: 45px;' - el: -> - $.el 'object', - innerHTML: "" - - Vimeo: - regExp: /.*(?:vimeo.com\/)([^#\&\?]*).*/ - el: -> - $.el 'iframe', - src: "//player.vimeo.com/video/#{@name}?wmode=opaque" - title: - api: (uid) -> "https://vimeo.com/api/oembed.json?url=http://vimeo.com/#{uid}" - text: -> JSON.parse(@responseText).title - - LiveLeak: - regExp: /.*(?:liveleak.com\/view.+i=)([0-9a-z_]+)/ - el: -> - $.el 'object', - innerHTML: "" - audio: - regExp: /(.*\.(mp3|ogg|wav))$/ + regExp: /(.*\.(mp3|ogg|wav))$/ el: -> $.el 'audio', controls: 'controls' preload: 'auto' src: @name + gist: + regExp: /.*(?:gist.github.com.*\/)([^\/][^\/]*)$/ + el: -> + 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: (uid) -> "https://api.github.com/gists/#{uid}" + text: -> + response = JSON.parse(@responseText).files + return file for file of response when response.hasOwnProperty file + image: - regExp: /(http|www).*\.(gif|png|jpg|jpeg|bmp)$/ + regExp: /(http|www).*\.(gif|png|jpg|jpeg|bmp)$/ style: 'border: 0; width: auto; height: auto;' el: -> $.el 'div', innerHTML: "" + InstallGentoo: + regExp: /.*(?:paste.installgentoo.com\/view\/)([0-9a-z_]+)/ + el: -> + $.el 'iframe', + src: "http://paste.installgentoo.com/view/embed/#{@name}" + + LiveLeak: + regExp: /.*(?:liveleak.com\/view.+i=)([0-9a-z_]+)/ + el: -> + $.el 'object', + innerHTML: "" + + pastebin: + regExp: /.*(?:pastebin.com\/(?!u\/))([^#\&\?]*).*/ + el: -> + div = $.el 'iframe', + src: "http://pastebin.com/embed_iframe.php?i=#{@name}" + SoundCloud: regExp: /.*(?:soundcloud.com\/|snd.sc\/)([^#\&\?]*).*/ style: 'height: auto; width: 500px; display: inline-block;' @@ -297,26 +296,48 @@ Linkify = api: (uid) -> "//soundcloud.com/oembed?show_artwork=false&&maxwidth=500px&show_comments=false&format=json&url=https://www.soundcloud.com/#{uid}" text: -> JSON.parse(@responseText).title - pastebin: - regExp: /.*(?:pastebin.com\/(?!u\/))([^#\&\?]*).*/ - el: -> - div = $.el 'iframe', - src: "http://pastebin.com/embed_iframe.php?i=#{@name}" +# WIP +# +# TwitchTV: +# regExp: /twitch\.tv\/(\w+)\/(?:b\/)?(\d+)/i +# style: "border: none; width: 640px; height: 360px;" +# el: -> +# [_, channel, archive] = @result +# el = $.el 'object', +# data: 'http://www.twitch.tv/widgets/archive_embed_player.swf' +# innerHTML: """ +# +# +#""" - gist: - regExp: /.*(?:gist.github.com.*\/)([^\/][^\/]*)$/ + Vocaroo: + regExp: /.*(?:vocaroo.com\/)([^#\&\?]*).*/ + style: 'border: 0; width: 150px; height: 45px;' el: -> - 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: (uid) -> "https://api.github.com/gists/#{uid}" - text: -> - response = JSON.parse(@responseText).files - return file for file of response when response.hasOwnProperty file + $.el 'object', + innerHTML: "" - InstallGentoo: - regExp: /.*(?:paste.installgentoo.com\/view\/)([0-9a-z_]+)/ + Vimeo: + regExp: /.*(?:vimeo.com\/)([^#\&\?]*).*/ el: -> $.el 'iframe', - src: "http://paste.installgentoo.com/view/embed/#{@name}" \ No newline at end of file + src: "//player.vimeo.com/video/#{@name}?wmode=opaque" + title: + api: (uid) -> "https://vimeo.com/api/oembed.json?url=http://vimeo.com/#{uid}" + text: -> JSON.parse(@responseText).title + + Vine: + regExp: /.*(?:vine.co\/)([^#\&\?]*).*/ + style: 'border: none; width: 500px; height: 500px;' + el: -> + $.el 'iframe', + src: "https://vine.co/#{@name}/card" + + YouTube: + regExp: /.*(?:youtu.be\/|youtube.*v=|youtube.*\/embed\/|youtube.*\/v\/|youtube.*videos\/)([^#\&\?]*)\??(t\=.*)?/ + el: -> + $.el 'iframe', + src: "//www.youtube.com/embed/#{@name}#{if @option then '#' + @option else ''}?wmode=opaque" + title: + api: (uid) -> "https://gdata.youtube.com/feeds/api/videos/#{uid}?alt=json&fields=title/text(),yt:noembed,app:control/yt:state/@reasonCode" + text: -> JSON.parse(@responseText).entry.title.$t \ No newline at end of file