z.B. so ähnlich:
JavaScript
(function() {
if (location.href !== 'chrome://browser/content/browser.xhtml') return;
try {
CustomizableUI.createWidget({
id: 'time-button',
type: 'custom',
defaultArea: CustomizableUI.AREA_NAVBAR,
onBuild: function(aDocument) {
let toolbaritem = aDocument.createElementNS('http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul', 'toolbarbutton');
// toolbaritem.onclick = event => onClick(event); // Fallback für Dharkness ;)
var props = {
id: 'time-button',
class: 'toolbarbutton-1 chromeclass-toolbar-additional',
removable: 'true',
label: 'Internationale Uhrzeiten',
accesskey: '', // Wer möchte kann hier z.B. 'C' eintragen, dann kann per "Alt + C" das Skript ausgeführt werden
tooltiptext: 'Internationale Uhrzeiten anzeigen',
};
for (var p in props)
toolbaritem.setAttribute(p, props[p]);
// Hinzufügen des Klick-Event-Handlers für das Popup
toolbaritem.onclick = function (event) {
if (event.button === 0) {
//-----------------------------------------------------------
const body = document.querySelector('body');
const dialog = document.createElement('dialog');
const btn = document.createElement('button');
dialog.style.backgroundColor = '#0f0';
dialog.style.borderColor = '#f00';
dialog.appendChild(btn);
btn.textContent = 'close';
btn.style.backgroundColor = '#ff0';
btn.addEventListener('click', () => {
dialog.close();
});
body.appendChild(dialog);
dialog.showModal();
//--------------------------------------------------------
var t,t10,t15,t20,t30,t40,t50;
t = new Date()
t10=t.toLocaleTimeString('de-DE',{timeZone:'Europe/Berlin',weekday:'long',day:'numeric',month:'short',hour:'numeric',minute:'numeric',hour12:false})
t15=t.toLocaleTimeString('de-DE',{timeZone:'Europe/Lisbon',weekday:'long',day:'numeric',month:'short',hour:'numeric',minute:'numeric',hour12:false})
t20=t.toLocaleTimeString('de-DE',{timeZone:'America/New_York',weekday:'long',day:'numeric',month:'short',hour:'numeric',minute:'numeric',hour12:false})
t30=t.toLocaleTimeString('de-DE',{timeZone:'Europe/Moscow',weekday:'long',day:'numeric',month:'short',hour:'numeric',minute:'numeric',hour12:false})
t40=t.toLocaleTimeString('de-DE',{timeZone:'Asia/Hong_Kong',weekday:'long',day:'numeric',month:'short',hour:'numeric',minute:'numeric',hour12:false})
t50=t.toLocaleTimeString('de-DE',{timeZone:'Australia/Sydney',weekday:'long',day:'numeric',month:'short',hour:'numeric',minute:'numeric',hour12:false})
alert(
t10+' Berlin\n'
+t15+' Lagos\n\n'
+t20+' New York\n'
+t30+' Moskau\n\n'
+t40+' Hongkong\n'
+t50+' Sydney')
};
}
return toolbaritem;
}
});
} catch(e) { };
let ProfilePath = PathUtils.toFileURI(PathUtils.join(PathUtils.profileDir, 'chrome', 'css', 'image')); // Pfad zum Profilordner und gleich in den entsprechenden Unterordner
let ButtonIcon = "16_time-3_ohne.svg"; // Name & Dateiendung des anzuzeigenden Symbols!
let sss = Components.classes["@mozilla.org/content/style-sheet-service;1"].getService(Components.interfaces.nsIStyleSheetService);
let uri = Services.io.newURI("data:text/css;charset=utf-8," + encodeURIComponent(`
#time-button { list-style-image: url("${ProfilePath}/${ButtonIcon}")
}
#time-button .toolbarbutton-icon {
overflow: hidden !important;
padding-top: 0px !important;
padding-bottom: 0px !important;
fill: var(--uc-color-yellow-button) !important;
fill-opacity: 1 !important;
}
#time-button:hover .toolbarbutton-icon {
fill: var(--uc-color-lightgray-icons) !important;
fill-opacity: 1 !important;
}
`), null, null);
sss.loadAndRegisterSheet(uri, sss.AUTHOR_SHEET);
})();
Alles anzeigen
ist nur als Bastelvorlage gedacht