Skip to content

Instantly share code, notes, and snippets.

@jsrjenkins
Created May 20, 2016 15:51
Show Gist options
  • Save jsrjenkins/f8685d765f79379a54c2eb1beeb55940 to your computer and use it in GitHub Desktop.
Save jsrjenkins/f8685d765f79379a54c2eb1beeb55940 to your computer and use it in GitHub Desktop.
Make a tiny url from the current page.
// TinyURL
// This will create a browser object and allow to create a tiny URL
// for the current page and put it on the clipboard.
define_browser_object_class(
"tinyurl", "Get a tinyurl for the current page",
function (I, prompt) {
check_buffer(I.buffer, content_buffer);
let createurl = 'http://tinyurl.com/api-create.php?url=' +
encodeURIComponent(
load_spec_uri_string(
load_spec(I.buffer.top_frame)));
try {
var content = yield send_http_request(
load_spec({uri: createurl}));
yield co_return(content.responseText);
} catch (e) { }
});
// to put a tiny url on the clipboard, simply do "* q c"
define_key(content_buffer_normal_keymap, "* q", "browser-object-tinyurl");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment