Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
ポップアップブックマークツールバー
// ==UserScript==
// @name PopupBookmarkToolbar.uc.js
// @namespace http://d.hatena.ne.jp/Griever/
// @include main
// @version 0.0.3
// ==/UserScript==
(function(){
var mode = 'icons'; // 'icons', 'text' or 'full'
var size = 'small'; // 'small' or 'large'
// array of toolbar item id, 'separator', 'spring' and 'spacer'.
var currentSet = [
'personal-bookmarks',
];
var tabs = gBrowser.mTabContainer;
var button = document.createElement('toolbarbutton');
button.setAttribute("id", "PopupBookmarkButton");
button.setAttribute("onmouseover", "if(document.getElementById('PersonalToolbar').collapsed) this.firstChild.openPopup(this, 'after_start');");
button.setAttribute("oncommand", "if (this == event.originalTarget) document.getElementById('PersonalToolbar').collapsed = !document.getElementById('PersonalToolbar').collapsed;");
button.setAttribute("image", 'data:image/png;base64,'+
'iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAACNFBMVEXDRgDweQDnbwC0NgDCRQC7PQDt'+
'pTu+QQD78q3PUwDCRAD//8vbYQDLTgDocAD0iQX1jQbGSgD7iAD4gwDVaw7vdwDyegD+igDweQDlawDy'+
'hAXveADmZwDzmBbtcwDwkhHveADmhBTkgxbweADkfRH+igD7hADXZQX0gADyjA/tfgvveQDiawDQVADR'+
'XgfnbwD1jAb9iQD9z0PVZAbxpinykRHtdgD5mRbERQDDRgDOYArCRAD9iQD3ewDxegD3dwDFRgDAQAD+'+
'hgD4fQDucgDtgQftfwTISQDCRQDvdgD5lxb1kRb2qh7wnynkagD766LDRQDDRwDDRQDspjbtpzbuqDbv'+
'qzv//8DUZAbCRQD//83pjhvveQbvggW+QQDfcxLlmUb//8veYADMTwDHSADVVwC8PgDwixb78q3oZgDU'+
'WADRVADCRQD9iQDERwDBQQDYVQC+PgC0NgDbYQDWWgDUWADSVQDFSAC+QAC7PAC0NgD+wRL+/kD+/zb+'+
'7i3+8Cv+/DX+wBL/+DD/rwz+qgz+rwz/tAz+sQzfbAT+3iP/+jD//Dz1jwP+nwf5iwf7pBz2tRr4lwb/'+
'ogfsdQT+2R7/9ET+2iT8yyLmgBL5iQL2egLokhP7zzT60zv1zUr0gAL1ewP50yn9+UL++EXooyngaAH4'+
'1EPzowzyySj+xxzlhhHvvyruwjXxvTnUag3+zxrwigP+swz86U/ZXwD75lHqegD6xzb//kn+uhPTXAG3'+
'OAD/+UC2vFeJAAAAe3RSTlMAAAAAAAAAAAAAAAAAAAAAAAAAAACfnwAIaelpAAA2+wD7UQAAa3oArKzR'+
'zMysnwgAvPQA/gAAw3prw0oALr16vS4AACnF6bspAAAA/mIAADQAAAAAAI8AAEwA0vv7kd2yAuuvr+vK'+
'ABL23U+8Sk/d9vUDIIAQAAAQgCAfvupHAAABB0lEQVR4Xi3IU3fDABgA0C+u26FdZ9u2bdu2vZSzbds2'+
'/tyac3IfLxjpGyA6MimqY6gHTNgiiNwkwRM1E7EhTrYyTfMzzsh0ZEPiH+D6+u5mV1jEhpe5haVCYW1T'+
'4suEvUOkk7PLpVJ5WFnl7hEUDN5LPvsHJ6cazdn13f3DYxu0B35+/Y2qVSr17NzGeUgohIVHLK/PMDa3'+
'9qKieRATGxd/9cS4uU1MwnmQktqY/qGlaVr7/ZOVDTmQm5df8PwyNj4xOTVdjOM4kCRZOr+wWFa+srpW'+
'QVEU8PnV2zu7NbV19UfHDQRBAIfTdNHc0soVdnR2dfdgGAgEvW99/QNc4eDQ8O8Ihv0D77NPgbVLZ6kA'+
'AAAASUVORK5CYII=');
tabs.parentNode.insertBefore(button, tabs);
var panel = button.appendChild( document.createElement('panel') );
panel.setAttribute("id", "PopupBookmark");
panel.setAttribute("onpopupshown", "this.style.maxWidth = this.firstChild.firstChild.style.maxWidth = (window.innerWidth-8) + 'px';");
panel.style.MozAppearance = 'toolbox';
var toolbox = panel.appendChild( document.createElement('toolbox') );
toolbox.palette = document.getElementById('navigator-toolbox').palette;
var toolbar = toolbox.appendChild( document.createElement('toolbar') );
toolbar.className = 'chromeclass-toolbar';
toolbar.setAttribute("id", "PopupBookmarkToolbar");
toolbar.setAttribute("mode", mode);
toolbar.setAttribute("iconsize", size);
toolbar.insertItem = document.getElementById('nav-bar').insertItem;
currentSet.forEach(function(id){
if (document.getElementById(id))
toolbar.appendChild( document.getElementById(id).cloneNode(true) );
else
toolbar.insertItem(id);
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.