Hallo Speravir.
Vielen Dank funktioniert wieder einwandfrei.
Das Script zum aktivieren - deaktivieren von Javascript
lade ich dann auch gleich mit hoch.
Vielen Dank für Deine Mühe.
Mfg.
Endor
Hallo Speravir.
Vielen Dank funktioniert wieder einwandfrei.
Das Script zum aktivieren - deaktivieren von Javascript
lade ich dann auch gleich mit hoch.
Vielen Dank für Deine Mühe.
Mfg.
Endor
Hallo zusammen.
Dieses Script geht hier im Nightly auch nicht mehr richtig:
// ==UserScript==
// @name moveReloadIntoUrl.uc.js
// @description Neuladen Schaltfläche in Adressleiste verschieben
// @compatibility Firefox 57
// @author Ryan, GOLF-AT
// @include main
// @shutdown window.moveReloadIntoURL.unload();
// @homepageURL https://github.com/benzBrake/FirefoxCustomize
// @version 1.2.4
// @note 1.2.4 Bug 1880914 Move Browser* helper functions used from global menubar and similar commands to a single object in a separate file, loaded as-needed and Bug 1820534 - Move front-end to modern flexbox
// @note 1.2.3 Änderung wird in neuen Fenstern nicht wirksam und kann nicht verwendet werden, wenn Hot-Swapping stattfindet.
// @note 1.2.2 Kompatibilität für Firefox 103
// @note 1.2.0 Hot-Swap-fähig, kompatibel mit Nachtmodus und Bilder wurden ins Script integriert
// @note 1.1 20220424 Fehler behoben, und Firefox 100 Kompatibel
// @note 1.0 20171104
// ==/UserScript==
(function () {
let { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
const isGerman = (Services.locale.appLocaleAsBCP47 || Services.locale.getAppLocaleAsBCP47()).includes("de");
if (window.moveReloadIntoURL) {
window.moveReloadIntoURL.unload();
delete window.moveReloadIntoURL;
}
window.moveReloadIntoURL = {
handleEvent: function (aEvent) {
if (aEvent.type === "MoveReloadIntoUrlUnload") {
let window = aEvent.originalTarget,
doc = window.document;
let RELOADBTN = CustomizableUI.getWidget("reload-button").forWindow(window).node;
if (RELOADBTN)
RELOADBTN.removeEventListener('DOMAttrModified', this.reloadBtnAttr);
let BTN = doc.getElementById("new-stop-reload-button");
if (BTN)
BTN.parentNode.removeChild(BTN);
if (this.STYLE) {
this.sss.unregisterSheet(this.STYLE.url, this.STYLE.type);
}
window.removeEventListener('MoveReloadIntoUrlUnload', this);
if (window.moveReloadIntoURL)
delete window.moveReloadIntoURL;
}
},
init: function () {
if (window.moveReloadIntoURL) {
this.sss = Cc["@mozilla.org/content/style-sheet-service;1"].getService(Ci.nsIStyleSheetService);
this.STYLE = {
url: Services.io.newURI('data:text/css;charset=UTF-8,' + encodeURIComponent(`
@-moz-document url-prefix('chrome://browser/content/browser.x') {
#stop-reload-button {
display: none;
}
#new-stop-reload-button {
display: flex !important;
order: 9999;
}
#new-stop-reload-button .urlbar-icon {
-moz-context-properties: fill, fill-opacity !important;
fill: currentColor !important;
}
}
`)),
type: this.sss.AGENT_SHEET
};
this.sss.loadAndRegisterSheet(this.STYLE.url, this.STYLE.type);
}
let PABTN = CustomizableUI.getWidget("pageActionButton").forWindow(window).node;
let RELOADBTN = CustomizableUI.getWidget("reload-button").forWindow(window).node;
let BTN = $C(document, 'hbox', {
id: "new-stop-reload-button",
class: "urlbar-page-action urlbar-addon-page-action",
"tooltiptext": isGerman ? 'Linksklick: Seite neuladen\r\nRechtsklick: Neu laden ohne Cache' : 'Left click: refresh page\nRight click: force refresh page',
style: "list-style-image: url('data:image/svg+xml;base64,PCEtLSBUaGlzIFNvdXJjZSBDb2RlIEZvcm0gaXMgc3ViamVjdCB0byB0aGUgdGVybXMgb2YgdGhlIE1vemlsbGEgUHVibGljCiAgIC0gTGljZW5zZSwgdi4gMi4wLiBJZiBhIGNvcHkgb2YgdGhlIE1QTCB3YXMgbm90IGRpc3RyaWJ1dGVkIHdpdGggdGhpcwogICAtIGZpbGUsIFlvdSBjYW4gb2J0YWluIG9uZSBhdCBodHRwOi8vbW96aWxsYS5vcmcvTVBMLzIuMC8uIC0tPgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgdmlld0JveD0iMCAwIDE2IDE2IiB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIGZpbGw9IiNkOTAwMDAiIGZpbGwtb3BhY2l0eT0iMS4wIiBzdHJva2U9IiNkOTAwMDAiIHN0cm9rZS13aWR0aD0iMSIgPgogIDxwYXRoIGQ9Ik0xMC43MDcgNiAxNC43IDZsLjMtLjMgMC0zLjk5M2EuNS41IDAgMCAwLS44NTQtLjM1NGwtMS40NTkgMS40NTlBNi45NSA2Ljk1IDAgMCAwIDggMUM0LjE0MSAxIDEgNC4xNDEgMSA4czMuMTQxIDcgNyA3YTYuOTcgNi45NyAwIDAgMCA2Ljk2OC02LjMyMi42MjYuNjI2IDAgMCAwLS41NjItLjY4Mi42MzUuNjM1IDAgMCAwLS42ODIuNTYyQTUuNzI2IDUuNzI2IDAgMCAxIDggMTMuNzVjLTMuMTcxIDAtNS43NS0yLjU3OS01Ljc1LTUuNzVTNC44MjkgMi4yNSA4IDIuMjVhNS43MSA1LjcxIDAgMCAxIDMuODA1IDEuNDQ1bC0xLjQ1MSAxLjQ1MWEuNS41IDAgMCAwIC4zNTMuODU0eiIvPgo8L3N2Zz4K",
onclick: function (e) {
let r = CustomizableUI.getWidget("reload-button").forWindow(window).node;
e.preventDefault();
if (r && r.getAttribute('displaystop'))
gBrowser.stop();
else
if (e.button == 2) {
gBrowser.reloadWithFlags(Ci.nsIWebNavigation.LOAD_FLAGS_BYPASS_CACHE)
} else {
if (gBrowser.selectedBrowser._userTypedValue) {
e.target.ownerGlobal.openTrustedLinkIn(gBrowser.selectedBrowser._userTypedValue, 'current', {
postData: null,
triggeringPrincipal: gBrowser.selectedBrowser.contentPrincipal
});
} else {
gBrowser.reload();
}
}
}
})
BTN.appendChild($C(document, 'image', {
class: 'urlbar-icon',
}));
PABTN.after(BTN);
RELOADBTN.addEventListener('DOMAttrModified', this.reloadBtnAttr);
this.reloadBtnAttr();
window.addEventListener('MoveReloadIntoUrlUnload', this)
},
unload: function () {
let windows = Services.wm.getEnumerator('navigator:browser');
while (windows.hasMoreElements()) {
let win = windows.getNext();
win.dispatchEvent(new CustomEvent("MoveReloadIntoUrlUnload"));
}
},
reloadBtnAttr: function (e) {
let doc = e ? e.target.ownerDocument : document;
btn = doc.getElementById('new-stop-reload-button');
if (btn && (!e || e.attrName == 'displaystop')) {
var newVal = e ? e.newValue : doc.getElementById(
"reload-button").getAttribute('displaystop');
if (newVal)
btn.style.listStyleImage = "url('data:image/svg+xml;base64,PCEtLSBUaGlzIFNvdXJjZSBDb2RlIEZvcm0gaXMgc3ViamVjdCB0byB0aGUgdGVybXMgb2YgdGhlIE1vemlsbGEgUHVibGljCiAgIC0gTGljZW5zZSwgdi4gMi4wLiBJZiBhIGNvcHkgb2YgdGhlIE1QTCB3YXMgbm90IGRpc3RyaWJ1dGVkIHdpdGggdGhpcwogICAtIGZpbGUsIFlvdSBjYW4gb2J0YWluIG9uZSBhdCBodHRwOi8vbW96aWxsYS5vcmcvTVBMLzIuMC8uIC0tPgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgdmlld0JveD0iMCAwIDE2IDE2IiB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIGZpbGw9IiMwMDhjMjMiIGZpbGwtb3BhY2l0eT0iMS4wIiBzdHJva2U9IiMwMDhjMjMiIHN0cm9rZS13aWR0aD0iMS41Ij4KICA8cGF0aCBkPSJtOS4xMDggNy43NzYgNC43MDktNC43MDlhLjYyNi42MjYgMCAwIDAtLjg4NC0uODg1TDguMjQ0IDYuODcxbC0uNDg4IDAtNC42ODktNC42ODhhLjYyNS42MjUgMCAxIDAtLjg4NC44ODVMNi44NyA3Ljc1NGwwIC40OTEtNC42ODcgNC42ODdhLjYyNi42MjYgMCAwIDAgLjg4NC44ODVMNy43NTQgOS4xM2wuNDkxIDAgNC42ODcgNC42ODdhLjYyNy42MjcgMCAwIDAgLjg4NSAwIC42MjYuNjI2IDAgMCAwIDAtLjg4NUw5LjEwOCA4LjIyM2wwLS40NDd6Ii8+Cjwvc3ZnPgo=')";
else
btn.style.listStyleImage = "url('data:image/svg+xml;base64,PCEtLSBUaGlzIFNvdXJjZSBDb2RlIEZvcm0gaXMgc3ViamVjdCB0byB0aGUgdGVybXMgb2YgdGhlIE1vemlsbGEgUHVibGljCiAgIC0gTGljZW5zZSwgdi4gMi4wLiBJZiBhIGNvcHkgb2YgdGhlIE1QTCB3YXMgbm90IGRpc3RyaWJ1dGVkIHdpdGggdGhpcwogICAtIGZpbGUsIFlvdSBjYW4gb2J0YWluIG9uZSBhdCBodHRwOi8vbW96aWxsYS5vcmcvTVBMLzIuMC8uIC0tPgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgdmlld0JveD0iMCAwIDE2IDE2IiB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIGZpbGw9IiNkOTAwMDAiIGZpbGwtb3BhY2l0eT0iMS4wIiBzdHJva2U9IiNkOTAwMDAiIHN0cm9rZS13aWR0aD0iMSIgPgogIDxwYXRoIGQ9Ik0xMC43MDcgNiAxNC43IDZsLjMtLjMgMC0zLjk5M2EuNS41IDAgMCAwLS44NTQtLjM1NGwtMS40NTkgMS40NTlBNi45NSA2Ljk1IDAgMCAwIDggMUM0LjE0MSAxIDEgNC4xNDEgMSA4czMuMTQxIDcgNyA3YTYuOTcgNi45NyAwIDAgMCA2Ljk2OC02LjMyMi42MjYuNjI2IDAgMCAwLS41NjItLjY4Mi42MzUuNjM1IDAgMCAwLS42ODIuNTYyQTUuNzI2IDUuNzI2IDAgMCAxIDggMTMuNzVjLTMuMTcxIDAtNS43NS0yLjU3OS01Ljc1LTUuNzVTNC44MjkgMi4yNSA4IDIuMjVhNS43MSA1LjcxIDAgMCAxIDMuODA1IDEuNDQ1bC0xLjQ1MSAxLjQ1MWEuNS41IDAgMCAwIC4zNTMuODU0eiIvPgo8L3N2Zz4K')";
}
},
}
function $C(aDoc, tag, attrs, skipAttrs) {
let d = (aDoc || document);
attrs = attrs || {};
skipAttrs = skipAttrs || [];
var el = "createXULElement" in d ? d.createXULElement(tag) : d.createElement(tag);
return $A(el, attrs, skipAttrs);
}
function $A(el, obj, skipAttrs) {
skipAttrs = skipAttrs || [];
if (obj) Object.keys(obj).forEach(function (key) {
if (!skipAttrs.includes(key)) {
if (typeof obj[key] === 'function') {
el.setAttribute(key, "(" + obj[key].toString() + ").call(this, event);");
} else {
el.setAttribute(key, obj[key]);
}
}
});
return el;
}
"canLoadToolbarContentPromise" in PlacesUIUtils ? PlacesUIUtils.canLoadToolbarContentPromise.then(_ => moveReloadIntoURL.init()) : moveReloadIntoURL.init();
})();
Alles anzeigen
ab Zeile 76 gibt es diesen Bereich den man wahrscheinlich ändern muss:
onclick: function (e) {
let r = CustomizableUI.getWidget("reload-button").forWindow(window).node;
e.preventDefault();
if (r && r.getAttribute('displaystop'))
gBrowser.stop();
else
if (e.button == 2) {
gBrowser.reloadWithFlags(Ci.nsIWebNavigation.LOAD_FLAGS_BYPASS_CACHE)
} else {
if (gBrowser.selectedBrowser._userTypedValue) {
e.target.ownerGlobal.openTrustedLinkIn(gBrowser.selectedBrowser._userTypedValue, 'current', {
postData: null,
triggeringPrincipal: gBrowser.selectedBrowser.contentPrincipal
});
} else {
gBrowser.reload();
}
}
}
Alles anzeigen
oncommand gibt es keine nur diesen onclick Bereich.
Wie muss man das ändern?
Mfg.
Endor
Alice wird antworten sobald er eine funktionierende Version hat.
Geduld ist angesagt.
Mfg.
Endor
Ich schreibe gerade Alice, dem Autor.
Erledigt:
Mfg.
Endor
ja dieser CSS Code gehört dazu, bzw. es steht auch im Script dass er dazu
über userchrome.css geladen werden muss:
@charset "utf-8";
/*@version 2023/05/18 fix for firefox113, flex-direction, frex-wrap*/
/*@version 2023/04/25 fix for firefox113, inline-block firefox 113*/
/*@version 2023/03/09 Bug 1820534 - Move front-end to modern flexbox.*/
/*@version 2022/11/24 21:00 Bug 1802142 - Remove no longer used browser-bottombox*/
/*@version 2022/11/20 19:00 107+ wip*/
/*@version 2022/02/16 Bug 1747422 - Remove preprocessor variable use from downloads CSS*/
/*@version 2020/03/13 fix for 74, broken listitem orient due to Bug 1606130
/*@version 2019/12/11 fix for 73 Bug 1601094 - Rename remaining .xul files to .xhtml in browser */
/*@version 2019/10/20 12:30*/
/*FullScreen*/
/*DOMFullScreen*/
:root[inFullscreen] #downloadsStatusModokiBar,
:root[inDOMFullscreen] #downloadsStatusModokiBar {
display: none !important;
}
#contentAreaDownloadsView[ucjsDownloadsStatusModoki] {
flex-direction: row !important;
background-color: var(--in-content-box-background) !important;
padding: 0 !important;
}
#contentAreaDownloadsView[ucjsDownloadsStatusModoki] > stack:first-child {
}
#ucjsDownloadsStatusModoki{
border-top-width: 1px !important;
border-top-style: solid !important;
border-top-color: #646473 !important;
}
#contentAreaDownloadsView[ucjsDownloadsStatusModoki] #downloadsListBox {
background-color: #fffff0 !important;
flex-direction: row;
flex-wrap: wrap;
overflow-y: auto !important;
scrollbar-width: thin;
border: none !important;
}
#contentAreaDownloadsView[ucjsDownloadsStatusModoki] richlistitem:not([hidden]) {
border-width: 0 1px 0 0 !important;
border-style: solid !important;
border-color: black !important;
width: 276px !important;
height: 3.0em !important;
min-height: 3.0em !important;
font-size: 12px !important;
}
#contentAreaDownloadsView[ucjsDownloadsStatusModoki] .downloadMainArea {
}
#contentAreaDownloadsView[ucjsDownloadsStatusModoki] .downloadContainer {
max-width: 200px !important;
}
#contentAreaDownloadsView[ucjsDownloadsStatusModoki] .downloadTypeIcon {
margin-inline-end: 4px !important;
margin-inline-start: 4px !important;
}
#contentAreaDownloadsView[ucjsDownloadsStatusModoki] .downloadButton {
width: 36px !important;
padding-inline-end: 4px !important;
padding-inline-start: 4px !important;
}
#contentAreaDownloadsView[ucjsDownloadsStatusModoki] #downloadsListEmptyDescription
{
flex: 1 !important;
}
Alles anzeigen
Deine Version funktioniert nicht richtig. Standardmäßig ist diese Leiste nicht sichtbar.
Sie kann manuell über Ansicht - Symbolleisten ein und ausgeblendet werden bzw.
bei Download öffnet sich diese automatisch. Eintrag unter Ansicht - Symbolleisten fehlt bei
deiner Version und Darstellung passt auch nicht. Werde den Autor mal kontaktieren, mal sehen was er sagt.
Trotzdem vielen Dank für Deine Mühe.
Mfg.
Endor
Hallo Boersenfeger .
Vom Script ucjsDownloadsStatusModoki.uc.js gibt es auch eine neue Version.
Muss ich erst noch fertig machen und hochladen.
Edit:
Das ist die neueste Version davon, aber funktioniert hier noch nichtnicht richtig. Überhaupt nicht. Unter Ansicht ist kein Eintrag zum ein und ausblenden der
Downloadleiste.
// ==UserScript==
// @name ucjsDownloadsStatusModoki.uc.js
// @namespace http://space.geocities.yahoo.co.jp/gl/alice0775
// @description Downloads Status Modoki
// @include main
// @compatibility Firefox 120
// @author Alice0775
// @note ucjsDownloadsStatusModoki.uc.js.css をuserChrome.cssに読み込ませる必要あり
// @version 2023/10/10 00:00 Stop using xml-stylesheet processing instructions
// @version 2023/07/17 00:00 use ES module imports
// @version 2023/06/20 remove Bug 1780695 - Remove Services.jsm
// @version 2023/06/18 21:00 null
// @version 2023/05/18 21:00
// @version 2022/11/24 21:00 Bug 1802142 - Remove no longer used browser-bottombox
// @version 2022/11/22 Bug 877389 - [meta] Replace calls to Cu.reportError, etc. from browser code, replace with console.error, etc.
// @version 2022/11/20 19:00 107+ wip
// @version 2022/04/01 23:00 Convert Components.utils.import to ChromeUtils.import
// @version 2022/02/16 Bug 1747422 - Remove preprocessor variable use from downloads CSS
// @version 2019/12/11 fix for 73 Bug 1601094 - Rename remaining .xul files to .xhtml in browser
// @version 2019/10/20 12:30 workaround Bug 1497200: Apply Meta CSP to about:downloads, Bug 1513325 - Remove textbox binding
// @version 2019/09/08 19:30 fix scrollbox
// @version 2019/05/21 08:30 fix 69.0a1 Bug 1551320 - Replace all createElement calls in XUL documents with createXULElement
// @version 2018/10/27 12:00 fix for 64+
// @version 2018/06/12 21:00 fix for private window mode
// @version 2018/06/07 12:00 fix file name for history
// @version 2018/02/10 12:00 try catch error when DO_NOT_DELETE_HISTORY = true
// @version 2017/12/10 12:00 fix error when DO_NOT_DELETE_HISTORY = true
// @version 2017/12/10 12:00 remove workaround Bug 1279329. Disable btn while clear list is doing, close button styling for 57.
// @version 2016/06/10 12:00 modify style independent of font-family
// @version 2016/06/10 07:00 modify style of close button, fix typo
// @version 2016/06/10 00:00 Workaround Bug 1279329. adjust some padding
// @version 2015/05/08 00:00 remove padding due to Bug 1160734
// @version 2014/03/31 00:00 fix for browser.download.manager.showWhenStarting
// @version 2013/12/22 13:00 chromehidden
// @version 2013/12/19 17:10 rename REMEMBERHISTOTY to DO_NOT_DELETE_HISTORY
// @version 2013/12/16 23:28 fixed initialize numDls
// @version 2013/12/16 23:24 open only download added
// @version 2013/12/16 23:10 open only download started
// @version 2013/12/16 21:20 modify css Windows7 Aero
// @version 2013/12/16 21:00 modify css
// @version 2013/12/16 19:30 add autocheck false
// @version 2013/12/16 18:31 fix pref name
// @version 2013/12/16 18:30
// @note
// ==/UserScript==
var ucjsDownloadsStatusModoki = {
_summary: null,
_list: null,
get downloadsStatusModokiBar() {
delete downloadsStatusModokiBar;
return this.downloadsStatusModokiBar = document.getElementById("downloadsStatusModokiBar");
},
get toggleMenuitem() {
delete toggleMenuitem;
return this.toggleMenuitem = document.getElementById("toggle_downloadsStatusModokiBar");
},
init: function() {
if (document.documentElement.getAttribute("chromehidden") !="" )
return;
ChromeUtils.defineESModuleGetters(this, {
Downloads: "resource://gre/modules/Downloads.sys.mjs",
});
var style = `
@namespace url(http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul);
#ucjsDownloadsStatusModoki {
width: 100%;
max-height: 100px;
height: 3.35em;
}
`.replace(/\s+/g, " ");
var sss = Cc['@mozilla.org/content/style-sheet-service;1']
.getService(Ci.nsIStyleSheetService);
var uri = makeURI('data:text/css;charset=UTF=8,' + encodeURIComponent(style));
if(!sss.sheetRegistered(uri, sss.USER_SHEET))
sss.loadAndRegisterSheet(uri, sss.USER_SHEET);
/*
var sspi = document.createProcessingInstruction(
'xml-stylesheet',
'type="text/css" href="data:text/css,' + encodeURIComponent(style) + '"'
);
document.insertBefore(sspi, document.documentElement);
sspi.getAttribute = function(name) {
return document.documentElement.getAttribute(name);
};
*/
var toolbar = document.createXULElement("vbox");
toolbar.setAttribute("id", "downloadsStatusModokiBar");
toolbar.collapsed = true;
var ref = document.getElementById("fullscreen-and-pointerlock-wrapper");
ref.parentNode.insertBefore(toolbar, ref.nextSibling)
// var bottombox = document.getElementById("browser-bottombox");
// bottombox.insertBefore(toolbar, bottombox.firstChild);
var browser = toolbar.appendChild(document.createXULElement("browser"));
browser.setAttribute("disablehistory", true);
browser.setAttribute("remote", false);
browser.setAttribute("id", "ucjsDownloadsStatusModoki");
browser.addEventListener("load", function(event){ucjsDownloadsStatusModoki.onload(event)}, true);
browser.setAttribute("src", "chrome://browser/content/downloads/contentAreaDownloadsView.xhtml?StatusModoki");
var menuitem = document.createXULElement("menuitem");
menuitem.setAttribute("id", "toggle_downloadsStatusModokiBar");
menuitem.setAttribute("type", "checkbox");
menuitem.setAttribute("autocheck", false);
menuitem.setAttribute("label", "Downloads Status Modoki Bar");
menuitem.setAttribute("checked", false);
menuitem.setAttribute("accesskey", "D");
//menuitem.setAttribute("oncommand", "ucjsDownloadsStatusModoki.toggleDownloadsStatusModokiBar()");
ref = document.getElementById("menu_customizeToolbars");
ref.parentNode.insertBefore(menuitem, ref.previousSibling);
document.getElementById("toggle_downloadsStatusModokiBar").addEventListener("command", () => ucjsDownloadsStatusModoki.toggleDownloadsStatusModokiBar());
// Ensure that the DownloadSummary object will be created asynchronously.
if (!this._summary) {
this.Downloads.getSummary(this.Downloads.ALL).then(summary => {
this._summary = summary;
return this._summary.addView(this);
}).then(null, console.error);
}
if (!this._list) {
this.Downloads.getList(this.Downloads.ALL).then(list => {
this._list = list;
return this._list.addView(this);
}).then(null, console.error);
}
window.addEventListener("unload", this, false);
},
uninit: function() {
window.removeEventListener("unload", this, false);
if (this._summary) {
this._summary.removeView(this);
}
if (this._list) {
this._list.removeView(this);
}
},
handleEvent: function(event) {
switch (event.type) {
case "unload":
this.uninit();
break;
}
},
toggleDownloadsStatusModokiBar: function() {
var collapsed = this.downloadsStatusModokiBar.collapsed;
this.downloadsStatusModokiBar.collapsed = !collapsed;
this.toggleMenuitem.setAttribute("checked", collapsed);
},
openDownloadsStatusModoki: function() {
this.downloadsStatusModokiBar.collapsed = false;
this.toggleMenuitem.setAttribute("checked", true);
},
hideDownloadsStatusModoki: function() {
this.downloadsStatusModokiBar.collapsed = true;
this.toggleMenuitem.setAttribute("checked", false);
},
onDownloadAdded: function (aDownload) {
var showWhenStarting = true;
try {
showWhenStarting = Services.prefs.getBoolPref("userChrome.downloadsStatusModoki.showWhenStarting");
} catch(e) {}
this.numDls = 0;
if (showWhenStarting) {
if (this._list) {
this._list.getAll().then(downloads => {
for (let download of downloads) {
if (!download.stopped)
this.numDls++;
}
if (this.numDls > 0)
this.openDownloadsStatusModoki(false);
}).then(null, console.error);
}
}
},
onSummaryChanged: function () {
if (!this._summary)
return;
if (this._summary.allHaveStopped || this._summary.progressTotalBytes == 0) {
var closeWhenDone = false;
try {
closeWhenDone = Services.prefs.getBoolPref("userChrome.downloadsStatusModoki.closeWhenDone");
} catch(e) {}
if (closeWhenDone) {
this.hideDownloadsStatusModoki();
}
}
},
// chrome://browser/content/downloads/contentAreaDownloadsView.xhtml
onload: function(event) {
var doc = event.originalTarget;
var win = doc.defaultView;
doc.documentElement.setAttribute("ucjsDownloadsStatusModoki", "true");
var button = doc.createXULElement("button");
button.setAttribute("label", "Clear");
button.setAttribute("id", "ucjs_clearListButton");
button.setAttribute("accesskey", "C");
var ref = doc.getElementById("downloadsListEmptyDescription");
var vbox = doc.createXULElement("vbox");
var box = vbox.appendChild(doc.createXULElement("hbox"));
box.appendChild(button);
box.appendChild(doc.createXULElement("spacer")).setAttribute("flex", 1);
var textbox = doc.createElementNS("http://www.w3.org/1999/xhtml", "input");
textbox.setAttribute("id", "downloadFilter");
textbox.setAttribute("clickSelectsAll", true);
textbox.setAttribute("type", "search");
textbox.setAttribute("placeholder", "Search...");
box.appendChild(textbox);
var closebtn = doc.createXULElement("toolbarbutton");
closebtn.setAttribute("id", "ucjsDownloadsStatusModoki-closebutton");
closebtn.setAttribute("class", "close-icon");
closebtn.setAttribute("tooltiptext", "Close this bar");
box.appendChild(closebtn);
ref.parentNode.insertBefore(vbox, ref.nextSibling);
doc.getElementById("ucjs_clearListButton").addEventListener("command", function(event) {
win.ucjsDownloadsStatusModoki_clearDownloads();
});
doc.getElementById("downloadFilter")
.addEventListener("input", function(event) {
win.ucjsDownloadsStatusModoki_doSearch(event.target.value);
});
doc.getElementById("ucjsDownloadsStatusModoki-closebutton")
.addEventListener("command", function(event) {
win.ucjsDownloadsStatusModoki_doClose();
});
/*
// xxx Bug 1279329 "Copy Download Link" of context menu in Library is grayed out
var listBox = doc.getElementById("downloadsListBox");
var placesView = listBox._placesView;
if (placesView) {
var place = placesView.place;
placesView.place= null;
placesView.place = place;
}
*/
win.ucjsDownloadsStatusModoki_clearDownloads = function ucjs_clearDownloads() {
var DO_NOT_DELETE_HISTORY = true; /* custmizable true or false */
var richListBox = doc.getElementById("downloadsListBox");
var places = [];
function addPlace(aURI, aTitle, aVisitDate) {
places.push({
uri: aURI,
title: aTitle,
visits: [{
visitDate: (aVisitDate || Date.now()) * 1000,
transitionType: Ci.nsINavHistoryService.TRANSITION_LINK
}]
});
}
function moveDownloads2History() {
if (DO_NOT_DELETE_HISTORY &&
!PrivateBrowsingUtils.isWindowPrivate(window)) {
try {
for (let element of richListBox.childNodes) {
let download = element._shell.download;
let aURI = makeURI(download.source.url);
// let aTitle = document.getAnonymousElementByAttribute(element, "class", "downloadTarget").value
let aTitle = download.target.path;
aTitle = aTitle.match( /[^\\]+$/i )[0];
aTitle = aTitle.match( /[^/]+$/i )[0];
let aVisitDate = download.endTime || download.startTime;
addPlace(aURI, aTitle, aVisitDate)
}
} catch(ex) {}
}
// Clear List
richListBox._placesView.doCommand('downloadsCmd_clearDownloads');
if (DO_NOT_DELETE_HISTORY &&
!PrivateBrowsingUtils.isWindowPrivate(window)) {
try {
if (places.length > 0) {
var asyncHistory = Components.classes["@mozilla.org/browser/history;1"]
.getService(Components.interfaces.mozIAsyncHistory);
asyncHistory.updatePlaces(places);
}
} catch(ex) {}
}
}
var btn = doc.getElementById("ucjs_clearListButton");
btn.setAttribute("disabled", true);
moveDownloads2History();
btn.removeAttribute("disabled");
// close toolbar
var closeWhenDone = false;
try {
closeWhenDone = Services.prefs.getBoolPref("userChrome.downloadsStatusModoki.closeWhenDone");
} catch(e) {}
if (closeWhenDone) {
top.ucjsDownloadsStatusModoki.hideDownloadsStatusModoki();
}
};
win.ucjsDownloadsStatusModoki_doSearch = function ucjs_doSearch(filterString) {
var richListBox = doc.getElementById("downloadsListBox");
richListBox._placesView.searchTerm = filterString;
};
win.ucjsDownloadsStatusModoki_doClose = function ucjs_doClose() {
top.ucjsDownloadsStatusModoki.hideDownloadsStatusModoki();
};
}
}
ucjsDownloadsStatusModoki.init();
Alles anzeigen
Mfg.
Endor
Hallo 2002Andreas
Habe ich ja gemacht. Aber meine Version ist etwas anders.
Da sind die Schaltflächen frei verschiebbar.
Hat aborix mal eingebaut.
Daher klemmt es irgendwo.
Mfg.
Endor
Nö, zu dritt.
Denn sonst würde meine Version funktionieren.
Wer mag sich das mal anschauen:
// ==UserScript==
// @name externalApplications.uc.js
// @namespace ithinc#mozine.cn
// @description External Applications
// @include main
// @compatibility Firefox 3.5.x 3.6.x 17.01
// @author ithinc
// @Version Fix by aborix
// @Version 20190108.2.0.0 Frei verschiebbare Schaltflächen von aborix
// @version 20091216.1.0.0 Final release
// @version 20091215.0.0.2 Handle toolbar apps and menu apps separately
// @version 20091212.0.0.1 Initial release
// ==/UserScript==
/* :::: External Applications :::: */
var gExternalApplications = {
toolbar: {
apps: [
{name: 'Photoshop', path: 'C:\\Program Files (x86)\\Adobe\\Adobe Photoshop CS2\\Photoshop.exe'},
{name: 'Wetter', path: 'C:\\Users\\xxx\\Wetter'},
{name: 'Notepad++', path: 'C:\\Program Files\\Notepad++\\notepad++.exe'},
{name: 'Microsoft Outlook', path: 'C:\\Program Files (x86)\\Microsoft Office\\OFFICE14\\Outlook.exe'},
{name: 'Phoenix Hotel', path: 'C:\\Program Files (x86)\\PCS Phoenix\\Phoenix.exe'},
{name: 'Videolan Player', path: 'C:\\Program Files\\VideoLAN\\VLC\\vlc.exe'},
{name: 'Windows Explorer', path: 'C:\\Windows\\explorer.exe'},
{name: 'WinMergeU', path: 'F:\\Adaten\\Downloads\\Freecomander\\WinMerge-2.14.0\\WinMerge-2.16.12-x64-exe\\WinMerge\\WinMergeU.exe'},
{name: 'Filezilla', path: 'F:\\Adaten\\Downloads\\Filezilla\\FileZilla_3.10.3_win64\\FileZilla-3.56.2\\filezilla.exe'},
{name: 'CarotDAV', path: 'F:\\Adaten\\Downloads\\Dropbox\\CarotDAV1.9.9.portable\\CarotDAV\\CarotDAV.exe'},
{name: 'Pickpick', path: 'F:\\Adaten\\Downloads\\picpick\\picpick.exe'},
{name: 'Profilmanager', path: 'F:\\Adaten\\Downloads\\Firefox\\Profile-Manager\\profilemanager.exe'},
{name: 'Profile', path: 'C:\\Users\\xxx\\AppData\\Roaming\\Mozilla\\Firefox\\Profiles'},
{name: 'FreeCommander', path: 'F:\\Adaten\\Downloads\\FreeComander\\FreeCommanderPortable\\FreeCommanderPortable.exe'},
{name: 'TV Browser', path: 'F:\\Adaten\\Downloads\\TVBrowser\\tvbrowser_3.2.1_bin_transportable\\tvbrowser-transportable\\tvbrowser-transportable.exe'},
{name: 'Radio Sure', path: 'F:\\Adaten\\Downloads\\Radio\\RadioSure.exe'},
]
},
// Menü für Firefox Extras - Externe Anwendungen
menu: {
apps: [
{name: 'Notepad', path: 'C:\\WINDOWS\\system32\\notepad.exe'},
{name: 'Rechner', path: 'C:\\WINDOWS\\system32\\calc.exe'},
{name: 'DOS', path: 'C:\\WINDOWS\\system32\\cmd.exe'},
{name: 'separator'},
{name: 'UltraSearch', path: 'F:\\Adaten\\Downloads\\FreeComander\\UltraSearch\\UltraSearch.exe'},
{name: 'CarotDAV', path: 'F:\\Adaten\\Downloads\\Dropbox\\CarotDAV1.9.9.portable\\CarotDAV\\CarotDAV.exe'},
{name: 'Windows Explorer', path: 'c:\\windows\\explorer.exe'},/*x?????*/
{name: 'Internet Explorer', path: 'C:\\Program Files\\Internet Explorer\\IEXPLORE.EXE', args: ['%u']},
{name: 'Firefox', path: 'F:\\Adaten\\Downloads\\Firefox'},
{name: 'Videos', path: 'F:\\Video'},
{name: 'Videos2', path: 'F:\\Adaten\\Müll'},
],
id: 'ExternalApplicationsMenu',
insertafter: 'menu_openAddons', // 'helpMenu', 'tools-menu' oder 'browserToolsSeparator'
label: 'Externe Anwendungen',
accesskey: 'A'
},
init: function() {
this.handleRelativePath(this.toolbar.apps);
this.handleRelativePath(this.menu.apps);
this.createToolbarbuttons(this.toolbar.apps);
if (this.menu.apps.length > 0) {
var refNode = document.getElementById(this.menu.insertafter);
if (refNode) {
var menu = refNode.parentNode.insertBefore(document.createXULElement('menu'), refNode.nextSibling);
menu.setAttribute('id', this.menu.id);
menu.setAttribute('label', this.menu.label);
menu.setAttribute('accesskey', this.menu.accesskey);
menu.appendChild(this.createMenupopup(this.menu.apps));
}
}
},
handleRelativePath: function(apps) {
for (var i=0; i<apps.length; i++) {
var app = apps[i];
if (app.path) {
app.path = app.path.replace(/\//g, '\\');
var ffdir = Cc['@mozilla.org/file/directory_service;1'].getService(Ci.nsIProperties).get('CurProcD', Ci.nsIFile).path;
if (/^(\.)/.test(app.path)) {
app.path = ffdir + '\\' + app.path;
}
else if (/^(\\)/.test(app.path)) {
app.path = ffdir.substr(0,2) + app.path;
}
}
}
},
exec: function(path, args) {
args = args || [];
for (var i=0; i<args.length; i++) {
args[i] = args[i].replace(/%u/g, gBrowser.currentURI.spec);
}
var file = Cc['@mozilla.org/file/local;1'].createInstance(Ci.nsIFile);
file.initWithPath(path);
if (!file.exists()) {
Cu.reportError('File Not Found: ' + path);
return;
}
if (!file.isExecutable()) {
file.launch();
}
else {
var process = Cc['@mozilla.org/process/util;1'].createInstance(Ci.nsIProcess);
process.init(file);
process.run(false, args, args.length);
}
},
createToolbarbuttons: function(apps) {
for (var i=0; i<apps.length; i++) {
var app = apps[i];
if (app.name != 'separator') {
createButton(app);
}
};
function createButton(app) {
var buttonId = app.name.replace(/ /g, '_').replace(/\+/g, 'Plus') + '-ExtApp-button';
try {
CustomizableUI.createWidget({
id: buttonId,
type: 'custom',
defaultArea: CustomizableUI.AREA_NAVBAR,
onBuild: function(aDocument) {
var toolbaritem = aDocument.createElementNS('http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul', 'toolbarbutton');
var attributes = {
id: buttonId,
class: 'toolbarbutton-1 chromeclass-toolbar-additional',
label: app.name,
tooltiptext: app.name,
image: 'moz-icon:file:///' + app.path + '?size=16',
//oncommand: 'gExternalApplications.exec(this.path, this.args);',
};
for (var a in attributes) {
toolbaritem.setAttribute(a, attributes[a]);
toolbaritem.addEventListener('click', event => {
if (event.button == 0) {
gExternalApplications.exec(this.path, this.args).click();
}
});
toolbaritem.path = app.path;
toolbaritem.args = app.args;
return toolbaritem;
}
}
});
} catch(e) {};
}
},
createMenupopup: function(apps) {
var menupopup = document.createXULElement('menupopup');
for (var i=0; i<apps.length; i++) {
var app = apps[i];
if (app.name == 'separator') {
menupopup.appendChild(document.createXULElement('menuseparator'));
}
else {
var item = menupopup.appendChild(document.createXULElement('menuitem'));
item.setAttribute('class', 'menuitem-iconic');
item.setAttribute('label', app.name);
item.setAttribute('image', 'moz-icon:file://' + app.path + '?size=16');
item.addEventListener ('command', function (event) {
if (event.button == 0) {
gExternalApplications.exec(this.path, this.args);
}
});
item.path = app.path;
item.args = app.args;
return menupopup;
}
}
};
};
gExternalApplications.init();
Alles anzeigen
Mfg.
Endor
FuchsFan
Teste mal meines:
// browsertoolbox.uc.js
(function() {
if (location != 'chrome://browser/content/browser.xhtml')
return;
try {
CustomizableUI.createWidget({
id: 'browser-toolbox-button',
type: 'custom',
defaultArea: CustomizableUI.AREA_MENUBAR,
onBuild: function(aDocument) {
var toolbaritem = aDocument.createElementNS('http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul', 'toolbarbutton');
var props = {
id: 'browser-toolbox-button',
class: 'toolbarbutton-1 chromeclass-toolbar-additional',
label: 'Browser-Werkzeuge',
tooltiptext: 'Browser-Werkzeuge',
style: 'list-style-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAAACXBIWXMAAA7EAAAOxAGVKw4bAAAAdUlEQVQokZVSwRHAIAgLPYfoXs7RCTpG53Avt7APrhaFU8gLMEEJAkEQgFbc7IxkVjt0r6Sp7VIVITumBpKt00FA2ThmjXzkfMMWO8EZFSj8LrUyjsG9b9DaJXq+qAIVxEUxtLHpaXE95dj1NcK2rmbwaGJ4Af0tIg00j/6iAAAAAElFTkSuQmCC)',
};
for (var p in props)
toolbaritem.setAttribute(p, props[p]);
toolbaritem.addEventListener('click', event => {
if (event.button == 0) {
onCommand()
}
});
return toolbaritem;
}
});
} catch(e) { };
function onCommand() {
var document = event.target.ownerDocument;
if (!document.getElementById('menu_browserToolbox')) {
let { require } = ChromeUtils.importESModule("resource://devtools/shared/loader/Loader.sys.mjs", {});
require("devtools/client/framework/devtools-browser");
};
document.getElementById('menu_browserToolbox').click();
};
})();
Alles anzeigen
Dafür hat mir Horstmann doch geholfen.
Nochmals vielen Dank dafür.
Mfg.
Endor
Hallo Horstmann .
Leider nein.
Mit dem was Speravir hier geschrieben hat, komme ich nicht klar:
Mfg.
Endor
Ah. Danke für den Hinweis.
Das mit dem Symbol hat sich erledigt.
Du hast eine externe Datei eingebunden.....
Dein Script haut bei mir gleich mehrere Fehler raus:
Uncaught NS_ERROR_FILE_NOT_FOUND: Component returned failure code: 0x80520012 (NS_ERROR_FILE_NOT_FOUND) [nsIFile.directoryEntries]
getCss file:///C:/Users/xxx/AppData/Roaming/Mozilla/Firefox/Profiles/9l0hyy5o.test/chrome/extraconfigmenu.uc.js:427
init file:///C:/Users/xxx/AppData/Roaming/Mozilla/Firefox/Profiles/9l0hyy5o.test/chrome/extraconfigmenu.uc.js:114
extraconfigmenu.uc.js:427
Uncaught NS_ERROR_FILE_NOT_FOUND: Component returned failure code: 0x80520012 (NS_ERROR_FILE_NOT_FOUND) [nsIFile.directoryEntries]
getCss file:///C:/Users/xxx/AppData/Roaming/Mozilla/Firefox/Profiles/9l0hyy5o.test/chrome/extraconfigmenu.uc.js:427
init file:///C:/Users/xxx/AppData/Roaming/Mozilla/Firefox/Profiles/9l0hyy5o.test/chrome/extraconfigmenu.uc.js:114
2 extraconfigmenu.uc.js:427
getCss file:///C:/Users/xxx/AppData/Roaming/Mozilla/Firefox/Profiles/9l0hyy5o.test/chrome/extraconfigmenu.uc.js:427
init file:///C:/Users/xxx/AppData/Roaming/Mozilla/Firefox/Profiles/9l0hyy5o.test/chrome/extraconfigmenu.uc.js:114
Uncaught TypeError: menu is null
init file:///C:/Users/xxx/AppData/Roaming/Mozilla/Firefox/Profiles/9l0hyy5o.test/chrome/extraconfigmenu.uc.js:89
<anonymous> file:///C:/Users/xxx/AppData/Roaming/Mozilla/Firefox/Profiles/9l0hyy5o.test/chrome/extraconfigmenu.uc.js:567
loadScript file:///C:/Program Files/Mozilla Firefox/userChromeJS/utilities.js:114
Alles anzeigen
Das Schaltflächensymbol wird auch nicht angezeigt.
Mfg.
Endor
FuchsFan.
Dann müsstest Du bitte Deine Version rein stellen.
Sonst wird es schwer das nachzuvollziehen.
Mfg.
Endor
Hallo Mira_Belle .
Hier meins:
// ==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 - 115*
// @charset UTF-8
// @version 0.0.4r4
// @note Fx92: getURLSpecFromFile() -> getURLSpecFromActualFile()
// @note AUTHOR_SHEET Unterstützung hinzugefügt, wichtig: Dateiendung muss .author.css sein!
// @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 ******
CSS-Ordner im Chrome-Ordner erstellen, CSS-Dateien dort ablegen - speichern.
Diejenigen, deren Dateiname mit "xul-" beginnen, diejenigen, die mit ".as.css" enden, sind AGENT_SHEET,
alle 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;
// 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;
}
const XULNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
window.UCL = {
// vFileManager: 'C:\\Programme\\totalcmd\\TOTALCMD.EXE',
vFileManager: '',
USE_UC: "UC" in window,
AGENT_SHEET: Ci.nsIStyleSheetService.AGENT_SHEET,
USER_SHEET : Ci.nsIStyleSheetService.USER_SHEET,
AUTHOR_SHEET: Ci.nsIStyleSheetService.AUTHOR_SHEET,
readCSS : {},
get disabled_list() {
let obj = [];
try {
obj = decodeURIComponent(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;
},
get CHRMFOLDER() {
let bFolder;
try {
// UserCSSLoader.CHRMFOLDER verwenden
let CHRMfolderPath = this.prefs.getCharPref("CHRMFOLDER");
bFolder = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsIFile)
bFolder.initWithPath(CHRMfolderPath);
} catch (e) {
bFolder = Services.dirsvc.get("UChrm", Ci.nsIFile);
}
if (!bFolder.exists() || !bFolder.isDirectory()) {
bFolder.create(Ci.nsIFile.DIRECTORY_TYPE, 0664);
}
delete this.CHRMFOLDER;
return this.CHRMFOLDER = bFolder;
},
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",
tooltiptext: "UserCSSLoader\n\nLinksklick: Stylesheets anzeigen\nMittelklick: Styles importieren",
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"));
const menuitem = $C('menuitem', {
label: 'CSS Datei erstellen',
accesskey: 'D'
});
menuitem.addEventListener('command', () => {
UCL.create();
})
mp.appendChild($C('menuseparator'));
mp.appendChild(menuitem);
mp.appendChild($C("menuitem", {
label: "CSS Ordner öffnen",
accesskey: "O",
oncommand: "UCL.openFolder();"
}));
mp.appendChild($C("menuitem", {
label: "Chrome Ordner öffnen",
accesskey: "c",
oncommand: "UCL.openCHRMFolder();"
}));
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" }));
if (window.__SSi == "window0") {
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", encodeURIComponent(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 = $C("menuitem", {
label : aLeafName,
id : "usercssloader-" + aLeafName,
class : "usercssloader-item " + (CSS.SHEET == this.AGENT_SHEET? "AGENT_SHEET" : CSS.SHEET == this.AUTHOR_SHEET? "AUTHOR_SHEET": "USER_SHEET"),
type : "checkbox",
autocheck : "false",
oncommand : "UCL.toggle('"+ aLeafName +"');",
onmouseup : "if (event.button == 1) event.preventDefault();",
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;
}
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();
}
},
openCHRMFolder: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.vFMParameter,this.CHRMFOLDER.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.CHRMFOLDER.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 = $C("menuitem", {
label : aLeafName,
tooltiptext : fileURL,
id : "usercssloader-" + aLeafName,
type : "checkbox",
autocheck : "false",
checked : "true",
oncommand : "this.setAttribute('checked', !(this.css.disabled = !this.css.disabled));",
onmouseup : "if(event.button == 1) event.preventDefault();",
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:
/\.author\.css$/i.test(this.leafName)?
Ci.nsIStyleSheetService.AUTHOR_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="de"><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) {
if(n == "oncommand") {
el.addEventListener('command', function(event) { Function(attr[n])(); });
}
else if(n == "onclick") {
el.addEventListener('click', function(event) { Function(attr[n])(); });
}
else if(n == "onmouseup") {
el.addEventListener('mouseup', function(event) { Function(attr[n])(); });
}
else {
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.getDate()).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
Mfg.
Endor
Zwei Gründe warum die Kompakt-Lösung nicht funktioniert hat.
Hallo BrokenHeart.
Diese Version funktioniert einwandfrei.
Vielen Dank!!
Hallo Mira_Belle.
Vielen Dank für Deine Version habe ich auch getestet.
Aber da funktionieren die Einträge in den Unterordner, zbs. Chromeordner öffen usw.
nicht. Da tut sich bei Klick nichts. Mit der Version von BrokenHeart funktioniert alles.
Trotzdem auch Dir vielen Dank für Deine Mühe.
lenny2, 2002Andreas und andere
Ich habe bei mir eine vom Autor selbst aktualisierte Version
davon hoch geladen. Ist Übersetzt.
Mfg.
Endor
Hallo Mira_Belle
Ja das ist die Version die ich hier in 134 und 135 verwende
und ich für 136 anpassen wollte.
Mfg.
Endor
Kein Problem. Lass Dir Zeit.
Hallo BrokenHeart
Habe ich auch getestet, dann geht das Script auch nicht mehr:
// ==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 - 115*
// @charset UTF-8
// @version 0.0.4r4
// @note Fx92: getURLSpecFromFile() -> getURLSpecFromActualFile()
// @note AUTHOR_SHEET Unterstützung hinzugefügt, wichtig: Dateiendung muss .author.css sein!
// @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 ******
CSS-Ordner im Chrome-Ordner erstellen, CSS-Dateien dort ablegen - speichern.
Diejenigen, deren Dateiname mit "xul-" beginnen, diejenigen, die mit ".as.css" enden, sind AGENT_SHEET,
alle 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;
// 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;
}
const XULNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
window.UCL = {
// vFileManager: 'C:\\Programme\\totalcmd\\TOTALCMD.EXE',
vFileManager: '',
USE_UC: "UC" in window,
AGENT_SHEET: Ci.nsIStyleSheetService.AGENT_SHEET,
USER_SHEET : Ci.nsIStyleSheetService.USER_SHEET,
AUTHOR_SHEET: Ci.nsIStyleSheetService.AUTHOR_SHEET,
readCSS : {},
get disabled_list() {
let obj = [];
try {
obj = decodeURIComponent(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;
},
get CHRMFOLDER() {
let bFolder;
try {
// UserCSSLoader.CHRMFOLDER verwenden
let CHRMfolderPath = this.prefs.getCharPref("CHRMFOLDER");
bFolder = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsIFile)
bFolder.initWithPath(CHRMfolderPath);
} catch (e) {
bFolder = Services.dirsvc.get("UChrm", Ci.nsIFile);
}
if (!bFolder.exists() || !bFolder.isDirectory()) {
bFolder.create(Ci.nsIFile.DIRECTORY_TYPE, 0664);
}
delete this.CHRMFOLDER;
return this.CHRMFOLDER = bFolder;
},
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",
tooltiptext: "UserCSSLoader\n\nLinksklick: Stylesheets anzeigen\nMittelklick: Styles importieren",
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: "Chrome Ordner öffnen",
accesskey: "c",
oncommand: "UCL.openCHRMFolder();"
}));
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" }));
if (window.__SSi == "window0") {
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", encodeURIComponent(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 = $C("menuitem", {
label : aLeafName,
id : "usercssloader-" + aLeafName,
class : "usercssloader-item " + (CSS.SHEET == this.AGENT_SHEET? "AGENT_SHEET" : CSS.SHEET == this.AUTHOR_SHEET? "AUTHOR_SHEET": "USER_SHEET"),
type : "checkbox",
autocheck : "false",
oncommand : "UCL.toggle('"+ aLeafName +"');",
onmouseup : "if (event.button == 1) event.preventDefault();",
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;
}
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();
}
},
openCHRMFolder: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.vFMParameter,this.CHRMFOLDER.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.CHRMFOLDER.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 = $C("menuitem", {
label : aLeafName,
tooltiptext : fileURL,
id : "usercssloader-" + aLeafName,
type : "checkbox",
autocheck : "false",
checked : "true",
oncommand : "this.setAttribute('checked', !(this.css.disabled = !this.css.disabled));",
onmouseup : "if(event.button == 1) event.preventDefault();",
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:
/\.author\.css$/i.test(this.leafName)?
Ci.nsIStyleSheetService.AUTHOR_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="de"><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) {
if(n == "oncommand") {
e1.addEventListener('command', function(event) { Function(attr[n])(); });
}
else if(n == "onclick") {
e1.addEventListener('click', function(event) { Function(attr[n])(); });
}
else {
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.getDate()).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
In dieser Version ab Zeile 671.