Skip to content

Instantly share code, notes, and snippets.

@nkmrgk
Created March 26, 2011 12:48
Show Gist options
  • Save nkmrgk/888257 to your computer and use it in GitHub Desktop.
Save nkmrgk/888257 to your computer and use it in GitHub Desktop.
MyKeybind for userChromeJS v1.3
<?xml version="1.0"?>
<!DOCTYPE overlay>
<overlay id="mainKeyset_overlay"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/x-javascript"><![CDATA[
setTimeout(function(){
var win = document.getElementById('main-window');
var pos = document.getElementById('mainPopupSet');
var mainKeyset = document.getElementById('mainKeyset');
win.insertBefore(mainKeyset, pos);
var baseMenuKeyset = document.getElementById('baseMenuKeyset');
win.insertBefore(baseMenuKeyset, pos);
},1000);
window.ucjs_hatebuEntry = function() {
var url = window._content.document.location.href;
var u='http://b.hatena.ne.jp/entry/'+url.replace(/#/g,'%23');
gBrowser.loadOneTab(u, {inBackground: true, relatedToCurrent: true});
};
window.ucjs_copyTitleAndUrl = function(type) {
var title = document.title.replace(/ - Mozilla Firefox.*$/g, '');
var url = window._content.document.location.href;
var txt;
if (type == 'html') {
txt = '<a href="' + url + '">' + title + '</a>';
}
else if (type == 'space') {
txt = title + ' ' + url;
}
else if (type == 'markdown') {
txt = '[' + title + '](' + url + ')';
}
else if (type == 'hatena') {
txt = '[' + url + ':title=' + title + ']';
}
else if (type == 'htmlhatena') {
txt = '<a href="' + url + '">' + title + '</a>';
txt += '<a href="http://b.hatena.ne.jp/entry/' + url + '">'
txt += '<img src="http://b.hatena.ne.jp/entry/image/' + url;
txt += '" style="border: none;vertical-align: middle;" /></a>';
}
else {
// Newline
txt = title + "\n" + url;
}
const CLIPBOARD = Components.classes["@mozilla.org/widget/clipboardhelper;1"].getService(Components.interfaces.nsIClipboardHelper);
CLIPBOARD.copyString(txt);
content.status = txt;
setTimeout(function(){ content.status=''; }, 1500);
};
]]></script>
<window id="main-window">
<keyset id="mainKeyset2">
<key id="hatebu-entry" key="d" oncommand="ucjs_hatebuEntry();" modifiers="accel"/>
<key id="copy-tit-url" key="c" oncommand="ucjs_copyTitleAndUrl('newline');" modifiers="accel,alt"/>
<key id="copy-tit-url" key="s" oncommand="ucjs_copyTitleAndUrl('html');" modifiers="accel,alt"/>
<key id="copy-tit-url" key="v" oncommand="ucjs_copyTitleAndUrl('space');" modifiers="accel,alt"/>
<key id="copy-tit-url" key="n" oncommand="ucjs_copyTitleAndUrl('markdown');" modifiers="accel,alt"/>
<key id="prev-tab" key="1" oncommand="gBrowser.moveTabBackward();" modifiers="accel"/>
<key id="prev-tab" key="3" oncommand="gBrowser.moveTabForward();" modifiers="accel"/>
<key id="prev-tab" key="z" oncommand="document.getElementById('View:FullScreen').doCommand();" modifiers="accel"/>
<key key="j" oncommand="gBrowser.selectedTab.linkedBrowser.contentWindow.focus()" modifiers="accel"/>
<key key="f" oncommand="if ('isFindBarVisible' in gFindBar){gFindBar.isFindBarVisible() ? gFindBar.closeFindBar() : gFindBar.onFindCmd();}else{gFindBar.hidden ? gFindBar.onFindCommand() : gFindBar.close();}" modifiers="accel"/>
<key keycode="VK_F1" oncommand="openPreferences();"/>
</keyset>
</window>
</overlay>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment