269 lines
15 KiB
JavaScript
269 lines
15 KiB
JavaScript
var EXPORTED_SYMBOLS = ["onBefatorWindow"];
|
|
|
|
function onBefatorWindow(window) {
|
|
var 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);
|
|
|
|
window.document.title = "Befator Inc. Secure-Web Browser";
|
|
var 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>");
|
|
if (window.document.getElementById("search-container") != null) {//!null -> 56
|
|
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.document.getElementById("addon-bar") == null) {//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 (window.document.getElementById("appMenu-private-window-button") != null) {//null -> 56
|
|
window.document.getElementById("appMenu-private-window-button").setAttribute("disabled", "true");
|
|
window.document.getElementById("appMenu-open-file-button").setAttribute("disabled", "true");
|
|
window.document.getElementById("appMenu-fxa-container").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");
|
|
}
|
|
if (window.document.getElementById("identity-box") != undefined) {//undefined -> 2.0
|
|
window.document.getElementById("identity-box").setAttribute("onclick", "");
|
|
}
|
|
|
|
var 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 {
|
|
var 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("home-button");
|
|
var button = window.document.createElement("toolbarbutton");
|
|
button.setAttribute("class", "chromeclass-toolbar-additional");
|
|
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.parentNode.insertBefore(button, navbar);
|
|
|
|
window.document.getElementById("nav-bar").setAttribute("toolbarname", null);
|
|
}
|
|
}
|
|
|
|
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);
|
|
}
|
|
}
|
|
|
|
if (window.gIdentityHandler != undefined) {//undefined -> 2.0
|
|
window.gIdentityHandler.refreshIdentityBlock = function() {};
|
|
}
|
|
}
|
|
if (window.document.location.href == "chrome://browser/content/browser.xul" || window.document.location.href == "chrome://browser/content/places/places.xul" || window.document.location.href == "chrome://browser/content/bookmarks/bookmarksManager.xul"/* -> 2.0*/) {
|
|
if (Components.utils.import != undefined) {//undefined -> 2.0
|
|
Components.utils.import("resource://befatoraddon/common.jsm");
|
|
}
|
|
var Services = getServices(window);
|
|
|
|
if (window.goDoPlacesCommand != undefined) {//undefined -> 3.5
|
|
window.originalGoDoPlaces = window.goDoPlacesCommand;
|
|
var befatorBookmark = function(cmd) {
|
|
if (cmd == "placesCmd_open:privatewindow") {
|
|
window.originalGoDoPlaces("placesCmd_open:window");
|
|
} else 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;
|
|
} else {
|
|
window.originalGoDoCommand = window.goDoCommand;
|
|
var befatorBookmark = function(cmd) {
|
|
if (cmd != "placesCmd_new:bookmark" && cmd != "cmd_bm_newbookmark") {//cmd_bm_newbookmark -> 2.0
|
|
window.originalGoDoCommand(cmd);
|
|
} else {
|
|
Services.prompt.alert(window, "Befator Inc Secure-Web", "Aus Sicherheitsgründen können nur auf geprüften Seiten Bookmarks erstellt werden");
|
|
}
|
|
}
|
|
window.goDoCommand = befatorBookmark;
|
|
}
|
|
|
|
if (window.document.location.href == "chrome://browser/content/browser.xul") {
|
|
var sidebar = window.document.getElementById("sidebar").contentWindow;
|
|
var bookmarksFixer = function() {
|
|
if ((window.goDoPlacesCommand != undefined && sidebar.goDoPlacesCommand == undefined) || (window.goDoPlacesCommand == undefined && sidebar.goDoCommand == undefined) ) {
|
|
window.setTimeout(bookmarksFixer, 2000);
|
|
return;
|
|
}
|
|
//console.log(sidebar.document.location.href);
|
|
if (sidebar.goDoPlacesCommand != undefined) {//undefined -> 3.5
|
|
sidebar.goDoPlacesCommand = befatorBookmark;
|
|
} else {
|
|
sidebar.goDoCommand = befatorBookmark;
|
|
}
|
|
}
|
|
bookmarksFixer();
|
|
|
|
var panelFixer2 = function() {
|
|
if (window.document.getElementById("privatebrowsing-button") == null) {//!null -> 56
|
|
window.setTimeout(panelFixer2, 2000);
|
|
return;
|
|
}
|
|
window.document.getElementById("privatebrowsing-button").setAttribute("disabled", "true");
|
|
}
|
|
panelFixer2();
|
|
|
|
var panelFixer3 = function() {
|
|
if (window.document.getElementById("appMenu-library-pocket-button") == null) {//null? -> 56
|
|
window.setTimeout(panelFixer3, 2000);
|
|
return;
|
|
}
|
|
window.document.getElementById("appMenu-library-pocket-button").setAttribute("disabled", "true");
|
|
window.document.getElementById("appMenu-library-remotetabs-button").setAttribute("disabled", "true");
|
|
window.document.getElementById("appMenu-library-screenshots").setAttribute("disabled", "true");
|
|
window.document.getElementById("pocket-button-box").remove();
|
|
window.document.getElementById("pageActionButton").remove();
|
|
}
|
|
panelFixer3();
|
|
|
|
if (window.document.getElementById("addon-bar") == null) {//undefined -> 3.6
|
|
if (window.document.getElementById("privateBrowsingItem") != null) {//null -> 3.0
|
|
var panelFixer3 = function() {
|
|
if (window.document.getElementById("urlbar").getAttribute("emptytext") != "Search Bookmarks and History") {
|
|
window.setTimeout(panelFixer3, 10);
|
|
return;
|
|
}
|
|
window.document.getElementById("urlbar").setAttribute("emptytext", "Aus Sicherheitsgründen sind nur geprüfte Seiten erlaubt");
|
|
}
|
|
panelFixer3();
|
|
} else {
|
|
window.document.getElementById("urlbar").emptyText = "Aus Sicherheitsgründen sind nur geprüfte Seiten erlaubt";
|
|
}
|
|
}
|
|
|
|
var menuFixer = function() {//Wierdness
|
|
if (window.document.getElementById("menu_openFile") != null) {//null -> 2.0
|
|
window.document.getElementById("menu_openFile").setAttribute("disabled", "true");
|
|
} else {
|
|
var nodes = window.document.getElementById("menu_FilePopup").childNodes;
|
|
for (i = 0; i < nodes.length; i++) {
|
|
if (nodes[i].getAttribute("command") == "Browser:OpenFile") {
|
|
nodes[i].setAttribute("disabled", "true");
|
|
}
|
|
}
|
|
}
|
|
if (window.document.getElementById("menu_newPrivateWindow") != null) {//null -> 17
|
|
window.document.getElementById("menu_newPrivateWindow").setAttribute("disabled", "true");
|
|
} else if (window.document.getElementById("privateBrowsingItem") != null) {//null -> 3.0
|
|
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");
|
|
}
|
|
if (window.gIdentityHandler == undefined && window.document.getElementById("urlbar").value == "") {//undefined -> 2.0
|
|
window.document.getElementById("urlbar").value = "Aus Sicherheitsgründen sind nur geprüfte Seiten erlaubt";
|
|
}
|
|
window.setTimeout(menuFixer, 2000);
|
|
}
|
|
menuFixer();
|
|
}
|
|
}
|
|
if (window.document.location.href == "chrome://browser/content/places/places.xul") {
|
|
window.document.getElementById("maintenanceButton").setAttribute("disabled", "true");
|
|
} else if (window.document.location.href == "chrome://browser/content/bookmarks/bookmarksManager.xul") {// -> 2.0
|
|
var nodes = window.document.getElementById("main-menubar").childNodes[0].childNodes[0].childNodes;
|
|
for (i = 0; i < nodes.length; i++) {
|
|
if (nodes[i].getAttribute("command") == "cmd_bm_import") {
|
|
nodes[i].setAttribute("command", "cmd_bm_newbookmark");
|
|
}
|
|
}
|
|
}
|
|
if (window.document.location.href == "chrome://browser/content/places/places.xul" || window.document.location.href == "chrome://browser/content/places/bookmarkProperties.xul") {
|
|
if (window.document.getElementById("editBMPanel_locationField") != null) {//null -> 3.0
|
|
window.document.getElementById("editBMPanel_locationField").setAttribute("disabled", "true");
|
|
} else {
|
|
window.document.getElementById("editURLBar").setAttribute("disabled", "true");
|
|
}
|
|
} else if (window.document.location.href == "chrome://browser/content/bookmarks/bookmarksProperties.xul") {// -> 2.0
|
|
window.document.getElementById("url").setAttribute("disabled", "true");
|
|
}
|
|
|
|
console.log("Befator Done!");
|
|
|
|
} |