227 lines
11 KiB
JavaScript
227 lines
11 KiB
JavaScript
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!");
|
|
|
|
} |