.



on-line?
? ?
Ru.Board » » » Firefox/Mozilla Firefox Extensions ( 8)

: gyra, Maz

gyra (16-09-2017 13:48): Firefox/Mozilla Firefox Extensions ( 9)    •

   

momo2000



Advanced Member
| | | |

/*global Components, Services*/
 
const Cu = Components.utils, Cc = Components.classes, Ci = Components.interfaces;
 
Cu.import("resource://gre/modules/Services.jsm");
 
const overlay = "chrome://browser/content/bookmarks/bookmarksPanel.xul";
 
function sidebar_change(sidebar) {
if (sidebar.currentURI.spec !== overlay) {
return false;
}
 
var bookmarks = sidebar.contentDocument.getElementById("bookmarks-view"), place;
 
if (!bookmarks || !(place = bookmarks.getAttribute("place"))) {
return false;
}
 
bookmarks.setAttribute("place-default", place);
bookmarks.place = "place:queryType=1&folder=BOOKMARKS_MENU";
 
return true;
}
 
function sidebar_restore(sidebar) {
if (sidebar.currentURI.spec !== overlay) {
return false;
}
 
var bookmarks = sidebar.contentDocument.getElementById("bookmarks-view"), place;
 
if (!bookmarks || !(place = bookmarks.getAttribute("place-default"))) {
return false;
}
 
bookmarks.place = place;
bookmarks.removeAttribute("place-default");
 
return true;
}
 
function window_load(doc) {
var sidebar = doc.getElementById("sidebar");
 
if (!sidebar) {
return false;
}
 
var stop = Ci.nsIWebProgressListener.STATE_STOP, win = Ci.nsIWebProgressListener.STATE_IS_WINDOW;
sidebar.addProgressListener(sidebar.old_bookmarks_sidebar = {
QueryInterface: function (id)
{
if (id.equals(Ci.nsIWebProgressListener) || id.equals(Ci.nsISupportsWeakReference) || id.equals(Ci.nsISupports)) {
return this;
}
 
throw Components.results.NS_NOINTERFACE;
},
 
onStateChange: function (progress, request, flag) {
return flag & stop && flag & win ? sidebar_change(sidebar) : false;
},
onLocationChange: function () {},
onProgressChange: function () {},
onStatusChange: function () {},
onSecurityChange: function () {}
});
 
return sidebar_change(sidebar);
}
 
function window_unload(doc) {
var sidebar = doc.getElementById("sidebar");
 
if (!sidebar) {
return false;
}
 
sidebar.removeProgressListener(sidebar.old_bookmarks_sidebar);
 
return sidebar_restore(sidebar);
}
 
function window_check(win) {
if (win.document.readyState === "complete") {
return window_load(win.document);
}
 
return win.addEventListener("load", function listener() {
win.removeEventListener("load", listener, false);
 
return window_load(win.document);
}, false);
}
 
const window_watcher = {
observe: function (win, action) {
return action === "domwindowopened" ? window_check(win) : false;
}
};
 
function startup() {
var all = Services.ww.getWindowEnumerator();
while (all.hasMoreElements()) {
window_check(all.getNext());
}
 
return Services.ww.registerNotification(window_watcher);
}
 
function shutdown() {
var all = Services.ww.getWindowEnumerator();
while (all.hasMoreElements()) {
window_unload(all.getNext().document);
}
 
return Services.ww.unregisterNotification(window_watcher);
}
 

: 1618 | . 14-04-2007 | : 08:31 18-08-2016 | : momo2000, 08:31 18-08-2016
   


Ru.Board » » » Firefox/Mozilla Firefox Extensions ( 8)
gyra (16-09-2017 13:48): Firefox/Mozilla Firefox Extensions ( 9)


Ru.Board.

Powered by Ikonboard "v2.1.7b" © 2000 Ikonboard.com
Modified by Ru.Board
© Ru.Board 2000-2020

BitCoin: 1NGG1chHtUvrtEqjeerQCKDMUi6S6CG4iC

.ru