1. Startseite
  2. Nachrichten
  3. Herunterladen
    1. Thunderbird Release-Version
    2. Thunderbird 128 ESR
    3. Thunderbird 115 ESR
    4. Thunderbird Beta-Version
    5. Sprachpaket (Benutzeroberfläche)
    6. Wörterbücher (Rechtschreibprüfung)
  4. Hilfe & Lexikon
    1. Anleitungen zu Thunderbird
    2. Fragen & Antworten (FAQ) zu Thunderbird
    3. Hilfe zu dieser Webseite
  5. Forum
    1. Unerledigte Themen
    2. Letzte Beiträge
    3. Themen der letzten 24 Stunden
  • Deutsch
  • Anmelden
  • Registrieren
  • 
  • Suche
Forum
  1. Thunderbird Mail DE
  2. seipe

Beiträge von seipe

  • 1
  • 4
  • 5
  • 6
  • 10
  • UserCSSLoader.uc.js arbeitet in TB 91nicht, in FF 91schon.

    • seipe
    • 18. August 2021 um 17:01

    Boersenfeger, dann mal recht herzlichen Dank für deine Bemühungen. Dann warte ich mal ab. Sollte sich was ändern, melde ich mich wieder.

  • UserCSSLoader.uc.js arbeitet in TB 91nicht, in FF 91schon.

    • seipe
    • 18. August 2021 um 16:56
    Code
    userChrome.ignoreCache = true;
    userChrome.import("*", "UChrm");

    Hier meine userChrome.js

  • UserCSSLoader.uc.js arbeitet in TB 91nicht, in FF 91schon.

    • seipe
    • 18. August 2021 um 16:47

    Bitte schön.

    Bilder

    • Zwischenablage01.jpg
      • 73,98 kB
      • 1.118 × 922
  • UserCSSLoader.uc.js arbeitet in TB 91nicht, in FF 91schon.

    • seipe
    • 18. August 2021 um 16:32
    HTML
    if (event.button == 1) {
    this.toggle(label);
    }
    else if (event.button == 2) {
    closeMenus(event.target);
    this.edit(this.getFileFromLeafName(label));
    }
    },
    getFileFromLeafName: function(aLeafName) {
    let f = this.FOLDER.clone();
    f.QueryInterface(Ci.nsIFile); // use appendRelativePath
    f.appendRelativePath(aLeafName);
    return f;
    },
    styleTest: function(aWindow) {
    aWindow || (aWindow = this.getFocusedWindow());
    new CSSTester(aWindow, function(tester){
    if (tester.saved)
    UCL.rebuild();
    });
    },
    searchStyle: function() {
    let word;
    try {
    word = gBrowser.currentURI.host;
    } catch {
    word = gBrowser.currentURI.spec;
    }
    openWebLinkIn("https://userstyles.org/styles/search/" + word, "tab", {});
    },
    openFolder:function(){
    if (this.vFileManager.length != 0) {
    var file = Cc['@mozilla.org/file/local;1'].createInstance(Ci.nsIFile);
    var process = Cc['@mozilla.org/process/util;1'].createInstance(Ci.nsIProcess);
    var args=[this.FOLDER.path];
    file.initWithPath(this.vFileManager);
    process.init(file);
    // Verzeichnis mit anderem Dateimanager öffnen
    process.run(false, args, args.length);
    } else {
    // Verzeichnis mit Dateimanager des Systems öffnen
    this.FOLDER.launch();
    }
    },
    editUserCSS: function(aLeafName) {
    let file = Services.dirsvc.get("UChrm", Ci.nsIFile);
    file.appendRelativePath(aLeafName);
    this.edit(file);
    },
    edit: function(aFile) {
    var editor = Services.prefs.getCharPref("view_source.editor.path");
    if (!editor) return alert("Unter about:config den vorhandenen Schalter:\n view_source.editor.path mit dem Editorpfad ergänzen");
    try {
    var UI = Components.classes["@mozilla.org/intl/scriptableunicodeconverter"].createInstance(Components.interfaces.nsIScriptableUnicodeConverter);
    UI.charset = window.navigator.platform.toLowerCase().indexOf("win") >= 0? "Shift_JIS": "UTF-8";
    var path = UI.ConvertFromUnicode(aFile.path);
    var app = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsIFile);
    app.initWithPath(editor);
    var process = Components.classes["@mozilla.org/process/util;1"].createInstance(Components.interfaces.nsIProcess);
    process.init(app);
    process.run(false, [path], 1);
    } catch (e) {}
    },
    create: function(aLeafName) {
    if (!aLeafName) aLeafName = prompt("Name des Styles", dateFormat(new Date(), "%Y_%m%d_%H%M%S"));
    if (aLeafName) aLeafName = aLeafName.replace(/\s+/g, " ").replace(/[\\/:*?\"<>|]/g, "");
    if (!aLeafName || !/\S/.test(aLeafName)) return;
    if (!/\.css$/.test(aLeafName)) aLeafName += ".css";
    let file = this.getFileFromLeafName(aLeafName);
    this.edit(file);
    },
    UCrebuild: function() {
    let re = /^file:.*\.uc\.css(?:\?\d+)?$/i;
    let query = "?" + new Date().getTime();
    Array.slice(document.styleSheets).forEach(function(css){
    if (!re.test(css.href)) return;
    if (css.ownerNode) {
    css.ownerNode.parentNode.removeChild(css.ownerNode);
    }
    let pi = document.createProcessingInstruction('xml-stylesheet','type="text/css" href="'+ css.href.replace(/\?.*/, '') + query +'"');
    document.insertBefore(pi, document.documentElement);
    });
    UCL.UCcreateMenuitem();
    },
    UCcreateMenuitem: function() {
    let sep = $("usercssloader-ucseparator");
    let popup = sep.parentNode;
    if (sep.nextSibling) {
    let range = document.createRange();
    range.setStartAfter(sep);
    range.setEndAfter(popup.lastChild);
    range.deleteContents();
    range.detach();
    }
    
    let re = /^file:.*\.uc\.css(?:\?\d+)?$/i;
    Array.slice(document.styleSheets).forEach(function(css) {
    if (!re.test(css.href)) return;
    let fileURL = decodeURIComponent(css.href).split("?")[0];
    let aLeafName = fileURL.split("/").pop();
    let m = document.createXULElement("menuitem");
    m.setAttribute("label", aLeafName);
    m.setAttribute("tooltiptext", fileURL);
    m.setAttribute("id", "usercssloader-" + aLeafName);
    m.setAttribute("type", "checkbox");
    m.setAttribute("autocheck", "false");
    m.setAttribute("checked", "true");
    m.setAttribute("oncommand", "this.setAttribute('checked', !(this.css.disabled = !this.css.disabled));");
    m.setAttribute("onclick", "UCL.UCItemClick(event);");
    m.css = css;
    popup.appendChild(m);
    });
    },
    UCItemClick: function(event) {
    if (event.button == 0) return;
    event.preventDefault();
    event.stopPropagation();
    
    if (event.button == 1) {
    event.target.doCommand();
    }
    else if (event.button == 2) {
    closeMenus(event.target);
    let fileURL = event.currentTarget.getAttribute("tooltiptext");
    let file = Services.io.getProtocolHandler("file").QueryInterface(Components.interfaces.nsIFileProtocolHandler).getFileFromURLSpec(fileURL);
    this.edit(file);
    }
    },
    };
    
    function CSSEntry(aFile) {
    this.path = aFile.path;
    this.leafName = aFile.leafName;
    this.lastModifiedTime = 1;
    this.SHEET = /^xul-|\.as\.css$/i.test(this.leafName) ?
    Ci.nsIStyleSheetService.AGENT_SHEET:
    Ci.nsIStyleSheetService.USER_SHEET;
    }
    CSSEntry.prototype = {
    sss: Components.classes["@mozilla.org/content/style-sheet-service;1"]
    .getService(Components.interfaces.nsIStyleSheetService),
    _enabled: false,
    get enabled() {
    return this._enabled;
    },
    set enabled(isEnable) {
    var aFile = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsIFile)
    aFile.initWithPath(this.path);
    
    var isExists = aFile.exists(); // Wenn die Datei existiert true
    var lastModifiedTime = isExists ? aFile.lastModifiedTime : 0;
    var isForced = this.lastModifiedTime != lastModifiedTime; // Wenn es eine Änderung in der Datei gibt true
    
    var fileURL = Services.io.getProtocolHandler("file").QueryInterface(Components.interfaces.nsIFileProtocolHandler).getURLSpecFromActualFile(aFile);
    var uri = Services.io.newURI(fileURL, null, null);
    
    if (this.sss.sheetRegistered(uri, this.SHEET)) {
    // Wenn diese Datei bereits gelesen wurde
    if (!isEnable || !isExists) {
    this.sss.unregisterSheet(uri, this.SHEET);
    }
    else if (isForced) {
    // Nach Stornierung erneut einlesen
    this.sss.unregisterSheet(uri, this.SHEET);
    this.sss.loadAndRegisterSheet(uri, this.SHEET);
    }
    } else {
    // Datei wurde nicht gelesen
    if (isEnable && isExists) {
    this.sss.loadAndRegisterSheet(uri, this.SHEET);
    }
    }
    if (this.lastModifiedTime !== 1 && isEnable && isForced) {
    log(this.leafName + " wurde aktualisiert");
    }
    this.lastModifiedTime = lastModifiedTime;
    return this._enabled = isEnable;
    },
    };
    
    function CSSTester(aWindow, aCallback) {
    this.win = aWindow || window;
    this.doc = this.win.document;
    this.callback = aCallback;
    this.init();
    }
    CSSTester.prototype = {
    sss: Components.classes["@mozilla.org/content/style-sheet-service;1"]
    .getService(Components.interfaces.nsIStyleSheetService),
    preview_code: "",
    saved: false,
    init: function() {
    this.dialog = openDialog(
    "data:text/html;charset=utf8,"+encodeURIComponent('<!DOCTYPE HTML><html lang="ja"><head><title>CSSTester</title></head><body></body></html>'),
    "",
    "width=550,height=400,dialog=no");
    this.dialog.addEventListener("load", this, false);
    },
    destroy: function() {
    this.preview_end();
    this.dialog.removeEventListener("unload", this, false);
    this.previewButton.removeEventListener("click", this, false);
    this.saveButton.removeEventListener("click", this, false);
    this.closeButton.removeEventListener("click", this, false);
    },
    handleEvent: function(event) {
    switch(event.type) {
    case "click":
    if (event.button != 0) return;
    if (this.previewButton == event.currentTarget) {
    this.preview();
    }
    else if (this.saveButton == event.currentTarget) {
    this.save();
    }
    else if (this.closeButton == event.currentTarget) {
    this.dialog.close();
    }
    break;
    case "load":
    var doc = this.dialog.document;
    doc.body.innerHTML = '\
    <style type="text/css">\
    :not(input):not(select) { padding: 0px; margin: 0px; }\
    table { border-spacing: 0px; }\
    body, html, #main, #textarea { width: 100%; height: 100%; }\
    #textarea { font-family: monospace; }\
    </style>\
    <table id="main">\
    <tr height="100%">\
    <td colspan="4"><textarea id="textarea"></textarea></td>\
    </tr>\
    <tr height="40">\
    <td><input type="button" value="Vorschau" id="Vorschau"/></td>\
    <td><input type="button" value="Speichern" id="Speichern"/></td>\
    <td width="80%"><span class="log"></span></td>\
    <td><input type="button" value="Schließen" id="Schliessen"/></td>\
    </tr>\
    </table>\
    ';
    this.textbox = doc.querySelector("textarea");
    this.previewButton = doc.querySelector('input[value="Vorschau"]');
    this.saveButton = doc.querySelector('input[value="Speichern"]');
    this.closeButton = doc.querySelector('input[value="Schließen"]');
    this.logField = doc.querySelector('.log');
    
    var code = "@namespace url(" + this.doc.documentElement.namespaceURI + ");\n";
    code += this.win.location.protocol.indexOf("http") === 0?
    "@-moz-document domain(" + this.win.location.host + ") {\n\n\n\n}":
    "@-moz-document url(" + this.win.location.href + ") {\n\n\n\n}";
    this.textbox.value = code;
    this.dialog.addEventListener("unload", this, false);
    this.previewButton.addEventListener("click", this, false);
    this.saveButton.addEventListener("click", this, false);
    this.closeButton.addEventListener("click", this, false);
    
    this.textbox.focus();
    let p = this.textbox.value.length - 3;
    this.textbox.setSelectionRange(p, p);
    
    break;
    case "unload":
    this.destroy();
    this.callback(this);
    break;
    }
    },
    preview: function() {
    var code = this.textbox.value;
    if (!code || !/\:/.test(code))
    return;
    code = "data:text/css;charset=utf-8," + encodeURIComponent(this.textbox.value);
    if (code == this.preview_code)
    return;
    this.preview_end();
    var uri = Services.io.newURI(code, null, null);
    this.sss.loadAndRegisterSheet(uri, Ci.nsIStyleSheetService.AGENT_SHEET);
    this.preview_code = code;
    this.log("Preview");
    },
    preview_end: function() {
    if (this.preview_code) {
    let uri = Services.io.newURI(this.preview_code, null, null);
    this.sss.unregisterSheet(uri, Ci.nsIStyleSheetService.AGENT_SHEET);
    this.preview_code = "";
    }
    },
    save: function() {
    var data = this.textbox.value;
    if (!data) return;
    
    var fp = Cc["@mozilla.org/filepicker;1"].createInstance(Ci.nsIFilePicker);
    fp.init(window, "", Ci.nsIFilePicker.modeSave);
    fp.appendFilter("CSS Files","*.css");
    fp.defaultExtension = "css";
    if (window.UCL)
    fp.displayDirectory = UCL.FOLDER;
    var res = fp.show();
    if (res != fp.returnOK && res != fp.returnReplace) return;
    
    var suConverter = Cc["@mozilla.org/intl/scriptableunicodeconverter"].createInstance(Ci.nsIScriptableUnicodeConverter);
    suConverter.charset = "UTF-8";
    data = suConverter.ConvertFromUnicode(data);
    var foStream = Cc["@mozilla.org/network/file-output-stream;1"].createInstance(Ci.nsIFileOutputStream);
    foStream.init(fp.file, 0x02 | 0x08 | 0x20, 0664, 0);
    foStream.write(data, data.length);
    foStream.close();
    this.saved = true;
    },
    log: function() {
    this.logField.textContent = dateFormat(new Date(), "%H:%M:%S") + ": " + $A(arguments);
    }
    };
    
    UCL.init();
    
    function $(id) { return document.getElementById(id); }
    function $A(arr) { return Array.slice(arr); }
    function $C(name, attr) {
    var el = document.createXULElement(name);
    if (attr) Object.keys(attr).forEach(function(n) { el.setAttribute(n, attr[n]) });
    return el;
    }
    function dateFormat(date, format) {
    format = format.replace("%Y", ("000" + date.getFullYear()).substr(-4));
    format = format.replace("%m", ("0" + (date.getMonth()+1)).substr(-2));
    format = format.replace("%d", ("0" + date.getDay()).substr(-2));
    format = format.replace("%H", ("0" + date.getHours()).substr(-2));
    format = format.replace("%M", ("0" + date.getMinutes()).substr(-2));
    format = format.replace("%S", ("0" + date.getSeconds()).substr(-2));
    return format;
    }
    
    function log() { Application.console.log(Array.slice(arguments)); }
    
    })();
    Alles anzeigen
  • UserCSSLoader.uc.js arbeitet in TB 91nicht, in FF 91schon.

    • seipe
    • 18. August 2021 um 16:31
    Code
    // ==UserScript==
    // @name UserCSSLoader
    // @description CSS Codes - Styles laden und verwalten
    // @namespace https://d.hatena.ne.jp/Griever/
    // @author Griever
    // @include main
    // @license MIT License
    // @compatibility Firefox 4 - 69*
    // @charset UTF-8
    // @version 0.0.4g
    // @note Version 0.0.4.g ermoeglicht "Styles importieren" per Mittelklick und Verwendung
    // @note eines anderen Dateimanager (s. vFileManager in Zeile 53)
    // @note Frei verschiebbare Schaltfläche eingebaut von aborix
    // @note 0.0.4 Remove E4X
    // @note CSSEntry-Klasse erstellt
    // @note Style-Test-Funktion überarbeitet
    // @note Wenn die Datei gelöscht wurde, CSS beim Neu erstellen und Löschen des Menüs abbrechen
    // @note uc einlesen .uc.css temporäre Korrespondenz zum erneuten Lesen
    
    // ==/UserScript==
    
    /****** Bedienungsanleitung ******
    
    Da der CSS-Ordner im Chrome-Ordner erstellt wurde, CSS-Dateien dort ablegen - speichern.
    Diejenigen, deren Dateiname mit "xul-" beginnen, diejenigen, die mit ".as.css" enden, sind AGENT_SHEET, andere außer USER_SHEET werden gelesen. Da der Inhalt der Datei nicht überprüft wird,
    darauf achten, @ Namespace Angabe nicht zu vergessen!
    
    CSS-Menü wird zur Menüleiste hinzugefügt
    Linksklick auf Stil, zum aktivieren/deaktivieren
    Mittelklick auf Stil zum aktivieren/deaktivieren, ohne Menü zu schließen
    Rechtsklick auf Stil zum Öffnen im Editor
    
    Verwenden des in "view_source.editor.path" angegebenen Editors
    Ordner kann geändert werden, indem ein Pfad in "UserCSSLoader.FOLDER" eingefügt wird
    
    **** Anleitung Ende ****/
    
    (function(){
    
    let { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
    if (!window.Services)
    Cu.import("resource://gre/modules/Services.jsm");
    // Wenn beim Start ein anderes Fenster angezeigt wird (das zweite Fenster), wird es beendet
    let list = Services.wm.getEnumerator("navigator:browser");
    while(list.hasMoreElements()){ if(list.getNext() != window) return; }
    
    if (window.UCL) {
    window.UCL.destroy();
    delete window.UCL;
    }
    
    window.UCL = {
    vFileManager: 'C:\\Program Files\\Notepad++\\notepad++.exe',
    //vFileManager: 'C:\\Program Files\\Notepad++\\notepad++.exe',
    USE_UC: "UC" in window,
    AGENT_SHEET: Ci.nsIStyleSheetService.AGENT_SHEET,
    USER_SHEET : Ci.nsIStyleSheetService.USER_SHEET,
    readCSS : {},
    get disabled_list() {
    let obj = [];
    try {
    obj = this.prefs.getCharPref("disabled_list").split("|");
    } catch(e) {}
    delete this.disabled_list;
    return this.disabled_list = obj;
    },
    get prefs() {
    delete this.prefs;
    return this.prefs = Services.prefs.getBranch("UserCSSLoader.")
    },
    get styleSheetServices(){
    delete this.styleSheetServices;
    return this.styleSheetServices = Cc["@mozilla.org/content/style-sheet-service;1"].getService(Ci.nsIStyleSheetService);
    },
    get FOLDER() {
    let aFolder;
    try {
    // UserCSSLoader.FOLDER verwenden
    let folderPath = this.prefs.getCharPref("FOLDER");
    aFolder = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsIFile)
    aFolder.initWithPath(folderPath);
    } catch (e) {
    aFolder = Services.dirsvc.get("UChrm", Ci.nsIFile);
    aFolder.appendRelativePath("CSS");
    }
    if (!aFolder.exists() || !aFolder.isDirectory()) {
    aFolder.create(Ci.nsIFile.DIRECTORY_TYPE, 0664);
    }
    delete this.FOLDER;
    return this.FOLDER = aFolder;
    },
    getFocusedWindow: function() {
    let win = document.commandDispatcher.focusedWindow;
    if (!win || win == window) win = content;
    return win;
    },
    
    init: function() {
    const cssmenu = $C("menu", {
    id: "usercssloader-menu",
    label: "CSS",
    accesskey: "C",
    onclick: "if (event.button == 1) UCL.rebuild()"
    });
    const menupopup = $C("menupopup", {
    id: "usercssloader-menupopup"
    });
    cssmenu.appendChild(menupopup);
    
    let menu = $C("menu", {
    label: "Style Loader Menü",
    accesskey: "M"
    });
    menupopup.appendChild(menu);
    let mp = $C("menupopup", { id: "usercssloader-submenupopup" });
    menu.appendChild(mp);
    mp.appendChild($C("menuitem", {
    label: "Styles importieren",
    accesskey: "R",
    acceltext: "Alt + R",
    oncommand: "UCL.rebuild();"
    }));
    mp.appendChild($C("menuseparator"));
    mp.appendChild($C("menuitem", {
    label: "CSS Datei erstellen",
    accesskey: "D",
    oncommand: "UCL.create();"
    }));
    mp.appendChild($C("menuitem", {
    label: "CSS Ordner öffnen",
    accesskey: "O",
    oncommand: "UCL.openFolder();"
    }));
    mp.appendChild($C("menuitem", {
    label: "userChrome.css bearbeiten",
    hidden: false,
    oncommand: "UCL.editUserCSS(\'userChrome.css\');"
    }));
    mp.appendChild($C("menuitem", {
    label: "userContent.css bearbeiten",
    hidden: false,
    oncommand: "UCL.editUserCSS(\'userContent.css\');"
    }));
    mp.appendChild($C("menuseparator"));
    mp.appendChild($C("menuitem", {
    label: "Style Test (Chrome)",
    id: "usercssloader-test-chrome",
    hidden: true,
    accesskey: "C",
    oncommand: "UCL.styleTest(window);"
    }));
    mp.appendChild($C("menuitem", {
    label: "Style Test (Web)",
    id: "usercssloader-test-content",
    hidden: true,
    accesskey: "W",
    oncommand: "UCL.styleTest();"
    }));
    mp.appendChild($C("menuitem", {
    label: "Styles dieser Seite auf userstyles.org finden",
    accesskey: "S",
    oncommand: "UCL.searchStyle();"
    }));
    
    menu = $C("menu", {
    label: ".uc.css",
    accesskey: "U",
    hidden: !UCL.USE_UC
    });
    menupopup.appendChild(menu);
    mp = $C("menupopup", { id: "usercssloader-ucmenupopup" });
    menu.appendChild(mp);
    mp.appendChild($C("menuitem", {
    label: "Importieren(.uc.js)",
    oncommand: "UCL.UCrebuild();"
    }));
    mp.appendChild($C("menuseparator", { id: "usercssloader-ucseparator" }));
    
    CustomizableUI.createWidget({
    id: 'usercssloader-menu-item',
    type: 'custom',
    defaultArea: CustomizableUI.AREA_NAVBAR,
    onBuild: function(aDocument) {
    let toolbaritem = aDocument.createElementNS('http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul', 'toolbaritem');
    toolbaritem.id = 'usercssloader-menu-item';
    toolbaritem.className = 'chromeclass-toolbar-additional';
    return toolbaritem;
    }
    });
    $('usercssloader-menu-item').appendChild(cssmenu);
    
    //let refNode = $('helpMenu');
    //refNode.parentNode.insertBefore(cssmenu, refNode.nextSibling);
    
    $("mainKeyset").appendChild($C("key", {
    id: "usercssloader-rebuild-key",
    oncommand: "UCL.rebuild();",
    key: "R",
    modifiers: "alt",
    }));
    this.rebuild();
    this.initialized = true;
    if (UCL.USE_UC) {
    setTimeout(function() {
    UCL.UCcreateMenuitem();
    }, 1000);
    }
    window.addEventListener("unload", this, false);
    },
    uninit: function() {
    const dis = [];
    for (let x of Object.keys(this.readCSS)) {
    if (!this.readCSS[x].enabled)
    dis.push(x);
    }
    this.prefs.setCharPref("disabled_list", dis.join("|"));
    window.removeEventListener("unload", this, false);
    },
    destroy: function() {
    var i = document.getElementById("usercssloader-menu");
    if (i) i.parentNode.removeChild(i);
    var i = document.getElementById("usercssloader-rebuild-key");
    if (i) i.parentNode.removeChild(i);
    this.uninit();
    },
    handleEvent: function(event) {
    switch(event.type){
    case "unload": this.uninit(); break;
    }
    },
    rebuild: function() {
    let ext = /\.css$/i;
    let not = /\.uc\.css/i;
    let files = this.FOLDER.directoryEntries.QueryInterface(Ci.nsISimpleEnumerator);
    while (files.hasMoreElements()) {
    let file = files.getNext().QueryInterface(Ci.nsIFile);
    if (!ext.test(file.leafName) || not.test(file.leafName)) continue;
    let CSS = this.loadCSS(file);
    CSS.flag = true;
    }
    for (let leafName of Object.keys(this.readCSS)) {
    const CSS = this.readCSS[leafName];
    if (!CSS.flag) {
    CSS.enabled = false;
    delete this.readCSS[leafName];
    }
    delete CSS.flag;
    this.rebuildMenu(leafName);
    }
    if (this.initialized) {
    if (typeof(StatusPanel) !== "undefined")
    StatusPanel._label = "Style importiert";
    else
    XULBrowserWindow.statusTextField.label = "Styles importieren";
    }
    },
    loadCSS: function(aFile) {
    var CSS = this.readCSS[aFile.leafName];
    if (!CSS) {
    CSS = this.readCSS[aFile.leafName] = new CSSEntry(aFile);
    if (this.disabled_list.indexOf(CSS.leafName) === -1) {
    CSS.enabled = true;
    }
    } else if (CSS.enabled) {
    CSS.enabled = true;
    }
    return CSS;
    },
    rebuildMenu: function(aLeafName) {
    var CSS = this.readCSS[aLeafName];
    var menuitem = document.getElementById("usercssloader-" + aLeafName);
    if (!CSS) {
    if (menuitem)
    menuitem.parentNode.removeChild(menuitem);
    return;
    }
    if (!menuitem) {
    menuitem = document.createXULElement("menuitem");
    menuitem.setAttribute("label", aLeafName);
    menuitem.setAttribute("id", "usercssloader-" + aLeafName);
    menuitem.setAttribute("class", "usercssloader-item " + (CSS.SHEET == this.AGENT_SHEET? "AGENT_SHEET" : "USER_SHEET"));
    menuitem.setAttribute("type", "checkbox");
    menuitem.setAttribute("autocheck", "false");
    menuitem.setAttribute("oncommand", "UCL.toggle('"+ aLeafName +"');");
    menuitem.setAttribute("onclick", "UCL.itemClick(event);");
    document.getElementById("usercssloader-menupopup").appendChild(menuitem);
    }
    menuitem.setAttribute("checked", CSS.enabled);
    },
    toggle: function(aLeafName) {
    var CSS = this.readCSS[aLeafName];
    if (!CSS) return;
    CSS.enabled = !CSS.enabled;
    this.rebuildMenu(aLeafName);
    },
    itemClick: function(event) {
    if (event.button == 0) return;
    event.preventDefault();
    event.stopPropagation();
    let label = event.currentTarget.getAttribute("label");
    Alles anzeigen
  • UserCSSLoader.uc.js arbeitet in TB 91nicht, in FF 91schon.

    • seipe
    • 18. August 2021 um 16:12

    Ja.

  • UserCSSLoader.uc.js arbeitet in TB 91nicht, in FF 91schon.

    • seipe
    • 18. August 2021 um 16:02
    Code
    // utilities.js
    
    /* ***** BEGIN LICENSE BLOCK *****
     * Version: MPL 1.1/GPL 2.0/LGPL 2.1
     *
     * The contents of this file are subject to the Mozilla Public License Version
     * 1.1 (the "License"); you may not use this file except in compliance with
     * the License. You may obtain a copy of the License at
     * http://www.mozilla.org/MPL/
     *
     * Software distributed under the License is distributed on an "AS IS" basis,
     * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
     * for the specific language governing rights and limitations under the
     * License.
     *
     * The Original Code is the userChromeJS utilities.
     *
     * The Initial Developer of the Original Code is
     * alta88 <alta88@gmail.com>
     *
     * Portions created by the Initial Developer are Copyright (C) 2014
     * the Initial Developer. All Rights Reserved.
     *
     * Contributor(s):
     * aborix <www.camp-firefox.de/forum>
     *
     * Alternatively, the contents of this file may be used under the terms of
     * either the GNU General Public License Version 2 or later (the "GPL"), or
     * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
     * in which case the provisions of the GPL or the LGPL are applicable instead
     * of those above. If you wish to allow use of your version of this file only
     * under the terms of either the GPL or the LGPL, and not to allow others to
     * use your version of this file under the terms of the MPL, indicate your
     * decision by deleting the provisions above and replace them with the notice
     * and other provisions required by the GPL or the LGPL. If you do not delete
     * the provisions above, a recipient may use your version of this file under
     * the terms of any one of the MPL, the GPL or the LGPL.
     *
     * ***** END LICENSE BLOCK ***** */
    
    /* ........ Utility functions ............................................... */
    
    var userChrome = {
    
      path: null,
      dirToken: null,
      ignoreCache: false,
    
      get loadOverlayDelay () {
        if (!this._loadOverlayDelay)
          this._loadOverlayDelay = 500;
        return this._loadOverlayDelay;
      },
    
      set loadOverlayDelay(delay) {
        this._loadOverlayDelay = delay;
      },
    
      get loadOverlayDelayIncr() {
        if (!this._loadOverlayDelayIncr)
          this._loadOverlayDelayIncr = 1600;
        return this._loadOverlayDelayIncr;
      },
    
      set loadOverlayDelayIncr(delay) {
        this._loadOverlayDelayIncr = delay;
      },
    
      import: function(aPath, aRelDirToken) {
        let file;
        this.path = aPath;
        this.dirToken = aRelDirToken;
    
        if (aRelDirToken) {
          // Relative file
          let absDir = this.getAbsoluteFile(aRelDirToken);
          if (!absDir)
            return;
          let pathSep = absDir.path.match(/[\/\\]/)[0];
          file = absDir.path + (aPath == "*" ?
              "" : pathSep + aPath.replace(/[\/\\]/g, pathSep));
        }
        else
          // Absolute file
          file = aPath;
    
        file = this.getFile(file);
        if (!file)
          return;
        if (file.isFile()) {
          if (/\.js$/i.test(file.leafName))
            this.loadScript(file, aRelDirToken, null);
          else if (/\.xul$/i.test(file.leafName)) {
            let xul_files = [];
            xul_files.push(file);
            this.loadOverlay(xul_files, this.dirToken, null, this.loadOverlayDelay);
    //      this.loadOverlayDelay = this.loadOverlayDelay + this.loadOverlayDelayIncr;
          }
          else
            this.log("File '" + this.path +
                     "' does not have a valid .js or .xul extension.", "userChrome.import");
        }
        else if (file.isDirectory())
          this.importFolder(file);
        else
          this.log("File '" + this.path +
                   "' is neither a file nor a directory.", "userChrome.import");
      },
    
      loadScript: function(aFile, aFolder, aRelDirToken) {
        setTimeout(function() {
          Components.classes["@mozilla.org/moz/jssubscript-loader;1"]
                    .getService(Components.interfaces.mozIJSSubScriptLoader)
                    .loadSubScriptWithOptions(userChrome.getURLSpecFromActualFile(aFile),
                                              {target: window,
                                               charset: userChrome.charSet,
                                               ignoreCache: userChrome.ignoreCache});
          // log it
          userChrome.log(aRelDirToken ? ("[" + aRelDirToken + "]/" +
              (aFolder && aFolder != "*" ? aFolder + "/" : "") + aFile.leafName) :
              aFile.path, "userChrome.loadScript");
        }, 0);
      },
    
      // XXX: Due to bug 330458, an overlay must finish before another can be
      // called, otherwise neither are successful.  Implementing an observer to
      // serialize is better left as a fix in the core bug.  Here, settimout values
      // are set to minimize but there is no quarantee; overlay cdata (if any)
      // needs to consider overlay completions and logging does not strictly mean
      // an overlay has completed, rather that the overlay file has been invoked.
    
      loadOverlay: function(aFiles, aRelDirToken, aFolder, aDelay) {
    //userChrome.log(aDelay+" multiple import delay", userChrome.loadOverlay);
        // Increment multiple import delay
        this.loadOverlayDelay = this.loadOverlayDelay + this.loadOverlayDelayIncr;
        setTimeout(function() {
          if (aFiles.length > 0) {
    //userChrome.log(userChrome.loadOverlayDelay+" inter folder delay", userChrome.loadOverlay);
            // log it
            userChrome.log(aRelDirToken ? ("[" + aRelDirToken + "]/" +
                (aFolder && aFolder != "*" ? aFolder + "/" : "") + aFiles[0].leafName) :
                aFiles[0].path, "userChrome.loadOverlay");
            document.loadOverlay(userChrome.getURLSpecFromActualFile(aFiles.shift()), null);
            setTimeout(arguments.callee, userChrome.loadOverlayDelay);
          }
        }, aDelay);
      },
    
      // Include all files ending in .js and .xul from passed folder
      importFolder: function(aFolder) {
        let files = aFolder.directoryEntries
                           .QueryInterface(Components.interfaces.nsISimpleEnumerator);
        let xul_files = [];
    
        while (files.hasMoreElements()) {
          let file = files.getNext().QueryInterface(Components.interfaces.nsIFile);
          if (/\.js$/i.test(file.leafName) && file.leafName != "userChrome.js")
            this.loadScript(file, this.path, this.dirToken);
          else if (/\.xul$/i.test(file.leafName)) {
            xul_files.push(file);
          }
        }
    
        if (xul_files.length > 0)
          this.loadOverlay(xul_files, this.dirToken, this.path);
      },
    
      getFile: function(aPath, aRelDirToken) {
        try {
          let file = Components.classes["@mozilla.org/file/local;1"]
                               .createInstance(Components.interfaces.nsIFile);
          file.initWithPath(aPath);
          // Bad file doesn't throw on initWithPath, need to test
          if (file.exists())
            return file;
          this.log("Invalid file '" + this.path + (this.dirToken ?
              ("' or file not found in directory with token '" + this.dirToken) :
              "") + "' or other access error.", "userChrome.getFile");
        }
        catch (e) {
          // Bad folder throws on initWithPath
          this.log("Invalid folder '" + this.path + (this.dirToken ?
              ("' or folder not found in directory with token '" + this.dirToken) :
              "") + "' or other access error.", "userChrome.getFile");
        }
        return null;
      },
    
      getAbsoluteFile: function(aRelDirToken) {
        try {
          let absDir = Components.classes["@mozilla.org/file/directory_service;1"]
                                 .getService(Components.interfaces.nsIProperties)
                                 .get(aRelDirToken, Components.interfaces.nsIFile);
          return absDir;
        }
        catch (e) {
          this.log("Invalid directory name token '" + this.dirToken +
                   "' or directory cannot be accessed.", "userChrome.getAbsoluteFile");
          return null;
        }
      },
    
      getURLSpecFromActualFile: Components.classes["@mozilla.org/network/io-service;1"]
                                    .getService(Components.interfaces.nsIIOService)
                                    .getProtocolHandler("file")
                                    .QueryInterface(Components.interfaces.nsIFileProtocolHandler)
                                    .getURLSpecFromActualFile,
    
      /* Console logger */
      log: function(aMsg, aCaller) {
        Components.classes["@mozilla.org/consoleservice;1"]
                  .getService(Components.interfaces.nsIConsoleService)
                  .logStringMessage(this.date + " userChromeJS " +
                                    (aCaller ? aCaller +": " : "") + aMsg);
      },
    
      get dateFormat() {
        if (!this._dateFormat)
          this._dateFormat = "%Y-%m-%d %H:%M:%S";
        return this._dateFormat;
      },
    
      set dateFormat(format) {
        this._dateFormat = format;
      },
    
      get date() {
        let date = new Date();
    //  return date.toLocaleFormat(this.dateFormat);
        try {
          date = date.toLocaleFormat(this.dateFormat);
        } catch(e) {
          date = date.toString();
        };    
        return date;
      },
    
      set charSet(val) {
        this._charSet = val;
      },
    
      get charSet() {
        if (!this._charSet)
          this._charSet = "UTF-8"; // use "UTF-8". Defaults to ascii if null.
        return this._charSet;
      }
    
    };
    Alles anzeigen
  • UserCSSLoader.uc.js arbeitet in TB 91nicht, in FF 91schon.

    • seipe
    • 18. August 2021 um 15:50
    Zitat von Boersenfeger
    Zitat von seipe

    edvoldi, die Scripts funktionieren ja, nur die css.Codes nicht. Mit der userChrome.css klappts mit den Codes.

    Also funktioniert das Script im TB 91.* nicht.

    //Ändere die Überschrift des Threads doch endlich mal entsprechend! :(

    edvoldi


    Entschuldigung, daß ich in der Überschrift des Threads TB und FF verwechselt habe. Wurde geändert.

  • UserCSSLoader.uc.js arbeitet in TB 91nicht, in FF 91schon.

    • seipe
    • 18. August 2021 um 12:19

    edvoldi, die Scripts funktionieren ja, nur die css.Codes nicht. Mit der userChrome.css klappts mit den Codes.

  • UserCSSLoader.uc.js arbeitet in TB 91nicht, in FF 91schon.

    • seipe
    • 18. August 2021 um 10:51

    Noch zur Information, auch mit einem neuen Profil keine Änderung.

  • UserCSSLoader.uc.js arbeitet in TB 91nicht, in FF 91schon.

    • seipe
    • 18. August 2021 um 10:37

    Ich rede doch die ganze Zeit von FF 91.0.1 und von TB 91.0.1. Das Script UserCSSLoader.uc.js arbeitet in FF korrekt, in TB nicht.

  • UserCSSLoader.uc.js arbeitet in TB 91nicht, in FF 91schon.

    • seipe
    • 18. August 2021 um 10:28
    Zitat von Boersenfeger

    Der Widerspruch in deiner Aussage ist noch nicht geklärt :/

    Die Vorarbeiten im TB sind bei mir die gleichen wie in FF.

  • Tableiste mit Bedienungsicons schmaler machen

    • seipe
    • 17. August 2021 um 19:29

    dharkness21, danke für den Code. Passt. :thumbup:

  • Tableiste mit Bedienungsicons schmaler machen

    • seipe
    • 17. August 2021 um 14:31

    Die Tabs selber sind jetzt bei mir breiter. Wie bekomme ich diese jetzt schmaler?

  • UserCSSLoader.uc.js arbeitet in TB 91nicht, in FF 91schon.

    • seipe
    • 17. August 2021 um 06:00

    Ok Boersenfeger, habe das Script jetzt aktualisiert. Zeigt aber in TB keine Wirkung.

  • UserCSSLoader.uc.js arbeitet in TB 91nicht, in FF 91schon.

    • seipe
    • 16. August 2021 um 19:36
    HTML
    // ==UserScript==
    // @name           UserCSSLoader
    // @description    CSS Codes - Styles laden und verwalten
    // @namespace      http://d.hatena.ne.jp/Griever/
    // @author         Griever
    // @include        main
    // @license        MIT License
    // @compatibility  Firefox 4
    // @charset        UTF-8
    // @version        0.0.4f
    // @note           0.0.4 Remove E4X
    // @note           CSSEntry-Klasse erstellt
    // @note           Style-Test-Funktion überarbeitet
    // @note           Wenn die Datei gelöscht wurde, CSS beim Neu erstellen und Löschen des Menüs abbrechen
    // @note           uc einlesen .uc.css temporäre Korrespondenz zum erneuten Lesen
    // ==/UserScript==
    
    
    /****** Bedienungsanleitung ******
    
    
    Da der CSS-Ordner im Chrome-Ordner erstellt wurde, CSS-Dateien dort ablegen - speichern.
    Diejenigen, deren Dateiname mit "xul-" beginnen, diejenigen, die mit ".as.css" enden, sind AGENT_SHEET,
    andere außer USER_SHEET werden gelesen. Da der Inhalt der Datei nicht überprüft wird,
    darauf achten, @ Namespace Angabe nicht zu vergessen!
    
    
    CSS-Menü wird zur Menüleiste hinzugefügt
    Linksklick auf Stil, zum aktivieren/deaktivieren
    Mittelklick auf Stil zum aktivieren/deaktivieren, ohne Menü zu schließen
    Rechtsklick auf Stil zum Öffnen im Editor
    
    
    Verwenden des in "view_source.editor.path" angegebenen Editors
    Ordner kann geändert werden, indem ein Pfad in "UserCSSLoader.FOLDER" eingefügt wird
    
    
    **** Anleitung Ende ****/
    
    
    (function(){
    
    
    let { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
    if (!window.Services)
    Cu.import("resource://gre/modules/Services.jsm");
    // Wenn beim Start ein anderes Fenster angezeigt wird (das zweite Fenster), wird es beendet
    let list = Services.wm.getEnumerator("navigator:browser");
    while(list.hasMoreElements()){ if(list.getNext() != window) return; }
    
    
    if (window.UCL) {
    window.UCL.destroy();
    delete window.UCL;
    }
    
    
    window.UCL = {
    // vFileManager: 'C:\\Program Files\\Notepad++\\notepad++.exe',
    vFileManager: 'C:\\Program Files\\Notepad++\\notepad++.exe',
    USE_UC: "UC" in window,
    AGENT_SHEET: Ci.nsIStyleSheetService.AGENT_SHEET,
    USER_SHEET : Ci.nsIStyleSheetService.USER_SHEET,
    readCSS    : {},
    get disabled_list() {
    let obj = [];
    try {
    obj = this.prefs.getCharPref("disabled_list").split("|");
    } catch(e) {}
    delete this.disabled_list;
    return this.disabled_list = obj;
    },
    get prefs() {
    delete this.prefs;
    return this.prefs = Services.prefs.getBranch("UserCSSLoader.")
    },
    get styleSheetServices(){
    delete this.styleSheetServices;
    return this.styleSheetServices = Cc["@mozilla.org/content/style-sheet-service;1"].getService(Ci.nsIStyleSheetService);
    },
    get FOLDER() {
    let aFolder;
    try {
    // UserCSSLoader.FOLDER verwenden
    let folderPath = this.prefs.getCharPref("FOLDER");
    aFolder = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsIFile)
    aFolder.initWithPath(folderPath);
    } catch (e) {
    aFolder = Services.dirsvc.get("UChrm", Ci.nsIFile);
    aFolder.appendRelativePath("CSS");
    }
    if (!aFolder.exists()  !aFolder.isDirectory()) {
    aFolder.create(Ci.nsIFile.DIRECTORY_TYPE, 0664);
    }
    delete this.FOLDER;
    return this.FOLDER = aFolder;
    },
    getFocusedWindow: function() {
    let win = document.commandDispatcher.focusedWindow;
    if (!win  win == window) win = content;
    return win;
    },
    
    
    init: function() {
    const cssmenu = $C("menu", {
    id: "usercssloader-menu",
    label: "CSS",
    accesskey: "C",
    onclick: "if (event.button == 1) UCL.rebuild()"
    });
    const menupopup = $C("menupopup", {
    id: "usercssloader-menupopup"
    });
    cssmenu.appendChild(menupopup);
    
    
    let menu = $C("menu", {
    label: "Style Loader Menü",
    accesskey: "M"
    });
    menupopup.appendChild(menu);
    let mp = $C("menupopup", { id: "usercssloader-submenupopup" });
    menu.appendChild(mp);
    mp.appendChild($C("menuitem", {
    label: "Styles importieren",
    accesskey: "R",
    acceltext: "Alt + R",
    oncommand: "UCL.rebuild();"
    }));
    mp.appendChild($C("menuseparator"));
    mp.appendChild($C("menuitem", {
    label: "CSS Datei erstellen",
    accesskey: "D",
    oncommand: "UCL.create();"
    }));
    mp.appendChild($C("menuitem", {
    label: "CSS Ordner öffnen",
    accesskey: "O",
    oncommand: "UCL.openFolder();"
    }));
    mp.appendChild($C("menuitem", {
    label: "userChrome.css bearbeiten",
    hidden: false,
    oncommand: "UCL.editUserCSS(\'userChrome.css\');"
    }));
    mp.appendChild($C("menuitem", {
    label: "userContent.css bearbeiten",
    hidden: false,
    oncommand: "UCL.editUserCSS(\'userContent.css\');"
    }));
    mp.appendChild($C("menuseparator"));
    mp.appendChild($C("menuitem", {
    label: "Style Test (Chrome)",
    id: "usercssloader-test-chrome",
    hidden: true,
    accesskey: "C",
    oncommand: "UCL.styleTest(window);"
    }));
    mp.appendChild($C("menuitem", {
    label: "Style Test (Web)",
    id: "usercssloader-test-content",
    hidden: true,
    accesskey: "W",
    oncommand: "UCL.styleTest();"
    }));
    mp.appendChild($C("menuitem", {
    label: "Styles dieser Seite auf userstyles.org finden",
    accesskey: "S",
    oncommand: "UCL.searchStyle();"
    }));
    
    
    menu = $C("menu", {
    label: ".uc.css",
    accesskey: "U",
    hidden: !UCL.USE_UC
    });
    menupopup.appendChild(menu);
    mp = $C("menupopup", { id: "usercssloader-ucmenupopup" });
    menu.appendChild(mp);
    mp.appendChild($C("menuitem", {
    label: "Importieren(.uc.js)",
    oncommand: "UCL.UCrebuild();"
    }));
    mp.appendChild($C("menuseparator", { id: "usercssloader-ucseparator" }));
    
    
    CustomizableUI.createWidget({
    id: 'usercssloader-menu-item',
    type: 'custom',
    defaultArea: CustomizableUI.AREA_MENUBAR,
    onBuild: function(aDocument) {
    let toolbaritem = aDocument.createElementNS('http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul', 'toolbaritem');
    toolbaritem.id = 'usercssloader-menu-item';
    toolbaritem.className = 'chromeclass-toolbar-additional';
    return toolbaritem;
    }
    });
    $('usercssloader-menu-item').appendChild(cssmenu);
    
    
    $("mainKeyset").appendChild($C("key", {
    id: "usercssloader-rebuild-key",
    oncommand: "UCL.rebuild();",
    key: "R",
    modifiers: "alt",
    }));
    this.rebuild();
    this.initialized = true;
    if (UCL.USE_UC) {
    setTimeout(function() {
    UCL.UCcreateMenuitem();
    }, 1000);
    }
    window.addEventListener("unload", this, false);
    },
    uninit: function() {
    const dis = [];
    for (let x of Object.keys(this.readCSS)) {
    if (!this.readCSS[x].enabled)
    dis.push(x);
    }
    this.prefs.setCharPref("disabled_list", dis.join("|"));
    window.removeEventListener("unload", this, false);
    },
    destroy: function() {
    var i = document.getElementById("usercssloader-menu");
    if (i) i.parentNode.removeChild(i);
    var i = document.getElementById("usercssloader-rebuild-key");
    if (i) i.parentNode.removeChild(i);
    this.uninit();
    },
    handleEvent: function(event) {
    switch(event.type){
    case "unload": this.uninit(); break;
    }
    },
    rebuild: function() {
    let ext = /\.css$/i;
    let not = /\.uc\.css/i;
    let files = this.FOLDER.directoryEntries.QueryInterface(Ci.nsISimpleEnumerator);
    while (files.hasMoreElements()) {
    let file = files.getNext().QueryInterface(Ci.nsIFile);
    if (!ext.test(file.leafName)  not.test(file.leafName)) continue;
    let CSS = this.loadCSS(file);
    CSS.flag = true;
    }
    for (let leafName of Object.keys(this.readCSS)) {
    const CSS = this.readCSS[leafName];
    if (!CSS.flag) {
    CSS.enabled = false;
    delete this.readCSS[leafName];
    }
    delete CSS.flag;
    this.rebuildMenu(leafName);
    }
    if (this.initialized) {
    if (typeof(StatusPanel) !== "undefined")
    StatusPanel._label = "Style importiert";
    else
    XULBrowserWindow.statusTextField.label = "Styles importieren";
    }
    },
    loadCSS: function(aFile) {
    var CSS = this.readCSS[aFile.leafName];
    if (!CSS) {
    CSS = this.readCSS[aFile.leafName] = new CSSEntry(aFile);
    if (this.disabled_list.indexOf(CSS.leafName) === -1) {
    CSS.enabled = true;
    }
    } else if (CSS.enabled) {
    CSS.enabled = true;
    }
    return CSS;
    },
    rebuildMenu: function(aLeafName) {
    var CSS = this.readCSS[aLeafName];
    var menuitem = document.getElementById("usercssloader-" + aLeafName);
    if (!CSS) {
    if (menuitem)
    menuitem.parentNode.removeChild(menuitem);
    return;
    }
    if (!menuitem) {
    menuitem = document.createXULElement("menuitem");
    menuitem.setAttribute("label", aLeafName);
    menuitem.setAttribute("id", "usercssloader-" + aLeafName);
    menuitem.setAttribute("class", "usercssloader-item " + (CSS.SHEET == this.AGENT_SHEET? "AGENT_SHEET" : "USER_SHEET"));
    menuitem.setAttribute("type", "checkbox");
    menuitem.setAttribute("autocheck", "false");
    menuitem.setAttribute("oncommand", "UCL.toggle('"+ aLeafName +"');");
    menuitem.setAttribute("onclick", "UCL.itemClick(event);");
    document.getElementById("usercssloader-menupopup").appendChild(menuitem);
    }
    menuitem.setAttribute("checked", CSS.enabled);
    },
    toggle: function(aLeafName) {
    var CSS = this.readCSS[aLeafName];
    if (!CSS) return;
    CSS.enabled = !CSS.enabled;
    this.rebuildMenu(aLeafName);
    },
    itemClick: function(event) {
    if (event.button == 0) return;
    event.preventDefault();
    event.stopPropagation();
    let label = event.currentTarget.getAttribute("label");
    if (event.button == 1) {
    this.toggle(label);
    }
    else if (event.button == 2) {
    closeMenus(event.target);
    this.edit(this.getFileFromLeafName(label));
    }
    },
    getFileFromLeafName: function(aLeafName) {
    let f = this.FOLDER.clone();
    f.QueryInterface(Ci.nsIFile); // use appendRelativePath
    f.appendRelativePath(aLeafName);
    return f;
    },
    styleTest: function(aWindow) {
    aWindow  (aWindow = this.getFocusedWindow());
    new CSSTester(aWindow, function(tester){
    if (tester.saved)
    UCL.rebuild();
    });
    },
    searchStyle: function() {
    let word;
    try {
    word = gBrowser.currentURI.host;
    } catch {
    word = gBrowser.currentURI.spec;
    }
    openLinkIn("https://userstyles.org/styles/search/" + word, "tab", {});
    },
    openFolder:function(){
    if (this.vFileManager.length != 0) {
    var file = Cc['@mozilla.org/file/local;1'].createInstance(Ci.nsIFile);
    var process = Cc['@mozilla.org/process/util;1'].createInstance(Ci.nsIProcess);
    var args=[this.FOLDER.path];
    file.initWithPath(this.vFileManager);
    process.init(file);
    // Verzeichnis mit anderem Dateimanager öffnen
    process.run(false, args, args.length);
    } else {
    // Verzeichnis mit Dateimanager des Systems öffnen
    this.FOLDER.launch();
    }
    },
    editUserCSS: function(aLeafName) {
    let file = Services.dirsvc.get("UChrm", Ci.nsIFile);
    file.appendRelativePath(aLeafName);
    this.edit(file);
    },
    edit: function(aFile) {
    var editor = Services.prefs.getCharPref("view_source.editor.path");
    if (!editor) return alert("Unter about:config den vorhandenen Schalter:\n view_source.editor.path mit dem Editorpfad ergänzen");
    try {
    var UI = Cc["@mozilla.org/intl/scriptableunicodeconverter"].createInstance(Ci.nsIScriptableUnicodeConverter);
    UI.charset = window.navigator.platform.toLowerCase().indexOf("win") >= 0? "Shift_JIS": "UTF-8";
    var path = UI.ConvertFromUnicode(aFile.path);
    var app = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsIFile);
    app.initWithPath(editor);
    var process = Cc["@mozilla.org/process/util;1"].createInstance(Ci.nsIProcess);
    process.init(app);
    process.run(false, [path], 1);
    } catch (e) {}
    },
    create: function(aLeafName) {
    if (!aLeafName) aLeafName = prompt("Name des Styles", dateFormat(new Date(), "%Y_%m%d_%H%M%S"));
    if (aLeafName) aLeafName = aLeafName.replace(/\s+/g, " ").replace(/[\\/:*?\"<>|]/g, "");
    if (!aLeafName  !/\S/.test(aLeafName)) return;
    if (!/\.css$/.test(aLeafName)) aLeafName += ".css";
    let file = this.getFileFromLeafName(aLeafName);
    this.edit(file);
    },
    UCrebuild: function() {
    let re = /^file:.*\.uc\.css(?:\?\d+)?$/i;
    let query = "?" + new Date().getTime();
    Array.slice(document.styleSheets).forEach(function(css){
    if (!re.test(css.href)) return;
    if (css.ownerNode) {
    css.ownerNode.parentNode.removeChild(css.ownerNode);
    }
    let pi = document.createProcessingInstruction('xml-stylesheet','type="text/css" href="'+ css.href.replace(/\?.*/, '') + query +'"');
    document.insertBefore(pi, document.documentElement);
    });
    UCL.UCcreateMenuitem();
    },
    UCcreateMenuitem: function() {
    let sep = $("usercssloader-ucseparator");
    let popup = sep.parentNode;
    if (sep.nextSibling) {
    let range = document.createRange();
    range.setStartAfter(sep);
    range.setEndAfter(popup.lastChild);
    range.deleteContents();
    range.detach();
    }
    
    
    let re = /^file:.*\.uc\.css(?:\?\d+)?$/i;
    Array.slice(document.styleSheets).forEach(function(css) {
    if (!re.test(css.href)) return;
    let fileURL = decodeURIComponent(css.href).split("?")[0];
    let aLeafName = fileURL.split("/").pop();
    let m = document.createXULElement("menuitem");
    m.setAttribute("label", aLeafName);
    m.setAttribute("tooltiptext", fileURL);
    m.setAttribute("id", "usercssloader-" + aLeafName);
    m.setAttribute("type", "checkbox");
    m.setAttribute("autocheck", "false");
    m.setAttribute("checked", "true");
    m.setAttribute("oncommand", "this.setAttribute('checked', !(this.css.disabled = !this.css.disabled));");
    m.setAttribute("onclick", "UCL.UCItemClick(event);");
    m.css = css;
    popup.appendChild(m);
    });
    },
    UCItemClick: function(event) {
    if (event.button == 0) return;
    event.preventDefault();
    event.stopPropagation();
    
    
    if (event.button == 1) {
    event.target.doCommand();
    }
    else if (event.button == 2) {
    closeMenus(event.target);
    let fileURL = event.currentTarget.getAttribute("tooltiptext");
    let file = Services.io.getProtocolHandler("file").QueryInterface(Ci.nsIFileProtocolHandler).getFileFromURLSpec(fileURL);
    this.edit(file);
    }
    },
    };
    
    
    function CSSEntry(aFile) {
    this.path = aFile.path;
    this.leafName = aFile.leafName;
    this.lastModifiedTime = 1;
    this.SHEET = /^xul-|\.as\.css$/i.test(this.leafName) ?
    Ci.nsIStyleSheetService.AGENT_SHEET:
    Ci.nsIStyleSheetService.USER_SHEET;
    }
    CSSEntry.prototype = {
    sss: Cc["@mozilla.org/content/style-sheet-service;1"].getService(Ci.nsIStyleSheetService),
    _enabled: false,
    get enabled() {
    return this._enabled;
    },
    set enabled(isEnable) {
    var aFile = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsIFile)
    aFile.initWithPath(this.path);
    
    
    var isExists = aFile.exists(); // Wenn die Datei existiert true
    var lastModifiedTime = isExists ? aFile.lastModifiedTime : 0;
    var isForced = this.lastModifiedTime != lastModifiedTime; // Wenn es eine Änderung in der Datei gibt true
    
    
    var fileURL = Services.io.getProtocolHandler("file").QueryInterface(Ci.nsIFileProtocolHandler).getURLSpecFromActualFile(aFile);
    var uri = Services.io.newURI(fileURL, null, null);
    
    
    if (this.sss.sheetRegistered(uri, this.SHEET)) {
    // Wenn diese Datei bereits gelesen wurde
    if (!isEnable  !isExists) {
    this.sss.unregisterSheet(uri, this.SHEET);
    }
    else if (isForced) {
    // Nach Stornierung erneut einlesen
    this.sss.unregisterSheet(uri, this.SHEET);
    this.sss.loadAndRegisterSheet(uri, this.SHEET);
    }
    } else {
    // Datei wurde nicht gelesen
    if (isEnable && isExists) {
    this.sss.loadAndRegisterSheet(uri, this.SHEET);
    }
    }
    if (this.lastModifiedTime !== 1 && isEnable && isForced) {
    log(this.leafName + " wurde aktualisiert");
    }
    this.lastModifiedTime = lastModifiedTime;
    return this._enabled = isEnable;
    },
    };
    
    
    function CSSTester(aWindow, aCallback) {
    this.win = aWindow  window;
    this.doc = this.win.document;
    this.callback = aCallback;
    this.init();
    }
    CSSTester.prototype = {
    sss: Cc["@mozilla.org/content/style-sheet-service;1"].getService(Ci.nsIStyleSheetService),
    preview_code: "",
    saved: false,
    init: function() {
    this.dialog = openDialog(
    "data:text/html;charset=utf8,"+encodeURIComponent('<!DOCTYPE HTML><html lang="ja"><head><title>CSSTester</title></head><body></body></html>'),
    "",
    "width=550,height=400,dialog=no");
    this.dialog.addEventListener("load", this, false);
    },
    destroy: function() {
    this.preview_end();
    this.dialog.removeEventListener("unload", this, false);
    this.previewButton.removeEventListener("click", this, false);
    this.saveButton.removeEventListener("click", this, false);
    this.closeButton.removeEventListener("click", this, false);
    },
    handleEvent: function(event) {
    switch(event.type) {
    case "click":
    if (event.button != 0) return;
    if (this.previewButton == event.currentTarget) {
    this.preview();
    }
    else if (this.saveButton == event.currentTarget) {
    this.save();
    }
    else if (this.closeButton == event.currentTarget) {
    this.dialog.close();
    }
    break;
    case "load":
    var doc = this.dialog.document;
    doc.body.innerHTML = '\
    <style type="text/css">\
    :not(input):not(select) { padding: 0px; margin: 0px; }\
    table { border-spacing: 0px; }\
    body, html, #main, #textarea { width: 100%; height: 100%; }\
    #textarea { font-family: monospace; }\
    </style>\
    <table id="main">\
    <tr height="100%">\
    <td colspan="4"><textarea id="textarea"></textarea></td>\
    </tr>\
    <tr height="40">\
    <td><input type="button" value="Vorschau" id="Vorschau"/></td>\
    <td><input type="button" value="Speichern" id="Speichern"/></td>\
    <td width="80%"><span class="log"></span></td>\
    <td><input type="button" value="Schließen" id="Schliessen"/></td>\
    </tr>\
    </table>\
    ';
    this.textbox = doc.querySelector("textarea");
    this.previewButton = doc.querySelector('input[value="Vorschau"]');
    this.saveButton = doc.querySelector('input[value="Speichern"]');
    this.closeButton = doc.querySelector('input[value="Schließen"]');
    this.logField = doc.querySelector('.log');
    
    
    var code = "@namespace url(" + this.doc.documentElement.namespaceURI + ");\n";
    code += this.win.location.protocol.indexOf("http") === 0?
    "@-moz-document domain(" + this.win.location.host + ") {\n\n\n\n}":
    "@-moz-document url(" + this.win.location.href + ") {\n\n\n\n}";
    this.textbox.value = code;
    this.dialog.addEventListener("unload", this, false);
    this.previewButton.addEventListener("click", this, false);
    this.saveButton.addEventListener("click", this, false);
    this.closeButton.addEventListener("click", this, false);
    
    
    this.textbox.focus();
    let p = this.textbox.value.length - 3;
    this.textbox.setSelectionRange(p, p);
    
    
    break;
    case "unload":
    this.destroy();
    this.callback(this);
    break;
    }
    },
    preview: function() {
    var code = this.textbox.value;
    if (!code  !/\:/.test(code))
    return;
    code = "data:text/css;charset=utf-8," + encodeURIComponent(this.textbox.value);
    if (code == this.preview_code)
    return;
    this.preview_end();
    var uri = Services.io.newURI(code, null, null);
    this.sss.loadAndRegisterSheet(uri, Ci.nsIStyleSheetService.AGENT_SHEET);
    this.preview_code = code;
    this.log("Preview");
    },
    preview_end: function() {
    if (this.preview_code) {
    let uri = Services.io.newURI(this.preview_code, null, null);
    this.sss.unregisterSheet(uri, Ci.nsIStyleSheetService.AGENT_SHEET);
    this.preview_code = "";
    }
    },
    save: function() {
    var data = this.textbox.value;
    if (!data) return;
    
    
    var fp = Cc["@mozilla.org/filepicker;1"].createInstance(Ci.nsIFilePicker);
    fp.init(window, "", Ci.nsIFilePicker.modeSave);
    fp.appendFilter("CSS Files","*.css");
    fp.defaultExtension = "css";
    if (window.UCL)
    fp.displayDirectory = UCL.FOLDER;
    var res = fp.show();
    if (res != fp.returnOK && res != fp.returnReplace) return;
    
    
    var suConverter = Cc["@mozilla.org/intl/scriptableunicodeconverter"].createInstance(Ci.nsIScriptableUnicodeConverter);
    suConverter.charset = "UTF-8";
    data = suConverter.ConvertFromUnicode(data);
    var foStream = Cc["@mozilla.org/network/file-output-stream;1"].createInstance(Ci.nsIFileOutputStream);
    foStream.init(fp.file, 0x02 | 0x08 | 0x20, 0664, 0);
    foStream.write(data, data.length);
    foStream.close();
    this.saved = true;
    },
    log: function() {
    this.logField.textContent = dateFormat(new Date(), "%H:%M:%S") + ": " + $A(arguments);
    }
    };
    
    
    UCL.init();
    
    
    function $(id) { return document.getElementById(id); }
    function $A(arr) { return Array.slice(arr); }
    function $C(name, attr) {
    var el = document.createXULElement(name);
    if (attr) Object.keys(attr).forEach(function(n) { el.setAttribute(n, attr[n]) });
    return el;
    }
    function dateFormat(date, format) {
    format = format.replace("%Y", ("000" + date.getFullYear()).substr(-4));
    format = format.replace("%m", ("0" + (date.getMonth()+1)).substr(-2));
    format = format.replace("%d", ("0" + date.getDay()).substr(-2));
    format = format.replace("%H", ("0" + date.getHours()).substr(-2));
    format = format.replace("%M", ("0" + date.getMinutes()).substr(-2));
    format = format.replace("%S", ("0" + date.getSeconds()).substr(-2));
    return format;
    }
    
    
    function log() { Application.console.log(Array.slice(arguments)); }
    
    
    })();
    Alles anzeigen

    Vorarbeiten wurden korrekt gemacht.

    Boersenfeger, was ist an meiner Aussage widersprüchlich?

  • UserCSSLoader.uc.js arbeitet in TB 91nicht, in FF 91schon.

    • seipe
    • 16. August 2021 um 10:46

    Ich habe versucht mittels im Titel genannten Script die css-Dateien zu laden. Klappt aber nicht. Kann vielleicht jemand Hilfestellung geben? In Firefox 91 funktionert es. Gehört eventuell das Script angepasst?

  • RestartThunderbird.uc.js hat in TB 91 keine Wirkung

    • seipe
    • 13. August 2021 um 17:19

    Jaaaaawohl. Danke edvoldi. :thumbsup:

  • RestartThunderbird.uc.js hat in TB 91 keine Wirkung

    • seipe
    • 13. August 2021 um 17:10

    Wie bewerkstellige ich das?

  • RestartThunderbird.uc.js hat in TB 91 keine Wirkung

    • seipe
    • 13. August 2021 um 16:59

    Hallo edvoldi, deine Version klappt auch bei mir. Das Icon (habe es in der Tableiste) ist nicht sichtbar.

  • 1
  • 4
  • 5
  • 6
  • 10
  • Hilfreichste Antworten

Aktuelle Programmversion

  • Thunderbird 139.0 veröffentlicht

    Thunder 27. Mai 2025 um 23:39

Aktuelle ESR-Version

  • Thunderbird 128.11.0 ESR veröffentlicht

    Thunder 28. Mai 2025 um 22:13

Keine Werbung

Hier wird auf Werbeanzeigen verzichtet. Vielleicht geben Sie dem Website-Betreiber (Alexander Ihrig - aka "Thunder") stattdessen etwas aus, um diese Seiten auf Dauer finanzieren zu können. Vielen Dank!

Vielen Dank für die Unterstützung!

Kaffee ausgeben für:

3,00 €
1
Per Paypal unterstützen*

*Weiterleitung zu PayPal.Me

Thunderbird Mail DE
  1. Impressum & Kontakt
  2. Datenschutzerklärung
    1. Einsatz von Cookies
  3. Nutzungsbedingungen
  4. Spendenaufruf für Thunderbird
Hilfe zu dieser Webseite
  • Übersicht der Hilfe zur Webseite
  • Die Suchfunktion benutzen
  • Foren-Benutzerkonto - Erstellen (Neu registrieren)
  • Foren-Thema erstellen und bearbeiten
  • Passwort vergessen - neues Passwort festlegen
Copyright © 2003-2025 Thunderbird Mail DE

Sie befinden sich NICHT auf einer offiziellen Seite der Mozilla Foundation. Mozilla®, mozilla.org®, Firefox®, Thunderbird™, Bugzilla™, Sunbird®, XUL™ und das Thunderbird-Logo sind (neben anderen) eingetragene Markenzeichen der Mozilla Foundation.

Community-Software: WoltLab Suite™
  • Alles
  • Forum
  • Lexikon
  • Artikel
  • Seiten
  • Erweiterte Suche
  • Deutsch
  • English