Work on extension and Firefox 2.0 support
This commit is contained in:
1 parent
92e10965bd
commit
c01f0a617e
7 files changed
+220
-213
No files matched your search
@@ -41,4 +41,36 @@ shadowJar {
|
||||
|
||||
test {
|
||||
useJUnitPlatform()
|
||||
}
|
||||
|
||||
TaskProvider<Task> prepareExtension = tasks.register("prepareExtension") {
|
||||
Provider<Directory> tempDir = layout.buildDirectory.dir("tmp/extension-build")
|
||||
|
||||
inputs.dir("extension")
|
||||
outputs.dir(tempDir)
|
||||
|
||||
doLast {
|
||||
delete(tempDir)
|
||||
|
||||
copy {
|
||||
from("extension") {
|
||||
exclude("extension.xpi")
|
||||
}
|
||||
into(tempDir)
|
||||
}
|
||||
|
||||
copy {
|
||||
from("extension/modules")
|
||||
into(tempDir.get().dir("content"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.register("extension", Zip) {
|
||||
dependsOn(prepareExtension)
|
||||
|
||||
from(prepareExtension.map { it.outputs.files.singleFile })
|
||||
|
||||
archiveFileName = "extension.xpi"
|
||||
destinationDirectory = layout.projectDirectory.dir("extension")
|
||||
}
|
||||
@@ -9,6 +9,10 @@ if (window.document.location.href == "chrome://browser/content/browser.xul") {
|
||||
}
|
||||
|
||||
console.log("Befator Init!");
|
||||
Components.utils.import("resource://befatoraddon/common.jsm");
|
||||
if (Components.utils.import != undefined) {//undefined -> 2.0
|
||||
Components.utils.import("resource://befatoraddon/common.jsm");
|
||||
} else {
|
||||
Components.classes["@mozilla.org/moz/jssubscript-loader;1"].getService(Components.interfaces.mozIJSSubScriptLoader).loadSubScript("chrome://befatoraddon/content/common.jsm");
|
||||
}
|
||||
befatorUpdate(window);
|
||||
}
|
||||
@@ -12,7 +12,7 @@
|
||||
<em:targetApplication>
|
||||
<Description>
|
||||
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id> <!--Firefox-->
|
||||
<em:minVersion>3.6</em:minVersion>
|
||||
<em:minVersion>2.0</em:minVersion>
|
||||
<em:maxVersion>52.*</em:maxVersion>
|
||||
</Description>
|
||||
</em:targetApplication>
|
||||
|
||||
+76
-129
@@ -30,160 +30,73 @@ const {Cc, Ci, Cu, Cr} = require("chrome");*/
|
||||
onClick: handleClick
|
||||
});
|
||||
}*/
|
||||
var EXPORTED_SYMBOLS = ["befatorUpdate", "handleBefatorClick"];
|
||||
var EXPORTED_SYMBOLS = ["befatorUpdate", "handleBefatorClick", "getServices"];
|
||||
|
||||
//console.log("Befator Inc grüßt Sie!");
|
||||
|
||||
var befatorWindow;
|
||||
function getServices(window) {
|
||||
try {
|
||||
return window.Cu.import('resource://gre/modules/Services.jsm').Services;
|
||||
} catch (e) {//e -> 3.6
|
||||
return Services = {
|
||||
io: Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService),
|
||||
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(""),
|
||||
prompt: Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
var Services = getServices(window);
|
||||
|
||||
let request = new window.XMLHttpRequest();
|
||||
var 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.open("GET", "http://proxy.befatorinc.de/api/progressMessage?currentPage=" + window.document.getElementById("content").selectedBrowser.contentDocument.location.href.replace("http://", ""), true);
|
||||
request.send(null);
|
||||
//tabs.open("https://wiki.befatorinc.de/index.php/Hauptseite");
|
||||
}
|
||||
|
||||
function realHandleWindow(window) {
|
||||
if (Components.utils.import != undefined) {//undefined -> 2.0
|
||||
Components.utils.import("resource://befatoraddon/main.jsm");
|
||||
} else {
|
||||
Components.classes["@mozilla.org/moz/jssubscript-loader;1"].getService(Components.interfaces.mozIJSSubScriptLoader).loadSubScript("chrome://befatoraddon/content/main.jsm");
|
||||
}
|
||||
onBefatorWindow(window);
|
||||
}
|
||||
|
||||
function handleWindow(window) {
|
||||
if (window.document.readyState == "complete") {
|
||||
befatorWindow.console.log("Window!");
|
||||
Components.utils.import("resource://befatoraddon/main.jsm");
|
||||
onBefatorWindow(window);
|
||||
//window.console.log("Window!");
|
||||
realHandleWindow(window);
|
||||
} else {
|
||||
window.addEventListener('load', function(e) {
|
||||
handleWindow(window);
|
||||
realHandleWindow(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) {
|
||||
function befatorUpdate(window) {
|
||||
if (Components.utils.import == undefined) {//undefined -> 2.0
|
||||
var globalWindow = Components.classes["@mozilla.org/appshell/appShellService;1"].getService(Components.interfaces.nsIAppShellService).hiddenDOMWindow;
|
||||
init = globalWindow.befatorWebInit;
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
if (Components.utils.import != undefined) {//undefined -> 2.0
|
||||
init = true;
|
||||
} else {
|
||||
globalWindow.befatorWebInit = true;
|
||||
}
|
||||
var Services = getServices(window);
|
||||
|
||||
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!");
|
||||
@@ -194,7 +107,7 @@ function befatorUpdate(newWindow) {
|
||||
reg: function () {
|
||||
var pref = Services.prefs;
|
||||
if (pref.addObserver == undefined) {//undefined -> 3.6
|
||||
pref = pref.QueryInterface(Components.interfaces.nsIPrefBranch2)
|
||||
pref = pref.QueryInterface(Components.interfaces.nsIPrefBranch2);
|
||||
}
|
||||
pref.addObserver("browser.startup.homepage", observers['homepage-pref'], false);
|
||||
},
|
||||
@@ -202,6 +115,40 @@ function befatorUpdate(newWindow) {
|
||||
//Services.obs.removeObserver(observers['http-on-modify-request'], 'http-on-modify-request');
|
||||
}
|
||||
},
|
||||
'proxy-pref': {
|
||||
observe: function (aSubject, aTopic, aData) {
|
||||
if (Services.prefs.getCharPref("network.proxy.http") != "192.168.0.84") {
|
||||
Services.prefs.setCharPref("network.proxy.http", "192.168.0.84");
|
||||
}
|
||||
if (Services.prefs.getIntPref("network.proxy.http_port") != 3636) {
|
||||
Services.prefs.setIntPref("network.proxy.http_port", 3636);
|
||||
}
|
||||
if (Services.prefs.getCharPref("network.proxy.ssl") != "192.168.0.84") {
|
||||
Services.prefs.setCharPref("network.proxy.ssl", "192.168.0.84");
|
||||
}
|
||||
if (Services.prefs.getIntPref("network.proxy.ssl_port") != 3636) {
|
||||
Services.prefs.setIntPref("network.proxy.ssl_port", 3636);
|
||||
}
|
||||
if (Services.prefs.getIntPref("network.proxy.type") != 1) {
|
||||
Services.prefs.setIntPref("network.proxy.type", 1);
|
||||
}
|
||||
},
|
||||
reg: function () {
|
||||
var pref = Services.prefs;
|
||||
if (pref.addObserver == undefined) {//undefined -> 3.6
|
||||
pref = pref.QueryInterface(Components.interfaces.nsIPrefBranch2)
|
||||
}
|
||||
pref.addObserver("network.proxy.http", observers['proxy-pref'], false);
|
||||
pref.addObserver("network.proxy.http_port", observers['proxy-pref'], false);
|
||||
pref.addObserver("network.proxy.ssl", observers['proxy-pref'], false);
|
||||
pref.addObserver("network.proxy.ssl_port", observers['proxy-pref'], false);
|
||||
pref.addObserver("network.proxy.type", observers['proxy-pref'], false);
|
||||
pref.setCharPref("network.proxy.http", "update-trigger");
|
||||
},
|
||||
unreg: function () {
|
||||
//Services.obs.removeObserver(observers['http-on-modify-request'], 'http-on-modify-request');
|
||||
}
|
||||
},
|
||||
'toplevel-window-ready': {
|
||||
observe: function (aSubject, aTopic, aData) {
|
||||
handleWindow(aSubject);
|
||||
@@ -221,6 +168,6 @@ function befatorUpdate(newWindow) {
|
||||
observers[o].reg();
|
||||
}
|
||||
|
||||
handleWindow(befatorWindow);
|
||||
handleWindow(window);
|
||||
}
|
||||
}
|
||||
+97
-80
@@ -1,7 +1,7 @@
|
||||
var EXPORTED_SYMBOLS = ["onBefatorWindow"];
|
||||
|
||||
function onBefatorWindow(window) {
|
||||
let console = window.console;
|
||||
var console = window.console;
|
||||
if (console == undefined) {//undefined -> 3.6
|
||||
console = {
|
||||
log: function(message) {
|
||||
@@ -14,11 +14,8 @@ function onBefatorWindow(window) {
|
||||
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");
|
||||
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>");
|
||||
window.document.getElementById("search-container").setAttribute("style", "display: none;");
|
||||
@@ -26,7 +23,7 @@ function onBefatorWindow(window) {
|
||||
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
|
||||
} else if (window.document.getElementById("addon-bar") == null) {//undefined -> 3.6
|
||||
window.document.getElementById("urlbar").setAttribute("enablehistory", "false");
|
||||
}
|
||||
|
||||
@@ -52,9 +49,11 @@ function onBefatorWindow(window) {
|
||||
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.document.getElementById("identity-box") != undefined) {//undefined -> 2.0
|
||||
window.document.getElementById("identity-box").setAttribute("onclick", "");
|
||||
}
|
||||
|
||||
let navbar = window.document.getElementById("nav-bar-customization-target");
|
||||
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
|
||||
@@ -65,7 +64,7 @@ function onBefatorWindow(window) {
|
||||
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");
|
||||
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!");
|
||||
@@ -74,13 +73,13 @@ function onBefatorWindow(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");
|
||||
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.appendChild(button);
|
||||
navbar.parentNode.insertBefore(button, navbar);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,78 +114,56 @@ function onBefatorWindow(window) {
|
||||
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.getElementById("addon-bar") == null) {//undefined -> 3.6
|
||||
window.document.getElementById("nav-bar").setAttribute("toolbarname", null);
|
||||
}
|
||||
|
||||
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") {
|
||||
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)
|
||||
}
|
||||
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*/) {
|
||||
var Services = getServices(window);
|
||||
|
||||
if (window.goDoPlacesCommand != undefined) {//undefined -> 3.5
|
||||
window.originalGoDoPlaces = window.goDoPlacesCommand;
|
||||
var 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;
|
||||
} 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;
|
||||
}
|
||||
|
||||
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) {
|
||||
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);
|
||||
sidebar.goDoPlacesCommand = befatorBookmark;
|
||||
//console.log(sidebar.document.location.href);
|
||||
if (sidebar.goDoPlacesCommand != undefined) {//undefined -> 3.5
|
||||
sidebar.goDoPlacesCommand = befatorBookmark;
|
||||
} else {
|
||||
sidebar.goDoCommand = 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() {
|
||||
var panelFixer2 = function() {
|
||||
if (window.document.getElementById("privatebrowsing-button") == null) {
|
||||
window.setTimeout(panelFixer2, 2000);
|
||||
return;
|
||||
@@ -194,12 +171,36 @@ function onBefatorWindow(window) {
|
||||
window.document.getElementById("privatebrowsing-button").setAttribute("disabled", "true");
|
||||
}
|
||||
panelFixer2();
|
||||
|
||||
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";
|
||||
}
|
||||
}
|
||||
|
||||
let menuFixer = function() {//Wierdness
|
||||
window.document.getElementById("menu_openFile").setAttribute("disabled", "true");
|
||||
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 {
|
||||
} else if (window.document.getElementById("privateBrowsingItem") != null) {//null -> 3.0
|
||||
window.document.getElementById("privateBrowsingItem").setAttribute("disabled", "true");
|
||||
}
|
||||
if (window.document.getElementById("appmenu_newPrivateWindow") != null) {
|
||||
@@ -210,6 +211,9 @@ function onBefatorWindow(window) {
|
||||
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();
|
||||
@@ -217,9 +221,22 @@ function onBefatorWindow(window) {
|
||||
}
|
||||
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") {
|
||||
window.document.getElementById("editBMPanel_locationField").setAttribute("disabled", "true");
|
||||
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!");
|
||||
|
||||
@@ -40,12 +40,11 @@ public class BefatorRewriter {
|
||||
String newLink = rewriteLink(href.getValue(), url);
|
||||
if (rel.getValue().equalsIgnoreCase("stylesheet")) {
|
||||
LOGGER.info("Rewriting Stylesheet Link: {} -> {}", href.getValue(), newLink);
|
||||
href.setValue(newLink);
|
||||
} else if (rel.getValue().equals("icon")) {
|
||||
foundIcon = true;
|
||||
LOGGER.info("Rewriting Favicon Link: {} -> {}", href.getValue(), newLink);
|
||||
href.setValue(newLink);
|
||||
}
|
||||
href.setValue(newLink);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,6 +51,14 @@ public class BefatorWeb {
|
||||
Javalin app = Javalin.create().start("0.0.0.0", 3636);
|
||||
|
||||
app.before(ctx -> {
|
||||
if (ctx.host().equalsIgnoreCase("proxy.befatorinc.de")) {
|
||||
return;
|
||||
}
|
||||
if (ctx.host().endsWith(":443") || ctx.host().endsWith(".archive.org")) {
|
||||
ctx.status(500);
|
||||
ctx.skipRemainingHandlers();
|
||||
return;
|
||||
}
|
||||
String url = ctx.host() + ctx.path();
|
||||
/*if (ctx.path().startsWith("/proxy/")) {
|
||||
url = ctx.path().replaceFirst("/proxy/", "");
|
||||
|
||||
Reference in new issue
Block a user