Skip to content

Instantly share code, notes, and snippets.

@tototoshi
Created December 5, 2010 12:08
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 tototoshi/729039 to your computer and use it in GitHub Desktop.
Save tototoshi/729039 to your computer and use it in GitHub Desktop.
my-keysnail-functions.js
// clipboard操作
function getCurrentURL() {
return window._content.document.location.href;
}
function getCurrentTitle() {
return window._content.document.title;
}
function copyTextToClipboard(text) {
const CLIPBOARD =
Components.classes['@mozilla.org/widget/clipboardhelper;1'].getService(Components.interfaces.nsIClipboardHelper);
CLIPBOARD.copyString(text);
}
key.setViewKey('t', function () {
copyTextToClipboard(getCurrentTitle())
}, 'タイトルコピー');
key.setViewKey('T', function () {
copyTextToClipboard("\"" + getCurrentTitle() + "\" - " + getCurrentURL());
}, 'タイトルとURLコピー');
key.setViewKey('u', function () {
copyTextToClipboard(getCurrentURL());
}, 'URLコピー');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment