"bookmark this tree" doesn't work on Firefox 11 and later

This commit is contained in:
SHIMODA Hiroshi 2012-01-26 11:05:28 +09:00
parent 8e1188d9be
commit 1e2ea4969f
2 changed files with 34 additions and 12 deletions

View File

@ -65,7 +65,7 @@ var TreeStyleTabBookmarksService = {
bookmarkTabSubtree : function TSTBMService_bookmarkTabSubtree(aTabOrTabs)
{
var tabs = aTabOrTabs;
if (!(tabs instanceof Array)) {
if (!Array.isArray(tabs)) {
tabs = [aTabOrTabs];
}

View File

@ -12,11 +12,11 @@
in JS files:
window['piro.sakura.ne.jp'].bookmarkMultipleTabs.addBookmarkFor(tabsArray, folderName);
license: The MIT License, Copyright (c) 2009-2010 SHIMODA "Piro" Hiroshi
http://www.cozmixng.org/repos/piro/fx3-compatibility-lib/trunk/license.txt
license: The MIT License, Copyright (c) 2009-2012 SHIMODA "Piro" Hiroshi
http://github.com/piroor/fxaddonlibs/blob/master/license.txt
original:
http://www.cozmixng.org/repos/piro/fx3-compatibility-lib/trunk/bookmarkMultipleTabs.xul
http://www.cozmixng.org/repos/piro/fx3-compatibility-lib/trunk/bookmarkMultipleTabs_bookmarkPropertiesOverlay.xul
http://github.com/piroor/fxaddonlibs/blob/master/bookmarkMultipleTabs.xul
http://github.com/piroor/fxaddonlibs/blob/master/bookmarkMultipleTabs_bookmarkPropertiesOverlay.xul
-->
<overlay xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript"><![CDATA[
@ -24,7 +24,7 @@
window.addEventListener('DOMContentLoaded', function() {
window.removeEventListener('DOMContentLoaded', arguments.callee, true);
const currentRevision = 4;
const currentRevision = 5;
if (!('piro.sakura.ne.jp' in window)) window['piro.sakura.ne.jp'] = {};
@ -57,12 +57,34 @@ window.addEventListener('DOMContentLoaded', function() {
var b = this.getTabBrowserFromChild(aTabs[0]);
if ('PlacesUIUtils' in window || 'PlacesUtils' in window) { // Firefox 3
if (aFolderName)
this.Prefs.setCharPref('temp.showMinimalAddMultiBookmarkUI.folderName', unescape(encodeURIComponent(aFolderName)));
var utils = 'PlacesUIUtils' in window ? PlacesUIUtils : PlacesUtils ;
utils.showMinimalAddMultiBookmarkUI(Array.slice(aTabs).map(this.addBookmarkTabsFilter));
this.Prefs.clearUserPref('temp.showMinimalAddMultiBookmarkUI.folderName');
if ('PlacesUIUtils' in window || 'PlacesUtils' in window) { // Firefox 3 or later
try {
var utils = 'PlacesUIUtils' in window ? PlacesUIUtils : PlacesUtils ;
var tabs = Array.slice(aTabs).map(this.addBookmarkTabsFilter);
if (aFolderName)
this.Prefs.setCharPref('temp.showMinimalAddMultiBookmarkUI.folderName', unescape(encodeURIComponent(aFolderName)));
if ('showBookmarkDialog' in utils) { // Firefox 11 or later
utils.showBookmarkDialog({
action : 'add',
type : 'folder',
// title : aFolderName, // don't specify it, because Firefox doesn't create bookmarks if the title is given!
URIList : tabs,
hiddenRows : ['description', 'location', 'loadInSidebar', 'keyword']
}, window);
}
else if ('showMinimalAddMultiBookmarkUI' in utils) { // Firefox 3 - 10
utils.showMinimalAddMultiBookmarkUI(tabs);
}
else {
throw new Error('there is no method to create bookmarks from tabs!');
}
}
catch(e) {
alert(e.message+'\n'+e.stack);
}
finally {
this.Prefs.clearUserPref('temp.showMinimalAddMultiBookmarkUI.folderName');
}
return;
}