Geändert habe ich vor allem die Icon-Erzeugung, die explizite Größe und die URL-Behandlung. Außerdem wird der / wieder tatsächlich ausgegeben. Sieht hier so aus: ![]()
Dann teste bitte mal:
CSS
// basiert auf Script von BrokenHeart
// Firefox 154+
(function() {
if (!window.gBrowser)
return;
setTimeout(function() {
setFunction();
}, 50);
// ============================================================
// Custom icons in profile/chrome/icons folder
// ============================================================
let ProfilePath = PathUtils.toFileURI(
PathUtils.join(PathUtils.profileDir, 'chrome', 'icons')
);
let icon1 = "folder.png";
let icon2 = "Bild36.png";
let icon1URL = `${ProfilePath}/${icon1}`;
let icon2URL = `${ProfilePath}/${icon2}`;
// ============================================================
// Einstellungen
// ============================================================
let cs_font_size = 14;
let cs_font_weight = 600;
let cs_font_color = "brown";
// feste Spaltenbreite
let colWidthCh = 4;
// ============================================================
// CSS
// ============================================================
function setFunction() {
const css = `
/*===== Counter rechtsbündig =====*/
#bmContent {
display: flex;
justify-content: flex-end;
align-items: center;
margin-top: -15px;
margin-right: 0px;
font-family: Consolas, "Lucida Console", "Courier New", monospace;
font-size: ${cs_font_size}px;
font-weight: ${cs_font_weight};
height: 18px;
white-space: nowrap;
}
/*============*/
/* Icon 1 */
/*============*/
.bmIcon1 {
display: inline-block;
width: 18px;
min-width: 18px;
height: 18px;
min-height: 18px;
flex: 0 0 18px;
background-image: url("${icon1URL}");
background-repeat: no-repeat;
background-position: center;
background-size: 16px 16px;
margin-left: 6px;
margin-right: 0;
margin-top: 0px;
}
/*============*/
/* Icon 2 */
/*============*/
.bmIcon2 {
display: inline-block;
width: 13px;
min-width: 13px;
height: 13px;
min-height: 13px;
flex: 0 0 13px;
background-image: url("${icon2URL}");
background-repeat: no-repeat;
background-position: center;
background-size: 13px 13px;
margin-left: 6px;
margin-right: 0;
margin-top: 0px;
}
/*===== Zahlen =====*/
.bmValue {
color: ${cs_font_color} !important;
flex: 0 0 auto;
min-width: ${colWidthCh}ch;
text-align: right;
}
/*===== Slash =====*/
.bmSlash {
color: ${cs_font_color} !important;
margin-left: 3px !important;
margin-right: -7px !important;
}
/*===== Hover-Farbwechsel =====*/
menupopup[placespopup="true"]
> menu.bookmark-item:hover
> .menu-text
> #bmContent
.bmValue {
color: red !important;
}
menupopup[placespopup="true"]
> menu.bookmark-item:hover
> .menu-text
> #bmContent
.bmSlash {
color: #000 !important;
}
`;
const sss =
Cc['@mozilla.org/content/style-sheet-service;1']
.getService(Ci.nsIStyleSheetService);
const uri = Services.io.newURI(
'data:text/css,' + encodeURIComponent(css)
);
sss.loadAndRegisterSheet(
uri,
sss.AGENT_SHEET
);
// ========================================================
// Bookmarks-Menü
// ========================================================
let bookMenu =
document.getElementById('bookmarksMenu');
let persToolBar =
document.getElementById('PersonalToolbar');
if (bookMenu) {
bookMenu.addEventListener(
'popupshown',
onPopupShowing
);
}
if (persToolBar) {
persToolBar.addEventListener(
'popupshowing',
onPopupShowing
);
}
}
// ============================================================
// Popup
// ============================================================
function onPopupShowing(aEvent) {
let popup = aEvent.originalTarget;
for (let item of popup.children) {
if (
item.localName != 'menu' ||
item.id?.startsWith('history')
)
continue;
setTimeout(() => {
let itemPopup = item.menupopup;
if (!itemPopup)
return;
// ------------------------------------------------
// Popup kurz öffnen, damit die Children
// zuverlässig vorhanden sind
// ------------------------------------------------
itemPopup.hidden = true;
itemPopup.collapsed = true;
itemPopup.openPopup();
itemPopup.hidePopup();
// ------------------------------------------------
// Zähler
// ------------------------------------------------
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++;
}
}
}
itemPopup.hidden = false;
itemPopup.collapsed = false;
// ------------------------------------------------
// Container für den Counter
// ------------------------------------------------
let bmCounta = item.childNodes[1];
if (!bmCounta)
return;
bmCounta.innerHTML = "";
let bmContent =
document.createXULElement("box");
bmContent.id = "bmContent";
// =================================================
// Anzahl Ordner
// =================================================
let v1 =
document.createXULElement("label");
v1.className = "bmValue";
v1.textContent = menuCount;
// =================================================
// Icon 1 = Ordner
// =================================================
let icon1El =
document.createXULElement("box");
icon1El.className = "bmIcon1";
// =================================================
// Slash
// =================================================
let slash =
document.createXULElement("label");
slash.className = "bmSlash";
slash.textContent = "/";
// =================================================
// Anzahl Lesezeichen
// =================================================
let v2 =
document.createXULElement("label");
v2.className = "bmValue";
v2.textContent = menuitemCount;
// =================================================
// Icon 2 = Lesezeichen
// =================================================
let icon2El =
document.createXULElement("box");
icon2El.className = "bmIcon2";
// =================================================
// Reihenfolge
//
// Zahl1 Icon1 / Zahl2 Icon2
// =================================================
bmContent.appendChild(v1);
bmContent.appendChild(icon1El);
bmContent.appendChild(slash);
bmContent.appendChild(v2);
bmContent.appendChild(icon2El);
// =================================================
// Einfügen
// =================================================
bmCounta.appendChild(bmContent);
}, 100);
}
}
})();
Alles anzeigen
Zusammen getestet mit deinem zweiten Script:
