Bei deinem Eintrag font-size: ${cs_font_size}px bin ich mir nicht sicher, was ist mit dem px ?
Schau Dir die Deklaration der Variabel an. ![]()
Aber ich gebe Dir recht let cs_font_size = 14px wäre besser gewesen.
Dharkness Schau mal, besser?
@Horstmann So und noch etwas an "Deinem" Skript geschraubt und, tada,
es passt!
JavaScript
(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 = "Test_3.svg" // Custom Folder Icon
let icon2 = "bookmark-hollow.svg" // Custom Link Icon
let cs_font_size = 14
let cs_font_weight = 900
let cs_font_color = "#FFD700"
let cs_icon_color = "#C0C0C0"
function setFunction() {
const css =`
#bmContent {
display: flex !important;
margin-inline: auto 0 !important;
font-family: Consolas, "Lucida Console", "Courier New", monospace !important;
font-size: ${cs_font_size}px !important;
font-weight: ${cs_font_weight} !important;
}
#bmContent::before {
content: url("${ProfilePath}/${icon1}") " "
attr(data-value1);
fill: ${cs_icon_color};
color: ${cs_font_color};
align-items: center;
display: flex;
justify-content: start;
width: 32px;
}
#bmContent::after {
content: url("${ProfilePath}/${icon2}") " "
attr(data-value2);
fill: ${cs_icon_color};
width: 50px;
color: ${cs_font_color};
align-items: center;
display: flex;
justify-content: end;
}
`;
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);
let bmbMenu = document.getElementById('bookmarks-menu-button');
let bookMenu = document.getElementById('bookmarksMenu');
let persToolBar = document.getElementById('PersonalToolbar');
if(bmbMenu)
bmbMenu.addEventListener('popupshowing', onPopupShowing );
if(bookMenu)
bookMenu.addEventListener('popupshowing', onPopupShowing );
if(persToolBar)
persToolBar.addEventListener('popupshowing', onPopupShowing );
}
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;
itemPopup.hidden = true;
itemPopup.collapsed = true;
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++;
}
}
}
itemPopup.hidden = false;
itemPopup.collapsed = false;
let bmCounta = item.childNodes[1];
bmCounta.innerHTML = " "
let bmContent = document.createElement("bmContent");
bmContent.id = "bmContent";
bmCounta.appendChild(bmContent);
// let strCountOut1 = + menuCount + " "; // Has square brackets
let strCountOut1 = String(menuCount).padStart(2, " ")
bmContent.setAttribute('data-value1', strCountOut1);
// let strCountOut2 = + menuitemCount + " "; // Has square brackets
let strCountOut2 = String(menuitemCount).padStart(2, " ")
bmContent.setAttribute('data-value2', strCountOut2);
}, 100);
}
}
})();
Alles anzeigen