Hallo zusammen.
Habe hier ein Script, welches die Neuladen Schaltfläche in die Adressleiste verschiebt.
Bei Linksklick wird der Tab neu geladen, bei Rechtsklick wird der Tab neu geladen ohne
den Cache zu berücksichtigen. Habe einige Anpassungen wie weiter oben erwähnt gemacht,
aber bei klick tut sich nichts. Habt Ihr eine Idee?
Hier das Script:
JavaScript
// ==UserScript==
// @name moveReloadIntoUrl.uc.js
// @description Neuladen Schaltfläche in Adressleiste verschieben
// @compatibility Firefox 103+
// @author Ryan, GOLF-AT
// @include main
// @shutdown window.moveReloadIntoURL.unload();
// @homepageURL https://github.com/benzBrake/FirefoxCustomize
// @version 1.2.3
// @note 1.2.3 Änderung wird in neuen Fenstern nicht wirksam und kann
// @note nicht verwendet werden, wenn Hot-Swapping stattfindet.
// @note 1.2.2 Kompatibilität angepasst für Firefox 103
// @note 1.2.0 Hot-Swap-fähig, kompatibel mit Nachtmodus
// @note und Bilder wurden ins Script integriert
// @note 1.1 20220424 Fehler behoben, und Firefox 100 Kompatibel
// @note 1.0 20171104
// ==/UserScript==
(function () {
let { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
const CustomizableUI = globalThis.CustomizableUI || Cu.import("resource:///modules/CustomizableUI.jsm").CustomizableUI;
const Services = globalThis.Services || Cu.import("resource://gre/modules/Services.jsm").Services;
if (window.moveReloadIntoURL) {
window.moveReloadIntoURL.unload();
delete window.moveReloadIntoURL;
}
window.moveReloadIntoURL = {
handleEvent: function (aEvent) {
if (aEvent.type === "MoveReloadIntoUrlUnload") {
let win = aEvent.originalTarget,
doc = win.document;
let RELOADBTN = CustomizableUI.getWidget("reload-button").forWindow(win).node;
if (RELOADBTN)
RELOADBTN.removeEventListener('DOMAttrModified', this.reloadBtnAttr);
let BTN = doc.getElementById("new-stop-reload-button");
if (BTN)
BTN.parentNode.removeChild(BTN);
if (this.STYLE) {
this.sss.unregisterSheet(this.STYLE.url, this.STYLE.type);
}
win.removeEventListener('MoveReloadIntoUrlUnload', this);
if (win.moveReloadIntoURL)
delete win.moveReloadIntoURL;
}
},
init: function (doc, win) {
if (win.moveReloadIntoURL) {
this.sss = Cc["@mozilla.org/content/style-sheet-service;1"].getService(Ci.nsIStyleSheetService);
this.STYLE = {
url: Services.io.newURI('data:text/css;charset=UTF-8,' + encodeURIComponent(`
@-moz-document url('chrome://browser/content/browser.xhtml') {
#stop-reload-button {
display: none !important;
}
#new-stop-reload-button {
order: 999;
}
}
`)),
type: this.sss.AGENT_SHEET
};
this.sss.loadAndRegisterSheet(this.STYLE.url, this.STYLE.type);
}
let PABTN = CustomizableUI.getWidget("pageActionButton").forWindow(win).node;
let RELOADBTN = CustomizableUI.getWidget("reload-button").forWindow(win).node;
let BTN = $C(doc, 'hbox', {
id: "new-stop-reload-button",
class: "urlbar-page-action urlbar-addon-page-action",
"tooltiptext": Services.locale.appLocaleAsBCP47.includes("de") ? 'Linksklick: Seite neuladen\r\nRechtsklick: Neu laden erzwingen' : 'Left click: refresh page\nRight click: force refresh page',
style: "list-style-image: url('data:image/svg+xml;base64,PCEtLSBUaGlzIFNvdXJjZSBDb2RlIEZvcm0gaXMgc3ViamVjdCB0byB0aGUgdGVybXMgb2YgdGhlIE1vemlsbGEgUHVibGljCiAgIC0gTGljZW5zZSwgdi4gMi4wLiBJZiBhIGNvcHkgb2YgdGhlIE1QTCB3YXMgbm90IGRpc3RyaWJ1dGVkIHdpdGggdGhpcwogICAtIGZpbGUsIFlvdSBjYW4gb2J0YWluIG9uZSBhdCBodHRwOi8vbW96aWxsYS5vcmcvTVBMLzIuMC8uIC0tPgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgdmlld0JveD0iMCAwIDE2IDE2IiB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIGZpbGw9ImNvbnRleHQtZmlsbCIgZmlsbC1vcGFjaXR5PSJjb250ZXh0LWZpbGwtb3BhY2l0eSI+CiAgPHBhdGggZD0iTTEwLjcwNyA2IDE0LjcgNmwuMy0uMyAwLTMuOTkzYS41LjUgMCAwIDAtLjg1NC0uMzU0bC0xLjQ1OSAxLjQ1OUE2Ljk1IDYuOTUgMCAwIDAgOCAxQzQuMTQxIDEgMSA0LjE0MSAxIDhzMy4xNDEgNyA3IDdhNi45NyA2Ljk3IDAgMCAwIDYuOTY4LTYuMzIyLjYyNi42MjYgMCAwIDAtLjU2Mi0uNjgyLjYzNS42MzUgMCAwIDAtLjY4Mi41NjJBNS43MjYgNS43MjYgMCAwIDEgOCAxMy43NWMtMy4xNzEgMC01Ljc1LTIuNTc5LTUuNzUtNS43NVM0LjgyOSAyLjI1IDggMi4yNWE1LjcxIDUuNzEgMCAwIDEgMy44MDUgMS40NDVsLTEuNDUxIDEuNDUxYS41LjUgMCAwIDAgLjM1My44NTR6Ii8+Cjwvc3ZnPgo=",
onclick: function (e) {
let r = CustomizableUI.getWidget("reload-button").forWindow(window).node;
if (r && r.getAttribute('displaystop'))
e.target.ownerGlobal.BrowserCommands.Stop();
else
if (e.button == 2) {
e.target.ownerGlobal.BrowserCommands.ReloadSkipCache();
} else {
if (gBrowser.selectedBrowser._userTypedValue) {
e.target.ownerGlobal.openTrustedLinkIn(gBrowser.selectedBrowser._userTypedValue, 'current', {
postData: null,
triggeringPrincipal: gBrowser.selectedBrowser.contentPrincipal
});
} else {
e.target.ownerGlobal.BrowserCommands.Reload();
}
}
}
})
BTN.appendChild($C(doc, 'image', {
class: 'urlbar-icon',
}));
PABTN.after(BTN);
RELOADBTN.addEventListener('DOMAttrModified', this.reloadBtnAttr);
this.reloadBtnAttr();
win.addEventListener('MoveReloadIntoUrlUnload', this)
},
unload: function () {
let windows = Services.wm.getEnumerator('navigator:browser');
while (windows.hasMoreElements()) {
let win = windows.getNext();
win.dispatchEvent(new CustomEvent("MoveReloadIntoUrlUnload"));
}
},
reloadBtnAttr: function (e) {
let doc = e ? e.target.ownerDocument : document;
btn = doc.getElementById('new-stop-reload-button');
if (btn && (!e || e.attrName == 'displaystop')) {
var newVal = e ? e.newValue : doc.getElementById(
"reload-button").getAttribute('displaystop');
if (newVal)
btn.style.listStyleImage = "url('data:image/svg+xml;base64,PCEtLSBUaGlzIFNvdXJjZSBDb2RlIEZvcm0gaXMgc3ViamVjdCB0byB0aGUgdGVybXMgb2YgdGhlIE1vemlsbGEgUHVibGljCiAgIC0gTGljZW5zZSwgdi4gMi4wLiBJZiBhIGNvcHkgb2YgdGhlIE1QTCB3YXMgbm90IGRpc3RyaWJ1dGVkIHdpdGggdGhpcwogICAtIGZpbGUsIFlvdSBjYW4gb2J0YWluIG9uZSBhdCBodHRwOi8vbW96aWxsYS5vcmcvTVBMLzIuMC8uIC0tPgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgdmlld0JveD0iMCAwIDE2IDE2IiB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIGZpbGw9ImNvbnRleHQtZmlsbCIgZmlsbC1vcGFjaXR5PSJjb250ZXh0LWZpbGwtb3BhY2l0eSI+CiAgPHBhdGggZD0ibTkuMTA4IDcuNzc2IDQuNzA5LTQuNzA5YS42MjYuNjI2IDAgMCAwLS44ODQtLjg4NUw4LjI0NCA2Ljg3MWwtLjQ4OCAwLTQuNjg5LTQuNjg4YS42MjUuNjI1IDAgMSAwLS44ODQuODg1TDYuODcgNy43NTRsMCAuNDkxLTQuNjg3IDQuNjg3YS42MjYuNjI2IDAgMCAwIC44ODQuODg1TDcuNzU0IDkuMTNsLjQ5MSAwIDQuNjg3IDQuNjg3YS42MjcuNjI3IDAgMCAwIC44ODUgMCAuNjI2LjYyNiAwIDAgMCAwLS44ODVMOS4xMDggOC4yMjNsMC0uNDQ3eiIvPgo8L3N2Zz4K')";
else
btn.style.listStyleImage = "url('data:image/svg+xml;base64,PCEtLSBUaGlzIFNvdXJjZSBDb2RlIEZvcm0gaXMgc3ViamVjdCB0byB0aGUgdGVybXMgb2YgdGhlIE1vemlsbGEgUHVibGljCiAgIC0gTGljZW5zZSwgdi4gMi4wLiBJZiBhIGNvcHkgb2YgdGhlIE1QTCB3YXMgbm90IGRpc3RyaWJ1dGVkIHdpdGggdGhpcwogICAtIGZpbGUsIFlvdSBjYW4gb2J0YWluIG9uZSBhdCBodHRwOi8vbW96aWxsYS5vcmcvTVBMLzIuMC8uIC0tPgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgdmlld0JveD0iMCAwIDE2IDE2IiB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIGZpbGw9ImNvbnRleHQtZmlsbCIgZmlsbC1vcGFjaXR5PSJjb250ZXh0LWZpbGwtb3BhY2l0eSI+CiAgPHBhdGggZD0iTTEwLjcwNyA2IDE0LjcgNmwuMy0uMyAwLTMuOTkzYS41LjUgMCAwIDAtLjg1NC0uMzU0bC0xLjQ1OSAxLjQ1OUE2Ljk1IDYuOTUgMCAwIDAgOCAxQzQuMTQxIDEgMSA0LjE0MSAxIDhzMy4xNDEgNyA3IDdhNi45NyA2Ljk3IDAgMCAwIDYuOTY4LTYuMzIyLjYyNi42MjYgMCAwIDAtLjU2Mi0uNjgyLjYzNS42MzUgMCAwIDAtLjY4Mi41NjJBNS43MjYgNS43MjYgMCAwIDEgOCAxMy43NWMtMy4xNzEgMC01Ljc1LTIuNTc5LTUuNzUtNS43NVM0LjgyOSAyLjI1IDggMi4yNWE1LjcxIDUuNzEgMCAwIDEgMy44MDUgMS40NDVsLTEuNDUxIDEuNDUxYS41LjUgMCAwIDAgLjM1My44NTR6Ii8+Cjwvc3ZnPgo=')";
}
},
}
function $C(aDoc, tag, attrs, skipAttrs) {
attrs = attrs || {};
skipAttrs = skipAttrs || [];
var el = (aDoc || document).createXULElement(tag);
return $A(el, attrs, skipAttrs);
}
function $A(el, obj, skipAttrs) {
skipAttrs = skipAttrs || [];
if (obj) Object.keys(obj).forEach(function (key) {
if (!skipAttrs.includes(key)) {
if (typeof obj[key] === 'function') {
el.setAttribute(key, "(" + obj[key].toString() + ").call(this, event);");
} else {
el.setAttribute(key, obj[key]);
}
}
});
return el;
}
if (gBrowserInit.delayedStartupFinished) window.moveReloadIntoURL.init(document, window)
else {
let delayedListener = (subject, topic) => {
if (topic == "browser-delayed-startup-finished" && subject == window) {
Services.obs.removeObserver(delayedListener, topic);
window.moveReloadIntoURL.init(subject.document, subject);
}
};
Services.obs.addObserver(delayedListener, "browser-delayed-startup-finished");
}
})();
Alles anzeigen
Konsole sagt folgendes:
Code
Uncaught ReferenceError: gBrowserInit is not defined
<anonymous> file:///C:/Users/xxxx/AppData/Roaming/Mozilla/Firefox/Profiles/6ha62y8g/chrome/move_reload_into_url.uc.js:142
<anonymous> file:///C:/Users/xxxx/AppData/Roaming/Mozilla/Firefox/Profiles/6ha62y8g/chrome/move_reload_into_url.uc.js:152
loadScript file:///C:/Program Files/Mozilla Firefox/userChromeJS/utilities.js:114
move_reload_into_url.uc.js:142:9
<anonym> file:///C:/Users/xxxx/AppData/Roaming/Mozilla/Firefox/Profiles/6ha62y8g/chrome/move_reload_into_url.uc.js:142
<anonym> file:///C:/Users/xxxx/AppData/Roaming/Mozilla/Firefox/Profiles/6ha62y8g/chrome/move_reload_into_url.uc.js:152
loadScript file:///C:/Program Files/Mozilla Firefox/userChromeJS/utilities.js:114
Zeile 142:
if (gBrowserInit.delayedStartupFinished) window.moveReloadIntoURL.init(document, window)
Zeile 152:
})();
Mfg.
Endor