Created
May 20, 2016 15:51
-
-
Save jsrjenkins/f8685d765f79379a54c2eb1beeb55940 to your computer and use it in GitHub Desktop.
Make a tiny url from the current page.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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