aboutsummaryrefslogtreecommitdiffstats
path: root/hints-for-embedded.js
diff options
context:
space:
mode:
authoranekos2012-05-02 06:51:48 +0900
committeranekos2012-05-02 06:51:48 +0900
commit1201ca2a8c3ef003b752a066c7031c1a098be770 (patch)
tree11a3eaae1607f80c6450d32839204dcb9c737a2b /hints-for-embedded.js
parent73a984d0080042488748ad9bf690fa588f3793fc (diff)
downloadvimperator-plugins-1201ca2a8c3ef003b752a066c7031c1a098be770.tar.bz2
Add "use_vlc" option.
Diffstat (limited to 'hints-for-embedded.js')
-rw-r--r--hints-for-embedded.js34
1 files changed, 23 insertions, 11 deletions
diff --git a/hints-for-embedded.js b/hints-for-embedded.js
index d4bc451..1fa940b 100644
--- a/hints-for-embedded.js
+++ b/hints-for-embedded.js
@@ -35,7 +35,7 @@ THE POSSIBILITY OF SUCH DAMAGE.
// INFO {{{
let INFO =
<>
- <plugin name="HintsForEmbeded" version="1.5.1"
+ <plugin name="HintsForEmbeded" version="1.6.0"
href="http://github.com/vimpr/vimperator-plugins/blob/master/hints-for-embedded.js"
summary="Add the hints mode for embedded objects."
lang="en-US"
@@ -133,6 +133,7 @@ let INFO =
let modeName = liberator.globalVariables.hints_for_embedded_mode || 'hints-for-embedded';
let where = liberator.globalVariables.hints_for_embedded_where;
let openParent = liberator.globalVariables.hints_for_embedded_open_parent_link || 0;
+ let useVLC = liberator.globalVariables.hints_for_embedded_use_vlc || 0;
if (typeof where === 'undefined')
where = liberator.NEW_TAB;
@@ -151,25 +152,29 @@ let INFO =
site: /youtube/,
name: /^src$/,
value: /http:\/\/www\.youtube\.com\/(?:embed|v)\/([-a-zA-Z0-9_]+)/,
- url: function (id) ('http://www.youtube.com/watch?v=' + id)
+ url: function (id) ('http://www.youtube.com/watch?v=' + id),
+ vlc: true
},
youtube: {
site: /youtube/,
name: /.*/,
value: /youtube\.com\/v\/([-a-zA-Z0-9_]+)/,
- url: function (id) ('http://www.youtube.com/watch?v=' + id)
+ url: function (id) ('http://www.youtube.com/watch?v=' + id),
+ vlc: true
},
youtube_image: {
site: /ytimg\.com/,
name: /^flashvars$/,
value: /video_id=([-a-zA-Z0-9_]+)/,
- url: function (id) ('http://www.youtube.com/watch?v=' + id)
+ url: function (id) ('http://www.youtube.com/watch?v=' + id),
+ vlc: true
},
vimeo: {
site: /vimeo/,
name: /.*/,
value: /clip_id=(\d+)/,
- url: function (id) ('http://vimeo.com/' + id)
+ url: function (id) ('http://vimeo.com/' + id),
+ vlc: true
},
collegehumor: {
site: /collegehumor/,
@@ -185,16 +190,18 @@ let INFO =
function getInfo (elem)
getAttrs(elem).concat((Array.slice(elem.querySelectorAll('object,embed,param')) || []).map(getInfo));
- function open (elem) {
+ function open (elem, where) {
let info = getInfo(elem.wrappedJSObject);
+ let doOpen = function (url) liberator.open(url, where);
+
if (elem.tagName === 'IMG' && elem.src) {
if (openParent) {
let p = elem.parentNode;
if (p.tagName === 'A' && /(gif|png|jpe?g)$/i.test(p.href))
- return liberator.open(p.href, liberator.NEW_TAB);
+ return doOpen(p.href);
}
- return liberator.open(elem.src, liberator.NEW_TAB);
+ return doOOpen(elem.src);
}
let site =
@@ -204,14 +211,19 @@ let INFO =
return site;
})();
+
if (site) {
+ if (useVLC && site.vlc) {
+ doOpen = function (url) io.run('vlc', [url]);
+ }
+
for each (let [n, v] in info) {
[n, v] = [String(n), String(v)];
if (site.name && !site.name.test(n))
continue;
let m = n.match(site.value) || v.match(site.value);
if (m)
- return site.url(Array.slice(m, 1));
+ return doOpen(site.url(Array.slice(m, 1)));
}
}
@@ -222,7 +234,7 @@ let INFO =
commandline.input(
'Select the link you wish to open: ',
function (url) {
- liberator.open(url, where);
+ doOpen(url);
},
{
default: urls[0][1],
@@ -237,7 +249,7 @@ let INFO =
modeName,
DESC,
function (elem) {
- liberator.open(open(elem), where);
+ open(elem, where);
},
function () '//embed | //object | //img | //iframe'
);