// buttonToggleStylesheet.uc.js (function() { if (location.href != 'chrome://browser/content/browser.xhtml') return; try { CustomizableUI.createWidget({ id: 'toolbar-button-sty', type: 'custom', defaultArea: CustomizableUI.AREA_NAVBAR, onBuild: function(aDocument) { var StyleDisabled = gPageStyleMenu._getStyleSheetInfo(gBrowser.selectedBrowser).authorStyleDisabled; var button = aDocument.createElementNS('http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul', 'toolbarbutton'); var attributes = { id: 'toolbar-button-sty', class: 'toolbarbutton-1 chromeclass-toolbar-additional', removable: 'true', label: 'Stylesheet ein-/ausschalten', tooltiptext: StyleDisabled ? 'Stylesheet ist ausgeschaltet' : 'Stylesheet ist eingeschaltet', oncommand: '(' + onCommand.toString() + ')()' }; for (var a in attributes) { button.setAttribute(a, attributes[a]); }; function onCommand() { var StyleDisabled = gPageStyleMenu._getStyleSheetInfo(gBrowser.selectedBrowser).authorStyleDisabled; // true wenn kein Style var windows = Services.wm.getEnumerator('navigator:browser'); while (windows.hasMoreElements()) { let button = windows.getNext().document.getElementById('toolbar-button-sty'); button.setAttribute('tooltiptext', StyleDisabled ? 'Stylesheet ist eingeschaltet' : 'Stylesheet ist ausgeschaltet') }; // gilt f.aktuelles Tab, Tab-Wechsel aktualisieren Icon nicht! if (StyleDisabled) gPageStyleMenu.switchStyleSheet(null); else gPageStyleMenu.disableStyle(); // Script bricht hier ab?! Egal... }; return button; } }); } catch(e) { }; var css = '#toolbar-button-sty[tooltiptext="Stylesheet ist ausgeschaltet"] {list-style-image: url("resource:///chrome/devtools/skin/images/eye-closed.svg");}' + '#toolbar-button-sty[tooltiptext="Stylesheet ist eingeschaltet"] {list-style-image: url("resource:///chrome/devtools/skin/images/eye-opened.svg");}'; var stylesheet = document.createProcessingInstruction('xml-stylesheet', 'type="text/css" href="data:text/css;utf-8,' + encodeURIComponent(css) + '"'); document.insertBefore(stylesheet, document.documentElement); })();