Tippfehler: Zeile 102-110...
So ist es und wurde soeben korrigiert.
Danke.
Tippfehler: Zeile 102-110...
So ist es und wurde soeben korrigiert.
Danke.
Du musst erst in die Adresszeile "about:config" eingeben!
Aber Sichere Dir erst das Profilverzeichnis!
Wenn Du "about:config" eingeben hast, dann in die Zeile "browser.profiles.enabled" eingeben.
Nun kannst Du den Eintrag auf "false" ändern.
Vorbereitung!
Damit der Firefox überhaupt mit JavaScript etwas anfangen kann
bedarf es einer Vorbereitung.
Hier die Erklärung was man genau machen muss:
Nur geht es ans Eingemachte!
Ich habe die userChrome.js etwas verändert!
userChrome.ignoreCache = true;
userChrome.import("*", "UChrm");
userChrome.import("scripts-Appmenu", "UChrm");
userChrome.import("userChrome", "UChrm");
Im Ordner "scripts-Appmenu" liegt mein Appscript, welches unbedingt geladen werden soll!
Im Ordner "userChrome" sind rebuild_userChrome.uc.js und userChromeJS.js.
userChromeJS.js ist von mir mit Absicht umbenannt worden, damit sie von der userChrome.js welche sich direkt im "chrome"-Verzeichnis befindet, besser unterschieden werden kann.
OK, in "chrome" habe ich noch das Verzeichnis "utils" in welchem sich die Dateien
"chrome.manifest", "userChrome.js" und "xPref.sys.mjs" befinden.
Des Weiteren gibt es noch den Ordner "scripts" der alle meine Skripte beinhaltet.
Und hier nun die von mir verwendete "userChromeJS.js"
/* :::::::: Sub-Script/Overlay Loader v3.0.79mod no bind version ::::::::::::::: */
// automatically includes all files ending in .uc.xul and .uc.js from the profile's chrome folder
// New Features:
// supports Greasemonkey-style metadata for userChrome scripts and overlays
// supports a "main" shortcut for the main browser window in include/exclude lines
// supports regexes in the include/exclude lines
// scripts without metadata will run only on the main browser window, for backwards compatibility
//
// 1.Including function of UCJS_loader.
// 2.Compatible with Fx2 and Fx3.0b5pre
// 3.Cached script data (path, leafname, regex)
// 4.Support window.userChrome_js.loadOverlay(overlay [,observer]) //
// Modified by Alice0775
//
// @version 2026/01/10 Modified by Mira Bellenbaum
// @Note Source code is available here: https://www.camp-firefox.de/forum/thema/140214/?postID=1284893#post1284893
// @version 2025/01/05 fix error handler
// @version 2025/01/04 add error handler
// @version 2025/01/03 use ChromeUtils.compileScript if async
// @version 2024/12/25 load script async if meta has @async true. nolonger use @charset
// @version 2023/09/07 remove to use nsIScriptableUnicodeConverter and AUTOREMOVEBOM
// @version 2022/03/15 fix UCJS_loader
// @version 2022/08/26 Bug 1695435 - Remove @@hasInstance for IDL interfaces in chrome context
// @version 2022/08/26 fix load sidebar
// @version 2022/04/01 remove nsIIOService
// @version 2021/08/05 fix for 92+ port Bug 1723723 - Switch JS consumers from getURLSpecFromFile to either getURLSpecFromActualFile or getURLSpecFromDir
// @version 2021/06/25 skip for in-content dialog etc.
// @version 2019/12/11 fix for 73 Bug 1601094 - Rename remaining .xul files to .xhtml in browser and Bug 1601093 - Rename remaining .xul files to .xhtml in toolkit
//
(function(){
"use strict";
var { AppConstants } = AppConstants || ChromeUtils.importESModule(
"resource://gre/modules/AppConstants.sys.mjs"
);
// -- config --
const EXCLUDE_CHROMEHIDDEN = false; //chromehiddenなwindow(popup等)ではロード: しないtrue, する[false]
const USE_0_63_FOLDER = true; //0.63のフォルダ規則を使う[true], 使わないfalse
const FORCESORTSCRIPT = (AppConstants.platform != "win") ? true : false; //強制的にスクリプトをファイル名順でソートするtrue, しない[false]
const REPLACECACHE = true; //スクリプトの更新日付によりキャッシュを更新する: true , しない:[false]
//=====================USE_0_63_FOLDER = falseの時===================
var UCJS = new Array("UCJSFiles","userContent","userMenu"); //UCJS Loader 仕様を適用 (NoScriptでfile:///を許可しておく)
var arrSubdir = new Array("","xul","TabMixPlus","withTabMixPlus", "SubScript", "UCJSFiles", "userCrome.js.0.8","userContent","userMenu"); //スクリプトはこの順番で実行される
//===================================================================
const ALWAYSEXECUTE = ['rebuild_userChrome.uc.xul', 'rebuild_userChrome.uc.js']; //常に実行するスクリプト
var INFO = true;
var BROWSERCHROME = "chrome://browser/content/browser.xhtml"; //Firfox
//"chrome://browser/content/browser.xul"; //Firfox
//var BROWSERCHROME = "chrome://navigator/content/navigator.xul"; //SeaMonkey:
// -- config --
/* USE_0_63_FOLDER true の時
* chrome直下およびchrome/xxx.uc 内の *.uc.js および *.uc.xul
* chrome/xxx.xul 内の *.uc.js , *.uc.xul および *.xul
* chrome/xxx.ucjs 内の *.uc.js は 特別に UCJS Loader 仕様を適用(NoScriptでfile:///を許可しておく)
*/
/* USE_0.63_FOLDER false の時
*[ フォルダは便宜上複数のフォルダに分けているだけで任意。 下のarrSubdirで指定する ]
*[ UCJS Loaderを適用するフォルダをUCJSで指定する ]
プロファイル-+-chrome-+-userChrome.js(このファイル)
+-*.uc.jsまたは*.uc.xul群
|
+-SubScript--------+-*.uc.jsまたは*.uc.xul群
|
+-UCJSFiles--------+-*.uc.jsまたは*.uc.xul群
| (UCJS_loaderでしか動かないもの JavaScript Version 1.7/日本語)
|
+-xul--------------+-*.xul, *.uc.xulおよび付随File
|
+-userCrome.js.0.8-+-*.uc.jsまたは*.uc.xul群 (綴りが変なのはなぜかって? )
*/
//chrome/aboutでないならスキップ
if(!/^(chrome:|about:)/i.test(location.href)) return;
if(/^(about:(blank|newtab|home))/i.test(location.href)) return;
//コモンダイアログに対するオーバーレイが今のところ無いので時間短縮のためスキップすることにした
if(location.href =='chrome://global/content/commonDialog.xul') return;
if(location.href =='chrome://global/content/commonDialog.xhtml') return;
if(location.href =='chrome://global/content/selectDialog.xhtml') return;
if(location.href =='chrome://global/content/alerts/alert.xul') return;
if(location.href =='chrome://global/content/alerts/alert.xhtml') return;
//if(/\.html?$/i.test(location.href)) return;
window.userChrome_js = {
USE_0_63_FOLDER: USE_0_63_FOLDER,
UCJS: UCJS,
arrSubdir: arrSubdir,
FORCESORTSCRIPT: FORCESORTSCRIPT,
ALWAYSEXECUTE: ALWAYSEXECUTE,
INFO: INFO,
BROWSERCHROME: BROWSERCHROME,
EXCLUDE_CHROMEHIDDEN: EXCLUDE_CHROMEHIDDEN,
REPLACECACHE: REPLACECACHE,
get hackVersion () {
delete this.hackVersion;
return this.hackVersion = "0.8";
//拡張のバージョン違いを吸収
this.baseUrl = /^(chrome:\/\/\S+\/content\/)\S+/i.test( Error().fileName).$1;
if (!/^(chrome:\/\/\S+\/content\/)\S+/i.test( Error().fileName) ){
} else if (Error().fileName.indexOf("chrome://uc_js/content/uc_js.xul") > -1 ||
"chrome://userchrome_js_cache/content/userChrome.js" == Error().fileName ){ //0.8.0+ or 0.7
return this.hackVersion = "0.8+";
} else if (Error().fileName.indexOf("chrome://browser/content/browser.xul -> ") == 0) {
return this.hackVersion = "0.8.1";
} else {
return this.hackVersion = "0.8mod";
}
},
//スクリプトデータを作成
getScripts: function(){
const Cc = Components.classes;
const Ci = Components.interfaces;
const fph = Services.io.getProtocolHandler("file").QueryInterface(Ci.nsIFileProtocolHandler);
const ds = Services.dirsvc;
var Start = new Date().getTime();
//getdir
if (this.USE_0_63_FOLDER) {
// var o = [""];
var o = ["scripts"];
this.UCJS =[];
this.arrSubdir =[];
/* var workDir = ds.get("UChrm", Ci.nsIFile);
var dir = workDir.directoryEntries;
while(dir.hasMoreElements()){
var file = dir.getNext().QueryInterface(Ci.nsIFile);
if( !file.isDirectory()) continue;
var dirName = file.leafName;
if(/(uc|xul|ucjs)$/i.test(dirName)){
o.push(dirName);
if(/ucjs$/i.test(dirName)){
this.UCJS.push(dirName);
}
}
}
*/
// Eingefügt !
// zusätzlichen Ordner "scripts" eintragen
// o.push("scripts_test");
// bis hier !
if(this.FORCESORTSCRIPT){
o.sort(cmp_name);
}
[].push.apply(this.arrSubdir, o);
}
var that = this;
var mediator = Components.classes["@mozilla.org/appshell/window-mediator;1"]
.getService(Components.interfaces.nsIWindowMediator);
if(mediator.getMostRecentWindow("navigator:browser"))
var mainWindowURL = that.BROWSERCHROME;
else if (mediator.getMostRecentWindow("mail:3pane"))
var mainWindowURL = "chrome://messenger/content/messenger.xul";
this.dirDisable = restoreState(getPref("userChrome.disable.directory", "str", "").split(','));
this.scriptDisable = restoreState(getPref("userChrome.disable.script", "str", "").split(','));
this.scripts = [];
this.overlays = [];
var findNextRe = /^\/\/ @(include|exclude)[ \t]+(\S+)/gm;
this.directory = {name:[], UCJS:[], enable:[]};
for(var i=0, len=this.arrSubdir.length; i<len; i++){
var s = [], o = [];
try{
var dir = this.arrSubdir[i]=="" ? "root" : this.arrSubdir[i];
this.directory.name.push(dir);
this.directory.UCJS.push(checkUCJS(dir));
var workDir = ds.get("UChrm", Ci.nsIFile);
workDir.append(this.arrSubdir[i]);
var files = workDir.directoryEntries.QueryInterface(Ci.nsISimpleEnumerator);
var istream = Cc["@mozilla.org/network/file-input-stream;1"].createInstance(Ci.nsIFileInputStream);
while(files.hasMoreElements()){
var file = files.getNext().QueryInterface(Ci.nsIFile);
if(/\.uc\.js$|\.uc\.xul$/i.test(file.leafName)
|| /\.xul$/i.test(file.leafName) && /\xul$/i.test(this.arrSubdir[i])) {
var script = getScriptData(readFile(file, true) ,file);
script.dir = dir;
if(/\.uc\.js$/i.test(script.filename)){
script.ucjs = checkUCJS(script.file.path);
s.push(script);
}else{
script.xul = '<?xul-overlay href=\"'+ script.url +'\"?>\n';
o.push(script);
}
}
}
}catch(e){}
if(this.FORCESORTSCRIPT){
s.sort(cmp_fname);
o.sort(cmp_fname);
}
[].push.apply(this.scripts, s);
[].push.apply(this.overlays, o);
}
this.debug('Parsing getScripts: '+((new Date()).getTime()-Start) +'msec');
//nameを比較する関数
function cmp_name(a, b) {
if(a.toLowerCase()==b.toLowerCase())
return a < b?-1:1;
else
return a.toLowerCase() < b.toLowerCase()?-1:1;
}
function cmp_fname(a, b) {
return cmp_name(a.filename, b.filename);
}
//UCJSローダ必要か
function checkUCJS(aPath){
for(var i=0,len=that.UCJS.length; i<len; i++){
if( aPath.indexOf(that.UCJS[i], 0)>-1 )
return true;
}
return false;
}
//メタデータ収集
function getScriptData(aContent,aFile){
var charset, description, async;
var header = (aContent.match(/^\/\/ ==UserScript==[ \t]*\n(?:.*\n)*?\/\/ ==\/UserScript==[ \t]*\n/m) || [""])[0];
var match, rex = { include: [], exclude: []};
while ((match = findNextRe.exec(header)))
{
rex[match[1]].push(match[2].replace(/^main$/i,mainWindowURL).replace(/\W/g, "\\$&").replace(/\\\*/g, ".*?"));
}
if( rex.include.length == 0) rex.include.push(mainWindowURL);
var exclude = rex.exclude.length > 0 ? "(?!" + rex.exclude.join("$|") + "$)" : "";
match = header.match(/\/\/ @charset\b(.+)\s*/i);
charset = "";
//try
if(match)
charset = match.length > 0 ? match[1].replace(/^\s+/,"") : "";
match = header.match(/\/\/ @async\b(.+)\s*/i);
async = "";
//try
if(match)
async = match.length > 0 ? match[1].replace(/^\s+/,"") : "";
match = header.match(/\/\/ @description\b(.+)\s*/i);
description = "";
//try
if(match)
description = match.length > 0 ? match[1].replace(/^\s+/,"") : "";
//}catch(e){}
if (description =="" || !description)
description = aFile.leafName;
var url = fph.getURLSpecFromActualFile(aFile);
return {
filename: aFile.leafName,
file: aFile,
url: url,
//namespace: "",
charset: charset,
description: description,
async: async,
//code: aContent.replace(header, ""),
regex: new RegExp("^" + exclude + "(" + (rex.include.join("|") || ".*") + ")$", "i")
}
}
//スクリプトファイル読み込み
function readFile(aFile, metaOnly){
if (typeof metaOnly == 'undefined')
metaOnly = false;
var stream = Cc["@mozilla.org/network/file-input-stream;1"].createInstance(Ci.nsIFileInputStream);
stream.init(aFile, 0x01, 0, 0);
var cvstream = Cc["@mozilla.org/intl/converter-input-stream;1"].
createInstance(Ci.nsIConverterInputStream);
cvstream.init(stream, "UTF-8", 1024, Ci.nsIConverterInputStream.DEFAULT_REPLACEMENT_CHARACTER);
var content = "", data = {};
while (cvstream.readString(4096, data)) {
content += data.value;
if (metaOnly &&
content.indexOf('// ==/UserScript==') > 0)
break;
}
cvstream.close();
return content.replace(/\r\n?/g, "\n");
}
//バイナリ読み込み
function readBinary(aFile){
var istream = Components.classes["@mozilla.org/network/file-input-stream;1"]
.createInstance(Components.interfaces.nsIFileInputStream);
istream.init(aFile, -1, -1, false);
var bstream = Components.classes["@mozilla.org/binaryinputstream;1"]
.createInstance(Components.interfaces.nsIBinaryInputStream);
bstream.setInputStream(istream);
return bstream.readBytes(bstream.available());
}
//バイナリ書き込み
function writeFile(aFile, aData){
var foStream = Components.classes["@mozilla.org/network/file-output-stream;1"]
.createInstance(Components.interfaces.nsIFileOutputStream);
// ファイル追記の際は、0x02 | 0x10 を使う
foStream.init(aFile, 0x02 | 0x08 | 0x20, parseInt(664, 8), 0); // write, create, truncate
foStream.write(aData, aData.length);
foStream.close();
return aData;
}
//prefを読み込み
function getPref(aPrefString, aPrefType, aDefault){
var xpPref = Components.classes['@mozilla.org/preferences-service;1']
.getService(Components.interfaces.nsIPrefService);
try{
switch (aPrefType){
case 'complex':
return xpPref.getComplexValue(aPrefString, Components.interfaces.nsILocalFile); break;
case 'str':
return unescape(xpPref.getCharPref(aPrefString).toString()); break;
case 'int':
return xpPref.getIntPref(aPrefString); break;
case 'bool':
default:
return xpPref.getBoolPref(aPrefString); break;
}
}catch(e){
}
return aDefault;
}
//pref文字列変換
function restoreState(a){
try{
var sd = [];
for(var i = 0,max = a.length;i < max;++i) sd[unescape(a[i])] = true;
return sd;
}
catch(e){ return []; }
}
},
getLastModifiedTime: function(aScriptFile) {
if (this.REPLACECACHE) {
return aScriptFile.lastModifiedTime;
}
return "";
},
//window.userChrome_js.loadOverlay
shutdown: false,
overlayWait:0,
overlayUrl:[],
loadOverlay: function(url, observer, doc){
window.userChrome_js.overlayUrl.push([url, observer, doc]);
if(!window.userChrome_js.overlayWait) window.userChrome_js.load(++window.userChrome_js.overlayWait);
},
load: function (){
if(!window.userChrome_js.overlayUrl.length) return --window.userChrome_js.overlayWait;
var [url, aObserver, doc] = this.overlayUrl.shift();
if (!!aObserver && typeof aObserver == 'function') {
aObserver.observe = aObserver;
}
if (!doc) doc = document;
/*if (!(doc instanceof XULDocument))
return 0;*/
var observer = {
observe:function (subject, topic, data) {
if (topic == 'xul-overlay-merged') {
//XXX We just caused localstore.rdf to be re-applied (bug 640158)
if ("retrieveToolbarIconsizesFromTheme" in window)
retrieveToolbarIconsizesFromTheme();
if (!!aObserver && typeof aObserver.observe == 'function') {
try {
aObserver.observe(subject, topic, data);
} catch(ex){
window.userChrome_js.error(url, ex);
}
}
if ('userChrome_js' in window)
window.userChrome_js.load();
}
},
QueryInterface: function(aIID){
if(!aIID.equals(Components.interfaces.nsISupports)
&& !aIID.equals(Components.interfaces.nsIObserver))
throw Components.results.NS_ERROR_NO_INTERFACE;
return this
}
};
//if (this.INFO) this.debug("document.loadOverlay: " + url);
try{
if (window.userChrome_js.shutdown) return;
doc.loadOverlay(url, observer);
} catch(ex){
window.userChrome_js.error(url, ex);
}
return 0;
},
//xulを読み込む
runOverlays: function(doc){
try {
var dochref = doc.location.href.replace(/#.*$/, "");
} catch (e) {
return;
}
var overlay;
for(var m=0,len=this.overlays.length; m<len; m++){
overlay = this.overlays[m];
if(this.ALWAYSEXECUTE.indexOf(overlay.filename) < 0
&& ( !!this.dirDisable['*']
|| !!this.dirDisable[overlay.dir]
|| !!this.scriptDisable[overlay.filename]) ) continue;
// decide whether to run the script
if(overlay.regex.test(dochref)){
if (this.INFO) this.debug("loadOverlay: " + overlay.filename);
this.loadOverlay(overlay.url + "?" + this.getLastModifiedTime(overlay.file), null, doc);
}
}
},
//uc.jsを読み込む
runScripts: function(doc){
try {
var dochref = doc.location.href.replace(/#.*$/, "");
} catch (e) {
return;
}
if (!HTMLDocument.isInstance(doc))
return;
var script, aScript, url;
const Cc = Components.classes;
const Ci = Components.interfaces;
const maxJSVersion = (function getMaxJSVersion() {
var appInfo = Components
.classes["@mozilla.org/xre/app-info;1"]
.getService(Components.interfaces.nsIXULAppInfo);
var versionChecker = Components
.classes["@mozilla.org/xpcom/version-comparator;1"]
.getService(Components.interfaces.nsIVersionComparator);
// Firefox 3.5 and higher supports 1.8.
if (versionChecker.compare(appInfo.version, "3.5") >= 0) {
return "1.8";
}
// Firefox 2.0 and higher supports 1.7.
if (versionChecker.compare(appInfo.version, "2.0") >= 0) {
return "1.7";
}
// Everything else supports 1.6.
return "1.6";
})();
for(var m=0,len=this.scripts.length; m<len; m++){
script = this.scripts[m];
if (this.ALWAYSEXECUTE.indexOf(script.filename) < 0
&& (!!this.dirDisable['*']
|| !!this.dirDisable[script.dir]
|| !!this.scriptDisable[script.filename]) ) continue;
if( !script.regex.test(dochref)) continue;
if( script.ucjs ){ //for UCJS_loader
if (this.INFO) this.debug("loadUCJSSubScript: " + script.filename);
aScript = doc.createElementNS("http://www.w3.org/1999/xhtml", "script");
aScript.type = "text/javascript";
aScript.src = script.url + "?" + this.getLastModifiedTime(script.file);
try {
doc.documentElement.appendChild(aScript);
}catch(ex) {
this.error(script.filename, ex);
}
}else{ //Not for UCJS_loader
if (this.INFO) this.debug("loadSubScript: " + script.filename);
let target = doc.defaultView;
/*
try {
if (script.charset)
Services.scriptloader.loadSubScript(
script.url + "?" + this.getLastModifiedTime(script.file),
target, script.charset);
else
Services.scriptloader.loadSubScript(
script.url + "?" + this.getLastModifiedTime(script.file),
target);
}catch(ex) {
this.error(script.filename, ex);
}
continue;
*/
if (!script.async) {
try {
if (script.charset)
Services.scriptloader.loadSubScript(
script.url + "?" + this.getLastModifiedTime(script.file),
target, script.charset);
else
Services.scriptloader.loadSubScript(
script.url + "?" + this.getLastModifiedTime(script.file),
target);
}catch(ex) {
this.error(script.filename, ex);
}
} else {
ChromeUtils.compileScript(
script.url + "?" + this.getLastModifiedTime(script.file)
).then((r) => {
r.executeInGlobal(/*global*/ target, {reportExceptions: true});
}).catch((ex) => {this.error(script.filename, ex);});
}
}
}
},
debug: function(aMsg){
Components.classes["@mozilla.org/consoleservice;1"]
.getService(Components.interfaces.nsIConsoleService)
.logStringMessage(aMsg);
},
error: function(aMsg,err){
const CONSOLE_SERVICE = Components.classes['@mozilla.org/consoleservice;1']
.getService(Components.interfaces.nsIConsoleService);
var error = Components.classes['@mozilla.org/scripterror;1']
.createInstance(Components.interfaces.nsIScriptError);
if(typeof(err) == 'object') error.init(aMsg + '\n' + err.name + ' : ' + err.message,err.fileName || null,null,err.lineNumber,null,2,err.name);
else error.init(aMsg + '\n' + err + '\n',null,null,null,null,2,null);
CONSOLE_SERVICE.logMessage(error);
}
};
//少しでも速くするためスクリプトデータの再利用
var prefObj = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefService);
try{
var pref = prefObj.getBoolPref("userChrome.enable.reuse");
}catch(e){
var pref = true;
}
var that = window.userChrome_js;
window.addEventListener("unload", function(){
that.shutdown = true;
},false);
window.xxdebug = that.debug;
//that.debug(typeof that.getScriptsDone);
if(pref){
//現在のメインウィンドウは一度もuserChrome.jsのスクリプトで初期化されていない?
if(!that.getScriptsDone){
//Firefox or Thunderbard?
var mediator = Components.classes["@mozilla.org/appshell/window-mediator;1"]
.getService(Components.interfaces.nsIWindowMediator);
if(mediator.getMostRecentWindow("navigator:browser"))
var windowType = "navigator:browser";
else if (mediator.getMostRecentWindow("mail:3pane"))
var windowType = "mail:3pane";
var enumerator = mediator.getEnumerator(windowType);
//他の身内のメインウィンドウではどうかな?
while(enumerator.hasMoreElements()) {
var win = enumerator.getNext();
//身内のメインウインドウは初期状態でない?
if(win.userChrome_js && win.userChrome_js.getScriptsDone){
//オブジェクトはたぶんこのウインドウのを複製すりゃいいんじゃぁないかな
that.UCJS = win.userChrome_js.UCJS;
that.arrSubdir = win.userChrome_js.arrSubdir;
that.scripts = win.userChrome_js.scripts;
that.overlays = win.userChrome_js.overlays;
that.dirDisable = win.userChrome_js.dirDisable;
that.scriptDisable = win.userChrome_js.scriptDisable;
that.getScriptsDone = true;
break;
}
}
}
}
if(!that.getScriptsDone){
if (that.INFO) that.debug("getScripts");
that.getScripts();
that.getScriptsDone= true;
}else{
if (that.INFO) that.debug("skip getScripts");
}
var href = location.href;
var doc = document;
//Bug 330458 Cannot dynamically load an overlay using document.loadOverlay
//until a previous overlay is completely loaded
if (that.INFO) that.debug("load " + href);
//chromehiddenならロードしない
if (location.href === that.BROWSERCHROME &&
that.EXCLUDE_CHROMEHIDDEN &&
document.documentElement.getAttribute("chromehidden") !="" )
return;
if (typeof gBrowser != undefined) {
that.runScripts(doc);
setTimeout(function(doc){that.runOverlays(doc);},0, doc);
} else {
setTimeout(function(doc){
that.runScripts(doc);
setTimeout(function(doc){that.runOverlays(doc);},0, doc);
},0, doc);
}
//Sidebar for Trunc
if(location.href != that.BROWSERCHROME) return;
window.document.addEventListener("load",
function(event){
if (!event.originalTarget.location) return;
if(/^(about:(blank|newtab|home))/i.test(event.originalTarget.location.href)) return;
if( !/^(about:|chrome:)/.test(event.originalTarget.location.href) )return;
var doc = event.originalTarget;
var href = doc.location.href;
// skip for in-content dialog etc.
if(href =='chrome://global/content/commonDialog.xhtml') return;
if(href =='chrome://global/content/selectDialog.xhtml') return;
if(href =='chrome://global/content/alerts/alert.xhtml') return;
if (that.INFO) that.debug("load Sidebar " + href);
setTimeout(function(doc){that.runScripts(doc);
setTimeout(function(doc){that.runOverlays(doc);}, 0, doc);
},0, doc);
if (href != "chrome://browser/content/web-panels.xul") return;
if (!window.document.getElementById("sidebar")) return;
var sidebarWindow = window.document.getElementById("sidebar").contentWindow;
if (sidebarWindow){
loadInWebpanel.init(sidebarWindow);
}
}
, true);
var loadInWebpanel = {
sidebarWindow: null,
init: function(sidebarWindow){
this.sidebarWindow = sidebarWindow;
this.sidebarWindow.document.getElementById("web-panels-browser").addEventListener("load", this, true);
this.sidebarWindow.addEventListener("unload", this, false);
},
handleEvent: function(event){
switch (event.type) {
case "unload":
this.uninit(event);
break;
case "load":
this.load(event);
break;
}
},
uninit: function(event){
this.sidebarWindow.document.getElementById("web-panels-browser").removeEventListener("load", this, true);
this.sidebarWindow.removeEventListener("unload", this, false);
},
load: function(event){
var doc = event.originalTarget;
var href = doc.location.href;
if( !/^chrome:/.test(href) )return;
if (that.INFO) that.debug("load Webpanel " + href);
setTimeout(function(doc){that.runScripts(doc);
setTimeout(function(doc){that.runOverlays(doc);},0, doc);
},0, doc);
}
}
})();
Alles anzeigen
und auch die von mir geänderte und verwendete "rebuild_userChrome.uc.js".
// ==UserScript==
// @name rebuild_userChrome.uc.js
// @namespace http://space.geocities.yahoo.co.jp/gl/alice0775
// @description userChrome.js Clear script cache, open new window, and go to Script Management.
// @description Comment from Mira: Open new window is hidden by CSS
// @charset utf-8
// @include main
// @compatibility Firefox 146
// @author Alice0775
// @version 2026/01/12 Modified by Mira Bellenbaum
// @Note Source code is available here: https://www.camp-firefox.de/forum/thema/140214/?postID=1284893#post1284893
// @version 2024/12/22 fix Bug 1936336 - Disallow inline event handlers
// @version 2023/09/07 remove to use nsIScriptableUnicodeConverter
// @version 2023/06/20 remove Bug 1780695 - Remove Services.jsm
// @version 2022/04/01 23:00 Convert Components.utils.import to ChromeUtils.import
// @version 2022/04/01 remove nsIIOService
// @version 2020/04/25 14:00 prevent close menu when middleclick
// Date 2019/05/21 08:30 fix 69.0a1 Bug 1534407 - Enable browser.xhtml by default, Bug 1551320 - Replace all CreateElement calls in XUL documents with CreateXULElement
// ==/UserScript==
// @Note Make sure your editor is set up correctly.
// @Note Required Sub-Script/Overlay Loader v3.0.38mod( https://github.com/alice0775/userChrome.js/blob/master/userChrome.js )
var userChromejs = {
// --- config ---
editor: (AppConstants.platform == "win")
? "C:\\Program Files\\Microsoft VS Code\\Code.exe"
: ((AppConstants.platform == "linux")
?"/usr/bin/gedit" /*"/usr/bin/xed"*/
: ""),
// --- config ---
_statusDisplay: null,
get statusDisplay() {
if (!this._statusDisplay)
this._statusDisplay = document.getElementById('status-bar') ||
document.getElementById('statusbar-display');
return this._statusDisplay;
},
_addonbar: null,
get addonbar() {
if (!this._addonbar)
this._addonbar = document.getElementById('addon-bar');
return this._addonbar;
},
handleEvent: function(event) {
switch(event.type) {
case 'dragover':
this.dragover(event);
break;
case 'drop':
this.drop(event);
break;
case 'unload':
this.uninit();
break;
}
},
createElement: function(localName, arryAttribute) {
let elm = document.createXULElement(localName);
for(let i = 0; i < arryAttribute.length; i++) {
elm.setAttribute(arryAttribute[i].attr, arryAttribute[i].value);
}
return elm;
},
init: function(){
window.addEventListener("unload",this , false);
let ref = document.getElementById("menu_preferences");
let menu = ref.parentNode.insertBefore(
this.createElement("menu",
[{attr: "id", value:"userChrome_js_menu"},
{attr: "label", value:"JavaScript-Loader-Menü"},
]), ref);
let popup = menu.appendChild(this.createElement("menupopup",
[{attr: "id", value:"userChromejs_options"},
{attr: "context", value:""}
]));
popup.appendChild(this.createElement("menuitem",
[{attr: "id", value:"userChrome_setting"},
{attr: "label", value:"Skript für jedes Fenster neuladen"},
{attr: "accesskey", value:"u"},
{attr: "type", value:"checkbox"}
]));
popup.appendChild(this.createElement("menuitem",
[{attr: "id", value:"userChrome_rebuild"},
{attr: "label", value:"Neues Fenster öffnen"},
]));
popup.appendChild(this.createElement("menuitem",
[{attr: "id", value:"userChrome_restartApp"},
{attr: "label", value:"Neustart (inkl. Script Cache leeren)"},
]));
popup.appendChild(this.createElement("menuitem",
[{attr: "id", value:"userChrome_openChrome"},
{attr: "label", value:"Chrome-Ordner öffnen"},
]));
/* menu = ref.parentNode.insertBefore(
this.createElement("menu",
[{attr: "id", value:"userChromejs_script_options_Menu"},
{attr: "label", value:"userChrome.js Scripte"},
]), ref);
popup = menu.appendChild(this.createElement("menupopup",
[{attr: "id", value:"userChromejs_script_options"}
]));
*/
document.getElementById('userChrome_setting').addEventListener("command", () => userChromejs.setting());
document.getElementById('userChrome_rebuild').addEventListener("command", () => userChromejs.rebuild());
document.getElementById('userChrome_restartApp').addEventListener("command", () => userChromejs.restartApp());
document.getElementById('userChrome_openChrome').addEventListener("command", () => {new Components.Constructor("@mozilla.org/file/local;1","nsIFile", "initWithPath")(Services.dirsvc.get("UChrm", Components.interfaces.nsIFile).path).reveal()});
if (AppConstants.platform == "linux")
userChromejs.onpopup();
if ("nsDragAndDrop" in window && this.statusDisplay) {
this.statusDisplay.addEventListener('dragover',function(event){nsDragAndDrop.dragOver(event,userChromejs.dndObserver);},true);
this.statusDisplay.addEventListener('dragdrop',function(event){nsDragAndDrop.drop(event,userChromejs.dndObserver);},true);
} else if(this.addonbar) {
this.addonbar.addEventListener('dragover', this ,true);
this.addonbar.addEventListener('drop', this ,true);
}
this.addPrefListener(userChromejs.readLaterPrefListener); // 登録処理
document.getElementById("menu_ToolsPopup").addEventListener("popupshowing", function(event) {if (event.target == this) userChromejs.onpopup(event);}, false);
},
uninit: function(){
if ("nsDragAndDrop" in window && this.statusDisplay) {
this.statusDisplay.removeEventListener('dragover',function(event){nsDragAndDrop.dragOver(event,userChromejs.dndObserver);},true);
this.statusDisplay.removeEventListener('dragdrop',function(event){nsDragAndDrop.drop(event,userChromejs.dndObserver);},true);
} else if(this.addonbar) {
this.addonbar.removeEventListener('dragover', this ,true);
this.addonbar.removeEventListener('drop', this ,true);
}
this.removePrefListener(userChromejs.readLaterPrefListener); // 登録解除
},
dragover: function(event) {
var dragService = Cc["@mozilla.org/widget/dragservice;1"]
.getService(Ci.nsIDragService);
var dragSession = dragService.getCurrentSession();
var supportedTypes = ["text/x-moz-url", "text/unicode", "application/x-moz-file"];
for (let type of supportedTypes) {
if (event.dataTransfer.types.contains(type)) {
var data = event.dataTransfer.getData(type);
var url = (/^\s*(.*?)\s*$/m.test(data))
? RegExp.$1 : null;
if (/(\.uc\.js|\.uc\.xul|\.uc\.xul\.txt)$/.test(url)) {
dragSession.canDrop = true;
event.preventDefault();
return;
}
}
}
},
drop: function(event) {
var dragService = Cc["@mozilla.org/widget/dragservice;1"]
.getService(Ci.nsIDragService);
var dragSession = dragService.getCurrentSession();
var supportedTypes = ["text/x-moz-url", "text/unicode", "application/x-moz-file"];
for (let type of supportedTypes) {
if (event.dataTransfer.types.contains(type)) {
var data = event.dataTransfer.getData(type);
this.dndObserver.onDrop(event, {data: data}, dragSession);
return;
}
}
},
dragDropSecurityCheck: function dragDropSecurityCheck(event, dragSession, url) {
if (!url)
return false;
// need to do a security check to make
// sure the source document can load the dropped URI.
url = url.replace(/^\s*|\s*$/g, '');
if (url.indexOf('chrome://') == 0 || url.indexOf('file://') == 0)
return url;
// urlSecurityCheck
try {
urlSecurityCheck(url, gBrowser.contentPrincipal, Ci.nsIScriptSecurityManager.DISALLOW_INHERIT_PRINCIPAL);
}
catch(e) {
event.stopPropagation();
//throw 'Drop of ' + url + ' denied.';
return false;
}
return url;
},
dndObserver: {
getSupportedFlavours : function () {
var flavours = new FlavourSet();
flavours.appendFlavour("text/x-moz-url");
flavours.appendFlavour("text/unicode");
flavours.appendFlavour("application/x-moz-file");
return flavours;
},
onDragOver: function (evt,flavour,session){},
onDrop: function (evt,dropdata,session){
var fname;
evt.stopPropagation();
evt.preventDefault();
if (dropdata.data!=""){
//ステータスバーの左1/3にドロップしたか
var target = evt.target;
while(target){
if(target == userChromejs.statusDisplay ||
target == userChromejs.addonbar)
break;
target = target.parentNode;
}
if(!target) return;
if(evt.screenX > target.boxObject.screenX + target.boxObject.width/3) return;
//saveFolderModokiが必要
if(!saveFolderModoki) return;
//ドロップしたurl
var url = (/^\s*(.*?)\s*$/m.test(dropdata.data))?RegExp.$1:null;
//保存ホルダ nsIFile
var folder = Services.dirsvc.get("UChrm", Components.interfaces.nsIFile);
//デフォルトのファイル名
if(/(.*)\n?(.*)?/m.test(dropdata.data) )
fname = RegExp.$2?RegExp.$2:"";
//データスキームか
if(/(^data:text\/javascript(;.*)?,?)|(^data:application\/x-javascript(;.*)?,?)/.test(url)){
// urlSecurityCheck は saveFolderModoki.directSaveLinkで実施している
saveScript(url, fname, folder);
}else{
//リンクか
if(!/(^h?ttps?:\/\/)|(^ftp:\/\/)/.test(url)) return;
if (/^h?.?.p(s?):(.+)$/i.test(url)){
url = "http" + RegExp.$1 + ':' + RegExp.$2;
if(!RegExp.$2) return null;
fname = url.match(/.+\/(.+)$/)[1];
}
fname = fname.replace(/\.uc\.xul\.txt$/,'.uc.xul');
//スクリプトファイルか?
if(/(\.uc\.js|\.uc\.xul|\.uc\.xul\.txt)$/.test(url)){
if (typeof gBrowser.dragDropSecurityCheck == 'function')
gBrowser.dragDropSecurityCheck(evt, session, url);
else {
userChromejs.dragDropSecurityCheck(evt, session, url)
}
saveScript(url, fname, folder);
}
}
}
function saveScript(url, fname, folder){
//ファイルピッカによりnsIFile決定
var aFile = getFolderPath(fname, folder)
if(!aFile) return;
//フォルダパス
folder = aFile.path.replace(aFile.leafName,'');
//nsILocalFileのフォルダ
var aFolder = saveFolderModoki.initFileWithPath(folder);
if(!aFolder) return;
//リンクを保存
saveFolderModoki.directSaveLink(null, url, aFile.leafName, gBrowser.currentURI, aFolder);
}
function getFolderPath(fname, folder){
//ファイルピッカにより保存先決定
var fp = Components.classes['@mozilla.org/filepicker;1']
.createInstance(Components.interfaces.nsIFilePicker);
fp.init(window, "Save script As", fp.modeSave);
fp.appendFilter("Script Files","*.uc.js; *.uc.xul");
if(/\.uc\.js$/.test(fname)){
fp.defaultExtension = "uc.js";
fp.defaultString = fname;
}else if(/\.uc\.xul$/.test(fname)){
fp.defaultExtension = "uc.xul";
fp.defaultString = fname;
}else{
fp.defaultExtension = "uc.js";
fp.defaultString = fname + ".uc.js";
}
fp.displayDirectory = folder;
if ( fp.show() == fp.returnCancel || !fp.file ) return;
//nsIFile
return fp.file;
}
}
},
rebuild: function(){
var flag = this.getPref("userChrome.enable.reuse",'bool',true);
this.setPref("userChrome.enable.reuse",'bool',false);
setTimeout(function(){OpenBrowserWindow();}, 0);
setTimeout(function(self,flag){self.setPref("userChrome.enable.reuse",'bool',flag);},2000,this,flag);
},
setting: function(){
var flag = this.getPref("userChrome.enable.reuse",'bool',true);
this.setPref("userChrome.enable.reuse",'bool',!flag);
},
onpopup: function(){
var menu;
var flag = this.getPref("userChrome.enable.reuse",'bool',true);
var menuitem = document.getElementById('userChrome_setting');
menuitem.setAttribute('checked', !flag);
var menupopup = document.getElementById("userChromejs_options");
// document.getElementById("userChromejs_script_options");
for(var i = 4, len = menupopup.childNodes.length; i < len; i++){
menupopup.removeChild(menupopup.lastChild);
}
/* var menuseparator = document.createXULElement('menuseparator'); */
/* menupopup.appendChild(menuseparator); */
menuitem = document.createXULElement('menuitem');
menuitem.setAttribute('label','Alle UserScripte aktivieren/deaktivieren');
menuitem.setAttribute('type','checkbox');
menuitem.setAttribute('checked', !userChrome_js.dirDisable['*']);
menuitem.dirName = '*';
menupopup.appendChild(menuitem);
menuitem.addEventListener('command', () => userChromejs.chgDirStat("*"));
menuitem.addEventListener('click', (event) => userChromejs.clickDirMenuitem(event,true));
for(var j = 0, lenj = userChrome_js.arrSubdir.length; j < lenj; j++){
var dirName = userChrome_js.arrSubdir[j] == "" ? "root" : userChrome_js.arrSubdir[j];
var flg = false;
for(var i = 0, len = userChrome_js.scripts.length; i < len; i++){
var script = userChrome_js.scripts[i];
if(script.dir != dirName) continue;
flg = true;
break;
}
if(!flg){
for(var i = 0, len = userChrome_js.overlays.length; i < len; i++){
var script = userChrome_js.overlays[i];
if(script.dir != dirName) continue;
flg = true;
break;
}
}
if(!flg) continue;
menu = document.createXULElement('menu');
menu.setAttribute('label','Alle UserScripte in ' +'"'+ (dirName=="root"?"":dirName) +'"');
menu.addEventListener('click', (event) => userChromejs.clickDirMenu(event));
if(userChrome_js.dirDisable[dirName])
menu.setAttribute('style', 'font-style:italic;');
menu.dirName = dirName;
menupopup = document.createXULElement('menupopup');
menuitem = document.createXULElement('menuitem');
menuitem.setAttribute('label','Alle UserScripte in ' +'"'+ (dirName=="root"?"":dirName) +'"' + ' aktivieren/deaktivieren');
menuitem.setAttribute('type', 'checkbox');
menuitem.setAttribute('checked', !userChrome_js.dirDisable[dirName]);
menuitem.dirName = dirName;
menupopup.appendChild(menuitem);
menuitem.addEventListener('command', () => userChromejs.chgDirStat(this.dirName));
menuitem.addEventListener('click', (event) => userChromejs.clickDirMenuitem(event));
menuseparator = document.createXULElement('menuseparator');
menupopup.appendChild(menuseparator);
var flg = false;
for(var i = 0, len = userChrome_js.scripts.length; i < len; i++){
var script = userChrome_js.scripts[i];
if(script.dir != dirName) continue;
flg = true;
menuitem = document.createXULElement('menuitem');
menuitem.setAttribute('label',script.filename);
menuitem.setAttribute('type','checkbox');
menuitem.setAttribute('autocheck','false');
menuitem.setAttribute('checked',!userChrome_js.scriptDisable[script.filename] );
if(script.description)
menuitem.setAttribute('tooltiptext',script.description);
menuitem.script = script;
menupopup.appendChild(menuitem);
menuitem.addEventListener('command', () => userChromejs.chgScriptStat(this.script.filename));
menuitem.addEventListener('click', (event) => userChromejs.clickScriptMenu(event));
menuitem.addEventListener('mouseup', (event) => {if(event.button == 1) event.preventDefault()});
}
for(var i = 0, len = userChrome_js.overlays.length; i < len; i++){
var script = userChrome_js.overlays[i];
if(script.dir != dirName) continue;
if(flg){
menuseparator = document.createXULElement('menuseparator');
menupopup.appendChild(menuseparator);
}
flg = false;
menuitem = document.createXULElement('menuitem');
menuitem.setAttribute('label',script.filename);
menuitem.setAttribute('type','checkbox');
menuitem.setAttribute('autocheck','false');
menuitem.setAttribute('checked',!userChrome_js.scriptDisable[script.filename] );
if(script.description)
menuitem.setAttribute('tooltiptext',script.description);
menuitem.script = script;
menupopup.appendChild(menuitem);
menuitem.addEventListener('command', () => userChromejs.chgScriptStat(this.script.filename));
menuitem.addEventListener('click', (event) => userChromejs.clickScriptMenu(event));
menuitem.addEventListener('mouseup', (event) => {if(event.button == 1) event.preventDefault()});
}
menu.appendChild(menupopup);
menupopup = document.getElementById("userChromejs_options");
menupopup.appendChild(menu);
}
},
clickDirMenu: function(event){
if(event.button == 1 || event.button == 2){
event.stopPropagation();
event.preventDefault();
userChromejs.chgDirStat(event.target.dirName);
if(event.target.firstChild && event.target.firstChild.firstChild)
event.target.firstChild.firstChild.setAttribute('checked',!userChrome_js.dirDisable[event.target.dirName] );
if(!!userChrome_js.dirDisable[event.target.dirName])
event.target.setAttribute('style', 'font-style:italic;');
else
event.target.removeAttribute('style');
}
},
clickDirMenuitem: function(event,stop){
if(event.button == 1 || event.button == 2){
event.stopPropagation();
event.preventDefault();
userChromejs.chgDirStat(event.target.dirName);
event.target.setAttribute('checked',!userChrome_js.dirDisable[event.target.dirName] );
if(!stop && !!userChrome_js.dirDisable[event.target.dirName])
event.target.parentNode.parentNode.setAttribute('style', 'font-style:italic;');
else
event.target.parentNode.parentNode.removeAttribute('style');
}
},
clickScriptMenu: function(event){
if(event.button==1){
event.stopPropagation();
event.preventDefault();
userChromejs.chgScriptStat(event.target.script.filename);
event.target.setAttribute('checked',!userChrome_js.scriptDisable[event.target.script.filename] );
}else if(event.button==2){
event.stopPropagation();
event.preventDefault();
this.launchEditor(event.target.script);
}
},
launchEditor: function(aScript){
var editor = this.editor;
var path = Services.io.newURI(aScript.url)
.QueryInterface(Ci.nsIFileURL).file.path;
var appfile = Components.classes['@mozilla.org/file/local;1'].createInstance(Components.interfaces.nsIFile);
appfile.initWithPath(editor);
var process = Components.classes['@mozilla.org/process/util;1'].createInstance(Components.interfaces.nsIProcess);
process.init(appfile);
process.runw(false, [path], 1, {});
},
chgDirStat: function(adirName){
var s = userChromejs.getPref("userChrome.disable.directory", "str", "");
if(!userChrome_js.dirDisable[adirName]){
s = (s+',').replace(adirName+',','') + adirName+',';
}else{
s = (s+',').replace(adirName+',','');
}
s = s.replace(/,,/g,',').replace(/^,/,'');
userChromejs.setPref("userChrome.disable.directory", "str", s);
userChrome_js.dirDisable = this.restoreState(s.split(','));
},
chgScriptStat: function(afilename){
var s = userChromejs.getPref("userChrome.disable.script", "str", "");
if(!userChrome_js.scriptDisable[afilename]){
s = (s+',').replace(afilename+',','') + afilename+',';
}else{
s = (s+',').replace(afilename+',','');
}
s = s.replace(/,,/g,',').replace(/^,/,'');
userChromejs.setPref("userChrome.disable.script", "str", s);
userChrome_js.scriptDisable = this.restoreState(s.split(','));
},
restoreState: function (arr){
var disable = [];
for(var i = 0,len = arr.length; i < len; i++)
disable[arr[i]] = true;
return disable;
},
//prefを読み込み
getPref: function(aPrefString, aPrefType, aDefault){
var xpPref = Services.prefs;
try {
switch (aPrefType){
case 'complex':
return xpPref.getComplexValue(aPrefString, Components.interfaces.nsIFile); break;
case 'str':
return unescape(xpPref.getCharPref(aPrefString).toString()); break;
case 'int':
return xpPref.getIntPref(aPrefString); break;
case 'bool':
default:
return xpPref.getBoolPref(aPrefString); break;
}
} catch(e) {}
return aDefault;
},
//prefを書き込み
setPref: function(aPrefString, aPrefType, aValue){
var xpPref = Services.prefs;
try {
switch (aPrefType){
case 'complex':
return xpPref.setComplexValue(aPrefString, Components.interfaces.nsIFile, aValue); break;
case 'str':
return xpPref.setCharPref(aPrefString, escape(aValue)); break;
case 'int':
aValue = parseInt(aValue);
return xpPref.setIntPref(aPrefString, aValue); break;
case 'bool':
default:
return xpPref.setBoolPref(aPrefString, aValue); break;
}
} catch(e) {}
return null;
},
// 監視を開始する
addPrefListener: function(aObserver) {
try {
var pbi = Services.prefs;
pbi.addObserver(aObserver.domain, aObserver, false);
} catch(e) {}
},
// 監視を終了する
removePrefListener: function(aObserver) {
try {
var pbi = Services.prefs;
pbi.removeObserver(aObserver.domain, aObserver);
} catch(e) {}
},
readLaterPrefListener:{
domain : 'userChrome.disable',
//"userChrome.disable"という名前の設定が変更された場合全てで処理を行う
observe : function(aSubject, aTopic, aPrefstring) {
if (aTopic == 'nsPref:changed') {
// 設定が変更された時の処理
setTimeout(function(){
var s = userChromejs.getPref("userChrome.disable.directory", "str", "");
userChrome_js.dirDisable = userChromejs.restoreState(s.split(','));
s = userChromejs.getPref("userChrome.disable.script", "str", "");
userChrome_js.scriptDisable = userChromejs.restoreState(s.split(','));
}, 0);
}
}
},
restartApp: function() {
if ("BrowserUtils" in window && typeof BrowserUtils.restartApplication == "function") {
Components.classes["@mozilla.org/xre/app-info;1"]
.getService(Components.interfaces.nsIXULRuntime).invalidateCachesOnRestart();
BrowserUtils.restartApplication();
return;
}
const appStartup = Components.classes["@mozilla.org/toolkit/app-startup;1"]
.getService(Components.interfaces.nsIAppStartup);
// Notify all windows that an application quit has been requested.
var os = Components.classes["@mozilla.org/observer-service;1"]
.getService(Components.interfaces.nsIObserverService);
var cancelQuit = Components.classes["@mozilla.org/supports-PRBool;1"]
.createInstance(Components.interfaces.nsISupportsPRBool);
os.notifyObservers(cancelQuit, "quit-application-requested", null);
// Something aborted the quit process.
if (cancelQuit.data)
return;
// Notify all windows that an application quit has been granted.
os.notifyObservers(null, "quit-application-granted", null);
// Enumerate all windows and call shutdown handlers
var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
.getService(Components.interfaces.nsIWindowMediator);
var windows = wm.getEnumerator(null);
var win;
while (windows.hasMoreElements()) {
win = windows.getNext();
if (("tryToClose" in win) && !win.tryToClose())
return;
}
let XRE = Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULRuntime);
if (typeof XRE.invalidateCachesOnRestart == "function")
XRE.invalidateCachesOnRestart();
appStartup.quit(appStartup.eRestart | appStartup.eAttemptQuit);
}
}
userChromejs.init();
//メニューが長くなりすぎるので, あまり使わないメニューを"userChrome.jsの各スクリプトの設定"の下に移動させる
var userChromejsScriptOptionsMenu = {
//あまり使わないメニューのリスト
/* menues: [
"GrabScroll_optionsMenu",
"Patch_XULrubySupportMenu",
"menutabTooltip",
"PipeliningToggle",
"linkInNewTabForSpecifiedPageToolMenu",
"ieviewModokiTool",
"linkloadInBackgroundToolMenu",
"SaveFolderToolsMenu",
"ucjs_copysysinfo-menu",
],
*/
interval: 500, //0.5秒間隔
maxcount: 50, //最大50回までトライ
count: 0,
timer: null,
run: function() {
//DOMの構築が完了するのを待ってからメニューを移動させる(5秒間隔で最大50回までトライ)
this.timer = setInterval(function(self){
if (++self.count > self.maxcount || self.moveMenu())
clearInterval(self.timer);
}, this.interval, this);
},
moveMenu: function(){
var menupopup = document.getElementById('userChromejs_script_options');
if (!menupopup)
return false;
var i = 0;
while (i < this.menues.length) {
var menu = document.getElementById(this.menues[i])
if (menu) {
setTimeout(function(menupopup, menu){menupopup.appendChild(menu);}, 100, menupopup, menu);
this.menues.splice(i, 1);
continue;
}
i++;
}
return this.menues.length == 0 ? true : false;
},
}
userChromejsScriptOptionsMenu.run();
/* Newly added by Mira Bellenbaum */
/* This code controls the appearance of the menu, adds icons, and controls spacing. */
(function () {
let ProfileDirectory = PathUtils.toFileURI(PathUtils.join(PathUtils.profileDir, 'chrome', 'icons'));
let ButtonIcon = "stop_smal_red.svg";
let sss = Components.classes["@mozilla.org/content/style-sheet-service;1"].getService(Components.interfaces.nsIStyleSheetService);
let uri = Services.io.newURI("data:text/css;charset=utf-8," + encodeURIComponent(`
/* Das userCrome.js Scripte Menü ausblenden */
#userChromejs_script_options_Menu {
display: none !important;
}
/* ^ kann eventuell entfernt werden ^ */
/* Neues Fenter öffnen, Neustert & Chrome-Ordner öffnen ausblenden */ /*
#userChrome_rebuild,
#userChrome_restartApp,
#userChrome_openChrome {
display: none !important;
}
/* Symbol vor dem JavaScript-Loader-Menü */
#userChrome_js_menu {
background-image: url("${ProfileDirectory}/js.svg") !important;
background-repeat: no-repeat !important;
padding-left: 36px;
}
/* Skript für jedes Fenster neuladen */
#userChrome_setting:not([checked="true"]) {
background-image: url("${ProfileDirectory}/${ButtonIcon}") !important;
background-repeat: no-repeat !important;
background-position: 11px 5px !important;
background-size: 16px 16px !important;
}
/* Menüpopup "Alle UserScripte aktivieren/deaktivieren */
#userChromejs_options {
margin-left: 5px !important;
}
/* Menüpopup "Alle UserScripte in "scripts" aktivieren/deaktivieren */
#userChromejs_options > menu[label='Alle UserScripte in "scripts"'] > menupopup[hasbeenopened="true"] {
margin-left: 5px !important;
}
/* Neues Fenster öffnen ausrichten */
#userChrome_rebuild {
padding-left: 12px !important;
}
/* Neustart (inkl. Script Cache leeren) ausrichten */
#userChrome_restartApp {
padding-left: 12px !important;
}
/* Chrome-Ordner öffnen ausrichten */
#userChrome_openChrome {
padding-left: 12px !important;
}
/* Alle UserScripte aktivieren/deaktivieren */
#userChromejs_options > menuitem[label='Alle UserScripte aktivieren/deaktivieren']:not([checked="true"]) {
background-image: url("${ProfileDirectory}/${ButtonIcon}") !important;
background-repeat: no-repeat !important;
background-position: 11px 5px !important;
background-size: 16px 16px !important;
}
#userChromejs_options > menuitem[checked="false"] {
background-repeat: no-repeat !important;
padding-left: 12px !important;
}
/* Alle UserScripte in "scripts" */
#userChromejs_options > menu[label='Alle UserScripte in "scripts"'] {
padding-left: 12px !important;
background-image: url("chrome://global/skin/icons/menu-check.svg") !important;
background-repeat: no-repeat !important;
background-position: 12px 5px !important;
background-size: 16px 16px !important;
}
#userChromejs_options > menu[style="font-style:italic;"] {
background-image: url("${ProfileDirectory}/${ButtonIcon}") !important;
background-repeat: no-repeat !important;
background-position: 11px 5px !important;
background-size: 16px 16px !important;
}
/* Alle UerScripte in "scripts" aktivieren/deaktivieren */
#userChromejs_options > menu[label='Alle UserScripte in "scripts"'] > menupopup[hasbeenopened="true"] > menuitem:not([checked="true"]){
background-image: url("${ProfileDirectory}/${ButtonIcon}") !important;
background-repeat: no-repeat !important;
background-position: 12px 5px !important;
background-size: 16px 16px !important;
}
#userChromejs_options > menu[label='Alle UserScripte in "scripts"'] > menupopup[hasbeenopened="true"] > menuitem[checked="false"]{
padding-left: 12px !important;
}
`), null, null);
sss.loadAndRegisterSheet(uri, sss.AGENT_SHEET);
})();
Alles anzeigen
Anmerkung ![]()
Der eine oder andere wird wohl einen anderen Editor verwenden,
daher wäre es klug, in Zeile 27 den Pfad zum Editor anzupassen.
Ich habe teilweise die Menüs umbenannt!
In Zeile 102 bis Zeile 110 das Menü auskommentiert!
Und auch in Zeile 610 bis Zeile 631 den dazu gehörenden Code!
Wer fragen dazu hat, bitte melden, oder siehe #48 bis #51
Tja, und zu guter Letzt habe ich ab Zeile 655 CSS eingefügt!
Für die Symbole müsst ihr eigene verwenden, oder eben "meine".
Oh, das habe ich doch tatsächlich irgendwie übersehen!
...und das gleich 2x:
Wohl eher die abgeschalteten Meldungen in deinem Windows...
Ich habe keine Ahnung wie das passieren konnte.
Genauer lesen, Tabs öfters mal erneuern, keine Ahnung.
Aber ich Danke Euch.
Oh, das habe ich doch tatsächlich irgendwie übersehen!
Jetzt funktioniert es!
Der Fehler?
Man sollte die Benachrichtigungen im BS nicht abschalten![]()
Denn daran lag es.
// ==UserScript==
// @name BackupProfile.uc.js
// @namespace BackupProfile.github.com
// @description Schaltfläche zum Sichern des Firefoxprofils
// @charset UTF-8
// @author ywzhaiqi、defpt
// @version v2026.01.14
// @note Vorlage Script von ywzhaiqi (+ Mischung aus diversen Varianten aus dem Fuchsforum 1.11.21)
// @note Sicherungsdatei enthaelt auch Profilname
// @note Von Mira Bellenbaum angepasst
// Source https://www.camp-firefox.de/forum/thema/133557/?postID=1285002#post1285002
// @reviewURL http://bbs.kafan.cn/thread-1758785-1-1.html
/* ----------------------------------------------------------------------------------- */
/* Zu beachten ist, dass die Grafiken sich im richtigen Ordner befinden müssen */
/* %appdata%\Mozilla\Firefox\Profiles\"Profilname"\chrome\icons */
/* ----------------------------------------------------------------------------------- */
(function () {
CustomizableUI.createWidget({
id : "backupProfile-button",
defaultArea : CustomizableUI.AREA_NAVBAR,
label : "Profilsicherung",
tooltiptext : "Sichern der aktuellen Konfiguration",
onClick: function(){
// Speicherort - Ordner festlegen - Sichern funktioniert nur wenn Speicherort- bzw. Ordner vorhanden ist!!
var path = "E:\\Firefox-Sicherung\\";
// var path = "";
// Ausschlussliste
var excludes = 'bookmarkbackups *cache* crashes fftmp *healthreport* minidumps safebrowsing *webapps* saved-telemetry-pings *thumbnails* *session* *Telemetry* *hotfix* *.sqlite-shm *.sqlite-wal *.bak parent.lock blocklist.xml content-prefs.sqlite directoryLinks.json mimeTypes.rdf compatibility.ini parent.lock formhistory.sqlite';
if (!path) {
var nsIFilePicker = Ci.nsIFilePicker;
var FP = Cc['@mozilla.org/filepicker;1'].createInstance(nsIFilePicker);
FP.init(window, 'Sicherungspfad wählen', nsIFilePicker.modeGetFolder);
if (FP.show() == nsIFilePicker.returnOK) {
path = FP.file.path;
} else {
return false;
}
}
excludes = excludes.replace(/\./g, '\\.').replace(/\*/g, '.*').replace(/\s+/g, '|');
excludes = new RegExp(excludes, 'i');
var zw = Cc['@mozilla.org/zipwriter;1'].createInstance(Ci.nsIZipWriter);
var pr = {PR_RDONLY: 0x01, PR_WRONLY: 0x02, PR_RDWR: 0x04, PR_CREATE_FILE: 0x08, PR_APPEND: 0x10, PR_TRUNCATE: 0x20, PR_SYNC: 0x40, PR_EXCL: 0x80};
var fu = ChromeUtils.importESModule('resource://gre/modules/FileUtils.sys.mjs').FileUtils;
var dir = new FileUtils.File(PathUtils.join(PathUtils.profileDir,[]));
let d = new Date();
d = d.getDate().toString().padStart(2, '0') + '.' + (d.getMonth() + 1).toString().padStart(2, '0') + '.' + d.getFullYear() + ' - ' + d.getHours().toString().padStart(2, '0') + '\u2236' + d.getMinutes().toString().padStart(2, '0');
// Die folgende Zeile formt den Archivnamen
var archiveName = 'Profil Andreas ' + AppConstants.MOZ_APP_VERSION_DISPLAY + ' - ' + d + '.zip'; /* 'd' ersetzt 'localnow' */
var xpi = fu.File(path + '\\' + archiveName);
zw.open(xpi, pr.PR_RDWR | pr.PR_CREATE_FILE | pr.PR_TRUNCATE);
var dirArr = [dir];
for (var i=0; i<dirArr.length; i++) {
var dirEntries = dirArr[i].directoryEntries;
while (dirEntries.hasMoreElements()) {
var entry = dirEntries.getNext().QueryInterface(Ci.nsIFile);
if (entry.path == xpi.path) {
continue;
}
if (entry.isDirectory()) {
dirArr.push(entry);
}
var relPath = entry.path.replace(dirArr[0].path, '');
if (relPath.match(excludes)) {
continue;
}
var saveInZipAs = relPath.substr(1);
saveInZipAs = saveInZipAs.replace(/\\/g,'/');
// Konfigurationsdateien können gesperrt werden
try {
zw.addEntryFile(saveInZipAs, Ci.nsIZipWriter.COMPRESSION_FASTEST, entry, false);
} catch (e) {}
}
}
zw.close();
alert('Die aktuelle Konfiguration wurde als:\n'+ archiveName +'\ngesichert in:\n' + path);
function alert(aString, aTitle) {
// Cc['@mozilla.org/alerts-service;1'].getService(Ci.nsIAlertsService).showAlertNotification("", aTitle, aString, false, "", null);
// ^ Ersetzt duch :
const AlertNotification = Components.Constructor(
'@mozilla.org/alert-notification;1',
'nsIAlertNotification',
'initWithObject'
);
Cc['@mozilla.org/alerts-service;1'].getService(Ci.nsIAlertsService).showAlert(
new AlertNotification({ title: aTitle, text: aString })
);
// ^
}
},
});
let ProfilePath = PathUtils.toFileURI(PathUtils.join(PathUtils.profileDir, 'chrome', 'icons')); // Pfad zum Profilordner und gleich in den entsprechenden Unterordner
let ButtonIcon = "backup.svg"; // Name & Dateiendung des anzuzeigenden Symbols!
let sss = Components.classes["@mozilla.org/content/style-sheet-service;1"].getService(Components.interfaces.nsIStyleSheetService);
let uri = Services.io.newURI("data:text/css;charset=utf-8," + encodeURIComponent(`
#backupProfile-button { list-style-image: url("${ProfilePath}/${ButtonIcon}") }
#backupProfile-button.toolbarbutton-1.chromeclass-toolbar-additional image.toolbarbutton-icon {
width: 32px !important;
height: 32px !important;
fill: #faea00 !important;
fill-opacity: 1 !important;
}
`), null, null);
sss.loadAndRegisterSheet(uri, sss.AUTHOR_SHEET);
})();
Alles anzeigen
Jetzt bin ich mit meinem Latein am Ende![]()
Ich habe das Script aus #348 getestet, so wie das aus #349.
Ich bekomme bei keinem von beiden eine Meldung wie von 2002Andreas in #349 gezeigt.
Beide Scripte legen ein BackUp an, diese Funktion ist gegeben.
Kann es sein, dass das irgendeine Einstellung im Firefox verhindert?
Ich habe das hier mal getestet.
Es wird kein Button angezeigt, auch kein Platzhalter. Ich habe ein eigenes Icon eingetragen, und auch den Pfad zum Sicherungsordner angepasst
PS:
Allerdings nutze ich so ein Skript auch nicht.
Merkwürdig.
Button ist bei mir vorhanden, Sicherung funktioniert auch.
Aber diese Statusmeldung, die erscheint bei mir nicht!
Denke, werde mal jene Version ausprobieren, die auch lenny nutzt!
uchst du nun ganz was spezielles, oder ist bei dir überhaupt keine Benachrichtigung zu sehen?
Diese Meldung erscheint bei mir überhaupt nicht!
Weswegen ich mir mit dem Promt beholfen habe.
Boersenfeger Ich verstehe Deinen Kommentar nicht!
Ich habe in Zeile 26 doch den "Pfad" festgetackert! => var path = "E:\\Firefox-Sicherung\\";
Und in Zeile 88 steht auch alert('Die aktuelle Konfiguration wurde als:\n'+ archiveName +'\ngesichert in:\n' + path); !
Und auch hier hilft Dir uBlock weiter.
Ich habe da solche Animationen nicht!
Oh ha![]()
Da hat mich lenny aber an was erinnert.
Ich nutze ebenfalls das Script, aber habe die Version von BrokenHeart etwas abgeändert!
Der Sicherungspfad ist fest vorgegeben und ich habe folgende Korrektur vor genommen.
Gelöscht => ChromeUtils.importESModule("moz-src:///browser/components/customizableui/CustomizableUI.sys.mjs");
// ==UserScript==
// @name BackupProfile.uc.js
// @namespace BackupProfile.github.com
// @description Schaltfläche zum Sichern des Firefoxprofils
// @charset UTF-8
// @author ywzhaiqi、defpt
// @version v2018.01.10
// @note Vorlage Script von ywzhaiqi (+ Mischung aus diversen Varianten aus dem Fuchsforum 1.11.21)
// @note Sicherungsdatei enthaelt auch Profilname
// @reviewURL http://bbs.kafan.cn/thread-1758785-1-1.html
// Source https://www.camp-firefox.de/forum/thema/133557/?postID=1232903#post1232903
/* ----------------------------------------------------------------------------------- */
/* Zu beachten ist, dass die Grafiken sich im richtigen Ordner befinden müssen */
/* %appdata%\Mozilla\Firefox\Profiles\"Profilname"\chrome\icons */
/* ----------------------------------------------------------------------------------- */
(function () {
CustomizableUI.createWidget({
id : "backupProfile-button",
defaultArea : CustomizableUI.AREA_NAVBAR,
label : "Profilsicherung",
tooltiptext : "Sichern der aktuellen Konfiguration",
onClick: function(){
// Speicherort - Ordner festlegen - Sichern funktioniert nur wenn Speicherort- bzw. Ordner vorhanden ist!!
var path = "E:\\Firefox-Sicherung\\";
// var path = "";
// Ausschlussliste
var excludes = 'bookmarkbackups *cache* crashes fftmp *healthreport* minidumps safebrowsing *webapps* saved-telemetry-pings *thumbnails* *session* *Telemetry* *hotfix* *.sqlite-shm *.sqlite-wal *.bak parent.lock blocklist.xml content-prefs.sqlite directoryLinks.json mimeTypes.rdf compatibility.ini parent.lock formhistory.sqlite';
if (!path) {
var nsIFilePicker = Ci.nsIFilePicker;
var FP = Cc['@mozilla.org/filepicker;1'].createInstance(nsIFilePicker);
FP.init(window, 'Sicherungspfad wählen', nsIFilePicker.modeGetFolder);
if (FP.show() == nsIFilePicker.returnOK) {
path = FP.file.path;
} else {
return false;
}
}
excludes = excludes.replace(/\./g, '\\.').replace(/\*/g, '.*').replace(/\s+/g, '|');
excludes = new RegExp(excludes, 'i');
var zw = Cc['@mozilla.org/zipwriter;1'].createInstance(Ci.nsIZipWriter);
var pr = {PR_RDONLY: 0x01, PR_WRONLY: 0x02, PR_RDWR: 0x04, PR_CREATE_FILE: 0x08, PR_APPEND: 0x10, PR_TRUNCATE: 0x20, PR_SYNC: 0x40, PR_EXCL: 0x80};
var fu = ChromeUtils.importESModule('resource://gre/modules/FileUtils.sys.mjs').FileUtils;
var dir = new FileUtils.File(PathUtils.join(PathUtils.profileDir,[]));
let d = new Date();
d = d.getDate().toString().padStart(2, '0') + '.' + (d.getMonth() + 1).toString().padStart(2, '0') + '.' + d.getFullYear() + ' - ' + d.getHours().toString().padStart(2, '0') + '\u2236' + d.getMinutes().toString().padStart(2, '0');
// Die folgende Zeile formt den Archivnamen
var archiveName = 'Profil Andreas ' + AppConstants.MOZ_APP_VERSION_DISPLAY + ' - ' + d + '.zip'; /* 'd' ersetzt 'localnow' */
var xpi = fu.File(path + '\\' + archiveName);
zw.open(xpi, pr.PR_RDWR | pr.PR_CREATE_FILE | pr.PR_TRUNCATE);
var dirArr = [dir];
for (var i=0; i<dirArr.length; i++) {
var dirEntries = dirArr[i].directoryEntries;
while (dirEntries.hasMoreElements()) {
var entry = dirEntries.getNext().QueryInterface(Ci.nsIFile);
if (entry.path == xpi.path) {
continue;
}
if (entry.isDirectory()) {
dirArr.push(entry);
}
var relPath = entry.path.replace(dirArr[0].path, '');
if (relPath.match(excludes)) {
continue;
}
var saveInZipAs = relPath.substr(1);
saveInZipAs = saveInZipAs.replace(/\\/g,'/');
// Konfigurationsdateien können gesperrt werden
try {
zw.addEntryFile(saveInZipAs, Ci.nsIZipWriter.COMPRESSION_FASTEST, entry, false);
} catch (e) {}
}
}
zw.close();
alert('Die aktuelle Konfiguration wurde als:\n'+ archiveName +'\ngesichert in:\n' + path);
function alert(aString, aTitle) {
// Cc['@mozilla.org/alerts-service;1'].getService(Ci.nsIAlertsService).showAlertNotification("", aTitle, aString, false, "", null);
// ^ Ersetzt duch :
const AlertNotification = Components.Constructor(
'@mozilla.org/alert-notification;1',
'nsIAlertNotification',
'initWithObject'
);
Cc['@mozilla.org/alerts-service;1'].getService(Ci.nsIAlertsService).showAlert(
new AlertNotification({ title: aTitle, text: aString })
);
// ^
}
let ProfilePath = PathUtils.toFileURI(PathUtils.join(PathUtils.profileDir, 'chrome', 'icons')); // Pfad zum Profilordner und gleich in den entsprechenden Unterordner
let ButtonIcon = "backup.svg"; // Name & Dateiendung des anzuzeigenden Symbols!
let sss = Components.classes["@mozilla.org/content/style-sheet-service;1"].getService(Components.interfaces.nsIStyleSheetService);
let uri = Services.io.newURI("data:text/css;charset=utf-8," + encodeURIComponent(`
#backupProfile-button { list-style-image: url("${ProfilePath}/${ButtonIcon}") }
#backupProfile-button.toolbarbutton-1.chromeclass-toolbar-additional image.toolbarbutton-icon {
width: 32px !important;
height: 32px !important;
fill: #faea00 !important;
fill-opacity: 1 !important;
}
`), null, null);
sss.loadAndRegisterSheet(uri, sss.AUTHOR_SHEET);
// #ffe10f // #fdeb4c
})();
Alles anzeigen
Auch mir fehlt irgendwie eine Meldung, dass die Sicherung erfolgreich beendet ist.
Ich habe mir notdürftig ein Promt gebastelt! Gefällt mir aber nicht wirklich![]()
function alert(aString, aTitle) {
let prompts = Services.prompt;
prompts.alert(
window,
aTitle || "BackUp des Profils abgeschlossen",
aString
);
}
Mir würde ein Popup oder ähnliches besser gefallen und wenn ich das aussehen dann auch noch per CSS beeinflussen könnte,
das wäre Mega!
Kann mir da jemand helfen?
wenn es doof läuft, ist so ein Button einfach weg und die Fehlersuche geht los.
Ja genau das selbe dachte ich mir auch eben.
Mfg.
Endor
Und wirklich viel Code ist es auch nicht wirklich, der da gelöscht werden würde.
Zum Testen habe ich jene Passagen mal auskommentiert.
Werde das mal beobachten, wenn alles stabil läuft und nichts Komisches passiert,
wirds zum WE eine kleine Anleitung und die nötigen Dateien geben.
Danke für's testen.
Ich denke, ich lasse für's erste die Finger vom Code und blende nur den Menüeintrag per CSS aus.
Skripte, bzw. deren Funktionen werden ja auch nur dann dorthin verschoben, wenn die mehrere Bedingungen erfüllen,
wenn es doof läuft, ist so ein Button einfach weg und die Fehlersuche geht los.
Danke Endor .
Jetzt verstehe ich![]()
Also, wenn man da z.b. die ID eines Ausführbaren Scripts einträgt, z.B. eines "Buttons" oder eines zusätzlichen "Menüs",
dann wird es dorthin verschoben, also von z.B. der Adressleiste oder der Symbolleiste, da hin!
Jetzt bin ich ernsthaft am überlegen, ob ich diese Funktion komplett aus dem Script werfen soll,
denn ich habe für selten genutzte "Buttons" zum einen, danke
@Horstmann eine eigene kleine Sidebar und weitere Funktionen
verbergen sich in "meinem" Appmenü.
Oder soll ich den Code unberührt lassen und nur den Menüeintrag per CSS ausblenden?
Mh.
var userChromejsScriptOptionsMenu = {
//あまり使わないメニューのリスト
menues: [
"GrabScroll_optionsMenu",
"Patch_XULrubySupportMenu",
"menutabTooltip",
"PipeliningToggle",
"linkInNewTabForSpecifiedPageToolMenu",
"ieviewModokiTool",
"linkloadInBackgroundToolMenu",
"SaveFolderToolsMenu",
"ucjs_copysysinfo-menu",
"AppMenuButton",
],
Alles anzeigen
Wieder gelöscht und er ist an seinem normalen Platz![]()
Himmel, Herr Gott, hatte noch einen Bug entdeckt, bis ich diesen Fehler beseitigen konnte,
da ist ja Kinder kriegen einfacher!
Eine Frage hätte ich noch an meine Spezies! Endor @Horstmann FuchsFan milupo & 2002Andreas
Wozu ist das Menü "userChrome.js Scripte" mit der id="userChromejs_script_options_Menu" da?
Bei mir ist es leer, es wird absolut nichts angezeigt!
Ich steige da im Code einfach nicht durch.
Deshalb habe ich es bei mir einfach per CSS ausgeblendet, den Code wollte ich dann doch nicht entfernen.
Was für'ne Geburt!
Erst ein mal ein ganz
liches DANKE an Endor,
@Horstmann, FuchsFan, milupo & 2002Andreas.
Ihr habt mir sehr weitergeholfen und ich habe mal wieder mit den Browserwerkzeugen hantieren dürfen.
Eure Kommentare, Hinweise und Codebeispiele haben mich inspiriert und irgendwann hatte ich dann
auch mal eine Lösung.
Hier nun das passende CSS zu meiner Version der "rebuild_userChrome.uc.js".
Das CSS habe ich ganz bewusst in das JavaScript integriert.
/* Symbol vor dem JavaScript-Loader-Menü */
#userChrome_js_menu {
background-image: url("${ProfileDirectory}/js.svg") !important;
padding-left: 36px;
}
/* Menüpopup "Alle UserScripte aktivieren/deaktivieren */
#userChromejs_options {
margin-left: 5px !important;
}
/* Menüpopup "Alle UserScripte aktivieren/deaktivieren */
#userChromejs_options {
margin-left: 5px !important;
}
/* Menüpopup "Alle UserScripte in "scripts" aktivieren/deaktivieren */
#userChromejs_options > menu:nth-child(6) > menupopup:nth-child(4) {
margin-left: 5px !important;
}
/* Alle UserScripte aktivieren/deaktivieren */
#userChromejs_options > menuitem:not([checked="true"]) {
background-image: url("${ProfileDirectory}/${ButtonIcon}") !important;
background-repeat: no-repeat !important;
background-position: 11px 5px !important;
background-size: 16px 16px !important;
}
#userChromejs_options > menuitem[checked="false"] {
padding-left: 12px !important;
}
/* Alle UserScripte in "scripts" */
#userChromejs_options > menu[label='Alle UserScripte in "scripts"'] {
padding-left: 12px !important;
background-image: url("chrome://global/skin/icons/menu-check.svg") !important;
background-repeat: no-repeat !important;
background-position: 12px 5px !important;
background-size: 16px 16px !important;
}
#userChromejs_options > menu[style="font-style:italic;"] {
background-image: url("${ProfileDirectory}/${ButtonIcon}") !important;
background-repeat: no-repeat !important;
background-position: 11px 5px !important;
background-size: 16px 16px !important;
}
/* Alle UerScripte in "scripts" aktivieren/deaktivieren */
#userChromejs_options > menu[label='Alle UserScripte in "scripts"'] > menupopup[hasbeenopened="true"] > menuitem:not([checked="true"]){
background-image: url("${ProfileDirectory}/${ButtonIcon}") !important;
background-repeat: no-repeat !important;
background-position: 12px 5px !important;
background-size: 16px 16px !important;
}
#userChromejs_options > menu[label='Alle UserScripte in "scripts"'] > menupopup[hasbeenopened="true"] > menuitem[checked="false"]{
padding-left: 12px !important;
}
Alles anzeigen
Nun funktioniert wirklich alles, so wie ich mir das vorgestellt habe.
Werde mich im Laufe der Woche drann machen und die Dateien von Coderesten zu befreien
und den einen oder anderen Kommentar noch hinzufügen.
Denke, werde bis spätestens nächstes Wochenende dann alles hier veröffentlichen können
und auch noch einmal eine kleine Erklärung dazu abgeben zu können.
@Horstmann Sorry, hatte nur kurz reingeschaut
und Deinen Kommentar nicht als Frage nach dem Code aufgefasst!
Hier mal der vorläufige Code für die "rebuild_userChrome.uc.js".
var userChromejs = {
// --- config ---
editor: (AppConstants.platform == "win")
// ? "C:\\Program Files\\Notepad++\\notepad++.exe"
? "C:\\Program Files\\Microsoft VS Code\\Code.exe"
: ((AppConstants.platform == "linux")
?"/usr/bin/gedit" /*"/usr/bin/xed"*/
: ""),
// --- config ---
_statusDisplay: null,
get statusDisplay() {
if (!this._statusDisplay)
this._statusDisplay = document.getElementById('status-bar') ||
document.getElementById('statusbar-display');
return this._statusDisplay;
},
_addonbar: null,
get addonbar() {
if (!this._addonbar)
this._addonbar = document.getElementById('addon-bar');
return this._addonbar;
},
handleEvent: function(event) {
switch(event.type) {
case 'dragover':
this.dragover(event);
break;
case 'drop':
this.drop(event);
break;
case 'unload':
this.uninit();
break;
}
},
createElement: function(localName, arryAttribute) {
let elm = document.createXULElement(localName);
for(let i = 0; i < arryAttribute.length; i++) {
elm.setAttribute(arryAttribute[i].attr, arryAttribute[i].value);
}
return elm;
},
init: function(){
window.addEventListener("unload",this , false);
let ref = document.getElementById("menu_preferences");
let menu = ref.parentNode.insertBefore(
this.createElement("menu",
[{attr: "id", value:"userChrome.js_menu"},
{attr: "label", value:"JavaScript-Loader-Menü"},
/*{attr: "accesskey", value:"u"}*/
]), ref);
let popup = menu.appendChild(this.createElement("menupopup",
[{attr: "id", value:"userChromejs_options"},
/*{attr: "onpopupshowing", value:"userChromejs.onpopup()"},*/
{attr: "context", value:""}
]));
popup.appendChild(this.createElement("menuitem",
[{attr: "id", value:"userChrome_setting"},
{attr: "label", value:"Skript für jedes Fenster neuladen"},
{attr: "accesskey", value:"u"},
/*{attr: "oncommand", value:"userChromejs.setting();"},*/
{attr: "type", value:"checkbox"}
]));
popup.appendChild(this.createElement("menuitem",
[{attr: "id", value:"userChrome_rebuild"},
{attr: "label", value:"userChrome.js/Neues Fenster neu erstellen"},
{attr: "accesskey", value:"x"},
/*{attr: "oncommand", value:"userChromejs.rebuild();"}*/
]));
popup.appendChild(this.createElement("menuitem",
[{attr: "id", value:"userChrome_restartApp"},
{attr: "label", value:"Browser neustarten"},
{attr: "accesskey", value:"r"},
/*{attr: "oncommand", value:"userChromejs.restartApp();"}*/
]));
popup.appendChild(this.createElement("menuitem",
[{attr: "id", value:"userChrome_openChrome"},
{attr: "label", value:"chrome Ordner öffnen"},
{attr: "accesskey", value:"h"},
/*{attr: "oncommand", value:'new Components.Constructor("@mozilla.org/file/local;1","nsIFile", "initWithPath")(Services.dirsvc.get("UChrm", Components.interfaces.nsIFile).path).reveal();'}*/
]));
menu = ref.parentNode.insertBefore(
this.createElement("menu",
[{attr: "id", value:"userChromejs_script_options_Menu"},
{attr: "label", value:"userChrome.js Scripte"},
{attr: "accesskey", value:"s"}
]), ref);
popup = menu.appendChild(this.createElement("menupopup",
[{attr: "id", value:"userChromejs_script_options"}
]));
document.getElementById('userChrome_setting').addEventListener("command", () => userChromejs.setting());
document.getElementById('userChrome_rebuild').addEventListener("command", () => userChromejs.rebuild());
document.getElementById('userChrome_restartApp').addEventListener("command", () => userChromejs.restartApp());
document.getElementById('userChrome_openChrome').addEventListener("command", () => {new Components.Constructor("@mozilla.org/file/local;1","nsIFile", "initWithPath")(Services.dirsvc.get("UChrm", Components.interfaces.nsIFile).path).reveal()});
if (AppConstants.platform == "linux")
userChromejs.onpopup();
if ("nsDragAndDrop" in window && this.statusDisplay) {
this.statusDisplay.addEventListener('dragover',function(event){nsDragAndDrop.dragOver(event,userChromejs.dndObserver);},true);
this.statusDisplay.addEventListener('dragdrop',function(event){nsDragAndDrop.drop(event,userChromejs.dndObserver);},true);
} else if(this.addonbar) {
this.addonbar.addEventListener('dragover', this ,true);
this.addonbar.addEventListener('drop', this ,true);
}
this.addPrefListener(userChromejs.readLaterPrefListener); // 登録処理
document.getElementById("menu_ToolsPopup").addEventListener("popupshowing", function(event) {if (event.target == this) userChromejs.onpopup(event);}, false);
},
uninit: function(){
if ("nsDragAndDrop" in window && this.statusDisplay) {
this.statusDisplay.removeEventListener('dragover',function(event){nsDragAndDrop.dragOver(event,userChromejs.dndObserver);},true);
this.statusDisplay.removeEventListener('dragdrop',function(event){nsDragAndDrop.drop(event,userChromejs.dndObserver);},true);
} else if(this.addonbar) {
this.addonbar.removeEventListener('dragover', this ,true);
this.addonbar.removeEventListener('drop', this ,true);
}
this.removePrefListener(userChromejs.readLaterPrefListener); // 登録解除
},
dragover: function(event) {
var dragService = Cc["@mozilla.org/widget/dragservice;1"]
.getService(Ci.nsIDragService);
var dragSession = dragService.getCurrentSession();
var supportedTypes = ["text/x-moz-url", "text/unicode", "application/x-moz-file"];
for (let type of supportedTypes) {
if (event.dataTransfer.types.contains(type)) {
var data = event.dataTransfer.getData(type);
var url = (/^\s*(.*?)\s*$/m.test(data))
? RegExp.$1 : null;
if (/(\.uc\.js|\.uc\.xul|\.uc\.xul\.txt)$/.test(url)) {
dragSession.canDrop = true;
event.preventDefault();
return;
}
}
}
},
drop: function(event) {
var dragService = Cc["@mozilla.org/widget/dragservice;1"]
.getService(Ci.nsIDragService);
var dragSession = dragService.getCurrentSession();
var supportedTypes = ["text/x-moz-url", "text/unicode", "application/x-moz-file"];
for (let type of supportedTypes) {
if (event.dataTransfer.types.contains(type)) {
var data = event.dataTransfer.getData(type);
this.dndObserver.onDrop(event, {data: data}, dragSession);
return;
}
}
},
dragDropSecurityCheck: function dragDropSecurityCheck(event, dragSession, url) {
if (!url)
return false;
// need to do a security check to make
// sure the source document can load the dropped URI.
url = url.replace(/^\s*|\s*$/g, '');
if (url.indexOf('chrome://') == 0 || url.indexOf('file://') == 0)
return url;
// urlSecurityCheck
try {
urlSecurityCheck(url, gBrowser.contentPrincipal, Ci.nsIScriptSecurityManager.DISALLOW_INHERIT_PRINCIPAL);
}
catch(e) {
event.stopPropagation();
//throw 'Drop of ' + url + ' denied.';
return false;
}
return url;
},
dndObserver: {
getSupportedFlavours : function () {
var flavours = new FlavourSet();
flavours.appendFlavour("text/x-moz-url");
flavours.appendFlavour("text/unicode");
flavours.appendFlavour("application/x-moz-file");
return flavours;
},
onDragOver: function (evt,flavour,session){},
onDrop: function (evt,dropdata,session){
var fname;
evt.stopPropagation();
evt.preventDefault();
if (dropdata.data!=""){
//ステータスバーの左1/3にドロップしたか
var target = evt.target;
while(target){
if(target == userChromejs.statusDisplay ||
target == userChromejs.addonbar)
break;
target = target.parentNode;
}
if(!target) return;
if(evt.screenX > target.boxObject.screenX + target.boxObject.width/3) return;
//saveFolderModokiが必要
if(!saveFolderModoki) return;
//ドロップしたurl
var url = (/^\s*(.*?)\s*$/m.test(dropdata.data))?RegExp.$1:null;
//保存ホルダ nsIFile
var folder = Services.dirsvc.get("UChrm", Components.interfaces.nsIFile);
//デフォルトのファイル名
if(/(.*)\n?(.*)?/m.test(dropdata.data) )
fname = RegExp.$2?RegExp.$2:"";
//データスキームか
if(/(^data:text\/javascript(;.*)?,?)|(^data:application\/x-javascript(;.*)?,?)/.test(url)){
// urlSecurityCheck は saveFolderModoki.directSaveLinkで実施している
saveScript(url, fname, folder);
}else{
//リンクか
if(!/(^h?ttps?:\/\/)|(^ftp:\/\/)/.test(url)) return;
if (/^h?.?.p(s?):(.+)$/i.test(url)){
url = "http" + RegExp.$1 + ':' + RegExp.$2;
if(!RegExp.$2) return null;
fname = url.match(/.+\/(.+)$/)[1];
}
fname = fname.replace(/\.uc\.xul\.txt$/,'.uc.xul');
//スクリプトファイルか?
if(/(\.uc\.js|\.uc\.xul|\.uc\.xul\.txt)$/.test(url)){
if (typeof gBrowser.dragDropSecurityCheck == 'function')
gBrowser.dragDropSecurityCheck(evt, session, url);
else {
userChromejs.dragDropSecurityCheck(evt, session, url)
}
saveScript(url, fname, folder);
}
}
}
function saveScript(url, fname, folder){
//ファイルピッカによりnsIFile決定
var aFile = getFolderPath(fname, folder)
if(!aFile) return;
//フォルダパス
folder = aFile.path.replace(aFile.leafName,'');
//nsILocalFileのフォルダ
var aFolder = saveFolderModoki.initFileWithPath(folder);
if(!aFolder) return;
//リンクを保存
saveFolderModoki.directSaveLink(null, url, aFile.leafName, gBrowser.currentURI, aFolder);
}
function getFolderPath(fname, folder){
//ファイルピッカにより保存先決定
var fp = Components.classes['@mozilla.org/filepicker;1']
.createInstance(Components.interfaces.nsIFilePicker);
fp.init(window, "Save script As", fp.modeSave);
fp.appendFilter("Script Files","*.uc.js; *.uc.xul");
if(/\.uc\.js$/.test(fname)){
fp.defaultExtension = "uc.js";
fp.defaultString = fname;
}else if(/\.uc\.xul$/.test(fname)){
fp.defaultExtension = "uc.xul";
fp.defaultString = fname;
}else{
fp.defaultExtension = "uc.js";
fp.defaultString = fname + ".uc.js";
}
fp.displayDirectory = folder;
if ( fp.show() == fp.returnCancel || !fp.file ) return;
//nsIFile
return fp.file;
}
}
},
rebuild: function(){
var flag = this.getPref("userChrome.enable.reuse",'bool',true);
this.setPref("userChrome.enable.reuse",'bool',false);
setTimeout(function(){OpenBrowserWindow();}, 0);
setTimeout(function(self,flag){self.setPref("userChrome.enable.reuse",'bool',flag);},2000,this,flag);
},
setting: function(){
var flag = this.getPref("userChrome.enable.reuse",'bool',true);
this.setPref("userChrome.enable.reuse",'bool',!flag);
},
onpopup: function(event){
var menu;
var flag = this.getPref("userChrome.enable.reuse",'bool',true);
var menuitem = document.getElementById('userChrome_setting');
menuitem.setAttribute('checked', !flag);
var menupopup = document.getElementById("userChromejs_options");
for(var i = 4, len = menupopup.childNodes.length; i < len; i++){
menupopup.removeChild(menupopup.lastChild);
}
/* var menuseparator = document.createXULElement('menuseparator'); */
/* menupopup.appendChild(menuseparator); */
menuitem = document.createXULElement('menuitem');
// menuitem.setAttribute('label','userCrome.js Aktivieren/Deaktivieren');
menuitem.setAttribute('label','Alle UserScripte aktivieren/deaktivieren');
//menuitem.setAttribute('oncommand','userChromejs.chgDirStat("*");');
//menuitem.setAttribute('onclick','userChromejs.clickDirMenuitem(event,true);');
menuitem.setAttribute('type','checkbox');
menuitem.setAttribute('checked', !userChrome_js.dirDisable['*']);
menuitem.dirName = '*';
menupopup.appendChild(menuitem);
menuitem.addEventListener('command', () => userChromejs.chgDirStat("*"));
menuitem.addEventListener('click', (event) => userChromejs.clickDirMenuitem(event,true));
for(var j = 0, lenj = userChrome_js.arrSubdir.length; j < lenj; j++){
var dirName = userChrome_js.arrSubdir[j] == "" ? "root" : userChrome_js.arrSubdir[j];
var flg = false;
for(var i = 0, len = userChrome_js.scripts.length; i < len; i++){
var script = userChrome_js.scripts[i];
if(script.dir != dirName) continue;
flg = true;
break;
}
if(!flg){
for(var i = 0, len = userChrome_js.overlays.length; i < len; i++){
var script = userChrome_js.overlays[i];
if(script.dir != dirName) continue;
flg = true;
break;
}
}
if(!flg) continue;
menu = document.createXULElement('menu');
// menu.setAttribute('label','chrome/' + (dirName=="root"?"":dirName) );
menu.setAttribute('label','Alle UserScripte in ' +'"'+ (dirName=="root"?"":dirName) +'"');
menu.addEventListener('click', (event) => userChromejs.clickDirMenu(event));
//menu.setAttribute('onclick','userChromejs.clickDirMenu(event);');
if(userChrome_js.dirDisable[dirName])
menu.setAttribute('style', 'font-style:italic;');
menu.dirName = dirName;
menupopup = document.createXULElement('menupopup');
//menupopup.setAttribute('onpopupshowing','event.stopPropagation();');
menuitem = document.createXULElement('menuitem');
// menuitem.setAttribute('label','chrome/' + (dirName=="root"?"":dirName) + ' Aktivieren/Deaktivieren Scripte Chromeordner');
menuitem.setAttribute('label','Alle UserScripte in ' +'"'+ (dirName=="root"?"":dirName) +'"' + ' aktivieren/deaktivieren');
//menuitem.setAttribute('oncommand', 'userChromejs.chgDirStat(this.dirName);');
//menuitem.setAttribute('onclick','userChromejs.clickDirMenuitem(event);');
menuitem.setAttribute('type', 'checkbox');
menuitem.setAttribute('checked', !userChrome_js.dirDisable[dirName]);
menuitem.dirName = dirName;
menupopup.appendChild(menuitem);
menuitem.addEventListener('command', () => userChromejs.chgDirStat(this.dirName));
menuitem.addEventListener('click', (event) => userChromejs.clickDirMenuitem(event));
menuseparator = document.createXULElement('menuseparator');
menupopup.appendChild(menuseparator);
var flg = false;
for(var i = 0, len = userChrome_js.scripts.length; i < len; i++){
var script = userChrome_js.scripts[i];
if(script.dir != dirName) continue;
flg = true;
menuitem = document.createXULElement('menuitem');
menuitem.setAttribute('label',script.filename);
//menuitem.setAttribute('oncommand','userChromejs.chgScriptStat(this.script.filename);');
//menuitem.setAttribute('onclick','userChromejs.clickScriptMenu(event);');
//menuitem.setAttribute('onmouseup','if(event.button == 1) event.preventDefault();');
menuitem.setAttribute('type','checkbox');
menuitem.setAttribute('autocheck','false');
menuitem.setAttribute('checked',!userChrome_js.scriptDisable[script.filename] );
if(script.description)
menuitem.setAttribute('tooltiptext',script.description);
menuitem.script = script;
menupopup.appendChild(menuitem);
menuitem.addEventListener('command', () => userChromejs.chgScriptStat(this.script.filename));
menuitem.addEventListener('click', (event) => userChromejs.clickScriptMenu(event));
menuitem.addEventListener('mouseup', (event) => {if(event.button == 1) event.preventDefault()});
}
for(var i = 0, len = userChrome_js.overlays.length; i < len; i++){
var script = userChrome_js.overlays[i];
if(script.dir != dirName) continue;
if(flg){
menuseparator = document.createXULElement('menuseparator');
menupopup.appendChild(menuseparator);
}
flg = false;
menuitem = document.createXULElement('menuitem');
menuitem.setAttribute('label',script.filename);
//menuitem.setAttribute('oncommand','userChromejs.chgScriptStat(this.script.filename);');
//menuitem.setAttribute('onclick','userChromejs.clickScriptMenu(event);');
//menuitem.setAttribute('onmouseup','if(event.button == 1) event.preventDefault();');
menuitem.setAttribute('type','checkbox');
menuitem.setAttribute('autocheck','false');
menuitem.setAttribute('checked',!userChrome_js.scriptDisable[script.filename] );
if(script.description)
menuitem.setAttribute('tooltiptext',script.description);
menuitem.script = script;
menupopup.appendChild(menuitem);
menuitem.addEventListener('command', () => userChromejs.chgScriptStat(this.script.filename));
menuitem.addEventListener('click', (event) => userChromejs.clickScriptMenu(event));
menuitem.addEventListener('mouseup', (event) => {if(event.button == 1) event.preventDefault()});
}
menu.appendChild(menupopup);
menupopup = document.getElementById("userChromejs_options");
menupopup.appendChild(menu);
}
},
clickDirMenu: function(event){
if(event.button == 1 || event.button == 2){
event.stopPropagation();
event.preventDefault();
userChromejs.chgDirStat(event.target.dirName);
if(event.target.firstChild && event.target.firstChild.firstChild)
event.target.firstChild.firstChild.setAttribute('checked',!userChrome_js.dirDisable[event.target.dirName] );
if(!!userChrome_js.dirDisable[event.target.dirName])
event.target.setAttribute('style', 'font-style:italic;');
else
event.target.removeAttribute('style');
}
},
clickDirMenuitem: function(event,stop){
if(event.button == 1 || event.button == 2){
event.stopPropagation();
event.preventDefault();
userChromejs.chgDirStat(event.target.dirName);
event.target.setAttribute('checked',!userChrome_js.dirDisable[event.target.dirName] );
if(!stop && !!userChrome_js.dirDisable[event.target.dirName])
event.target.parentNode.parentNode.setAttribute('style', 'font-style:italic;');
else
event.target.parentNode.parentNode.removeAttribute('style');
}
},
clickScriptMenu: function(event){
if(event.button==1){
event.stopPropagation();
event.preventDefault();
userChromejs.chgScriptStat(event.target.script.filename);
event.target.setAttribute('checked',!userChrome_js.scriptDisable[event.target.script.filename] );
}else if(event.button==2){
event.stopPropagation();
event.preventDefault();
this.launchEditor(event.target.script);
}
},
launchEditor: function(aScript){
var editor = this.editor;
var path = Services.io.newURI(aScript.url)
.QueryInterface(Ci.nsIFileURL).file.path;
var appfile = Components.classes['@mozilla.org/file/local;1'].createInstance(Components.interfaces.nsIFile);
appfile.initWithPath(editor);
var process = Components.classes['@mozilla.org/process/util;1'].createInstance(Components.interfaces.nsIProcess);
process.init(appfile);
process.runw(false, [path], 1, {});
},
chgDirStat: function(adirName){
var s = userChromejs.getPref("userChrome.disable.directory", "str", "");
if(!userChrome_js.dirDisable[adirName]){
s = (s+',').replace(adirName+',','') + adirName+',';
}else{
s = (s+',').replace(adirName+',','');
}
s = s.replace(/,,/g,',').replace(/^,/,'');
userChromejs.setPref("userChrome.disable.directory", "str", s);
userChrome_js.dirDisable = this.restoreState(s.split(','));
},
chgScriptStat: function(afilename){
var s = userChromejs.getPref("userChrome.disable.script", "str", "");
if(!userChrome_js.scriptDisable[afilename]){
s = (s+',').replace(afilename+',','') + afilename+',';
}else{
s = (s+',').replace(afilename+',','');
}
s = s.replace(/,,/g,',').replace(/^,/,'');
userChromejs.setPref("userChrome.disable.script", "str", s);
userChrome_js.scriptDisable = this.restoreState(s.split(','));
},
restoreState: function (arr){
var disable = [];
for(var i = 0,len = arr.length; i < len; i++)
disable[arr[i]] = true;
return disable;
},
//prefを読み込み
getPref: function(aPrefString, aPrefType, aDefault){
var xpPref = Services.prefs;
try {
switch (aPrefType){
case 'complex':
return xpPref.getComplexValue(aPrefString, Components.interfaces.nsIFile); break;
case 'str':
return unescape(xpPref.getCharPref(aPrefString).toString()); break;
case 'int':
return xpPref.getIntPref(aPrefString); break;
case 'bool':
default:
return xpPref.getBoolPref(aPrefString); break;
}
} catch(e) {}
return aDefault;
},
//prefを書き込み
setPref: function(aPrefString, aPrefType, aValue){
var xpPref = Services.prefs;
try {
switch (aPrefType){
case 'complex':
return xpPref.setComplexValue(aPrefString, Components.interfaces.nsIFile, aValue); break;
case 'str':
return xpPref.setCharPref(aPrefString, escape(aValue)); break;
case 'int':
aValue = parseInt(aValue);
return xpPref.setIntPref(aPrefString, aValue); break;
case 'bool':
default:
return xpPref.setBoolPref(aPrefString, aValue); break;
}
} catch(e) {}
return null;
},
// 監視を開始する
addPrefListener: function(aObserver) {
try {
var pbi = Services.prefs;
pbi.addObserver(aObserver.domain, aObserver, false);
} catch(e) {}
},
// 監視を終了する
removePrefListener: function(aObserver) {
try {
var pbi = Services.prefs;
pbi.removeObserver(aObserver.domain, aObserver);
} catch(e) {}
},
readLaterPrefListener:{
domain : 'userChrome.disable',
//"userChrome.disable"という名前の設定が変更された場合全てで処理を行う
observe : function(aSubject, aTopic, aPrefstring) {
if (aTopic == 'nsPref:changed') {
// 設定が変更された時の処理
setTimeout(function(){
var s = userChromejs.getPref("userChrome.disable.directory", "str", "");
userChrome_js.dirDisable = userChromejs.restoreState(s.split(','));
s = userChromejs.getPref("userChrome.disable.script", "str", "");
userChrome_js.scriptDisable = userChromejs.restoreState(s.split(','));
}, 0);
}
}
},
restartApp: function() {
if ("BrowserUtils" in window && typeof BrowserUtils.restartApplication == "function") {
Components.classes["@mozilla.org/xre/app-info;1"]
.getService(Components.interfaces.nsIXULRuntime).invalidateCachesOnRestart();
BrowserUtils.restartApplication();
return;
}
const appStartup = Components.classes["@mozilla.org/toolkit/app-startup;1"]
.getService(Components.interfaces.nsIAppStartup);
// Notify all windows that an application quit has been requested.
var os = Components.classes["@mozilla.org/observer-service;1"]
.getService(Components.interfaces.nsIObserverService);
var cancelQuit = Components.classes["@mozilla.org/supports-PRBool;1"]
.createInstance(Components.interfaces.nsISupportsPRBool);
os.notifyObservers(cancelQuit, "quit-application-requested", null);
// Something aborted the quit process.
if (cancelQuit.data)
return;
// Notify all windows that an application quit has been granted.
os.notifyObservers(null, "quit-application-granted", null);
// Enumerate all windows and call shutdown handlers
var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
.getService(Components.interfaces.nsIWindowMediator);
var windows = wm.getEnumerator(null);
var win;
while (windows.hasMoreElements()) {
win = windows.getNext();
if (("tryToClose" in win) && !win.tryToClose())
return;
}
let XRE = Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULRuntime);
if (typeof XRE.invalidateCachesOnRestart == "function")
XRE.invalidateCachesOnRestart();
appStartup.quit(appStartup.eRestart | appStartup.eAttemptQuit);
}
}
userChromejs.init();
//メニューが長くなりすぎるので, あまり使わないメニューを"userChrome.jsの各スクリプトの設定"の下に移動させる
var userChromejsScriptOptionsMenu = {
//あまり使わないメニューのリスト
menues: [
"GrabScroll_optionsMenu",
"Patch_XULrubySupportMenu",
"menutabTooltip",
"PipeliningToggle",
"linkInNewTabForSpecifiedPageToolMenu",
"ieviewModokiTool",
"linkloadInBackgroundToolMenu",
"SaveFolderToolsMenu",
"ucjs_copysysinfo-menu",
],
interval: 500, //0.5秒間隔
maxcount: 50, //最大50回までトライ
count: 0,
timer: null,
run: function() {
//DOMの構築が完了するのを待ってからメニューを移動させる(5秒間隔で最大50回までトライ)
this.timer = setInterval(function(self){
if (++self.count > self.maxcount || self.moveMenu())
clearInterval(self.timer);
}, this.interval, this);
},
moveMenu: function(){
var menupopup = document.getElementById('userChromejs_script_options');
if (!menupopup)
return false;
var i = 0;
while (i < this.menues.length) {
var menu = document.getElementById(this.menues[i])
if (menu) {
setTimeout(function(menupopup, menu){menupopup.appendChild(menu);}, 100, menupopup, menu);
this.menues.splice(i, 1);
continue;
}
i++;
}
return this.menues.length == 0 ? true : false;
},
}
userChromejsScriptOptionsMenu.run();
(function () {
let sss = Components.classes["@mozilla.org/content/style-sheet-service;1"].getService(Components.interfaces.nsIStyleSheetService);
let uri = Services.io.newURI("data:text/css;charset=utf-8," + encodeURIComponent(`
#userChrome_setting,
#userChrome_rebuild,
#userChrome_restartApp,
#userChrome_openChrome,
#userChromejs_script_options_Menu {
display: none !important;
}
`), null, null);
sss.loadAndRegisterSheet(uri, sss.AGENT_SHEET);
})();
Alles anzeigen
@Horstmann
Hat sich mit dem Code von 2002Andreas aus #36 erledigt,
wenn er auf das Loadermenü eingegrenzt werden könnte.
Danke 2002Andreas
menuitem[checked="false"] {
background: url("file:///C:/Users/weiss/IconsFirefox/2.jpg") no-repeat !important;
height: 25px !important;
padding-top: 5px !important;
padding-left: 15px !important;
background-position: 7px 3px !important;
}
Das reicht schon fast!
Der Selektor müsste nur etwas "genauer" sein.
Es würde möglicherweise schon reichen, wenn das CSS nur auf das Skript. bzw, das Loadermenü eingeschränkt wäre.
Hallo 2002Andreas ,
ich bin fast so weit mit dem JavaScript-Loader fertig!
Ich bräuchte aber mal Deine Hilfe, CSS, wieder so 'ne widerspenstige Sache!
Man kann in dem Menü Scripte aktivieren bzw. deaktivieren, so weit, so gut.
Nun mein Problem, wenn ein Skript aktiviert ist, ist ein Häkchen davor,
ist es deaktiviert, nicht, aber der Eintrag springt dann ein Stück nach rechts!
Blöd, sieht einfach nicht gut aus.
Schöner wäre es, wenn anstatt des Häkchens einfach ein anderes Symbol angezeigt werden würde.
Nur ich bekomme das einfach nicht gebacken.
Dieses Verhalten ist auch bei anderen Menüeinträgen, wo aktiviert/deaktiviert werden kann, zu beobachten.