From 9193c3e0f1a1722826d62eb06a30575e3f82a730 Mon Sep 17 00:00:00 2001 From: ccd0 Date: Mon, 31 Mar 2014 21:20:12 -0700 Subject: [PATCH] fix wrongly embedded links with dummy types --- LICENSE | 2 +- builds/4chan-X.user.js | 44 ++++++++++++++++++++++++-------- builds/crx/script.js | 44 ++++++++++++++++++++++++-------- src/Linkification/Linkify.coffee | 10 ++++++++ 4 files changed, 77 insertions(+), 23 deletions(-) diff --git a/LICENSE b/LICENSE index e578ec01e..9c4c72ac9 100755 --- a/LICENSE +++ b/LICENSE @@ -1,5 +1,5 @@ /* -* 4chan X - Version 1.4.1 - 2014-03-25 +* 4chan X - Version 1.4.1 - 2014-03-31 * * Licensed under the MIT license. * https://github.com/Spittie/4chan-x/blob/master/LICENSE diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index 472eafdb5..f84085ff3 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -24,7 +24,7 @@ // ==/UserScript== /* -* 4chan X - Version 1.4.1 - 2014-03-25 +* 4chan X - Version 1.4.1 - 2014-03-31 * * Licensed under the MIT license. * https://github.com/Spittie/4chan-x/blob/master/LICENSE @@ -8251,6 +8251,9 @@ if (!(match = type.regExp.exec(href))) { continue; } + if (type.dummy) { + break; + } return [type.key, match[1], match[2], link]; } }, @@ -8620,6 +8623,14 @@ return data.entry.title.$t; } } + }, { + key: 'Loopvid', + regExp: /.*loopvid.appspot.com\/.*/, + dummy: true + }, { + key: 'MediaFire', + regExp: /.*mediafire.com\/.*/, + dummy: true }, { key: 'video', regExp: /(.*\.(ogv|webm|mp4))$/, @@ -8795,6 +8806,9 @@ if (!(match = type.regExp.exec(href))) { continue; } + if (type.dummy) { + return; + } return [type.key, match[1], match[2], link]; } }, @@ -8916,6 +8930,16 @@ }, ordered_types: [ { + key: 'audio', + regExp: /(.*\.(mp3|ogg|wav))$/, + el: function(a) { + return $.el('audio', { + controls: 'controls', + preload: 'auto', + src: a.dataset.uid + }); + } + }, { key: 'gist', regExp: /.*(?:gist.github.com.*\/)([^\/][^\/]*)$/, el: function(a) { @@ -8938,16 +8962,6 @@ } } } - }, { - key: 'audio', - regExp: /(.*\.(mp3|ogg|wav))$/, - el: function(a) { - return $.el('audio', { - controls: 'controls', - preload: 'auto', - src: a.dataset.uid - }); - } }, { key: 'image', regExp: /(http|www).*\.(gif|png|jpg|jpeg|bmp)$/, @@ -9164,6 +9178,14 @@ return data.entry.title.$t; } } + }, { + key: 'Loopvid', + regExp: /.*loopvid.appspot.com\/.*/, + dummy: true + }, { + key: 'MediaFire', + regExp: /.*mediafire.com\/.*/, + dummy: true }, { key: 'video', regExp: /(.*\.(ogv|webm|mp4))$/, diff --git a/builds/crx/script.js b/builds/crx/script.js index eb084c289..d9d4ee844 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -1,6 +1,6 @@ // Generated by CoffeeScript /* -* 4chan X - Version 1.4.1 - 2014-03-25 +* 4chan X - Version 1.4.1 - 2014-03-31 * * Licensed under the MIT license. * https://github.com/Spittie/4chan-x/blob/master/LICENSE @@ -8248,6 +8248,9 @@ if (!(match = type.regExp.exec(href))) { continue; } + if (type.dummy) { + break; + } return [type.key, match[1], match[2], link]; } }, @@ -8617,6 +8620,14 @@ return data.entry.title.$t; } } + }, { + key: 'Loopvid', + regExp: /.*loopvid.appspot.com\/.*/, + dummy: true + }, { + key: 'MediaFire', + regExp: /.*mediafire.com\/.*/, + dummy: true }, { key: 'video', regExp: /(.*\.(ogv|webm|mp4))$/, @@ -8792,6 +8803,9 @@ if (!(match = type.regExp.exec(href))) { continue; } + if (type.dummy) { + return; + } return [type.key, match[1], match[2], link]; } }, @@ -8913,6 +8927,16 @@ }, ordered_types: [ { + key: 'audio', + regExp: /(.*\.(mp3|ogg|wav))$/, + el: function(a) { + return $.el('audio', { + controls: 'controls', + preload: 'auto', + src: a.dataset.uid + }); + } + }, { key: 'gist', regExp: /.*(?:gist.github.com.*\/)([^\/][^\/]*)$/, el: function(a) { @@ -8935,16 +8959,6 @@ } } } - }, { - key: 'audio', - regExp: /(.*\.(mp3|ogg|wav))$/, - el: function(a) { - return $.el('audio', { - controls: 'controls', - preload: 'auto', - src: a.dataset.uid - }); - } }, { key: 'image', regExp: /(http|www).*\.(gif|png|jpg|jpeg|bmp)$/, @@ -9161,6 +9175,14 @@ return data.entry.title.$t; } } + }, { + key: 'Loopvid', + regExp: /.*loopvid.appspot.com\/.*/, + dummy: true + }, { + key: 'MediaFire', + regExp: /.*mediafire.com\/.*/, + dummy: true }, { key: 'video', regExp: /(.*\.(ogv|webm|mp4))$/, diff --git a/src/Linkification/Linkify.coffee b/src/Linkification/Linkify.coffee index d534c74de..175f4bbd2 100755 --- a/src/Linkification/Linkify.coffee +++ b/src/Linkification/Linkify.coffee @@ -151,6 +151,7 @@ Linkify = for type in Linkify.ordered_types continue unless match = type.regExp.exec href + break if type.dummy return [type.key, match[1], match[2], link] return @@ -433,6 +434,15 @@ Linkify = title: api: (uid) -> "https://gdata.youtube.com/feeds/api/videos/#{uid}?alt=json&fields=title/text(),yt:noembed,app:control/yt:state/@reasonCode" text: (data) -> data.entry.title.$t + , + # dummy entries: not implemented yet but included to prevent them being wrongly embedded as a subsequent type + key: 'Loopvid' + regExp: /.*loopvid.appspot.com\/.*/ + dummy: true + , + key: 'MediaFire' + regExp: /.*mediafire.com\/.*/ + dummy: true , key: 'video' regExp: /(.*\.(ogv|webm|mp4))$/