Dieses Skript lädt und installiert ein Skript von Github über das Fx-Kontextmenü. Ich habe es eine Weile nicht benutzt, deshalb weiß ich nicht, ab welcher Fx-Version es nicht mehr funktioniert.
Die Fehlerkonsole zeigt diesen Fehler:
Zitat22:50:54.338 Uncaught NS_ERROR_XPC_BAD_CONVERT_JS: Could not convert JavaScript argument arg 0 [nsIFilePicker.init]
saveUCJS file:///C:/Users/bege/AppData/Roaming/Mozilla/Firefox/Profiles/487kit50.Quantum/chrome/JS/saveUCJS_lite.uc.js:56
onload file:///C:/Users/bege/AppData/Roaming/Mozilla/Firefox/Profiles/487kit50.Quantum/chrome/JS/saveUCJS_lite.uc.js:49
saveUCJS_lite.uc.js:56
Was muss da geändert werden?
JSON: saveUCJS_lite.uc.js
// ==UserScript==
// @name saveUCJS_lite.uc.js
// @description GitHub Scripte Downloaden und Installieren
// @charset UTF-8
// @include main
// @note userChrome.js Update-Funktion entfernen
// ==/UserScript==
(function(){
"use strict";
// config Anfang true = ja / false = nein
const skipDialogCxt = false // Speichern Dialog nicht anzeigen - übergehen
const urgeRestart = true // Firefox Neustarten Aufforderung nach dem Runterladen anzeigen
// config Ende
const areaMenu = document.getElementById('contentAreaContextMenu');
const saveLink = document.getElementById('context-savelink');
const github = 'https://github.com/';
const sep = navigator.platform.indexOf('Win') != -1? '\\' : '/';
areaMenu.addEventListener('popupshowing', function(){
const _areaMenu = document.getElementById('ucjs_getUCJS_areamenu');
if(_areaMenu) this.removeChild(_areaMenu);
if(!gBrowser.currentURI.spec.startsWith(github)) return;
if((gBrowser.currentURI.spec + gContextMenu.linkURL).indexOf('blob') == -1) return;
createMenu(gContextMenu.onLink? gContextMenu.linkURL : gBrowser.currentURI.spec);
}, false);
function createMenu(file){
const url = file.replace('/blob/', '/raw/');
const menu = document.createXULElement('menuitem');
menu.setAttribute('id', 'ucjs_getUCJS_areamenu');
menu.setAttribute('label',(gContextMenu.onLink? 'Link' : 'Seite') + ' als uc.js Script' + ' speichern');
menu.setAttribute('tooltiptext', 'als uc.js speichern');
menu.setAttribute('class', 'menuitem-iconic');
menu.setAttribute('style', 'list-style-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAANTSURBVHgBvVeNTdtAFH7vbCilUptuYFQihUhNzQQJEzSZoGSChgkIEwATNJ0AmICM4ISKWCKoHiGtVDUCn1/v2cRx4nNIcNRPgpzvnd/fvT8jLAnLsgrGVqEOQlaR0AYECwgKIRFhpNYeITkQYFeOf195njdahi8+K7hUsgzcaCPi51jgElDKdGTweOK5rgcvUYAtNl+/PVbLFuSBoDP/j3Hiec5oaQUiqzevFdGCNYAAPEkPBzpviPmNYrlsr1M4g3kxz2KxbGtoU6zb8nnoPBF7IIzyOeH8gvp/Gf2uCJUZRNRRK2e6FXnCsuxCSgEOuJTlBO3h4KZxP+jvKGbNWBFOu5AxdeO/aO9JMBwOb/vv792bJlBwNKsXWOYbeZx4jlxv4ubPlBG+2L+7c2ILLFtpPh4XslLLKtkWjGGUjHjeMzFI8fbpYYf5mPzAea5j+GjATOp4Tsg4s8B4ruPBkjDEBnuhKdgqBPyiPQSyBjlhZgS0qqZ1jgVhjGVddyCMWDC6kBP+FjgZQaxKu6wLFQU10GvQXsWlWeBrQwqaeqqoClXjP+lIciyuYE0Yuj+mWZIACrI5Da15Arssq3bngAdpQZZYpcPlApHOoIKA/wVEraFCezdhZbbX6xkCW7M7Yg94uvPGtqzCmrBbsmtaAoInKICelkY5B5EECOWhdj9AR0TNRKtCbXevkluJ4l7la1alZdlCbhmXujh4wuluuXIMOYSrlD7LonOtCbvhh71KRy0iLQlOwukW8HTSnrkuKFedEYne0HW6sEho0bbBDKqEcJgReJEYws6922s+teNpywzrtqQjuW10zYfgOs0EL4eDXkPHdLf88UJdeB2WgE9ih0t9WAd4oQSfh+yVPmjgN+77fiAaqUZC8jyTa0DZtCQLJWvSZ+JCJF+JdkIYj2ctPiRJHPALPF4p5VphXc/AIlpCuCf/ivbkeW4otdXMFsRzIfq+mohuHVgBKnNooXBlULLLpr4LeCwPyLyIA1B94QhCJyDxS2Dw7m7QP3+JAmEgo2goe2YMyvgwmfVEEsNBH1dVQGf5BNpmxAd5EuaUhJzg+FF3vp813CzshkO33+Z0UUy+w7LgohaO5tjhd5UhrbXMFtwdeXx/9py6vlU66T98qp4a9HCubgAAAABJRU5ErkJggg==)');
menu.addEventListener('command', function(){getFile(url)}, false);
areaMenu.insertBefore(menu, saveLink? saveLink : areaMenu.firstChild);
}
function getFile(url){
const title = url.split(/\//)[url.split(/\//).length -1]
const date = new Date();
const stamp = '?' + date.getTime();
const xhr = new XMLHttpRequest();
xhr.responseType = '';
xhr.open('GET', url + stamp);
xhr.send();
xhr.onload = function(){
saveUCJS(xhr.responseText, title)
}
}
function saveUCJS(string, title){
if(!skipDialogCxt){
const fp =Cc["@mozilla.org/filepicker;1"].createInstance(Ci.nsIFilePicker);
fp.init(window, 'Select a File', Ci.nsIFilePicker.modeSave);
fp.appendFilter('userChrome.js', '*.uc.js');
fp.displayDirectory = Services.dirsvc.get('UChrm', Ci.nsIFile);
fp.defaultExtension = 'uc.js';
fp.defaultString = (title == 'userChrome.js.uc.js')? 'userChrome.js' : title;
const result = fp.open(_saveUCJS);
function _saveUCJS(result){
if (result == Ci.nsIFilePicker.returnOK || result == Ci.nsIFilePicker.returnReplace){
writeFile(fp.file, string)
}
}
}else{
const aFile = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsIFile);
const dir = Services.dirsvc.get('UChrm', Ci.nsIFile).path;
const path = dir + sep +((title == 'userChrome.js.uc.js')? 'userChrome.js' : title);
aFile.initWithPath(path);
writeFile(aFile, string);
}
}
function writeFile(file, string){
const charset = 'UTF-8';
const fileStream = Cc['@mozilla.org/network/file-output-stream;1']
.createInstance(Ci.nsIFileOutputStream);
fileStream.init(file, 0x02 | 0x08 | 0x20, -1, 0);
const converterStream = Cc['@mozilla.org/intl/converter-output-stream;1']
.createInstance(Ci.nsIConverterOutputStream);
converterStream.init(
fileStream,
charset,
string.length,
Ci.nsIConverterInputStream.DEFAULT_REPLACEMENT_CHARACTER
);
converterStream.writeString(string);
converterStream.close();
fileStream.close();
setTimeout(function(){
if(urgeRestart && window.confirm('Downladen abgeschlossen. Möchten Sie Firefox sofort neu starten?')) Services.appinfo.invalidateCachesOnRestart() || Services.startup.quit(Ci.nsIAppStartup.eRestart | Ci.nsIAppStartup.eAttemptQuit);
},100);
}
})()
Alles anzeigen