forked from PurpleI2P/i2pdbrowser
R4SAS
4 years ago
38 changed files with 791 additions and 5343 deletions
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,32 @@
@@ -0,0 +1,32 @@
|
||||
-----BEGIN CERTIFICATE----- |
||||
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 |
||||
3ZUnv2ipo2fpr69NtuBnutK6gw== |
||||
-----END CERTIFICATE----- |
@ -1,32 +0,0 @@
@@ -1,32 +0,0 @@
|
||||
-----BEGIN CERTIFICATE----- |
||||
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 |
||||
wpBgPyAFAwouPy1whmnx |
||||
-----END CERTIFICATE----- |
@ -1,32 +0,0 @@
@@ -1,32 +0,0 @@
|
||||
-----BEGIN CERTIFICATE----- |
||||
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 |
||||
o3eNsanvTU+TIFBh2Q== |
||||
-----END CERTIFICATE----- |
@ -0,0 +1,34 @@
@@ -0,0 +1,34 @@
|
||||
-----BEGIN CERTIFICATE----- |
||||
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 |
||||
LD8d2z2Lgg== |
||||
-----END CERTIFICATE----- |
@ -1 +0,0 @@
@@ -1 +0,0 @@
|
||||
resource cck2 modules/ |
@ -1,154 +0,0 @@
@@ -1,154 +0,0 @@
|
||||
const {classes: Cc, interfaces: Ci, utils: Cu} = Components; |
||||
Cu.import("resource://gre/modules/Services.jsm"); |
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm"); |
||||
|
||||
const EXPORTED_SYMBOLS = []; |
||||
|
||||
var gForceExternalHandler = false; |
||||
|
||||
XPCOMUtils.defineLazyServiceGetter(this, "extProtocolSvc", |
||||
"@mozilla.org/uriloader/external-protocol-service;1", "nsIExternalProtocolService"); |
||||
|
||||
var documentObserver = { |
||||
observe: function observe(subject, topic, data) { |
||||
if (subject instanceof Ci.nsIDOMWindow && topic == 'content-document-global-created') { |
||||
var doc = subject.document; |
||||
doc.addEventListener("DOMContentLoaded", function onLoad(event) { |
||||
event.target.removeEventListener("DOMContentLoaded", onLoad, false); |
||||
// If the parent document is a local file, don't do anything
|
||||
// Links will just work
|
||||
if (doc.location.href.indexOf("file://") == 0) { |
||||
return; |
||||
} |
||||
var links = event.target.getElementsByTagName("a"); |
||||
for (var i=0; i < links.length; i++) { |
||||
var link = links[i]; |
||||
if (link.href.indexOf("file://") != 0) { |
||||
continue; |
||||
} |
||||
link.addEventListener("click", function(link) { |
||||
return function(event) { |
||||
event.preventDefault(); |
||||
if (gForceExternalHandler) { |
||||
extProtocolSvc.loadUrl(Services.io.newURI(link.href, null, null)); |
||||
} else { |
||||
var target = "_self"; |
||||
if (link.hasAttribute("target")) { |
||||
target = link.getAttribute("target"); |
||||
} |
||||
// If we were told somewhere other than current (based on modifier keys), use it
|
||||
var where = whereToOpenLink(event); |
||||
if (where != "current" || target == "_blank") { |
||||
sendAsyncMessage("cck2:open-url", { |
||||
"url": link.href, |
||||
"where": (target == "_blank") ? "tab" : where |
||||
}); |
||||
return; |
||||
} |
||||
switch (target) { |
||||
case "_self": |
||||
link.ownerDocument.location = link.href; |
||||
break; |
||||
case "_parent": |
||||
link.ownerDocument.defaultView.parent.document.location = link.href; |
||||
break; |
||||
case "_top": |
||||
link.ownerDocument.defaultView.top.document.location = link.href; |
||||
break; |
||||
default: |
||||
// Attempt to find the iframe that this goes into
|
||||
var iframes = doc.defaultView.parent.document.getElementsByName(target); |
||||
if (iframes.length > 0) { |
||||
iframes[0].contentDocument.location = link.href; |
||||
} else { |
||||
link.ownerDocument.location = link.href; |
||||
} |
||||
break; |
||||
} |
||||
} |
||||
} |
||||
}(link), false); |
||||
} |
||||
}, false); |
||||
} |
||||
} |
||||
} |
||||
|
||||
// Don't do this check before Firefox 29
|
||||
if (Services.vc.compare(Services.appinfo.version, "29") > 0) { |
||||
try { |
||||
if (Services.prefs.getCharPref("capability.policy.default.checkloaduri.enabled") == "allAccess") { |
||||
gForceExternalHandler = !extProtocolSvc.isExposedProtocol('file'); |
||||
Services.obs.addObserver(documentObserver, "content-document-global-created", false); |
||||
addEventListener("unload", function() { |
||||
Services.obs.removeObserver(documentObserver, "content-document-global-created", false); |
||||
}) |
||||
} |
||||
} catch (e) {} |
||||
} |
||||
|
||||
|
||||
/* Copied from http://mxr.mozilla.org/mozilla-central/source/browser/base/content/utilityOverlay.js?raw=1 */ |
||||
|
||||
function getBoolPref(prefname, def) |
||||
{ |
||||
try { |
||||
return Services.prefs.getBoolPref(prefname); |
||||
} |
||||
catch(er) { |
||||
return def; |
||||
} |
||||
} |
||||
|
||||
/* whereToOpenLink() looks at an event to decide where to open a link. |
||||
* |
||||
* The event may be a mouse event (click, double-click, middle-click) or keypress event (enter). |
||||
* |
||||
* On Windows, the modifiers are: |
||||
* Ctrl new tab, selected |
||||
* Shift new window |
||||
* Ctrl+Shift new tab, in background |
||||
* Alt save |
||||
* |
||||
* Middle-clicking is the same as Ctrl+clicking (it opens a new tab). |
||||
* |
||||
* Exceptions: |
||||
* - Alt is ignored for menu items selected using the keyboard so you don't accidentally save stuff. |
||||
* (Currently, the Alt isn't sent here at all for menu items, but that will change in bug 126189.) |
||||
* - Alt is hard to use in context menus, because pressing Alt closes the menu. |
||||
* - Alt can't be used on the bookmarks toolbar because Alt is used for "treat this as something draggable". |
||||
* - The button is ignored for the middle-click-paste-URL feature, since it's always a middle-click. |
||||
*/ |
||||
function whereToOpenLink( e, ignoreButton, ignoreAlt ) |
||||
{ |
||||
Components.utils.import("resource://gre/modules/AppConstants.jsm"); |
||||
|
||||
// This method must treat a null event like a left click without modifier keys (i.e.
|
||||
// e = { shiftKey:false, ctrlKey:false, metaKey:false, altKey:false, button:0 })
|
||||
// for compatibility purposes.
|
||||
if (!e) |
||||
return "current"; |
||||
|
||||
var shift = e.shiftKey; |
||||
var ctrl = e.ctrlKey; |
||||
var meta = e.metaKey; |
||||
var alt = e.altKey && !ignoreAlt; |
||||
|
||||
// ignoreButton allows "middle-click paste" to use function without always opening in a new window.
|
||||
var middle = !ignoreButton && e.button == 1; |
||||
var middleUsesTabs = true; |
||||
|
||||
// Don't do anything special with right-mouse clicks. They're probably clicks on context menu items.
|
||||
|
||||
var metaKey = AppConstants.platform == "macosx" ? meta : ctrl; |
||||
if (metaKey || (middle && middleUsesTabs)) |
||||
return shift ? "tabshifted" : "tab"; |
||||
|
||||
if (alt && getBoolPref("browser.altClickSave", false)) |
||||
return "save"; |
||||
|
||||
if (shift || (middle && !middleUsesTabs)) |
||||
return "window"; |
||||
|
||||
return "current"; |
||||
} |
@ -1,183 +0,0 @@
@@ -1,183 +0,0 @@
|
||||
const {classes: Cc, interfaces: Ci, utils: Cu} = Components; |
||||
Cu.import("resource://gre/modules/Services.jsm"); |
||||
|
||||
const EXPORTED_SYMBOLS = []; |
||||
|
||||
var gAllowedPasteSites = []; |
||||
var gAllowedCutCopySites = []; |
||||
var gDeniedPasteSites = []; |
||||
var gDeniedCutCopySites = []; |
||||
var gDefaultPastePolicy = false; |
||||
var gDefaultCutCopyPolicy = false; |
||||
|
||||
function allowCutCopy(doc) { |
||||
var win = doc.defaultView; |
||||
if (win !== win.top) { |
||||
// It's an iframe. Use the top level window
|
||||
// for security purposes
|
||||
win = win.top; |
||||
} |
||||
|
||||
if (gDefaultCutCopyPolicy == true) { |
||||
for (var i=0; i < gDeniedCutCopySites.length; i++) { |
||||
if (win.location.href.indexOf(gDeniedCutCopySites[i]) == 0) { |
||||
return false; |
||||
} |
||||
} |
||||
return true; |
||||
} else { |
||||
for (var i=0; i < gAllowedCutCopySites.length; i++) { |
||||
if (win.location.href.indexOf(gAllowedCutCopySites[i]) == 0) { |
||||
return true; |
||||
} |
||||
} |
||||
return false; |
||||
} |
||||
} |
||||
|
||||
function allowPaste(doc) { |
||||
var win = doc.defaultView; |
||||
if (win !== win.top) { |
||||
// It's an iframe. Use the top level window
|
||||
// for security purposes
|
||||
win = win.top; |
||||
} |
||||
|
||||
if (gDefaultPastePolicy == true) { |
||||
for (var i=0; i < gDeniedPasteSites.length; i++) { |
||||
if (win.location.href.indexOf(gDeniedPasteSites[i]) == 0) { |
||||
return false; |
||||
break; |
||||
} |
||||
} |
||||
return true; |
||||
} else { |
||||
for (var i=0; i < gAllowedPasteSites.length; i++) { |
||||
if (win.location.href.indexOf(gAllowedPasteSites[i]) == 0) { |
||||
return true; |
||||
break; |
||||
} |
||||
} |
||||
return false; |
||||
} |
||||
} |
||||
|
||||
function myExecCommand(doc, originalExecCommand) { |
||||
return function(aCommandName, aShowDefaultUI, aValueArgument) { |
||||
switch (aCommandName.toLowerCase()) { |
||||
case "cut": |
||||
case "copy": |
||||
if (allowCutCopy(doc)) { |
||||
var win = Services.wm.getMostRecentWindow("navigator:browser"); |
||||
win.goDoCommand("cmd_" + aCommandName.toLowerCase()); |
||||
return true; |
||||
} |
||||
break; |
||||
case "paste": |
||||
if (allowPaste(doc)) { |
||||
var win = Services.wm.getMostRecentWindow("navigator:browser"); |
||||
win.goDoCommand("cmd_" + aCommandName.toLowerCase()); |
||||
return true; |
||||
} |
||||
break; |
||||
} |
||||
return originalExecCommand.call(doc, aCommandName, aShowDefaultUI, aValueArgument); |
||||
} |
||||
} |
||||
|
||||
function myQueryCommandSupported(doc, originalQueryCommandSupported) { |
||||
return function(aCommandName) { |
||||
switch (aCommandName.toLowerCase()) { |
||||
case "cut": |
||||
case "copy": |
||||
if (allowCutCopy(doc)) { |
||||
return true; |
||||
} |
||||
break; |
||||
case "paste": |
||||
if (allowPaste(doc)) { |
||||
return true; |
||||
} |
||||
break; |
||||
} |
||||
return originalQueryCommandSupported.call(doc, aCommandName, aShowDefaultUI, aValueArgument); |
||||
} |
||||
} |
||||
|
||||
var documentObserver = { |
||||
observe: function observe(subject, topic, data) { |
||||
if (subject instanceof Ci.nsIDOMWindow && topic == 'content-document-global-created') { |
||||
var doc = subject.document; |
||||
var cutCopyAllowed = allowCutCopy(doc); |
||||
var pasteAllowed = allowPaste(doc); |
||||
if (!cutCopyAllowed && !pasteAllowed) { |
||||
return; |
||||
} |
||||
var originalExecCommand = Cu.waiveXrays(doc).execCommand; |
||||
Cu.exportFunction(myExecCommand(doc, originalExecCommand), doc, {defineAs: "execCommand"}); |
||||
var originalQueryCommandSupported = Cu.waiveXrays(doc).queryCommandSupported; |
||||
Cu.exportFunction(myQueryCommandSupported(doc, originalQueryCommandSupported), doc, {defineAs: "queryCommandSupported"}); |
||||
var originalQueryCommandEnabled = Cu.waiveXrays(doc).queryCommandEnabled; |
||||
Cu.exportFunction(myQueryCommandSupported(doc, originalQueryCommandEnabled), doc, {defineAs: "queryCommandEnabled"}); |
||||
} |
||||
} |
||||
} |
||||
|
||||
// Don't do this check before Firefox 29
|
||||
if (Services.vc.compare(Services.appinfo.version, "29") > 0) { |
||||
try { |
||||
if (Services.prefs.getCharPref("capability.policy.default.Clipboard.cutcopy") == "allAccess") { |
||||
gDefaultCutCopyPolicy = true; |
||||
} |
||||
} catch (e) {} |
||||
try { |
||||
if (Services.prefs.getCharPref("capability.policy.default.Clipboard.paste") == "allAccess") { |
||||
gDefaultPastePolicy = true; |
||||
} |
||||
} catch (e) {} |
||||
try { |
||||
var policies = []; |
||||
policies = Services.prefs.getCharPref("capability.policy.policynames").split(', '); |
||||
for (var i=0; i < policies.length; i++ ) { |
||||
try { |
||||
if (Services.prefs.getCharPref("capability.policy." + policies[i] + ".Clipboard.cutcopy") == "allAccess") { |
||||
var allowedCutCopySites = Services.prefs.getCharPref("capability.policy." + policies[i] + ".sites").split(" "); |
||||
for (var j=0; j < allowedCutCopySites.length; j++) { |
||||
gAllowedCutCopySites.push(allowedCutCopySites[j]); |
||||
} |
||||
} |
||||
} catch(e) {} |
||||
try { |
||||
if (Services.prefs.getCharPref("capability.policy." + policies[i] + ".Clipboard.cutcopy") == "noAccess") { |
||||
var deniedCutCopySites = Services.prefs.getCharPref("capability.policy." + policies[i] + ".sites").split(" "); |
||||
for (var j=0; j < deniedCutCopySites.length; j++) { |
||||
gDeniedCutCopySites.push(deniedCutCopySites[j]); |
||||
} |
||||
} |
||||
} catch(e) {} |
||||
try { |
||||
if (Services.prefs.getCharPref("capability.policy." + policies[i] + ".Clipboard.paste") == "allAccess") { |
||||
var allowedPasteSites = Services.prefs.getCharPref("capability.policy." + policies[i] + ".sites").split(" "); |
||||
for (var j=0; j < allowedPasteSites.length; j++) { |
||||
gAllowedPasteSites.push(allowedPasteSites[j]); |
||||
} |
||||
} |
||||
} catch(e) {} |
||||
try { |
||||
if (Services.prefs.getCharPref("capability.policy." + policies[i] + ".Clipboard.paste") == "noAccess") { |
||||
var deniedPasteSites = Services.prefs.getCharPref("capability.policy." + policies[i] + ".sites").split(" "); |
||||
for (var j=0; j < deniedPasteSites.length; j++) { |
||||
gDeniedPasteSites.push(deniedPasteSites[j]); |
||||
} |
||||
} |
||||
} catch(e) {} |
||||
} |
||||
} catch (e) {} |
||||
if (gDefaultCutCopyPolicy || gDefaultPastePolicy || |
||||
gAllowedCutCopySites.length > 0 || gAllowedPasteSites> 0) { |
||||
Services.obs.addObserver(documentObserver, "content-document-global-created", false); |
||||
addEventListener("unload", function() { |
||||
Services.obs.removeObserver(documentObserver, "content-document-global-created", false); |
||||
}) |
||||
} |
||||
} |
File diff suppressed because it is too large
Load Diff
@ -1,111 +0,0 @@
@@ -1,111 +0,0 @@
|
||||
/* This file overlays about:addons. It does the following: */ |
||||
/* Workaround https://bugzilla.mozilla.org/show_bug.cgi?id=1132971 */ |
||||
/* Hide the "Install Add-on From File" menu if xpinstall.enabled is false */ |
||||
/* Hides the discover pane if xpinstall.enabled is false */ |
||||
/* Hides the add-on entry if specified in the CCK2 config */ |
||||
|
||||
const EXPORTED_SYMBOLS = []; |
||||
|
||||
const {classes: Cc, interfaces: Ci, utils: Cu} = Components; |
||||
|
||||
Cu.import("resource://gre/modules/Services.jsm"); |
||||
Cu.import("resource://cck2/CCK2.jsm"); |
||||
|
||||
var addonId = "cck2wizard@kaply.com"; |
||||
|
||||
var observer = { |
||||
observe: function observe(subject, topic, data) { |
||||
switch (topic) { |
||||
case "chrome-document-global-created": |
||||
var win = subject.QueryInterface(Components.interfaces.nsIDOMWindow); |
||||
win.addEventListener("load", function onLoad(event) { |
||||
win.removeEventListener("load", onLoad, false); |
||||
var doc = event.target; |
||||
var url = doc.location.href.split("?")[0].split("#")[0]; |
||||
switch (url) { |
||||
case "about:addons": |
||||
case "chrome://mozapps/content/extensions/extensions.xul": |
||||
var configs = CCK2.getConfigs(); |
||||
var hiddenAddons = []; |
||||
var requiredAddons = []; |
||||
for (let id in configs) { |
||||
var config = configs[id]; |
||||
if (config && "extension" in config && config.extension.hide) { |
||||
hiddenAddons.push(config.extension.id); |
||||
} |
||||
if (config.requiredAddons) { |
||||
requiredAddons.push.apply(requiredAddons, config.requiredAddons.split(",")); |
||||
} |
||||
} |
||||
if (hiddenAddons.length > 0 || requiredAddons.length > 0) { |
||||
var ss; |
||||
for (var i = 0; i < doc.styleSheets.length; i++) { |
||||
if (doc.styleSheets[i].href == "chrome://mozapps/skin/extensions/extensions.css") { |
||||
ss = doc.styleSheets[i]; |
||||
break; |
||||
} |
||||
} |
||||
for (var i=0; i < hiddenAddons.length; i++) { |
||||
ss.insertRule("richlistitem[value='" + hiddenAddons[i] + "'] { display: none;}", ss.cssRules.length); |
||||
} |
||||
for (var i=0; i < requiredAddons.length; i++) { |
||||
ss.insertRule("richlistitem[value='" + requiredAddons[i] + "'] button[anonid='disable-btn'] { display: none;}", ss.cssRules.length); |
||||
ss.insertRule("richlistitem[value='" + requiredAddons[i] + "'] button[anonid='remove-btn'] { display: none;}", ss.cssRules.length); |
||||
} |
||||
if (requiredAddons.length > 0) { |
||||
win.gViewController.commands.cmd_disableItem.origIsEnabled = win.gViewController.commands.cmd_disableItem.isEnabled; |
||||
win.gViewController.commands.cmd_disableItem.isEnabled = function(aAddon) { if (aAddon && requiredAddons.indexOf(aAddon.id) != -1) return false; return this.origIsEnabled;} |
||||
win.gViewController.commands.cmd_uninstallItem.origIsEnabled = win.gViewController.commands.cmd_disableItem.isEnabled; |
||||
win.gViewController.commands.cmd_uninstallItem.isEnabled = function(aAddon) { if (aAddon && requiredAddons.indexOf(aAddon.id) != -1) return false; return this.origIsEnabled;} |
||||
} |
||||
} |
||||
var showDiscoverPane = true; |
||||
var xpinstallEnabled = true; |
||||
try { |
||||
xpinstallEnabled = Services.prefs.getBoolPref("xpinstall.enabled"); |
||||
} catch (e) {} |
||||
try { |
||||
showDiscoverPane = Services.prefs.getBoolPref("extensions.getAddons.showPane"); |
||||
} catch (e) {} |
||||
if (!xpinstallEnabled || !showDiscoverPane) { |
||||
// Work around Mozilla bug 1132971
|
||||
// Hide the discover pane if it is the selected pane
|
||||
if (E("view-port", doc) && E("view-port", doc).selectedIndex == 0) { |
||||
try { |
||||
win.gViewController.loadView("addons://list/extension"); |
||||
} catch (ex) { |
||||
// This fails with Webconverger installed. Ignore it.
|
||||
} |
||||
} |
||||
} |
||||
if (!xpinstallEnabled) { |
||||
// Hide the "Install Add-on From File" separator
|
||||
hide(E("utils-installFromFile-separator", doc)); |
||||
// Hide the "Install Add-on From File" menuitem
|
||||
hide(E("utils-installFromFile", doc)); |
||||
win.gDragDrop.onDragOver = function(event) { |
||||
event.dataTransfer.dropEffect = "none"; |
||||
event.stopPropagation(); |
||||
event.preventDefault(); |
||||
}; |
||||
} |
||||
break; |
||||
} |
||||
}, false); |
||||
break; |
||||
} |
||||
} |
||||
} |
||||
|
||||
Services.obs.addObserver(observer, "chrome-document-global-created", false); |
||||
|
||||
function E(id, context) { |
||||
var element = context.getElementById(id); |
||||
return element; |
||||
} |
||||
|
||||
function hide(element) { |
||||
if (element) { |
||||
element.setAttribute("hidden", "true"); |
||||
} |
||||
} |
@ -1,33 +0,0 @@
@@ -1,33 +0,0 @@
|
||||
/* This file is a workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=1139509 */ |
||||
/* It bolds the Firefox version in the about dialog and unbolds the distribution information */ |
||||
/* It can be removed once Firefox 38 ESR is out of support */ |
||||
|
||||
const EXPORTED_SYMBOLS = []; |
||||
|
||||
const {classes: Cc, interfaces: Ci, utils: Cu} = Components; |
||||
|
||||
Cu.import("resource://gre/modules/Services.jsm"); |
||||
|
||||
var observer = { |
||||
observe: function observe(subject, topic, data) { |
||||
switch (topic) { |
||||
case "chrome-document-global-created": |
||||
var win = subject.QueryInterface(Components.interfaces.nsIDOMWindow); |
||||
win.addEventListener("load", function onLoad(event) { |
||||
win.removeEventListener("load", onLoad, false); |
||||
var doc = event.target; |
||||
var url = doc.location.href.split("?")[0].split("#")[0]; |
||||
switch (url) { |
||||
case "chrome://browser/content/aboutDialog.xul": |
||||
doc.querySelector("#version").style.fontWeight = "bold"; |
||||
doc.querySelector("#distribution").style.fontWeight = "normal"; |
||||
doc.querySelector("#distributionId").style.fontWeight = "normal"; |
||||
break; |
||||
} |
||||
}, false); |
||||
break; |
||||
} |
||||
} |
||||
} |
||||
|
||||
Services.obs.addObserver(observer, "chrome-document-global-created", false); |
@ -1,79 +0,0 @@
@@ -1,79 +0,0 @@
|
||||
/* This file overrides about:home. It does the following: |
||||
* Remove the sync button if Sync is disabled |
||||
* Remove the Addons button if Sync is disabled |
||||
* Remove the snippets if snippets are disabled |
||||
*/ |
||||
|
||||
const EXPORTED_SYMBOLS = []; |
||||
|
||||
const {classes: Cc, interfaces: Ci, utils: Cu} = Components; |
||||
|
||||
Cu.import("resource://gre/modules/Services.jsm"); |
||||
|
||||
var configs = null; |
||||
|
||||
var observer = { |
||||
observe: function observe(subject, topic, data) { |
||||
switch (topic) { |
||||
case "content-document-global-created": |
||||
var win = subject.QueryInterface(Components.interfaces.nsIDOMWindow); |
||||
win.addEventListener("load", function onLoad(event) { |
||||
win.removeEventListener("load", onLoad, false); |
||||
var doc = event.target; |
||||
var url = doc.location.href.split("?")[0].split("#")[0]; |
||||
switch (url) { |
||||
case "about:home": |
||||
case "chrome://browser/content/abouthome/aboutHome.xhtml": |
||||
if (!configs) { |
||||
// TODO - Make this Async
|
||||
configs = sendSyncMessage("cck2:get-configs")[0]; |
||||
} |
||||
for (let id in configs) { |
||||
var config = configs[id]; |
||||
if (config.disableSync) { |
||||
remove(E("sync", doc)); |
||||
} |
||||
if (config.disableAddonsManager) { |
||||
remove(E("addons", doc)); |
||||
} |
||||
if (config.disableWebApps) { |
||||
remove(E("apps", doc)); |
||||
} |
||||
if (config.removeSnippets) { |
||||
var snippets = E("snippets", doc); |
||||
if (snippets) { |
||||
snippets.style.display = "none"; |
||||
} |
||||
} |
||||
if (config.hiddenUI) { |
||||
for (var i=0; i < config.hiddenUI.length; i++) { |
||||
var uiElements = doc.querySelectorAll(config.hiddenUI[i]); |
||||
for (var j=0; j < uiElements.length; j++) { |
||||
var uiElement = uiElements[j]; |
||||
uiElement.setAttribute("hidden", "true"); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
break; |
||||
} |
||||
}, false); |
||||
break; |
||||
} |
||||
} |
||||
} |
||||
Services.obs.addObserver(observer, "content-document-global-created", false); |
||||
|
||||
addEventListener("unload", function() { |
||||
Services.obs.removeObserver(observer, "content-document-global-created", false); |
||||
}) |
||||
|
||||
function E(id, context) { |
||||
var element = context.getElementById(id); |
||||
return element; |
||||
} |
||||
|
||||
function remove(element) { |
||||
if (element && element.parentNode) |
||||
element.parentNode.removeChild(element); |
||||
} |
@ -1,62 +0,0 @@
@@ -1,62 +0,0 @@
|
||||
/* This file overrides about:support It does the following: |
||||
* Remove the reset Firefox button if disableResetFirefox is set |
||||
* Remove the safe mode Button if disableSafeMode is set |
||||
* Remove the box if both are set |
||||
*/ |
||||
|
||||
const EXPORTED_SYMBOLS = []; |
||||
|
||||
const {classes: Cc, interfaces: Ci, utils: Cu} = Components; |
||||
|
||||
Cu.import("resource://gre/modules/Services.jsm"); |
||||
Cu.import("resource://cck2/CCK2.jsm"); |
||||
|
||||
var configs = null; |
||||
|
||||
var observer = { |
||||
observe: function observe(subject, topic, data) { |
||||
switch (topic) { |
||||
case "chrome-document-global-created": |
||||
var win = subject.QueryInterface(Components.interfaces.nsIDOMWindow); |
||||
win.addEventListener("load", function onLoad(event) { |
||||
win.removeEventListener("load", onLoad, false); |
||||
var doc = event.target; |
||||
var url = doc.location.href.split("?")[0].split("#")[0]; |
||||
switch (url) { |
||||
case "about:support": |
||||
case "chrome://global/content/aboutSupport.xhtml": |
||||
if (!configs) { |
||||
configs = CCK2.getConfigs(); |
||||
} |
||||
for (let id in configs) { |
||||
var config = configs[id]; |
||||
if (config.disableResetFirefox) { |
||||
remove(E("reset-box", doc)); |
||||
} |
||||
if (config.disableSafeMode) { |
||||
remove(E("safe-mode-box", doc)); |
||||
} |
||||
if (config.disableResetFirefox && |
||||
config.disableSafeMode) { |
||||
remove(E("action-box", doc)); |
||||
} |
||||
} |
||||
break; |
||||
} |
||||
}, false); |
||||
break; |
||||
} |
||||
} |
||||
} |
||||
Services.obs.addObserver(observer, "chrome-document-global-created", false); |
||||
|
||||
function E(id, context) { |
||||
var element = context.getElementById(id); |
||||
return element; |
||||
} |
||||
|
||||
|
||||
function remove(element) { |
||||
if (element && element.parentNode) |
||||
element.parentNode.removeChild(element); |
||||
} |
@ -1,373 +0,0 @@
@@ -1,373 +0,0 @@
|
||||
/* This file modifies the main browser window. It does the following: |
||||
* Goes through the hiddenUI list and hides any UI |
||||
* |
||||
*/ |
||||
|
||||
const EXPORTED_SYMBOLS = []; |
||||
|
||||
const {classes: Cc, interfaces: Ci, utils: Cu} = Components; |
||||
|
||||
Cu.import("resource://gre/modules/Services.jsm"); |
||||
Cu.import("resource:///modules/CustomizableUI.jsm"); |
||||
Cu.import("resource://gre/modules/PrivateBrowsingUtils.jsm"); |
||||
Cu.import("resource://cck2/CCK2.jsm"); |
||||
|
||||
var configs = null; |
||||
|
||||
var observer = { |
||||
observe: function observe(subject, topic, data) { |
||||
switch (topic) { |
||||
case "chrome-document-global-created": |
||||
var win = subject.QueryInterface(Components.interfaces.nsIDOMWindow); |
||||
win.addEventListener("load", function onLoad(event) { |
||||
win.removeEventListener("load", onLoad, false); |
||||
var doc = event.target; |
||||
var url = doc.location.href.split("?")[0].split("#")[0]; |
||||
switch (url) { |
||||
case "chrome://browser/content/browser.xul": |
||||
// Workaround https://bugzilla.mozilla.org/show_bug.cgi?id=1149617
|
||||
var origSetReportPhishingMenu = win.gSafeBrowsing.setReportPhishingMenu; |
||||
win.gSafeBrowsing.setReportPhishingMenu = function() { |
||||
try { |
||||
origSetReportPhishingMenu(); |
||||
} catch (e) {} |
||||
} |
||||
|
||||
win.addEventListener("unload", function onUnload(event) { |
||||
win.removeEventListener("unload", onUnload, false); |
||||
var panelUIPopup = doc.getElementById("PanelUI-popup"); |
||||
if (panelUIPopup) { |
||||
E("PanelUI-popup", doc).removeEventListener("popupshowing", onPanelShowing, false); |
||||
} |
||||
}); |
||||
var panelUIPopup = doc.getElementById("PanelUI-popup"); |
||||
if (panelUIPopup) { |
||||
E("PanelUI-popup", doc).addEventListener("popupshowing", onPanelShowing, false); |
||||
} |
||||
var appMenuPopup = doc.getElementById("appMenu-popup"); |
||||
if (appMenuPopup) { |
||||
E("appMenu-popup", doc).addEventListener("popupshowing", onAppMenuShowing, false); |
||||
} |
||||
configs = CCK2.getConfigs(); |
||||
for (let id in configs) { |
||||
config = configs[id]; |
||||
if (config.disablePrivateBrowsing && |
||||
PrivateBrowsingUtils.isWindowPrivate(win)) { |
||||
win.setTimeout(function() { |
||||
Services.prompt.alert(win, "Private Browsing", "Private Browsing has been disabled by your administrator"); |
||||
win.close(); |
||||
}, 0, false); |
||||
} |
||||
if (config.disablePrivateBrowsing) { |
||||
disablePrivateBrowsing(doc); |
||||
} |
||||
if (config.disableSync) { |
||||
disableSync(doc); |
||||
} |
||||
if (config.disableAddonsManager) { |
||||
disableAddonsManager(doc); |
||||
} |
||||
if (config.removeDeveloperTools) { |
||||
Services.tm.mainThread.dispatch(function() { |
||||
removeDeveloperTools(doc); |
||||
}, Ci.nsIThread.DISPATCH_NORMAL); |
||||
} |
||||
if (config.disableErrorConsole) { |
||||
disableErrorConsole(doc); |
||||
} |
||||
if (config.disableFirefoxHealthReport) { |
||||
var healthReportMenu = doc.getElementById("healthReport"); |
||||
if (healthReportMenu) { |
||||
healthReportMenu.parentNode.removeChild(healthReportMenu); |
||||
} |
||||
} |
||||
if (config.removeSafeModeMenu) { |
||||
hide(E("helpSafeMode", doc)); |
||||
} |
||||
if (config.titlemodifier) { |
||||
doc.getElementById("main-window").setAttribute("titlemodifier", config.titlemodifier); |
||||
} |
||||
if (config.removeSetDesktopBackground) { |
||||
// Because this is on a context menu, we can't use "hidden"
|
||||
if (E("context-setDesktopBackground", doc)) { |
||||
E("context-setDesktopBackground", doc).setAttribute("style", "display: none;"); |
||||
} |
||||
} |
||||
if (config.disableWebApps) { |
||||
CustomizableUI.destroyWidget("web-apps-button"); |
||||
hide(E("menu_openApps", doc)); |
||||
} |
||||
if (config.disableHello) { |
||||
CustomizableUI.destroyWidget("loop-button"); |
||||
hide(E("menu_openLoop", doc)); |
||||
} |
||||
if (config.disablePocket) { |
||||
CustomizableUI.destroyWidget("pocket-button"); |
||||
} |
||||
if (config.disableSharePage) { |
||||
CustomizableUI.destroyWidget("social-share-button"); |
||||
// Because these are on a context menu, we can't use "hidden"
|
||||
if (E("context-sharelink", doc)) { |
||||
E("context-sharelink", doc).setAttribute("style", "display: none;"); |
||||
} |
||||
if (E("context-shareselect", doc)) { |
||||
E("context-shareselect", doc).setAttribute("style", "display: none;"); |
||||
} |
||||
if (E("context-shareimage", doc)) { |
||||
E("context-shareimage", doc).setAttribute("style", "display: none;"); |
||||
} |
||||
if (E("context-sharevideo", doc)) { |
||||
E("context-sharevideo", doc).setAttribute("style", "display: none;"); |
||||
} |
||||
if (E("context-sharepage", doc)) { |
||||
E("context-sharepage", doc).setAttribute("style", "display: none;"); |
||||
} |
||||
} |
||||
if (config.disableSocialAPI) { |
||||
win.SocialActivationListener = {}; |
||||
} |
||||
if (config.disableForget) { |
||||
CustomizableUI.destroyWidget("panic-button"); |
||||
} |
||||
if (config.hiddenUI) { |
||||
hideUIElements(doc, config.hiddenUI); |
||||
} |
||||
if (config.helpMenu) { |
||||
// We need to run this function on a delay, because we won't know
|
||||
// if the about menu is hidden for mac until after it is run.
|
||||
Services.tm.mainThread.dispatch(function() { |
||||
var helpMenuPopup = doc.getElementById("menu_HelpPopup"); |
||||
var menuitem = doc.createElement("menuitem"); |
||||
menuitem.setAttribute("label", config.helpMenu.label); |
||||
if ("accesskey" in config.helpMenu) { |
||||
menuitem.setAttribute("accesskey", config.helpMenu.accesskey); |
||||
} |
||||
menuitem.setAttribute("oncommand", "openUILink('" + config.helpMenu.url + "');"); |
||||
menuitem.setAttribute("onclick", "checkForMiddleClick(this, event);"); |
||||
if (!E("aboutName", doc) || E("aboutName", doc).hidden) { |
||||
// Mac
|
||||
helpMenuPopup.appendChild(menuitem); |
||||
} else { |
||||
helpMenuPopup.insertBefore(menuitem, E("aboutName", doc)); |
||||
helpMenuPopup.insertBefore(doc.createElement("menuseparator"), |
||||
E("aboutName", doc)); |
||||
} |
||||
}, Ci.nsIThread.DISPATCH_NORMAL); |
||||
} |
||||
if (config.firstrun || config.upgrade) { |
||||
if (config.displayBookmarksToolbar || (config.bookmarks && config.bookmarks.toolbar)) { |
||||
CustomizableUI.setToolbarVisibility("PersonalToolbar", "true"); |
||||
} |
||||
if (config.displayMenuBar) { |
||||
CustomizableUI.setToolbarVisibility("toolbar-menubar", "true"); |
||||
} |
||||
if (config.showSearchBar) { |
||||
CustomizableUI.addWidgetToArea("search-container", CustomizableUI.AREA_NAVBAR, |
||||
CustomizableUI.getPlacementOfWidget("urlbar-container").position + 1); |
||||
} |
||||
config.firstrun = false; |
||||
config.upgrade = false; |
||||
} |
||||
} |
||||
break; |
||||
case "chrome://browser/content/places/places.xul": |
||||
case "chrome://browser/content/bookmarks/bookmarksPanel.xul": |
||||
case "chrome://browser/content/history/history-panel.xul": |
||||
configs = CCK2.getConfigs(); |
||||
for (let id in configs) { |
||||
var config = configs[id]; |
||||
if (config.disablePrivateBrowsing) { |
||||
if (E("placesContext_open:newprivatewindow", doc)) { |
||||
E("placesContext_open:newprivatewindow", doc).setAttribute("style", "display: none;"); |
||||
} |
||||
} |
||||
if (config.hiddenUI) { |
||||
hideUIElements(doc, config.hiddenUI); |
||||
} |
||||
} |
||||
break; |
||||
} |
||||
}, false); |
||||
break; |
||||
} |
||||
} |
||||
} |
||||
Services.obs.addObserver(observer, "chrome-document-global-created", false); |
||||
|
||||
function disableSync(doc) { |
||||
var win = doc.defaultView; |
||||
if (win.gSyncUI) { |
||||
var mySyncUI = { |
||||
init: function() { |
||||
return; |
||||
}, |
||||
initUI: function() { |
||||
return; |
||||
}, |
||||
updateUI: function() { |
||||
hide(E("sync-setup-state", doc)); |
||||
hide(E("sync-syncnow-state", doc)); |
||||
hide(E("sync-setup", doc)); |
||||
hide(E("sync-syncnowitem", doc)); |
||||
} |
||||
} |
||||
win.gSyncUI = mySyncUI; |
||||
} |
||||
CustomizableUI.destroyWidget("sync-button"); |
||||
CustomizableUI.removeWidgetFromArea("sync-button"); |
||||
var toolbox = doc.getElementById("navigator-toolbox"); |
||||
if (toolbox && toolbox.palette) { |
||||
let element = toolbox.palette.querySelector("#sync-button"); |
||||
if (element) { |
||||
element.parentNode.removeChild(element); |
||||
} |
||||
} |
||||
hide(E("sync-setup-state", doc)); |
||||
hide(E("sync-syncnow-state", doc)); |
||||
hide(E("sync-setup", doc)); |
||||
hide(E("sync-syncnowitem", doc)); |
||||
} |
||||
|
||||
function disablePrivateBrowsing(doc) { |
||||
disable(E("Tools:PrivateBrowsing", doc)); |
||||
hide(E("menu_newPrivateWindow", doc)); |
||||
// Because this is on a context menu, we can't use "hidden"
|
||||
if (E("context-openlinkprivate", doc)) |
||||
E("context-openlinkprivate", doc).setAttribute("style", "display: none;"); |
||||
if (E("placesContext_open:newprivatewindow", doc)) |
||||
E("placesContext_open:newprivatewindow", doc).setAttribute("style", "display: none;"); |
||||
CustomizableUI.destroyWidget("privatebrowsing-button") |
||||
} |
||||
|
||||
function disableAddonsManager(doc) { |
||||
hide(E("menu_openAddons", doc)); |
||||
disable(E("Tools:Addons", doc)); // Ctrl+Shift+A
|
||||
CustomizableUI.destroyWidget("add-ons-button") |
||||
} |
||||
|
||||
function removeDeveloperTools(doc) { |
||||
var win = doc.defaultView; |
||||
// Need to delay this because devtools is created dynamically
|
||||
win.setTimeout(function() { |
||||
CustomizableUI.destroyWidget("developer-button") |
||||
hide(E("webDeveloperMenu", doc)); |
||||
var devtoolsKeyset = doc.getElementById("devtoolsKeyset"); |
||||
if (devtoolsKeyset) { |
||||
for (var i = 0; i < devtoolsKeyset.childNodes.length; i++) { |
||||
devtoolsKeyset.childNodes[i].removeAttribute("oncommand"); |
||||
devtoolsKeyset.childNodes[i].removeAttribute("command"); |
||||
} |
||||
} |
||||
}, 0); |
||||
try { |
||||
doc.getElementById("Tools:ResponsiveUI").removeAttribute("oncommand"); |
||||
} catch (e) {} |
||||
try { |
||||
doc.getElementById("Tools:Scratchpad").removeAttribute("oncommand"); |
||||
} catch (e) {} |
||||
try { |
||||
doc.getElementById("Tools:BrowserConsole").removeAttribute("oncommand"); |
||||
} catch (e) {} |
||||
try { |
||||
doc.getElementById("Tools:BrowserToolbox").removeAttribute("oncommand"); |
||||
} catch (e) {} |
||||
try { |
||||
doc.getElementById("Tools:DevAppsMgr").removeAttribute("oncommand"); |
||||
} catch (e) {} |
||||
try { |
||||
doc.getElementById("Tools:DevToolbar").removeAttribute("oncommand"); |
||||
} catch (e) {} |
||||
try { |
||||
doc.getElementById("Tools:DevToolbox").removeAttribute("oncommand"); |
||||
} catch (e) {} |
||||
try { |
||||
doc.getElementById("Tools:DevToolbarFocus").removeAttribute("oncommand"); |
||||
} catch (e) {} |
||||
CustomizableUI.destroyWidget("developer-button") |
||||
} |
||||
|
||||
function disableErrorConsole(doc) { |
||||
doc.getElementById("Tools:ErrorConsole").removeAttribute("oncommand"); |
||||
} |
||||
|
||||
function onPanelShowing(event) { |
||||
var configs = CCK2.getConfigs(); |
||||
for (let id in configs) { |
||||
var config = configs[id]; |
||||
if (config.disableSync) { |
||||
hide(E("PanelUI-fxa-status", event.target.ownerDocument)); |
||||
hide(E("PanelUI-footer-fxa", event.target.ownerDocument)); // Firefox 42+
|
||||
} |
||||
} |
||||
} |
||||
|
||||
function onAppMenuShowing(event) { |
||||
var configs = CCK2.getConfigs(); |
||||
for (let id in configs) { |
||||
var config = configs[id]; |
||||
if (config.disableSync) { |
||||
hide(E("appMenu-fxa-container", event.target.ownerDocument)); |
||||
} |
||||
if (config.removeDeveloperTools) { |
||||
hide(E("appMenu-developer-button", event.target.ownerDocument)); |
||||
} |
||||
} |
||||
} |
||||
|
||||
function E(id, context) { |
||||
var element = context.getElementById(id); |
||||
return element; |
||||
} |
||||
|
||||
function hide(element) { |
||||
if (element) { |
||||
element.setAttribute("hidden", "true"); |
||||
} |
||||
} |
||||
|
||||
function disable(element) { |
||||
if (element) { |
||||
element.disabled = true; |
||||
element.setAttribute("disabled", "true"); |
||||
} |
||||
} |
||||
|
||||
function hideUIElements(doc, hiddenUI) { |
||||
for (var i=0; i < hiddenUI.length; i++) { |
||||
var uiElements = doc.querySelectorAll(hiddenUI[i]); |
||||
// Don't use .hidden since it doesn't work sometimes
|
||||
var style = doc.getElementById("cck2-hidden-style"); |
||||
if (!style) { |
||||
style = doc.createElementNS("http://www.w3.org/1999/xhtml", "style"); |
||||
style.setAttribute("id", "cck2-hidden-style"); |
||||
style.setAttribute("type", "text/css"); |
||||
doc.documentElement.appendChild(style); |
||||
} |
||||
style.textContent = style.textContent + hiddenUI[i] + "{display: none !important;}"; |
||||
if (!uiElements || uiElements.length == 0) { |
||||
continue; |
||||
} |
||||
for (var j=0; j < uiElements.length; j++) { |
||||
var uiElement = uiElements[j]; |
||||
if (uiElement.nodeName == "menuitem") { |
||||
uiElement.removeAttribute("key"); |
||||
uiElement.removeAttribute("oncommand"); |
||||
if (uiElement.hasAttribute("command")) { |
||||
var commandId = uiElement.getAttribute("command"); |
||||
uiElement.removeAttribute("command"); |
||||
var command = doc.getElementById(commandId); |
||||
command.removeAttribute("oncommand"); |
||||
var keys = doc.querySelectorAll("key[command='" + commandId + "']") |
||||
for (var k=0; k < keys.length; k++) { |
||||
keys[k].removeAttribute("command"); |
||||
} |
||||
} |
||||
} |
||||
// Horrible hack to work around the crappy Australis help menu
|
||||
// Items on the menu always show up in the Australis menu, so we have to remove them.
|
||||
if (uiElements[j].parentNode.id == "menu_HelpPopup") { |
||||
uiElements[j].parentNode.removeChild(uiElements[j]); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -1,47 +0,0 @@
@@ -1,47 +0,0 @@
|
||||
const {classes: Cc, interfaces: Ci, utils: Cu} = Components; |
||||
|
||||
var EXPORTED_SYMBOLS = []; |
||||
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm"); |
||||
|
||||
let CCK2FileBlock = { |
||||
chromeBlacklist: ["browser", "mozapps", "marionette", "specialpowers", |
||||
"branding", "alerts"], |
||||
shouldLoad: function(aContentType, aContentLocation, aRequestOrigin, aContext, aMimeTypeGuess, aExtra) { |
||||
// Prevent the loading of chrome URLs into the main browser window
|
||||
if (aContentLocation.scheme == "chrome") { |
||||
if (aRequestOrigin && |
||||
(aRequestOrigin.spec == "chrome://browser/content/browser.xul" || |
||||
aRequestOrigin.scheme == "moz-nullprincipal")) { |
||||
for (var i=0; i < this.chromeBlacklist.length; i++) { |
||||
if (aContentLocation.host == this.chromeBlacklist[i]) { |
||||
if (aContentLocation.spec.includes(".xul")) { |
||||
return Ci.nsIContentPolicy.REJECT_REQUEST; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
return Ci.nsIContentPolicy.ACCEPT; |
||||
}, |
||||
shouldProcess: function(aContentType, aContentLocation, aRequestOrigin, aContext, aMimeTypeGuess, aExtra) { |
||||
return Ci.nsIContentPolicy.ACCEPT; |
||||
}, |
||||
classDescription: "CCK2 FileBlock Service", |
||||
contractID: "@kaply.com/cck2-fileblock-service;1", |
||||
classID: Components.ID('{26e7afc9-e22d-4d12-bb57-c184fe24b828}'), |
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIContentPolicy]), |
||||
createInstance: function(outer, iid) { |
||||
return this.QueryInterface(iid); |
||||
}, |
||||
}; |
||||
|
||||
var registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar); |
||||
registrar.registerFactory(CCK2FileBlock.classID, |
||||
CCK2FileBlock.classDescription, |
||||
CCK2FileBlock.contractID, |
||||
CCK2FileBlock); |
||||
|
||||
var cm = Cc["@mozilla.org/categorymanager;1"].getService(Ci.nsICategoryManager); |
||||
cm.addCategoryEntry("content-policy", CCK2FileBlock.contractID, |
||||
CCK2FileBlock.contractID, false, true); |
@ -1,51 +0,0 @@
@@ -1,51 +0,0 @@
|
||||
const {classes: Cc, interfaces: Ci, utils: Cu} = Components; |
||||
Cu.import("resource://gre/modules/Services.jsm"); |
||||
|
||||
var disableSearchEngineInstall = false; |
||||
|
||||
var documentObserver = { |
||||
observe: function observe(subject, topic, data) { |
||||
if (subject instanceof Ci.nsIDOMWindow && topic == 'content-document-global-created') { |
||||
var doc = subject.document; |
||||
doc.addEventListener("DOMContentLoaded", function onLoad(event) { |
||||
event.target.removeEventListener("DOMContentLoaded", onLoad, false); |
||||
if (disableSearchEngineInstall) { |
||||
subject.wrappedJSObject.external.AddSearchProvider = function() {}; |
||||
} |
||||
if (!doc.documentURI.startsWith("about:")) { |
||||
return; |
||||
} |
||||
for (let id in configs) { |
||||
var config = configs[id]; |
||||
if (config.hiddenUI) { |
||||
for (var i=0; i < config.hiddenUI.length; i++) { |
||||
// Don't use .hidden since it doesn't work sometimes
|
||||
var style = doc.getElementById("cck2-hidden-style"); |
||||
if (!style) { |
||||
style = doc.createElementNS("http://www.w3.org/1999/xhtml", "style"); |
||||
style.setAttribute("id", "cck2-hidden-style"); |
||||
style.setAttribute("type", "text/css"); |
||||
doc.documentElement.appendChild(style); |
||||
} |
||||
style.textContent = style.textContent + config.hiddenUI[i] + "{display: none !important;}"; |
||||
} |
||||
} |
||||
} |
||||
}, false); |
||||
} |
||||
} |
||||
} |
||||
|
||||
var configs = sendSyncMessage("cck2:get-configs")[0]; |
||||
for (var id in configs) { |
||||
var config = configs[id]; |
||||
if (config.disableSearchEngineInstall) { |
||||
disableSearchEngineInstall = true; |
||||
break; |
||||
} |
||||
} |
||||
|
||||
Services.obs.addObserver(documentObserver, "content-document-global-created", false); |
||||
addEventListener("unload", function() { |
||||
Services.obs.removeObserver(documentObserver, "content-document-global-created", false); |
||||
}) |
@ -1,123 +0,0 @@
@@ -1,123 +0,0 @@
|
||||
/* This file modifies the preferences dialogs. It does the following: |
||||
* Removes private browsing from the pref UI if it is disabled |
||||
* Removes Sync from the pref UI if it is diabled |
||||
* Disables the crash reporter button if crash reporter is disabled |
||||
* Removed the master password UI if it is disabled |
||||
* Goes through the hiddenUI list and hides any UI |
||||
* |
||||
*/ |
||||
|
||||
const EXPORTED_SYMBOLS = []; |
||||
|
||||
const {classes: Cc, interfaces: Ci, utils: Cu} = Components; |
||||
|
||||
Cu.import("resource://gre/modules/Services.jsm"); |
||||
Cu.import("resource://cck2/CCK2.jsm"); |
||||
|
||||
var configs = null; |
||||
|
||||
var observer = { |
||||
observe: function observe(subject, topic, data) { |
||||
switch (topic) { |
||||
case "chrome-document-global-created": |
||||
var win = subject.QueryInterface(Components.interfaces.nsIDOMWindow); |
||||
win.addEventListener("load", function onLoad(event) { |
||||
win.removeEventListener("load", onLoad, false); |
||||
var doc = event.target; |
||||
var url = doc.location.href.split("?")[0].split("#")[0]; |
||||
switch (url) { |
||||
case "chrome://browser/content/preferences/preferences.xul": |
||||
configs = CCK2.getConfigs(); |
||||
win.addEventListener("paneload", function(event) { |
||||
updatePrefUI(event.target.ownerDocument); |
||||
}, false); |
||||
updatePrefUI(doc); |
||||
for (let id in configs) { |
||||
var config = configs[id]; |
||||
if (!config.disableSync) { |
||||
continue; |
||||
} |
||||
var prefWindow = E("BrowserPreferences", doc); |
||||
var paneSyncRadio = doc.getAnonymousElementByAttribute(prefWindow, "pane", "paneSync"); |
||||
hide(paneSyncRadio); |
||||
var paneDeck = doc.getAnonymousElementByAttribute(prefWindow, "anonid", "paneDeck"); |
||||
var paneSync = E("paneSync", doc); |
||||
paneSync.removeAttribute("helpTopic"); |
||||
var weavePrefsDeck = E("weavePrefsDeck", doc); |
||||
if (weavePrefsDeck) |
||||
weavePrefsDeck.parentNode.removeChild(weavePrefsDeck); |
||||
if (prefWindow.currentPane == E("paneSync", doc)) |
||||
prefWindow.showPane(E("paneMain", doc)); |
||||
} |
||||
break; |
||||
case "about:preferences": |
||||
case "chrome://browser/content/preferences/in-content/preferences.xul": |
||||
configs = CCK2.getConfigs(); |
||||
for (let id in configs) { |
||||
var config = configs[id]; |
||||
if (config.disableSync) { |
||||
hide(E("category-sync", doc)); |
||||
} |
||||
} |
||||
updatePrefUI(doc); |
||||
break; |
||||
} |
||||
}, false); |
||||
break; |
||||
} |
||||
} |
||||
} |
||||
Services.obs.addObserver(observer, "chrome-document-global-created", false); |
||||
|
||||
// The IDs are the same, so I can reuse this for regular and in-content prefs
|
||||
function updatePrefUI(doc) { |
||||
for (var id in configs) { |
||||
var config = configs[id]; |
||||
if (config.disablePrivateBrowsing) { |
||||
hide(E("privateBrowsingAutoStart", doc)); |
||||
var privateBrowsingMenu = doc.querySelector("menuitem[value='dontremember']"); |
||||
hide(privateBrowsingMenu, doc); |
||||
} |
||||
if (config.disableCrashReporter) { |
||||
disable(E("submitCrashesBox", doc)); |
||||
} |
||||
if (config.disableSync) { |
||||
hide(E("noFxaAccount", doc)); |
||||
hide(E("hasFxaAccount", doc)); |
||||
} |
||||
if (config.noMasterPassword == true) { |
||||
hide(E("useMasterPassword", doc)); |
||||
hide(E("changeMasterPassword", doc)); |
||||
} |
||||
if (config.hiddenUI) { |
||||
for (var i=0; i < config.hiddenUI.length; i++) { |
||||
// Don't use .hidden since it doesn't work sometimes
|
||||
var style = doc.getElementById("cck2-hidden-style"); |
||||
if (!style) { |
||||
style = doc.createElementNS("http://www.w3.org/1999/xhtml", "style"); |
||||
style.setAttribute("id", "cck2-hidden-style"); |
||||
style.setAttribute("type", "text/css"); |
||||
doc.documentElement.appendChild(style); |
||||
} |
||||
style.textContent = style.textContent + config.hiddenUI[i] + "{display: none !important;}"; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
function E(id, context) { |
||||
var element = context.getElementById(id); |
||||
return element; |
||||
} |
||||
|
||||
function hide(element) { |
||||
if (element) { |
||||
element.setAttribute("hidden", "true"); |
||||
} |
||||
} |
||||
|
||||
function disable(element) { |
||||
if (element) { |
||||
element.disabled = true; |
||||
} |
||||
} |
@ -1,123 +0,0 @@
@@ -1,123 +0,0 @@
|
||||
/** |
||||
* Copied from https://github.com/jvillalobos/CTP-Manager/blob/master/extension/modules/permissions.js
|
||||
**/ |
||||
|
||||
/** |
||||
* Copyright 2013 Jorge Villalobos |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
**/ |
||||
|
||||
var EXPORTED_SYMBOLS = ["CTP"]; |
||||
|
||||
const Cc = Components.classes; |
||||
const Ci = Components.interfaces; |
||||
|
||||
Components.utils.import("resource://gre/modules/Services.jsm"); |
||||
|
||||
var CTP = { |
||||
/** |
||||
* Cleans up the plugin name to a more readable form. |
||||
* Taken from /browser/base/content/pageinfo/permissions.js (Firefox 20) |
||||
* @param aPluginName the name to clean up. |
||||
* @return cleaned up plugin name. |
||||
*/ |
||||
makeNicePluginName : function(aPluginName) { |
||||
let newName = |
||||
aPluginName.replace(/[\s\d\.\-\_\(\)]+$/, ""). |
||||
replace(/\bplug-?in\b/i, "").trim(); |
||||
|
||||
return newName; |
||||
}, |
||||
|
||||
/** |
||||
* Gets the plugin permission string from the tag object. In Firefox 20, this |
||||
* is the plugin filename. In 21 an above, the file extension is removed and |
||||
* Flash and Java are special-cased. |
||||
* @param aTag the tag object with the plugin information. |
||||
* @return permission string that corresponds to the plugin in the tag. |
||||
*/ |
||||
getPluginPermissionFromTag : function(aTag) { |
||||
let permission = null; |
||||
let majorVersion = Services.appinfo.platformVersion.split(".")[0]; |
||||
|
||||
if (21 <= majorVersion) { |
||||
let mimeTypes = aTag.getMimeTypes(); |
||||
|
||||
if (CTP.isFlashPlugin(mimeTypes)) { |
||||
permission = "flash"; |
||||
} else if (CTP.isJavaPlugin(mimeTypes)) { |
||||
permission = "java"; |
||||
} else { |
||||
let lastPeriod = aTag.filename.lastIndexOf("."); |
||||
|
||||
permission = |
||||
((0 < lastPeriod) ? aTag.filename.substring(0, lastPeriod) : |
||||
aTag.filename); |
||||
// Remove digits at the end
|
||||
permission = permission.replace(/[0-9]+$/, ""); |
||||
permission = permission.toLowerCase(); |
||||
} |
||||
} else { |
||||
permission = aTag.filename; |
||||
} |
||||
|
||||
return permission; |
||||
}, |
||||
|
||||
/** |
||||
* Checks if the tag object corresponds to the Java plugin. |
||||
* @param aMimeTypes the list of MIME types for the plugin. |
||||
* @return true if the tag corresponds to the Java plugin. |
||||
*/ |
||||
isJavaPlugin : function(aMimeTypes) { |
||||
let isJava = false; |
||||
let mimeType; |
||||
|
||||
for (let i = 0; i < aMimeTypes.length; i++) { |
||||
mimeType = |
||||
((null != aMimeTypes[i].type) ? aMimeTypes[i].type : aMimeTypes[i]); |
||||
|
||||
if ((0 == mimeType.indexOf("application/x-java-vm")) || |
||||
(0 == mimeType.indexOf("application/x-java-applet")) || |
||||
(0 == mimeType.indexOf("application/x-java-bean"))) { |
||||
isJava = true; |
||||
break; |
||||
} |
||||
} |
||||
|
||||
return isJava; |
||||
}, |
||||
|
||||
/** |
||||
* Checks if the tag object corresponds to the Flash plugin. |
||||
* @param aMimeTypes the list of MIME types for the plugin. |
||||
* @return true if the tag corresponds to the Flash plugin. |
||||
*/ |
||||
isFlashPlugin : function(aMimeTypes) { |
||||
let isFlash = false; |
||||
let mimeType; |
||||
|
||||
for (let i = 0; i < aMimeTypes.length; i++) { |
||||
mimeType = |
||||
((null != aMimeTypes[i].type) ? aMimeTypes[i].type : aMimeTypes[i]); |
||||
|
||||
if (0 == mimeType.indexOf("application/x-shockwave-flash")) { |
||||
isFlash = true; |
||||
break; |
||||
} |
||||
} |
||||
|
||||
return isFlash; |
||||
} |
||||
}; |
@ -1,629 +0,0 @@
@@ -1,629 +0,0 @@
|
||||
/* ***** BEGIN LICENSE BLOCK ***** |
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1 |
||||
* |
||||
* The contents of this file are subject to the Mozilla Public License Version |
||||
* 1.1 (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* http://www.mozilla.org/MPL/
|
||||
* |
||||
* Software distributed under the License is distributed on an "AS IS" basis, |
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License |
||||
* for the specific language governing rights and limitations under the |
||||
* License. |
||||
* |
||||
* The Original Code is Preferences. |
||||
* |
||||
* The Initial Developer of the Original Code is Mozilla. |
||||
* Portions created by the Initial Developer are Copyright (C) 2008 |
||||
* the Initial Developer. All Rights Reserved. |
||||
* |
||||
* Contributor(s): |
||||
* Myk Melez <myk@mozilla.org> |
||||
* Daniel Aquino <mr.danielaquino@gmail.com> |
||||
* |
||||
* Alternatively, the contents of this file may be used under the terms of |
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or |
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), |
||||
* in which case the provisions of the GPL or the LGPL are applicable instead |
||||
* of those above. If you wish to allow use of your version of this file only |
||||
* under the terms of either the GPL or the LGPL, and not to allow others to |
||||
* use your version of this file under the terms of the MPL, indicate your |
||||
* decision by deleting the provisions above and replace them with the notice |
||||
* and other provisions required by the GPL or the LGPL. If you do not delete |
||||
* the provisions above, a recipient may use your version of this file under |
||||
* the terms of any one of the MPL, the GPL or the LGPL. |
||||
* |
||||
* ***** END LICENSE BLOCK ***** */ |
||||
|
||||
let EXPORTED_SYMBOLS = ["Preferences"]; |
||||
|
||||
const Cc = Components.classes; |
||||
const Ci = Components.interfaces; |
||||
const Cr = Components.results; |
||||
const Cu = Components.utils; |
||||
|
||||
Cu.import("resource://gre/modules/Services.jsm"); |
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm"); |
||||
|
||||
// The minimum and maximum integers that can be set as preferences.
|
||||
// The range of valid values is narrower than the range of valid JS values
|
||||
// because the native preferences code treats integers as NSPR PRInt32s,
|
||||
// which are 32-bit signed integers on all platforms.
|
||||
const MAX_INT = Math.pow(2, 31) - 1; |
||||
const MIN_INT = -MAX_INT; |
||||
|
||||
function Preferences(args) { |
||||
if (isObject(args)) { |
||||
if (args.branch) |
||||
this._prefBranch = args.branch; |
||||
} |
||||
else if (args) |
||||
this._prefBranch = args; |
||||
this.isDefaultBranch = false; |
||||
} |
||||
|
||||
Preferences.prototype = { |
||||
/** |
||||
* Get the value of a pref, if any; otherwise return the default value. |
||||
* |
||||
* @param prefName {String|Array} |
||||
* the pref to get, or an array of prefs to get |
||||
* |
||||
* @param defaultValue |
||||
* the default value, if any, for prefs that don't have one |
||||
* |
||||
* @returns the value of the pref, if any; otherwise the default value |
||||
*/ |
||||
get: function(prefName, defaultValue) { |
||||
if (isArray(prefName)) |
||||
return prefName.map(v => this.get(v, defaultValue)); |
||||
|
||||
return this._get(prefName, defaultValue); |
||||
}, |
||||
|
||||
// In all cases below, the preference might exist as a user pref, but not
|
||||
// have a default value. In those cases, get* throws. Return the default value.
|
||||
_get: function(prefName, defaultValue) { |
||||
switch (this._prefSvc.getPrefType(prefName)) { |
||||
case Ci.nsIPrefBranch.PREF_STRING: |
||||
try { |
||||
return this._prefSvc.getComplexValue(prefName, Ci.nsISupportsString).data; |
||||
} catch (ex) { |
||||
if (this.isDefaultBranch) |
||||
return defaultValue; |
||||
else |
||||
return this._prefSvc.getCharPref(prefName); |
||||
} |
||||
|
||||
case Ci.nsIPrefBranch.PREF_INT: |
||||
try { |
||||
return this._prefSvc.getIntPref(prefName); |
||||
} catch (ex) { |
||||
return defaultValue; |
||||
} |
||||
|
||||
case Ci.nsIPrefBranch.PREF_BOOL: |
||||
try { |
||||
return this._prefSvc.getBoolPref(prefName); |
||||
} catch (ex) { |
||||
return defaultValue; |
||||
} |
||||
|
||||
case Ci.nsIPrefBranch.PREF_INVALID: |
||||
return defaultValue; |
||||
|
||||
default: |
||||
// This should never happen.
|
||||
throw "Error getting pref " + prefName + "; its value's type is " + |
||||
this._prefSvc.getPrefType(prefName) + ", which I don't know " + |
||||
"how to handle."; |
||||
} |
||||
}, |
||||
|
||||
/** |
||||
* Set a preference to a value. |
||||
* |
||||
* You can set multiple prefs by passing an object as the only parameter. |
||||
* In that case, this method will treat the properties of the object |
||||
* as preferences to set, where each property name is the name of a pref |
||||
* and its corresponding property value is the value of the pref. |
||||
* |
||||
* @param prefName {String|Object} |
||||
* the name of the pref to set; or an object containing a set |
||||
* of prefs to set |
||||
* |
||||
* @param prefValue {String|Number|Boolean} |
||||
* the value to which to set the pref |
||||
* |
||||
* Note: Preferences cannot store non-integer numbers or numbers outside |
||||
* the signed 32-bit range -(2^31-1) to 2^31-1, If you have such a number, |
||||
* store it as a string by calling toString() on the number before passing |
||||
* it to this method, i.e.: |
||||
* Preferences.set("pi", 3.14159.toString()) |
||||
* Preferences.set("big", Math.pow(2, 31).toString()). |
||||
*/ |
||||
set: function(prefName, prefValue) { |
||||
if (isObject(prefName)) { |
||||
for (let [name, value] in Iterator(prefName)) |
||||
this.set(name, value); |
||||
return; |
||||
} |
||||
|
||||
this._set(prefName, prefValue); |
||||
}, |
||||
|
||||
_set: function(prefName, prefValue) { |
||||
let prefType; |
||||
if (typeof prefValue != "undefined" && prefValue != null) |
||||
prefType = prefValue.constructor.name; |
||||
|
||||
var existingPrefType = this._prefSvc.getPrefType(prefName); |
||||
if (existingPrefType != Ci.nsIPrefBranch.PREF_INVALID) |
||||
{ |
||||
// convert
|
||||
if (existingPrefType == Ci.nsIPrefBranch.PREF_INT && prefType == "String") |
||||
{ |
||||
prefValue = parseInt(prefValue); |
||||
if (isNaN(prefValue)) |
||||
throw "Incompatible pref value type - " + prefName; |
||||
prefType = "Number"; |
||||
} |
||||
else if (existingPrefType == Ci.nsIPrefBranch.PREF_BOOL && prefType == "String") |
||||
{ |
||||
if (prefValue == "true") |
||||
prefValue = true; |
||||
else if (prefValue == "false") |
||||
prefValue = false; |
||||
else |
||||
throw "Incompatible pref value type - " + prefName; |
||||
prefType = "Boolean"; |
||||
} |
||||
else if (existingPrefType == Ci.nsIPrefBranch.PREF_BOOL && prefType == "Number") |
||||
{ |
||||
prefValue = prefValue != 0; |
||||
prefType = "Boolean"; |
||||
} |
||||
} |
||||
|
||||
switch (prefType) { |
||||
case "String": |
||||
{ |
||||
try { |
||||
this._prefSvc.setStringPref(prefName, prefValue); |
||||
} catch (e) { |
||||
try { |
||||
let string = Cc["@mozilla.org/supports-string;1"].createInstance(Ci.nsISupportsString); |
||||
string.data = prefValue; |
||||
this._prefSvc.setComplexValue(prefName, Ci.nsISupportsString, string); |
||||
} catch (e2) { |
||||
Components.utils.reportError(e2); |
||||
} |
||||
} |
||||
} |
||||
break; |
||||
|
||||
case "Number": |
||||
// We throw if the number is outside the range, since the result
|
||||
// will never be what the consumer wanted to store, but we only warn
|
||||
// if the number is non-integer, since the consumer might not mind
|
||||
// the loss of precision.
|
||||
if (prefValue > MAX_INT || prefValue < MIN_INT) |
||||
throw("you cannot set the " + prefName + " pref to the number " + |
||||
prefValue + ", as number pref values must be in the signed " + |
||||
"32-bit integer range -(2^31-1) to 2^31-1. To store numbers " + |
||||
"outside that range, store them as strings."); |
||||
try { |
||||
this._prefSvc.setIntPref(prefName, prefValue); |
||||
} catch (e) { |
||||
throw new Error(e.toString() + " - " + prefName); |
||||
} |
||||
if (prefValue % 1 != 0) |
||||
Cu.reportError("Warning: setting the " + prefName + " pref to the " + |
||||
"non-integer number " + prefValue + " converted it " + |
||||
"to the integer number " + this.get(prefName) + |
||||
"; to retain fractional precision, store non-integer " + |
||||
"numbers as strings."); |
||||
break; |
||||
|
||||
case "Boolean": |
||||
this._prefSvc.setBoolPref(prefName, prefValue); |
||||
break; |
||||
|
||||
default: |
||||
throw "can't set pref " + prefName + " to value '" + prefValue + |
||||
"'; it isn't a String, Number, or Boolean"; |
||||
} |
||||
}, |
||||
|
||||
/** |
||||
* Whether or not the given pref has a value. This is different from isSet |
||||
* because it returns true whether the value of the pref is a default value |
||||
* or a user-set value, while isSet only returns true if the value |
||||
* is a user-set value. |
||||
* |
||||
* @param prefName {String|Array} |
||||
* the pref to check, or an array of prefs to check |
||||
* |
||||
* @returns {Boolean|Array} |
||||
* whether or not the pref has a value; or, if the caller provided |
||||
* an array of pref names, an array of booleans indicating whether |
||||
* or not the prefs have values |
||||
*/ |
||||
has: function(prefName) { |
||||
if (isArray(prefName)) |
||||
return prefName.map(this.has, this); |
||||
|
||||
return this._has(prefName); |
||||
}, |
||||
|
||||
_has: function(prefName) { |
||||
return (this._prefSvc.getPrefType(prefName) != Ci.nsIPrefBranch.PREF_INVALID); |
||||
}, |
||||
|
||||
/** |
||||
* Whether or not the given pref has a user-set value. This is different |
||||
* from |has| because it returns true only if the value of the pref is a user- |
||||
* set value, while |has| returns true if the value of the pref is a default |
||||
* value or a user-set value. |
||||
* |
||||
* @param prefName {String|Array} |
||||
* the pref to check, or an array of prefs to check |
||||
* |
||||
* @returns {Boolean|Array} |
||||
* whether or not the pref has a user-set value; or, if the caller |
||||
* provided an array of pref names, an array of booleans indicating |
||||
* whether or not the prefs have user-set values |
||||
*/ |
||||
isSet: function(prefName) { |
||||
if (isArray(prefName)) |
||||
return prefName.map(this.isSet, this); |
||||
|
||||
return (this.has(prefName) && this._prefSvc.prefHasUserValue(prefName)); |
||||
}, |
||||
|
||||
/** |
||||
* Whether or not the given pref has a user-set value. Use isSet instead, |
||||
* which is equivalent. |
||||
* @deprecated |
||||
*/ |
||||
modified: function(prefName) { return this.isSet(prefName) }, |
||||
|
||||
reset: function(prefName) { |
||||
if (isArray(prefName)) { |
||||
prefName.map(v => this.reset(v)); |
||||
return; |
||||
} |
||||
|
||||
this._reset(prefName); |
||||
}, |
||||
|
||||
_reset: function(prefName) { |
||||
try { |
||||
this._prefSvc.clearUserPref(prefName); |
||||
} |
||||
catch(ex) { |
||||
// The pref service throws NS_ERROR_UNEXPECTED when the caller tries
|
||||
// to reset a pref that doesn't exist or is already set to its default
|
||||
// value. This interface fails silently in those cases, so callers
|
||||
// can unconditionally reset a pref without having to check if it needs
|
||||
// resetting first or trap exceptions after the fact. It passes through
|
||||
// other exceptions, however, so callers know about them, since we don't
|
||||
// know what other exceptions might be thrown and what they might mean.
|
||||
if (ex.result != Cr.NS_ERROR_UNEXPECTED) |
||||
throw ex; |
||||
} |
||||
}, |
||||
|
||||
/** |
||||
* If you need to know the default values, without resetting the actual |
||||
* user prefs, you can use this. |
||||
* @returns {Preferences} a new Preferences object, which accesses |
||||
* the defaults rather than the user prefs. |
||||
* *Only* call get() on this. |
||||
* If you call set(), you will modify the defaults, so don't do that! |
||||
*/ |
||||
get defaults() { |
||||
// nsIPrefService
|
||||
let defaultBranch = Services.prefs. |
||||
getDefaultBranch(this._prefBranch). |
||||
QueryInterface(Ci.nsIPrefBranch); |
||||
let prefs = new Preferences(this._prefBranch); |
||||
// override. nasty, but this is internal, so OK.
|
||||
Object.defineProperty(prefs, "_prefSvc", { |
||||
get: function() { |
||||
return defaultBranch; |
||||
} |
||||
}); |
||||
prefs.isDefaultBranch = true; |
||||
return prefs; |
||||
}, |
||||
|
||||
/** |
||||
* Lock a pref so it can't be changed. |
||||
* |
||||
* @param prefName {String|Array} |
||||
* the pref to lock, or an array of prefs to lock |
||||
* @param prefValue {String} (optional) |
||||
* default value of pref to lock only works if prefName isn't an array |
||||
*/ |
||||
lock: function(prefName, prefValue) { |
||||
if (isArray(prefName)) |
||||
prefName.map(this.lock, this); |
||||
else if (typeof prefValue != "undefined") |
||||
this.defaults.set(prefName, prefValue); |
||||
|
||||
this._prefSvc.lockPref(prefName); |
||||
}, |
||||
|
||||
/** |
||||
* Unlock a pref so it can be changed. |
||||
* |
||||
* @param prefName {String|Array} |
||||
* the pref to lock, or an array of prefs to lock |
||||
*/ |
||||
unlock: function(prefName) { |
||||
if (isArray(prefName)) |
||||
prefName.map(this.unlock, this); |
||||
|
||||
this._prefSvc.unlockPref(prefName); |
||||
}, |
||||
|
||||
/** |
||||
* Whether or not the given pref is locked against changes and |
||||
* if it is set to the passedi n value |
||||
* |
||||
* @param prefName {String|Array} |
||||
* the pref to check, or an array of prefs to check |
||||
* @param prefValue {String|Number|Boolean}} |
||||
* the pref value to compare against |
||||
* |
||||
* @returns {Boolean|Array} |
||||
* whether or not the pref is locked; or, if the caller |
||||
* provided an array of pref names, an array of booleans indicating |
||||
* whether or not the prefs are locked |
||||
* If a pref value was specified returns whether or not the pref |
||||
* was locked and equal to the passed in value. |
||||
*/ |
||||
locked: function(prefName, prefValue) { |
||||
if (isArray(prefName)) |
||||
return prefName.map(this.locked, this); |
||||
|
||||
if (prefValue) |
||||
return this._prefSvc.prefIsLocked(prefName) && (this.get(prefName) == prefValue); |
||||
else |
||||
return this._prefSvc.prefIsLocked(prefName); |
||||
}, |
||||
|
||||
/** |
||||
* Start observing a pref. |
||||
* |
||||
* The callback can be a function or any object that implements nsIObserver. |
||||
* When the callback is a function and thisObject is provided, it gets called |
||||
* as a method of thisObject. |
||||
* |
||||
* @param prefName {String} |
||||
* the name of the pref to observe |
||||
* |
||||
* @param callback {Function|Object} |
||||
* the code to notify when the pref changes; |
||||
* |
||||
* @param thisObject {Object} [optional] |
||||
* the object to use as |this| when calling a Function callback; |
||||
* |
||||
* @returns the wrapped observer |
||||
*/ |
||||
observe: function(prefName, callback, thisObject) { |
||||
let fullPrefName = this._prefBranch + (prefName || ""); |
||||
|
||||
let observer = new PrefObserver(fullPrefName, callback, thisObject); |
||||
Preferences._prefSvc.addObserver(fullPrefName, observer, true); |
||||
observers.push(observer); |
||||
|
||||
return observer; |
||||
}, |
||||
|
||||
/** |
||||
* Stop observing a pref. |
||||
* |
||||
* You must call this method with the same prefName, callback, and thisObject |
||||
* with which you originally registered the observer. However, you don't have |
||||
* to call this method on the same exact instance of Preferences; you can call |
||||
* it on any instance. For example, the following code first starts and then |
||||
* stops observing the "foo.bar.baz" preference: |
||||
* |
||||
* let observer = function() {...}; |
||||
* Preferences.observe("foo.bar.baz", observer); |
||||
* new Preferences("foo.bar.").ignore("baz", observer); |
||||
* |
||||
* @param prefName {String} |
||||
* the name of the pref being observed |
||||
* |
||||
* @param callback {Function|Object} |
||||
* the code being notified when the pref changes |
||||
* |
||||
* @param thisObject {Object} [optional] |
||||
* the object being used as |this| when calling a Function callback |
||||
*/ |
||||
ignore: function(prefName, callback, thisObject) { |
||||
let fullPrefName = this._prefBranch + (prefName || ""); |
||||
|
||||
// This seems fairly inefficient, but I'm not sure how much better we can
|
||||
// make it. We could index by fullBranch, but we can't index by callback
|
||||
// or thisObject, as far as I know, since the keys to JavaScript hashes
|
||||
// (a.k.a. objects) can apparently only be primitive values.
|
||||
let [observer] = observers.filter(v => v.prefName == fullPrefName && |
||||
v.callback == callback && |
||||
v.thisObject == thisObject); |
||||
|
||||
if (observer) { |
||||
Preferences._prefSvc.removeObserver(fullPrefName, observer); |
||||
observers.splice(observers.indexOf(observer), 1); |
||||
} |
||||
}, |
||||
|
||||
/** |
||||
* Same as observe(), but automatically unregisters itself when |
||||
* the window closes, saving you from writing an unload handler and |
||||
* calling ignore(). |
||||
* @param win {nsIDOMWindow} your |window| |
||||
*/ |
||||
observeAuto: function(win, prefName, callback, thisObject) { |
||||
if (!win instanceof Ci.nsIDOMWindow) |
||||
throw "Need your |window| as first parameter"; |
||||
this.observe(prefName, callback, thisObject); |
||||
var self = this; |
||||
win.addEventListener("unload", function() |
||||
{ |
||||
self.ignore(prefName, callback, thisObject); |
||||
}, false); |
||||
win = null; // don't let closure hold on to window unnecessarily
|
||||
}, |
||||
|
||||
resetBranch: function(prefBranch) { |
||||
try { |
||||
this._prefSvc.resetBranch(prefBranch); |
||||
} |
||||
catch(ex) { |
||||
// The current implementation of nsIPrefBranch in Mozilla
|
||||
// doesn't implement resetBranch, so we do it ourselves.
|
||||
if (ex.result == Cr.NS_ERROR_NOT_IMPLEMENTED) |
||||
this.reset(this._prefSvc.getChildList(prefBranch, [])); |
||||
else |
||||
throw ex; |
||||
} |
||||
}, |
||||
|
||||
/** |
||||
* Returns all child prefs of this pref branch. |
||||
* This equals nsIPrefBranch.getChildList(). |
||||
* This allows you to do e.g. |
||||
* var myPrefs = new Preferences("extensions.cooler."); |
||||
* var contents = myPrefs.branch("contents."); |
||||
* for each (let prefname in contents.childPrefNames()) |
||||
* dump("have " + contents.get(prefname) + " " + prefname + "\n"); |
||||
* |
||||
* @returns {Array of String} The names of the children, |
||||
* without the base pref branch, but with subbranch. |
||||
*/ |
||||
childPrefNames : function() { |
||||
return this._prefSvc.getChildList("", []); |
||||
}, |
||||
|
||||
/** |
||||
* Returns an nsIPrefBranch for the pref branch that this object stands for. |
||||
* You can use this to use functions that are not supported here. |
||||
* @returns {nsIPrefBranch} |
||||
*/ |
||||
get mozillaPrefBranch() { |
||||
return this._prefSvc; |
||||
}, |
||||
|
||||
/** |
||||
* Returns the base pref name that this object stands for. |
||||
* E.g. "extensions.yourcooler."; |
||||
* @returns {String} |
||||
*/ |
||||
get prefBranchName() { |
||||
return this._prefBranch; |
||||
}, |
||||
|
||||
/** |
||||
* Returns an Preferences object for an sub pref branch |
||||
* underneath the current pref branch. |
||||
* @param subbranch {String} Will be appended to the |
||||
* current pref branch. Don't forget the trailing dot, |
||||
* where necessary. |
||||
* E.g. "contents." |
||||
* @returns {Preferences} |
||||
*/ |
||||
branch : function(subbranch) { |
||||
return new Preferences(this._prefBranch + subbranch); |
||||
}, |
||||
|
||||
/** |
||||
* The branch of the preferences tree to which this instance provides access. |
||||
* @private |
||||
*/ |
||||
_prefBranch: "", |
||||
|
||||
/** |
||||
* Preferences Service |
||||
* @private |
||||
*/ |
||||
get _prefSvc() { |
||||
// nsIPrefService
|
||||
let prefSvc = Services.prefs. |
||||
getBranch(this._prefBranch). |
||||
QueryInterface(Ci.nsIPrefBranch); |
||||
Object.defineProperty(this, "_prefSvc", { |
||||
get: function() { |
||||
return prefSvc; |
||||
} |
||||
}); |
||||
return this._prefSvc; |
||||
} |
||||
|
||||
}; |
||||
|
||||
// Give the constructor the same prototype as its instances, so users can access
|
||||
// preferences directly via the constructor without having to create an instance
|
||||
// first.
|
||||
Preferences.__proto__ = Preferences.prototype; |
||||
|
||||
/** |
||||
* A cache of pref observers. |
||||
* |
||||
* We use this to remove observers when a caller calls Preferences::ignore. |
||||
* |
||||
* All Preferences instances share this object, because we want callers to be |
||||
* able to remove an observer using a different Preferences object than the one |
||||
* with which they added it. That means we have to identify the observers |
||||
* in this object by their complete pref name, not just their name relative to |
||||
* the root branch of the Preferences object with which they were created. |
||||
*/ |
||||
let observers = []; |
||||
|
||||
function PrefObserver(prefName, callback, thisObject) { |
||||
this.prefName = prefName; |
||||
this.callback = callback; |
||||
this.thisObject = thisObject; |
||||
} |
||||
|
||||
PrefObserver.prototype = { |
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver, Ci.nsISupportsWeakReference]), |
||||
|
||||
observe: function(subject, topic, data) { |
||||
// The pref service only observes whole branches, but we only observe
|
||||
// individual preferences, so we check here that the pref that changed
|
||||
// is the exact one we're observing (and not some sub-pref on the branch).
|
||||
if (data != this.prefName) |
||||
return; |
||||
|
||||
if (typeof this.callback == "function") { |
||||
let prefValue = Preferences.get(this.prefName); |
||||
|
||||
if (this.thisObject) |
||||
this.callback.call(this.thisObject, prefValue); |
||||
else |
||||
this.callback(prefValue); |
||||
} |
||||
else // typeof this.callback == "object" (nsIObserver)
|
||||
this.callback.observe(subject, topic, data); |
||||
} |
||||
}; |
||||
|
||||
function isArray(val) { |
||||
// We can't check for |val.constructor == Array| here, since the value
|
||||
// might be from a different context whose Array constructor is not the same
|
||||
// as ours, so instead we match based on the name of the constructor.
|
||||
return (typeof val != "undefined" && val != null && typeof val == "object" && |
||||
val.constructor.name == "Array"); |
||||
} |
||||
|
||||
function isObject(val) { |
||||
// We can't check for |val.constructor == Object| here, since the value
|
||||
// might be from a different context whose Object constructor is not the same
|
||||
// as ours, so instead we match based on the name of the constructor.
|
||||
return (typeof val != "undefined" && val != null && typeof val == "object" && |
||||
val.constructor.name == "Object"); |
||||
} |
@ -1,43 +0,0 @@
@@ -1,43 +0,0 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public |
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this |
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
"use strict"; |
||||
|
||||
/** |
||||
* JS module implementation of nsIDOMJSWindow.setTimeout and clearTimeout. |
||||
*/ |
||||
|
||||
this.EXPORTED_SYMBOLS = ["setTimeout", "clearTimeout"]; |
||||
|
||||
const Cc = Components.classes; |
||||
const Ci = Components.interfaces; |
||||
const Cu = Components.utils; |
||||
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm"); |
||||
|
||||
// This gives us >=2^30 unique timer IDs, enough for 1 per ms for 12.4 days.
|
||||
let gNextTimeoutId = 1; // setTimeout must return a positive integer
|
||||
|
||||
let gTimeoutTable = new Map(); // int -> nsITimer
|
||||
|
||||
this.setTimeout = function setTimeout(aCallback, aMilliseconds) { |
||||
let id = gNextTimeoutId++; |
||||
let args = Array.slice(arguments, 2); |
||||
let timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer); |
||||
timer.initWithCallback(function setTimeout_timer() { |
||||
gTimeoutTable.delete(id); |
||||
aCallback.apply(null, args); |
||||
}, aMilliseconds, timer.TYPE_ONE_SHOT); |
||||
|
||||
gTimeoutTable.set(id, timer); |
||||
return id; |
||||
} |
||||
|
||||
this.clearTimeout = function clearTimeout(aId) { |
||||
if (gTimeoutTable.has(aId)) { |
||||
gTimeoutTable.get(aId).cancel(); |
||||
gTimeoutTable.delete(aId); |
||||
} |
||||
} |
||||
|
@ -1,10 +0,0 @@
@@ -1,10 +0,0 @@
|
||||
const {classes: Cc, interfaces: Ci, utils: Cu} = Components; |
||||
|
||||
var EXPORTED_SYMBOLS = ["errorCritical"]; |
||||
|
||||
Components.utils.import("resource://gre/modules/Services.jsm"); |
||||
|
||||
function errorCritical(e) |
||||
{ |
||||
Services.prompt.alert(null, "", e); |
||||
} |
@ -1,24 +0,0 @@
@@ -1,24 +0,0 @@
|
||||
-----BEGIN CERTIFICATE----- |
||||
MIID9zCCAt+gAwIBAgIUervWv7EoWkk4Gt8J34xDR9nhH50wDQYJKoZIhvcNAQEL |
||||
BQAwgYIxCzAJBgNVBAYTAldXMRQwEgYDVQQIDAtJMlAgTmV0d29yazESMBAGA1UE |
||||
CgwJUHVycGxlSTJQMSowKAYDVQQDDCFQdXJwbGVJMlAgQ2VydGlmaWNhdGlvbiBB |
||||
dXRob3JpdHkxHTAbBgkqhkiG9w0BCQEWDnI0c2FzQG1haWwuaTJwMB4XDTE5MDMw |
||||
MzE2MjcxNFoXDTI5MDIyODE2MjcxNFowgYIxCzAJBgNVBAYTAldXMRQwEgYDVQQI |
||||
DAtJMlAgTmV0d29yazESMBAGA1UECgwJUHVycGxlSTJQMSowKAYDVQQDDCFQdXJw |
||||
bGVJMlAgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkxHTAbBgkqhkiG9w0BCQEWDnI0 |
||||
c2FzQG1haWwuaTJwMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwLEy |
||||
A0TamzrfORA+aIM/NRRGrKYkI9o5Q9UB/pTM8IFlSBREGleUfnC6LFHZeNV+Y1Tn |
||||
jrMBOZ7PmIKjPIv+fJP7KjhHACZdk6iqVZqkiGqE0/V17kG16g1+g05Bj2lkWr94 |
||||
mp1rhzBeKJJSI8cG82824qdfDcgWZheziye+O0okENhi0o2bDhg78EnyysJiN/tu |
||||
OuoZSGfC9ZdITbpMWgqwuQcdeBg0FNy4hEqUJWoYNgrghe5uc0WMOjTAegSntYPE |
||||
MeaaZyzlGICZ2F+rKZgTjnzVYW60QlHqfg7sShieSPYIZmeN5l5hZ5GZk9Giaj/X |
||||
4pz4sup2iafKclWAmQIDAQABo2MwYTAdBgNVHQ4EFgQUCARvpDaXqPaF4amObzzV |
||||
GaDoZm4wHwYDVR0jBBgwFoAUCARvpDaXqPaF4amObzzVGaDoZm4wDwYDVR0TBAgw |
||||
BgEB/wIBADAOBgNVHQ8BAf8EBAMCAQYwDQYJKoZIhvcNAQELBQADggEBAKcmGUXV |
||||
gCw8PRHe0+XlkcSTX69e0TIPP+j5uJxMT3BHasvBdyV4FcjuUokHGjAnHal5OV4N |
||||
yWdbRPnIge7su4yLQZzlNM1OzbcRds1wSbqTEpb68R/6E8mv3ms6Rc8AcRoXwusc |
||||
byZvzS9tBSXTQ21wCVrltnIARAYabWlWu+URv+DFvlwMik6H8+DklHSVkPC6K3Ov |
||||
V1aMJztMnJ/XTTsFDS/yvaTfmJFG16LABIiSsEAW5QK64sWsN4sxvpcg0D6/EjWP |
||||
knyLM4KXuD3i08mzwzus8d97AjGxC5RCEFL5ADBpVaDU/5CpmZmZdY1daYjiHrXm |
||||
EVNoSbqid1fAVyA= |
||||
-----END CERTIFICATE----- |
@ -1,29 +0,0 @@
@@ -1,29 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<OpenSearchDescription |
||||
xmlns="http://a9.com/-/spec/opensearch/1.1/" |
||||
xmlns:suggestions="http://www.opensearch.org/specifications/opensearch/extensions/suggestions/1.1"> |
||||
<ShortName>YaCy 'legwork'</ShortName> |
||||
<LongName>YaCy.net - Searching the I2P network</LongName> |
||||
<Image type="image/gif">http://legwork.i2p/env/grafics/yacy.png</Image> |
||||
<Image width="16" height="16">data:image/x-icon;base64,AAABAAEAEBAAAAAAGABoAwAAFgAAACgAAAAQAAAAIAAAAAEAGAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD////////Chiu+fBm+fRq+fRq+fRq+fRq+fRq8ehXMmk////////////////////////////++exjUqGfZsnjYsXbYsXbYsXbZsnjTp2W+fBr///////////////////////////+9exfs2r/69/L58+z58+z58+z59e/z59bChSn///////////////////////////+9fBnnz638+fX69O369e748un38Ob59O3Ll0fVrGz////////////////////////Jk0HJlUjXuYrWt4jVtYPr28T58+r59OzPn1fPnlX////////////////////////Rolu8eRXCiTPEjTvCijbNnlj169359e7Zs3vLlkf////////////////////////UqmrAgSLt3MP27eH1693169327+T59Ozo0rG/gB////////////////////////////+/gCDv4Mn48+v38Of59Oz58+v48+vr2b2+fRv///////////////////////////+9ehXr17n58+z48ejo0bDp07T48+zx49DBhCj///////////////////////////+/fhzjyJ/59Oz59OzQoVvNmU759Oz58+vKlUbXrnH////////////////////////LlkfUqmn59Oz48+vZtHzNm1D48+v59OzPoFjOnlX////////////////////////OnVPOnFL59e348+vq1rnEiC7u38j69vDXsHTIkT3////////////////////////UqWjIkD327+T58+3s2bzAgSLp07T79/Pmzqq+fBn///////////////////////////+/fx7v4Mr7+PTx5NDHkD3kyqP8+vjs2r+9exf///////////////////////////++fBjQoFnVq2zTp2bGjTjJk0LWrW7SpWC+exf////////////////////////////Nm1C6dQy7eBG8eBK9exe8ehS7dxC6dQzLlkj////////////AH///wB8x+sAf///AD/+PwA///8AP///AD///4A9PU+APoz/gB///4AdxvOAHoz/gB3368AfjU/AHT1PwB/+P |
||||
</Image> |
||||
<Language>en-us</Language> |
||||
<OutputEncoding>UTF-8</OutputEncoding> |
||||
<InputEncoding>UTF-8</InputEncoding> |
||||
<AdultContent>true</AdultContent> |
||||
<Description>YaCy is an open-source GPL-licensed software that can be used for stand-alone search engine installations or as a client for a multi-user P2P-based web indexing cluster. This is the access to peer 'legwork'.</Description> |
||||
|
||||
<Url type="text/html" method="GET" template="http://legwork.i2p/yacysearch.html?query={searchTerms}&startRecord={startIndex?}&maximumRecords={count?}&nav=all&resource=global" /> |
||||
<Url type="application/rss+xml" method="GET" template="http://legwork.i2p/yacysearch.rss?nav=&query={searchTerms}&startRecord={startIndex?}&maximumRecords={count?}&nav=all&resource=global" /> |
||||
<Url type="application/atom+xml" method="GET" template="http://legwork.i2p/yacysearch.atom?query={searchTerms}&startRecord={startIndex?}&maximumRecords={count?}&resource=global" /> |
||||
|
||||
<Url type="application/x-suggestions+json" template="http://legwork.i2p/suggest.json?query={searchTerms}"/> |
||||
<Url type="application/x-suggestions+xml" template="http://legwork.i2p/suggest.xml?query={searchTerms}"/> |
||||
<!-- syntax according to http://www.loc.gov/standards/sru/. Set verify=true to get snippets in the search results --> |
||||
<Developer>See https://github.com/orgs/yacy/teams/yacy_developers</Developer> |
||||
<Query role="example" searchTerms="yacy+free+software" /> |
||||
<Tags>YaCy Free Software Open Source P2P Peer-to-Peer Uncensored Distributed Web Search Engine</Tags> |
||||
<Contact>See http://legwork.i2p/ViewProfile.html?hash=localhash</Contact> |
||||
<Attribution>http://yacy.net YaCy Software &copy; 2004-2014 by Michael Christen et al., YaCy.net; Content: ask peer owner</Attribution> |
||||
<SyndicationRight>open</SyndicationRight> |
||||
</OpenSearchDescription> |
@ -0,0 +1,96 @@
@@ -0,0 +1,96 @@
|
||||
{ |
||||
"policies": { |
||||
"AppUpdateURL": "http://127.0.0.1/", |
||||
"CaptivePortal": false, |
||||
"Certificates": { |
||||
"ImportEnterpriseRoots": false |
||||
}, |
||||
"DNSOverHTTPS": { |
||||
"Enabled": false, |
||||
"Locked": true |
||||
}, |
||||
"DisableAppUpdate": true, |
||||
"DisableFeedbackCommands": true, |
||||
"DisableFirefoxAccounts": true, |
||||
"DisableFirefoxScreenshots": true, |
||||
"DisableFirefoxStudies": true, |
||||
"DisablePasswordReveal": true, |
||||
"DisablePocket": true, |
||||
"DisableProfileImport": true, |
||||
"DisableProfileRefresh": true, |
||||
"DisableSafeMode": true, |
||||
"DisableSetDesktopBackground": true, |
||||
"DisableSystemAddonUpdate": true, |
||||
"DisableTelemetry": true, |
||||
"DontCheckDefaultBrowser": true, |
||||
"ExtensionUpdate": false, |
||||
"Extensions": { |
||||
"Locked": [ |
||||
"73a6fe31-595d-460b-a920-fcc0f8843232" |
||||
] |
||||
}, |
||||
"FirefoxHome": { |
||||
"Highlights": false, |
||||
"Pocket": false, |
||||
"Search": true, |
||||
"Snippets": false, |
||||
"TopSites": true |
||||
}, |
||||
"FlashPlugin": { |
||||
"Default": false |
||||
}, |
||||
"NetworkPrediction": false, |
||||
"NoDefaultBookmarks": true, |
||||
"OfferToSaveLoginsDefault": false, |
||||
"OverrideFirstRunPage": "http://i2pd.i2p/", |
||||
"OverridePostUpdatePage": "", |
||||
"Permissions": { |
||||
"Camera": { |
||||
"BlockNewRequests": true |
||||
}, |
||||
"Location": { |
||||
"BlockNewRequests": true |
||||
}, |
||||
"Microphone": { |
||||
"BlockNewRequests": true |
||||
} |
||||
}, |
||||
"PopupBlocking": { |
||||
"Default": true |
||||
}, |
||||
"Preferences": { |
||||
"browser.cache.disk.enable": true, |
||||
"browser.fixup.dns_first_for_single_words": false, |
||||
"browser.search.update": false, |
||||
"browser.tabs.warnOnClose": false, |
||||
"browser.urlbar.suggest.bookmark": true, |
||||
"browser.urlbar.suggest.history": true, |
||||
"browser.urlbar.suggest.openpage": true, |
||||
"datareporting.policy.dataSubmissionPolicyBypassNotification": true, |
||||
"dom.disable_window_flip": true, |
||||
"dom.disable_window_move_resize": true, |
||||
"dom.event.contextmenu.enabled": false, |
||||
"network.IDN_show_punycode": false, |
||||
"network.dns.disableIPv6": true, |
||||
"places.history.enabled": true, |
||||
"privacy.file_unique_origin": true |
||||
}, |
||||
"PromptForDownloadLocation": true, |
||||
"Proxy": { |
||||
"AutoLogin": true, |
||||
"FTPProxy": "127.0.0.1:4444", |
||||
"HTTPProxy": "127.0.0.1:4444", |
||||
"Mode": "manual", |
||||
"SOCKSVersion": 5, |
||||
"SSLProxy": "127.0.0.1:4444", |
||||
"UseHTTPProxyForAllProtocols": false, |
||||
"UseProxyForDNS": true |
||||
}, |
||||
"SearchBar": "unified", |
||||
"SearchSuggestEnabled": false, |
||||
"SupportMenu": { |
||||
"Title": "Ilita IRC", |
||||
"URL": "http://irc.r4sas.i2p/?nick=WebClient...&channels=dev%2Cen%2Cru&prompt=1&uio=OT10cnVlde" |
||||
} |
||||
} |
||||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,23 @@
@@ -0,0 +1,23 @@
|
||||
-----BEGIN CERTIFICATE----- |
||||
MIID7DCCAtSgAwIBAgIJAKXaTovgoTIUMA0GCSqGSIb3DQEBCwUAMIGCMQswCQYD |
||||
VQQGEwJXVzEUMBIGA1UECAwLSTJQIE5ldHdvcmsxEjAQBgNVBAoMCVB1cnBsZUky |
||||
UDEqMCgGA1UEAwwhUHVycGxlSTJQIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MR0w |
||||
GwYJKoZIhvcNAQkBFg5yNHNhc0BtYWlsLmkycDAeFw0xODA4MjQyMTQ3NTJaFw0y |
||||
MzA4MjMyMTQ3NTJaMIGCMQswCQYDVQQGEwJXVzEUMBIGA1UECAwLSTJQIE5ldHdv |
||||
cmsxEjAQBgNVBAoMCVB1cnBsZUkyUDEqMCgGA1UEAwwhUHVycGxlSTJQIENlcnRp |
||||
ZmljYXRpb24gQXV0aG9yaXR5MR0wGwYJKoZIhvcNAQkBFg5yNHNhc0BtYWlsLmky |
||||
cDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALAZnN/U5bgkmiBqp/Np |
||||
yiMOkUPjr2tLhV78Oba46xDLA6AiQ7yTPg+/ZYPIfbF2dPBTpfgGdly2M1xymRKc |
||||
3Pa+IUXkLw6oCA+lFzOFW0Swtekk9HRAgGyHgj6/Hvagva5Wer4HJIO1qRsFPew+ |
||||
XcM3uhhiXoiO8o+YGpJ/7kz0gED3p2b9OVsLPd8G/GfdR3miD+Au+kUx/27z/WdJ |
||||
ISfFILFnYeYZGffrpRcFtoGwuZUCugwnbLtpQpNKuGq8jDidm1v6Rb85JmkoH3Sg |
||||
lRaX1MK0aPhM4WfCf7aWCNe669FAWPNB3Ya2lue7ewPLI84ZUEqcoJwmWn2ci2SU |
||||
EXUCAwEAAaNjMGEwHQYDVR0OBBYEFG3hwzikpXqMasw678OHM8uLyjEoMB8GA1Ud |
||||
IwQYMBaAFG3hwzikpXqMasw678OHM8uLyjEoMA8GA1UdEwQIMAYBAf8CAQAwDgYD |
||||
VR0PAQH/BAQDAgEGMA0GCSqGSIb3DQEBCwUAA4IBAQA07URxJMI/Ta9y1wIg+k7o |
||||
1aHXsl6YOXmd2ymhKZhZHrZlutE2U19IQSoEV0SBddP9D05xD6Ovsrwo7caeYzNt |
||||
+2DJnlJ2IY61NqYUIDEoJyNPL/S7WleH+xO+bcSqWvbntTNYAD6WQVfHCAimVE6P |
||||
RnSZGqG089i84DRCyrh/6F1OxnBd6j14z+2ctQD+h6NlQXiCAUIwzVirYoE7oGpH |
||||
Xta7Ei+RDvBXLXLAQRdXpzSP/Ddf7MCJzmH3VYAy+0sVuHr09hpFMtC59hTrdLVD |
||||
/qma0eKrBr1DGH6QrZMZDqpNfv4wUPyVQBsRbbn2/1fL9IqK43CIj8RUllCOsmyU |
||||
-----END CERTIFICATE----- |
@ -1 +0,0 @@
@@ -1 +0,0 @@
|
||||
{"chrome://browser/content/browser.xul":{"navigator-toolbox":{"iconsize":"small"},"titlebar-placeholder-on-menubar-for-caption-buttons":{"width":"102"},"titlebar-placeholder-on-TabsToolbar-for-captions-buttons":{"width":"102"},"main-window":{"screenX":"30","screenY":"30","width":"1280","height":"720","sizemode":"normal"},"PersonalToolbar":{"collapsed":"false","currentset":"personal-bookmarks"},"toolbar-menubar":{"currentset":"menubar-items"},"TabsToolbar":{"currentset":"tabbrowser-tabs,new-tab-button,alltabs-button"},"addon-bar":{"currentset":"addonbar-closebutton,status-bar"},"nav-bar":{"currentset":"back-button,forward-button,stop-reload-button,urlbar-container,bookmarks-menu-button,downloads-button,_73a6fe31-595d-460b-a920-fcc0f8843232_-browser-action"},"sidebar-title":{"value":""}}} |
Loading…
Reference in new issue