Ich habe gerade mit folgendem Skript, das im Lesezeichen-Menü die Anzahl der Ordner/Lesezeichen je Ordner anzeigt, herumgespielt...
JavaScript
(function() {
if (!window.gBrowser)
return;
function setFunction() {
PlacesViewBase.prototype._onPopupShowing = function PVB__onPopupShowing(aEvent) {
let popup = aEvent.originalTarget;
this._ensureMarkers(popup);
if ("_delayedRemovals" in popup) {
while (popup._delayedRemovals.length) {
popup.removeChild(popup._delayedRemovals.shift());
}
}
if (popup._placesNode && PlacesUIUtils.getViewForNode(popup) == this) {
if (!popup._placesNode.containerOpen) {
popup._placesNode.containerOpen = true;
}
if (!popup._built) {
this._rebuildPopup(popup);
}
this._mayAddCommandsItems(popup);
}
/* original function end */
for (let item of popup.children) {
if (item.localName != 'menu' || item.id?.startsWith('history'))
continue;
setTimeout(() => {
let itemPopup = item.menupopup;
itemPopup.openPopup();
itemPopup.hidePopup();
let menuitemCount = 0;
let menuCount = 0;
for (let subitem of itemPopup.children) {
if (subitem.classList.contains('bookmark-item') && !subitem.disabled && !subitem.hidden) {
if (subitem.localName == 'menuitem') {
menuitemCount++;
} else if (subitem.localName == 'menu') {
menuCount++;
}
}
}
if (!item.labelOriginal) {
item.labelOriginal = item.label;
}
item.labelSuffix = ' (' + menuCount + '/' + menuitemCount + ')';
// item.setAttribute("id", "menu-menuitem-count");
// item.labelSuffix.setAttribute("color", "red");
// item.labelSuffix = className("menu-menuitem-count");
// item.labelSuffix.className = "menu-menuitem-count";
// menuitemCount.setAttribute("id", "menu-menuitem-count");
item.label = item.labelOriginal + item.labelSuffix;
}, 100);
}
popup.addEventListener('popuphidden', function onPopuphidden(event) {
if (event.target != this)
return;
popup.removeEventListener('popuphidden', onPopuphidden);
for (let item of popup.children) {
if (item.localName == 'menu') {
if (item.labelOriginal) {
item.label = item.labelOriginal;
item.labelOriginal = undefined;
}
}
}
});
}
}
setTimeout(function() {
setFunction();
},50);
})();
Alles anzeigen
Ich suche nach einem Weg, nur die Anzeige der Ordner/Lesezeichenanzahl in einer anderen Farbe darzustellen, wie in dem zusammen gebastelten Screenshot.
Kann mir da jemand auf die Sprünge helfen?