Skip to content

Instantly share code, notes, and snippets.

@willietdog
Created May 19, 2009 00:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save willietdog/113841 to your computer and use it in GitHub Desktop.
Save willietdog/113841 to your computer and use it in GitHub Desktop.
CmdUtils.CreateCommand({
name: "keepvid",
icon: "http://keepvid.com/favicon.ico",
author: {name: "Ryan Peach", email: "browlerakill@gmail.com"},
license: "GPL",
description: "Downloads Youtube videos through KeepVid",
help: "Go to the youtube video you want to download in your browser, then execute this command.",
takes: {"video url": noun_arb_text},
preview: function(pblock, videoURL) {
//This gets the present url of the active window/tab and names it "doc"
var doc = CmdUtils.getDocument()
//The following tells the program if the user has no input or inputs the word "this" automatically show the user they will be downloading the video at the current location
if(videoURL.text=="this" || videoURL.text==""){
pblock.innerHTML = "This will download the video at your current location.<br /><br /> <b>Hint</b>: You may also copy and paste a different location into the command line above.";
}
//If the user enters something else tell them that is the url they will be downloading from
else {
pblock.innerHTML = "This will download the video at: <b>" + videoURL.text + "</b>";
}
},
execute: function(videoURL) {
//if the user inputs nothing or "this" goto keepvid for this page
if(videoURL.text=="this" || videoURL.text==""){
var doc = CmdUtils.getDocument()
var url = "http://www.keepvid.com/?url={QUERY}"
var query = doc.location;
var urlString = url.replace("{QUERY}", query);
Utils.openUrlInBrowser(urlString);
}
//otherwise go to the keepvid for the inputted url
else {
var url = "http://www.keepvid.com/?url={QUERY}"
var query = videoURL.text;
var urlString = url.replace("{QUERY}", query);
Utils.openUrlInBrowser(urlString);
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment