So, hier eine meiner Versionen, natürlich zusammen geklaut und geschustert.
JavaScript
// BookmarkCount.uc.js
/* ******************************************************************************************************************* */
/* Author BrokenHeart => https://www.camp-firefox.de/forum/thema/136572/?postID=1229536#post1229536 **** */
/* Correction from BrokenHeart => https://www.camp-firefox.de/forum/thema/136572/?postID=1229696#post1229696 **** */
/* Extension from Sören Henschel => https://www.camp-firefox.de/forum/thema/136572/?postID=1229555#post1229555 **** */
/* Customized by Mira inspired by grisu2099 ********************************************************************** */
/* Source => https://www.camp-firefox.de/forum/thema/136572/?postID=1229875#post1229883 **** */
/* Customized by Mira inspired by Horstmann ********************************************************************** */
/* Source => https://www.camp-firefox.de/forum/thema/136572/?postID=1229993#post1229993 **** */
/* Adjustments for 139 and customized by Mira inspired by Horstmann ********************************************** */
/* Source => https://www.camp-firefox.de/forum/thema/136572/?postID=1270038#post1270038 **** */
/* ******************************************************************************************************************* */
/* Version 1.01 => https://www.camp-firefox.de/forum/thema/136572/?postID=1230128#post1230128 **** */
/* Version 1.02 => https://www.camp-firefox.de/forum/thema/136572/?postID=1230334#post1230334 **** */
/* Version 1.03 => https://www.camp-firefox.de/forum/thema/136572/?postID=1270113#post1270113 **** */
/* ******************************************************************************************************************* */
/* Custom Counter in the Bookmarks for folders and links ************************************************************* */
/* ******************************************************************************************************************* */
(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 = 12
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;
padding-left: 10px; / Abstand zwischen Label und Icon */
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}") /* Custom icon */
attr(data-value1);
width: calc(8px + 2.1em); /* Feste Breite rechter Counter für 2 Ziffern -> Icons auf gleicher Höhe */
justify-content: space-between;
align-items: center;
display: flex;
/* margin-inline: 5px; */ /* Abstand links für enge Popups, rechts zum 2ten Counter */
margin-right: 5px; /* Abstand 1. Zahl bis Icon */
fill: ${cs_icon_color}; /* Farbe des Icons */
color: ${cs_font_color}; /* Farbe der 1. Zahl */
}
#bmContent::after {
content: url("${ProfilePath}/${icon2}") /* Custom icon */
attr(data-value2);
width: calc(8px + 2.1em); /* Feste Breite rechter Counter für 2 Ziffern -> Icons auf gleicher Höhe */
align-items: center;
display: flex;
margin-inline: -4px; /* Abstand 2. Zahl bis Pfeil */
justify-content: space-between;
fill: ${cs_icon_color}; /* Farbe des Icons */
color: ${cs_font_color}; /* Farbe der 2. Zahl */
}
`;
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 = + menuCount + ""; // Has no brackets
let strCountOut1 = String(menuCount).padEnd(2, " ");
bmContent.setAttribute('data-value1', strCountOut1);
// let strCountOut2 = "[" + menuitemCount + "]"; // Has square brackets
// let strCountOut2 = + menuitemCount + ""; // Has no brackets
let strCountOut2 = String(menuitemCount).padEnd(2, "");
bmContent.setAttribute('data-value2', strCountOut2);
}, 50);
}
}
})();
Alles anzeigen
