Initial Extension Commit

This commit is contained in:
Bommels05 2025-11-10 20:10:53 +01:00
parent 7ca161caeb
commit 28ffb254a3
9 changed files with 635 additions and 0 deletions

View File

@ -0,0 +1,3 @@
content befatoraddon content/
overlay chrome://browser/content/browser.xul chrome://befatoraddon/content/browserOverlay.xul
resource befatoraddon modules/

View File

@ -0,0 +1,5 @@
<?xml version="1.0"?>
<overlay id="befatoraddon-browser-overlay" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/x-javascript" src="chrome://befatoraddon/content/init.js" />
</overlay>

BIN
extension/content/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 925 B

14
extension/content/init.js Normal file
View File

@ -0,0 +1,14 @@
if (window.document.location.href == "chrome://browser/content/browser.xul") {
var console;
if (console == undefined) {//undefined -> 3.6
console = {
log: function(message) {
dump(message);
}
}
}
console.log("Befator Init!");
Components.utils.import("resource://befatoraddon/common.jsm");
befatorUpdate(window);
}

140
extension/content/old.js Normal file
View File

@ -0,0 +1,140 @@
console.log(window.document.location.href)
if (window.document.location.href == "chrome://browser/content/browser.xul") {
console.log(window.document);
Components.utils.import("chrome://befatoraddon/content/common.jsm");
befatorWindow = window;
befatorUpdate();
window.document.title = "Befator Inc Secure-Web Browser";
let windowElement = window.document.getElementById("main-window");
windowElement.setAttribute("titlemodifier", windowElement.getAttribute("titlemodifier") + " (Befator Inc. Secure-Web)")
//window.document.children[0].append("<h1>Befator Inc grüßt Sie</h1>");
window.document.getElementById("search-container").setAttribute("style", "display: none;");
window.document.getElementById("urlbar").setAttribute("placeholder", "Aus Sicherheitsgründen sind nur geprüfte Seiten erlaubt");
window.document.getElementById("urlbar").setAttribute("disabled", "true");
if (window.toggleAddonBar != null) {//!null -> 24
window.document.getAnonymousElementByAttribute(window.document.getElementById("urlbar"), "anonid", "historydropmarker").setAttribute("enablehistory", "false");
}
//window.document.getElementById("history-menu").setAttribute("disabled", "true");
if (window.document.getElementById("pocket-button") != null) {//Null -> 38
window.document.getElementById("pocket-button").setAttribute("disabled", "true");
window.document.getElementById("menu_pocket").setAttribute("disabled", "true");
}
if (window.document.getElementById("identity-icon") != null) {//null -> 31
window.document.getElementById("identity-icon").setAttribute("style", "list-style-image: url(chrome://befatoraddon/content/icon.png);");
window.document.getElementById("connection-icon").setAttribute("style", "display: none;");
} else {
window.document.getElementById("page-proxy-favicon").setAttribute("style", "list-style-image: url(chrome://befatoraddon/content/icon.png);-moz-image-region: initial;");
window.gIdentityHandler.checkIdentity = function() {};
}
window.document.getElementById("identity-icon-labels").setAttribute("collapsed", "false");
window.document.getElementById("identity-icon-labels").setAttribute("style", "visibility: visible;");
window.document.getElementById("identity-icon-label").setAttribute("value", "Secure-Web");
window.document.getElementById("identity-box").setAttribute("onclick", "");
if (window.SidebarUI != undefined) {
window.SidebarUI.hide = function() {
window.SidebarUI.show("viewBookmarksSidebar");
}
window.SidebarUI.toggle = window.SidebarUI.hide;
window.SidebarUI.hide();
} else {
window.originalSidebar = window.toggleSidebar;
window.toggleSidebar = function() {
window.originalSidebar("viewBookmarksSidebar", true);
}
window.toggleSidebar();
}
if (window.toggleAddonBar != null) {
window.originalAddonBar = window.setToolbarVisibility;
window.setToolbarVisibility = function(toolbar, visible) {
if (window.document.getElementById("addon-bar") == toolbar) {
window.originalAddonBar(toolbar, true);
} else {
window.originalAddonBar(toolbar, visible);
}
}
window.setToolbarVisibility(window.document.getElementById("addon-bar"), true);
}
window.gIdentityHandler.refreshIdentityBlock = function() {};
window.gBrowser.addProgressListener({
onLocationChange: function (browser, webProgress, request, location, flags) {
/*window.setTimeout(function() {
if (!window.document.title.endsWith("(Befator Inc. Secure-Web)")) {
console.log(window.document.title);
window.document.title = window.document.title + " (Befator Inc. Secure-Web)";
}
}, 333);*/
let currentUrl = window.gURLBar.value;
console.log(currentUrl);
if (currentUrl.startsWith("http://proxy.befatorinc.de:3636/proxy/")) {
window.gURLBar.value = currentUrl.replace("http://proxy.befatorinc.de:3636/proxy/", "");
} else if (currentUrl.startsWith("proxy.befatorinc.de:3636/proxy/")) {
window.gURLBar.value = currentUrl.replace("proxy.befatorinc.de:3636/proxy/", "");
}
}
});
}
if (window.document.location.href == "chrome://browser/content/browser.xul" || window.document.location.href == "chrome://browser/content/places/places.xul") {
window.originalGoDoPlaces = window.goDoPlacesCommand;
let befatorBookmark = function(cmd) {
if (cmd != "placesCmd_new:bookmark") {
window.originalGoDoPlaces(cmd);
} else {
Services.prompt.alert(window, "Befator Inc Secure-Web", "Aus Sicherheitsgründen können nur auf geprüften Seiten Bookmarks erstellt werden");
}
}
window.goDoPlacesCommand = befatorBookmark;
if (window.document.location.href == "chrome://browser/content/browser.xul") {
let sidebar = window.document.getElementById("sidebar").contentWindow;
let bookmarksFixer = function() {
if (sidebar.goDoPlacesCommand == undefined) {
window.setTimeout(bookmarksFixer, 2000);
return;
}
console.log(sidebar.document.location.href);
sidebar.goDoPlacesCommand = befatorBookmark;
}
bookmarksFixer();
/*let panelFixer = function() {
if (window.document.getElementById("history-panelmenu") == null) {
window.setTimeout(panelFixer, 2000);
return;
}
window.document.getElementById("history-panelmenu").setAttribute("disabled", "true");
window.document.getElementById("privatebrowsing-button").setAttribute("disabled", "true");
}
panelFixer();*/
let panelFixer2 = function() {
if (window.document.getElementById("privatebrowsing-button") == null) {
window.setTimeout(panelFixer2, 2000);
return;
}
window.document.getElementById("privatebrowsing-button").setAttribute("disabled", "true");
}
panelFixer2();
let menuFixer = function() {//Wierdness
window.document.getElementById("menu_openFile").setAttribute("disabled", "true");
window.document.getElementById("menu_newPrivateWindow").setAttribute("disabled", "true");
window.setTimeout(menuFixer, 2000);
}
menuFixer();
}
}
if (window.document.location.href == "chrome://browser/content/places/places.xul" || window.document.location.href == "chrome://browser/content/places/bookmarkProperties.xul") {
window.document.getElementById("editBMPanel_locationField").setAttribute("disabled", "true");
}
console.log("Befator Done!");

20
extension/install.rdf Normal file
View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest">
<em:type>2</em:type>
<em:id>befatoraddon@jetpack</em:id>
<em:name>Befator Inc. Secure-Web</em:name>
<em:creator>Bommels05</em:creator>
<em:description>Erlaubt das browsen durch das Befator Inc. Secure-Web (&quot;BefatorWeb&quot;)</em:description>
<em:version>0.2.0</em:version>
<em:targetApplication>
<Description>
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id> <!--Firefox-->
<em:minVersion>3.6</em:minVersion>
<em:maxVersion>52.*</em:maxVersion>
</Description>
</em:targetApplication>
</Description>
</RDF>

View File

@ -0,0 +1,226 @@
/*var self = require("sdk/self");
var buttons;
try {
buttons = require('sdk/ui/button/action');
} catch (ex) {
buttons = null;
}
var tabs = require("sdk/tabs");
const {Cc, Ci, Cu, Cr} = require("chrome");*/
/*if (buttons != null) {//null -> 24
var button = buttons.ActionButton({
id: "mozilla-link",
label: "Befator Inc. Secure-Web!",
icon: {
"16": "./icon-64.png",
"32": "./icon-64.png",
"64": "./icon-64.png"
},
onClick: handleClick
});
} else {
var widgets = require("sdk/widget")
var widget = widgets.Widget({
id: "mozilla-link",
label: "Befator Inc. Secure-Web!",
contentURL: "resource://befatoraddon-at-jetpack/befatoraddon/data/icon-64.png",
onClick: handleClick
});
}*/
var EXPORTED_SYMBOLS = ["befatorUpdate", "handleBefatorClick"];
//console.log("Befator Inc grüßt Sie!");
var befatorWindow;
function handleBefatorClick(window) {
try {
window.Cu.import('resource://gre/modules/Services.jsm');
} catch (e) {//e -> 3.6
var Services = {
prompt: window.Cc["@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService)
}
}
let request = new window.XMLHttpRequest();
request.onreadystatechange = function() {
if (request.readyState == 4) {
Services.prompt.alert(window, "Befator Inc Secure-Web", request.responseText);
}
}
request.open("GET", "http://proxy.befatorinc.de:3636/api/progressMessage?currentPage=" + window.document.getElementById("content").selectedBrowser.contentDocument.location.href.replace("http://proxy.befatorinc.de:3636/proxy/", ""), true);
request.send(null);
//tabs.open("https://wiki.befatorinc.de/index.php/Hauptseite");
}
function handleWindow(window) {
if (window.document.readyState == "complete") {
befatorWindow.console.log("Window!");
Components.utils.import("resource://befatoraddon/main.jsm");
onBefatorWindow(window);
} else {
window.addEventListener('load', function(e) {
handleWindow(window);
}, false);
}
}
//https://udn.realityripple.com/docs/Archive/Add-ons/Tabbed_browser#Getting_the_tab_that_fires_the_http-on-modify-request_notification
function loadContextGoodies(httpChannel) {
//httpChannel must be the subject of http-on-modify-request QI'ed to nsiHTTPChannel as is done on line 8 "httpChannel = subject.QueryInterface(Ci.nsIHttpChannel);"
//start loadContext stuff
var loadContext;
try {
var interfaceRequestor = httpChannel.notificationCallbacks.QueryInterface(befatorWindow.Ci.nsIInterfaceRequestor);
//var DOMWindow = interfaceRequestor.getInterface(Components.interfaces.nsIDOMWindow); //not to be done anymore because: https://developer.mozilla.org/docs/Updating_extensions_for_Firefox_3.5#Getting_a_load_context_from_a_request //instead do the loadContext stuff below
try {
loadContext = interfaceRequestor.getInterface(befatorWindow.Ci.nsILoadContext);
} catch (ex) {
try {
loadContext = subject.loadGroup.notificationCallbacks.getInterface(befatorWindow.Ci.nsILoadContext);
} catch (ex2) {}
}
} catch (ex0) {}
if (!loadContext) {
//no load context so dont do anything although you can run this, which is your old code
//this probably means that its loading an ajax call or like a google ad thing
return null;
} else {
var contentWindow = loadContext.associatedWindow;
if (!contentWindow) {
//this channel does not have a window, its probably loading a resource
//this probably means that its loading an ajax call or like a google ad thing
return null;
} else {
try {
var aDOMWindow = contentWindow.top.QueryInterface(befatorWindow.Ci.nsIInterfaceRequestor)
.getInterface(befatorWindow.Ci.nsIWebNavigation)
.QueryInterface(befatorWindow.Ci.nsIDocShellTreeItem)
.rootTreeItem
.QueryInterface(befatorWindow.Ci.nsIInterfaceRequestor)
.getInterface(befatorWindow.Ci.nsIDOMWindow);
var gBrowser = aDOMWindow.gBrowser;
var aTab = gBrowser._getTabForContentWindow(contentWindow.top); //this is the clickable tab xul element, the one found in the tab strip of the firefox window, aTab.linkedBrowser is same as browser var above //can stylize tab like aTab.style.backgroundColor = 'blue'; //can stylize the tab like aTab.style.fontColor = 'red';
var browser = aTab.linkedBrowser; //this is the browser within the tab //this is where the example in the previous section ends
return {
aDOMWindow: aDOMWindow,
gBrowser: gBrowser,
aTab: aTab,
browser: browser,
contentWindow: contentWindow
};
} catch(e) {
return null;
}
}
}
}
var init = false;
function befatorUpdate(newWindow) {
if (!init) {
befatorWindow = newWindow;
init = true;
try {
Components.utils.import('resource://gre/modules/Services.jsm');
} catch(e) {//e -> 3.6
var Services = {
obs: Components.classes["@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService),
prefs: Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService).getBranch(""),
io: Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService)
}
}
var observers = {
'http-on-modify-request': {
observe: function (aSubject, aTopic, aData) {
//console.log('http-on-modify-request: aSubject = ' + aSubject + ' | aTopic = ' + aTopic + ' | aData = ' + aData);
var httpChannel = aSubject.QueryInterface(befatorWindow.Ci.nsIHttpChannel);
var requestUrl = httpChannel.URI.spec.toLowerCase();
//befatorWindow.console.log("Requesting: " + requestUrl);
//for (var i=0; i<urls_block.length; i++) {
//if (requestUrl.indexOf(urls_block[i]) > -1) {
//httpChannel.cancel(Cr.NS_BINDING_ABORTED); //this aborts the load
var contains = false;
if (requestUrl.includes != undefined) {
contains = requestUrl.includes("befatorinc.de:3636/");
} else if (requestUrl.contains != undefined) {
contains = requestUrl.contains("befatorinc.de:3636/");
} else {
contains = requestUrl.indexOf("befatorinc.de:3636/") != -1;
}
if (!contains) {
if (httpChannel.redirectTo != undefined) {//undefined -> 17
httpChannel.redirectTo(Services.io.newURI("http://proxy.befatorinc.de:3636/proxy/" + requestUrl, null, null/*redir_obj[urls_block[i]], null, null)*/)); //can redirect with this line, if dont want to redirect and just block, then uncomment this line and comment out line above (line 17)
} else {
httpChannel.cancel(befatorWindow.Cr.NS_BINDING_ABORTED);
var goodies = loadContextGoodies(httpChannel);
if (goodies && requestUrl.indexOf("web-static.archive.org") == -1) {
goodies.contentWindow.location.href = "http://proxy.befatorinc.de:3636/proxy/" + requestUrl;
} else {
//error?
}
//Components.utils.import("chrome://befatoraddon/content/ChannelReplacement.jsm");
//ChannelReplacement.runWhenPending(httpChannel, function() {
//var cr = new ChannelReplacement(httpChannel, Services.io.newURI("http://proxy.befatorinc.de:3636/proxy/" + requestUrl, null, null));
//cr.replace(true, null);
//cr.open();
//});
}
}
//break;
//}
//}
},
reg: function () {
Services.obs.addObserver(observers['http-on-modify-request'], 'http-on-modify-request', false);
},
unreg: function () {
Services.obs.removeObserver(observers['http-on-modify-request'], 'http-on-modify-request');
}
},
'homepage-pref': {
observe: function (aSubject, aTopic, aData) {
//befatorWindow.console.log("HomePage!");
if (Services.prefs.getCharPref("browser.startup.homepage") != "about:home") {
Services.prefs.setCharPref("browser.startup.homepage", "about:home");
}
},
reg: function () {
var pref = Services.prefs;
if (pref.addObserver == undefined) {//undefined -> 3.6
pref = pref.QueryInterface(Components.interfaces.nsIPrefBranch2)
}
pref.addObserver("browser.startup.homepage", observers['homepage-pref'], false);
},
unreg: function () {
//Services.obs.removeObserver(observers['http-on-modify-request'], 'http-on-modify-request');
}
},
'toplevel-window-ready': {
observe: function (aSubject, aTopic, aData) {
handleWindow(aSubject);
},
reg: function () {
Services.obs.addObserver(observers['toplevel-window-ready'], 'toplevel-window-ready', false);
},
unreg: function () {
Services.obs.removeObserver(observers['toplevel-window-ready'], 'toplevel-window-ready');
}
}
};
//console.log("Startup");
for (var o in observers) {
observers[o].reg();
}
handleWindow(befatorWindow);
}
}

227
extension/modules/main.jsm Normal file
View File

@ -0,0 +1,227 @@
var EXPORTED_SYMBOLS = ["onBefatorWindow"];
function onBefatorWindow(window) {
let console = window.console;
if (console == undefined) {//undefined -> 3.6
console = {
log: function(message) {
dump(message);
}
}
}
console.log(window.document.location.href)
if (window.document.location.href == "chrome://browser/content/browser.xul") {
console.log(window.document);
Components.utils.import("resource://befatoraddon/common.jsm");
befatorUpdate();
window.document.title = "Befator Inc Secure-Web Browser";
let windowElement = window.document.getElementById("main-window");
windowElement.setAttribute("titlemodifier", windowElement.getAttribute("titlemodifier") + " (Befator Inc. Secure-Web)")
//window.document.children[0].append("<h1>Befator Inc grüßt Sie</h1>");
window.document.getElementById("search-container").setAttribute("style", "display: none;");
window.document.getElementById("urlbar").setAttribute("placeholder", "Aus Sicherheitsgründen sind nur geprüfte Seiten erlaubt");
window.document.getElementById("urlbar").setAttribute("disabled", "true");
if (window.toggleAddonBar != null) {//!null -> 24
window.document.getAnonymousElementByAttribute(window.document.getElementById("urlbar"), "anonid", "historydropmarker").setAttribute("enablehistory", "false");
} else if (window.console == undefined) {//undefined -> 3.6
window.document.getElementById("urlbar").setAttribute("enablehistory", "false");
}
//window.document.getElementById("history-menu").setAttribute("disabled", "true");
if (window.document.getElementById("pocket-button") != null) {//Null -> 38
window.document.getElementById("pocket-button").setAttribute("disabled", "true");
window.document.getElementById("menu_pocket").setAttribute("disabled", "true");
}
if ("".startsWith != undefined) {//undefined -> 10
if (window.document.getElementById("identity-icon") != null) {//null -> 31
window.document.getElementById("identity-icon").setAttribute("style", "list-style-image: url(chrome://befatoraddon/content/icon.png);");
window.document.getElementById("connection-icon").setAttribute("style", "display: none;");
} else {
if (window.document.getElementById("page-proxy-favicon").insertAdjacentHTML != undefined) {//undefined -> 17
window.document.getElementById("page-proxy-favicon").setAttribute("style", "list-style-image: url(chrome://befatoraddon/content/icon.png);-moz-image-region: initial;");
} else {
window.document.getElementById("page-proxy-favicon").setAttribute("style", "list-style-image: url(chrome://befatoraddon/content/icon16.png);");
}
window.gIdentityHandler.checkIdentity = function() {};
}
window.document.getElementById("identity-icon-labels").setAttribute("collapsed", "false");
window.document.getElementById("identity-icon-labels").setAttribute("style", "visibility: visible;");
window.document.getElementById("identity-icon-label").setAttribute("value", "Secure-Web");
}
window.document.getElementById("identity-box").setAttribute("onclick", "");
let navbar = window.document.getElementById("nav-bar-customization-target");
if (window.document.getElementById("identity-icon") != null) {
navbar.insertAdjacentHTML("beforeend", '<toolbarbutton xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" class="toolbarbutton-1 chromeclass-toolbar-additional badged-button" type="undefined" label="Befator Inc. Secure-Web!" tooltiptext="Befator Inc. Secure-Web!" image="chrome://befatoraddon/content/icon.png" constrain-size="true" cui-areatype="toolbar" badge="" id="befator-button" onclick="handleBefatorClick(window);"/>');
} else if (navbar != null) {//null -> 24
navbar.insertAdjacentHTML("beforeend", '<toolbarbutton xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" class="toolbarbutton-1 chromeclass-toolbar-additional badged-button" type="undefined" label="Befator Inc. Secure-Web!" tooltiptext="Befator Inc. Secure-Web!" image="chrome://befatoraddon/content/icon16.png" constrain-size="true" cui-areatype="toolbar" badge="" id="befator-button" onclick="handleBefatorClick(window);"/>');
} else {
navbar = window.document.getElementById("addon-bar");
if (navbar != null) {//null -> 3.6
if (navbar.insertAdjacentHTML != undefined) {//undefined -> 17
navbar.insertAdjacentHTML("beforeend", '<toolbarbutton xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" class="toolbarbutton-1 chromeclass-toolbar-additional badged-button" type="undefined" label="Befator Inc. Secure-Web!" tooltiptext="Befator Inc. Secure-Web!" image="chrome://befatoraddon/content/icon16.png" constrain-size="true" cui-areatype="toolbar" badge="" id="befator-button" onclick="handleBefatorClick(window);"/>');
} else {
let button = window.document.createElement("toolbarbutton");
button.setAttribute("class", "toolbarbutton-1 chromeclass-toolbar-additional badged-button");
button.setAttribute("label", "Befator Inc. Secure-Web!");
button.setAttribute("tooltiptext", "Befator Inc. Secure-Web!");
button.setAttribute("style", "list-style-image: url(chrome://befatoraddon/content/icon16.png);");
button.setAttribute("onclick", "handleBefatorClick(window);");
navbar.appendChild(button);
}
} else {
navbar = window.document.getElementById("status-bar");
let button = window.document.createElement("statusbarpanel");
//button.setAttribute("class", "toolbarbutton-1 chromeclass-toolbar-additional badged-button");
button.setAttribute("tooltiptext", "Befator Inc. Secure-Web!");
button.setAttribute("style", "list-style-image: url(chrome://befatoraddon/content/icon16.png);");
button.setAttribute("onclick", "handleBefatorClick(window);");
navbar.appendChild(button);
}
}
if (window.SidebarUI != undefined) {
window.SidebarUI.hide = function() {
window.SidebarUI.show("viewBookmarksSidebar");
}
window.SidebarUI.toggle = window.SidebarUI.hide;
window.SidebarUI.hide();
} else {
window.originalSidebar = window.toggleSidebar;
window.toggleSidebar = function() {
window.originalSidebar("viewBookmarksSidebar", true);
}
window.toggleSidebar();
}
if (window.toggleAddonBar != null) {
window.originalAddonBar = window.setToolbarVisibility;
window.setToolbarVisibility = function(toolbar, visible) {
if (window.document.getElementById("addon-bar") == toolbar) {
window.originalAddonBar(toolbar, true);
} else {
window.originalAddonBar(toolbar, visible);
}
}
window.setToolbarVisibility(window.document.getElementById("addon-bar"), true);
} else if (window.goToggleToolbar != undefined) {
window.originalStatusBar = window.goToggleToolbar;
window.goToggleToolbar = function(toolbar, type) {
if (toolbar == "status-bar") {
}
window.originalStatusBar(toolbar, type);
}
}
window.gIdentityHandler.refreshIdentityBlock = function() {};
window.gBrowser.addProgressListener({
onLocationChange: function (browser, webProgress, request, location, flags) {
/*window.setTimeout(function() {
if (!window.document.title.endsWith("(Befator Inc. Secure-Web)")) {
console.log(window.document.title);
window.document.title = window.document.title + " (Befator Inc. Secure-Web)";
}
}, 333);*/
let currentUrl = window.gURLBar.value;
console.log(currentUrl);
if (currentUrl.startsWith != undefined) {//undefined -> 10
if (currentUrl.startsWith("http://proxy.befatorinc.de:3636/proxy/")) {
window.gURLBar.value = currentUrl.replace("http://proxy.befatorinc.de:3636/proxy/", "");
} else if (currentUrl.startsWith("proxy.befatorinc.de:3636/proxy/")) {
window.gURLBar.value = currentUrl.replace("proxy.befatorinc.de:3636/proxy/", "");
}
} else {
if (currentUrl.indexOf("http://proxy.befatorinc.de:3636/proxy/") == 0) {
window.gURLBar.value = currentUrl.replace("http://proxy.befatorinc.de:3636/proxy/", "");
} else if (currentUrl.indexOf("proxy.befatorinc.de:3636/proxy/") == 0) {
window.gURLBar.value = currentUrl.replace("proxy.befatorinc.de:3636/proxy/", "");
}
}
}
});
}
if (window.document.location.href == "chrome://browser/content/browser.xul" || window.document.location.href == "chrome://browser/content/places/places.xul") {
try {
Components.utils.import('resource://gre/modules/Services.jsm');
} catch (e) {//e -> 3.6
var Services = {
prompt: Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService)
}
}
window.originalGoDoPlaces = window.goDoPlacesCommand;
let befatorBookmark = function(cmd) {
if (cmd != "placesCmd_new:bookmark") {
window.originalGoDoPlaces(cmd);
} else {
Services.prompt.alert(window, "Befator Inc Secure-Web", "Aus Sicherheitsgründen können nur auf geprüften Seiten Bookmarks erstellt werden");
}
}
window.goDoPlacesCommand = befatorBookmark;
if (window.document.location.href == "chrome://browser/content/browser.xul") {
let sidebar = window.document.getElementById("sidebar").contentWindow;
let bookmarksFixer = function() {
if (sidebar.goDoPlacesCommand == undefined) {
window.setTimeout(bookmarksFixer, 2000);
return;
}
console.log(sidebar.document.location.href);
sidebar.goDoPlacesCommand = befatorBookmark;
}
bookmarksFixer();
/*let panelFixer = function() {
if (window.document.getElementById("history-panelmenu") == null) {
window.setTimeout(panelFixer, 2000);
return;
}
window.document.getElementById("history-panelmenu").setAttribute("disabled", "true");
window.document.getElementById("privatebrowsing-button").setAttribute("disabled", "true");
}
panelFixer();*/
let panelFixer2 = function() {
if (window.document.getElementById("privatebrowsing-button") == null) {
window.setTimeout(panelFixer2, 2000);
return;
}
window.document.getElementById("privatebrowsing-button").setAttribute("disabled", "true");
}
panelFixer2();
let menuFixer = function() {//Wierdness
window.document.getElementById("menu_openFile").setAttribute("disabled", "true");
if (window.document.getElementById("menu_newPrivateWindow") != null) {//null -> 17
window.document.getElementById("menu_newPrivateWindow").setAttribute("disabled", "true");
} else {
window.document.getElementById("privateBrowsingItem").setAttribute("disabled", "true");
}
if (window.document.getElementById("appmenu_newPrivateWindow") != null) {
window.document.getElementById("appmenu_newPrivateWindow").setAttribute("disabled", "true");
window.document.getElementById("appmenu_openFile").setAttribute("disabled", "true");
}
if (window.document.getElementById("appmenu_privateBrowsing") != null) {
window.document.getElementById("appmenu_privateBrowsing").setAttribute("disabled", "true");
window.document.getElementById("appmenu_openFile").setAttribute("disabled", "true");
}
window.setTimeout(menuFixer, 2000);
}
menuFixer();
}
}
if (window.document.location.href == "chrome://browser/content/places/places.xul") {
window.document.getElementById("maintenanceButton").setAttribute("disabled", "true");
}
if (window.document.location.href == "chrome://browser/content/places/places.xul" || window.document.location.href == "chrome://browser/content/places/bookmarkProperties.xul") {
window.document.getElementById("editBMPanel_locationField").setAttribute("disabled", "true");
}
console.log("Befator Done!");
}