2019-11-11 23:31:37 -05:00
|
|
|
var webpref = chrome.i18n.getMessage("webPreface");
|
|
|
|
var webprefpriv = chrome.i18n.getMessage("webPrefacePrivate");
|
|
|
|
var routerpref = chrome.i18n.getMessage("routerPreface");
|
|
|
|
var routerprefpriv = chrome.i18n.getMessage("routerPrefacePrivate");
|
|
|
|
var mailpref = chrome.i18n.getMessage("mailPreface");
|
|
|
|
var mailprefpriv = chrome.i18n.getMessage("mailPrefacePrivate");
|
|
|
|
var torrentpref = chrome.i18n.getMessage("torrentPreface");
|
|
|
|
var torrentprefpriv = chrome.i18n.getMessage("torrentPrefacePrivate");
|
|
|
|
var tunnelpref = chrome.i18n.getMessage("i2ptunnelPreface");
|
|
|
|
var tunnelprefpriv = chrome.i18n.getMessage("i2ptunnelPrefacePrivate");
|
|
|
|
|
2019-05-02 17:31:11 -04:00
|
|
|
function onSet(result) {
|
2019-10-06 15:18:10 -04:00
|
|
|
if (result) {
|
|
|
|
console.log("->: Value was updated");
|
|
|
|
} else {
|
|
|
|
console.log("-X: Value was not updated");
|
|
|
|
}
|
2019-05-02 17:31:11 -04:00
|
|
|
}
|
|
|
|
|
2019-11-10 20:28:31 -05:00
|
|
|
/* This disables queries to centralized databases of bad URLs to screen for
|
|
|
|
risky sites in your browser */
|
2019-05-02 17:31:11 -04:00
|
|
|
function disableHyperlinkAuditing() {
|
2019-10-28 01:11:16 -04:00
|
|
|
var setting = browser.privacy.websites.hyperlinkAuditingEnabled.set({
|
|
|
|
value: false
|
|
|
|
});
|
|
|
|
console.log("Disabling hyperlink auditing/val=", {
|
|
|
|
value: false
|
|
|
|
});
|
|
|
|
setting.then(onSet);
|
2019-05-02 17:31:11 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// This enables first-party isolation
|
|
|
|
function enableFirstPartyIsolation() {
|
2019-10-28 01:11:16 -04:00
|
|
|
var setting = browser.privacy.websites.firstPartyIsolate.set({
|
|
|
|
value: true
|
|
|
|
});
|
|
|
|
console.log("Enabling first party isolation/val=", {
|
|
|
|
value: true
|
|
|
|
});
|
|
|
|
setting.then(onSet);
|
2019-05-02 17:31:11 -04:00
|
|
|
}
|
|
|
|
|
2019-11-10 20:28:31 -05:00
|
|
|
/* This rejects tracking cookies and third-party cookies but it
|
|
|
|
LEAVES "Persistent" Cookies unmodified in favor of an option in the content
|
|
|
|
interface for now */
|
2019-05-02 17:31:11 -04:00
|
|
|
function disableEvilCookies() {
|
2019-10-28 01:11:16 -04:00
|
|
|
var getting = browser.privacy.websites.cookieConfig.get({});
|
|
|
|
getting.then(got => {
|
|
|
|
var setting = browser.privacy.websites.cookieConfig.set({
|
|
|
|
value: {
|
|
|
|
behavior: "reject_third_party",
|
|
|
|
nonPersistentCookies: got.value.nonPersistentCookies
|
|
|
|
}
|
2019-10-06 15:18:10 -04:00
|
|
|
});
|
2019-10-28 01:11:16 -04:00
|
|
|
console.log("Setting cookie behavior/val=", {
|
|
|
|
value: {
|
|
|
|
behavior: "reject_third_party",
|
|
|
|
nonPersistentCookies: got.value.nonPersistentCookies
|
|
|
|
}
|
|
|
|
});
|
|
|
|
setting.then(onSet);
|
|
|
|
});
|
2019-05-02 17:31:11 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Make sure that they're gone
|
|
|
|
/*function disableBadCookies(){
|
|
|
|
var setting = browser.privacy.websites.thirdPartyCookiesAllowed.set({
|
|
|
|
value: false
|
|
|
|
});
|
|
|
|
console.log("Disabling third party cookies/val=", {
|
|
|
|
value: false
|
|
|
|
})
|
|
|
|
setting.then(onSet);
|
|
|
|
}*/
|
|
|
|
|
|
|
|
// this disables the use of referrer headers
|
|
|
|
function disableReferrers() {
|
2019-10-28 01:11:16 -04:00
|
|
|
var setting = browser.privacy.websites.referrersEnabled.set({
|
|
|
|
value: false
|
|
|
|
});
|
|
|
|
console.log("Disabling referrer headers/val=", {
|
|
|
|
value: false
|
|
|
|
});
|
|
|
|
setting.then(onSet);
|
2019-05-02 17:31:11 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// enable fingerprinting resistent features(letterboxing and stuff)
|
|
|
|
function enableResistFingerprinting() {
|
2019-10-28 01:11:16 -04:00
|
|
|
var setting = browser.privacy.websites.referrersEnabled.set({
|
|
|
|
value: true
|
|
|
|
});
|
|
|
|
console.log("Enabling resist fingerprinting/val=", {
|
|
|
|
value: true
|
|
|
|
});
|
|
|
|
setting.then(onSet);
|
2019-05-02 17:31:11 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// This is essentially a blocklist of clearnet web-sites known to do bad tracking
|
|
|
|
function enableTrackingProtection() {
|
2019-10-28 01:11:16 -04:00
|
|
|
var setting = browser.privacy.websites.trackingProtectionMode.set({
|
|
|
|
value: "always"
|
|
|
|
});
|
|
|
|
console.log("Enabling tracking protection/val=", {
|
|
|
|
value: "always"
|
|
|
|
});
|
|
|
|
setting.then(onSet);
|
2019-05-02 17:31:11 -04:00
|
|
|
}
|
|
|
|
|
2019-11-10 20:28:31 -05:00
|
|
|
/* This disables protected content, which is a form of digital restrictions
|
|
|
|
management dependent on identifying information */
|
2019-05-02 17:31:11 -04:00
|
|
|
function disableDigitalRestrictionsManagement() {
|
2019-10-28 01:11:16 -04:00
|
|
|
var gettingInfo = browser.runtime.getPlatformInfo();
|
|
|
|
gettingInfo.then(got => {
|
|
|
|
if (got.os == "win") {
|
|
|
|
var setting = browser.privacy.websites.protectedContentEnabled.set({
|
|
|
|
value: false
|
|
|
|
});
|
|
|
|
console.log(
|
|
|
|
"Setting Protected Content(Digital Restrictions Management) false/val=",
|
|
|
|
{
|
2019-10-06 15:18:10 -04:00
|
|
|
value: false
|
2019-10-28 01:11:16 -04:00
|
|
|
}
|
|
|
|
);
|
|
|
|
setting.then(onSet);
|
|
|
|
}
|
|
|
|
});
|
2019-05-02 17:31:11 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
function setAllPrivacy() {
|
2019-10-06 15:18:10 -04:00
|
|
|
disableHyperlinkAuditing();
|
|
|
|
enableFirstPartyIsolation();
|
|
|
|
disableEvilCookies();
|
|
|
|
disableReferrers();
|
|
|
|
enableTrackingProtection();
|
|
|
|
enableResistFingerprinting();
|
|
|
|
disableDigitalRestrictionsManagement();
|
2019-05-02 17:31:11 -04:00
|
|
|
}
|
|
|
|
|
2019-10-06 15:18:10 -04:00
|
|
|
setAllPrivacy();
|
2019-05-02 17:31:11 -04:00
|
|
|
|
2019-07-13 22:07:24 -04:00
|
|
|
function ResetPeerConnection() {
|
2019-10-28 01:11:16 -04:00
|
|
|
browser.privacy.network.peerConnectionEnabled.set({
|
|
|
|
value: false
|
|
|
|
});
|
|
|
|
browser.privacy.network.networkPredictionEnabled.set({
|
|
|
|
value: false
|
|
|
|
});
|
2019-10-06 15:18:10 -04:00
|
|
|
chrome.privacy.network.webRTCIPHandlingPolicy.set({
|
|
|
|
value: "disable_non_proxied_udp"
|
|
|
|
});
|
|
|
|
console.log("Re-disabled WebRTC");
|
2019-05-02 17:31:11 -04:00
|
|
|
}
|
|
|
|
|
2019-07-13 22:07:24 -04:00
|
|
|
function EnablePeerConnection() {
|
2019-10-28 01:11:16 -04:00
|
|
|
browser.privacy.network.peerConnectionEnabled.set({
|
|
|
|
value: true
|
|
|
|
});
|
|
|
|
browser.privacy.network.networkPredictionEnabled.set({
|
|
|
|
value: false
|
|
|
|
});
|
2019-10-06 15:18:10 -04:00
|
|
|
chrome.privacy.network.webRTCIPHandlingPolicy.set({
|
|
|
|
value: "disable_non_proxied_udp"
|
|
|
|
});
|
|
|
|
console.log("Enabled WebRTC");
|
2019-05-02 17:31:11 -04:00
|
|
|
}
|
|
|
|
|
2019-10-06 15:18:10 -04:00
|
|
|
ResetPeerConnection();
|
2019-05-02 17:31:11 -04:00
|
|
|
|
2019-07-13 22:07:24 -04:00
|
|
|
function ResetDisableSavePasswords() {
|
2019-10-06 15:18:10 -04:00
|
|
|
browser.privacy.services.passwordSavingEnabled.set({
|
|
|
|
value: false
|
|
|
|
});
|
|
|
|
console.log("Re-disabled saved passwords");
|
2019-05-02 17:31:11 -04:00
|
|
|
}
|
|
|
|
|
2019-07-13 22:07:24 -04:00
|
|
|
function EnableSavePasswords() {
|
2019-10-06 15:18:10 -04:00
|
|
|
browser.privacy.services.passwordSavingEnabled.set({
|
|
|
|
value: true
|
|
|
|
});
|
|
|
|
console.log("Enabled saved passwords");
|
2019-05-02 17:31:11 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
//ResetDisableSavePasswords()
|
|
|
|
|
|
|
|
var defaultSettings = {
|
2019-10-06 15:18:10 -04:00
|
|
|
since: "forever",
|
2019-10-16 17:24:02 -04:00
|
|
|
dataTypes: ["downloads", "passwords", "formData", "localStorage", "history"]
|
2019-05-02 17:31:11 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
var appSettings = {
|
2019-10-06 15:18:10 -04:00
|
|
|
since: "forever",
|
|
|
|
dataTypes: [""]
|
2019-05-02 17:31:11 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
function onError(e) {
|
2019-10-06 15:18:10 -04:00
|
|
|
console.error(e);
|
2019-05-02 17:31:11 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
function checkStoredSettings(storedSettings) {
|
2019-10-06 15:18:10 -04:00
|
|
|
chrome.storage.local.set(appSettings);
|
2019-05-02 17:31:11 -04:00
|
|
|
}
|
|
|
|
|
2019-10-28 01:11:16 -04:00
|
|
|
const gettingStoredSettings = browser.storage.local.get();
|
|
|
|
gettingStoredSettings.then(checkStoredSettings, onError);
|
2019-05-02 17:31:11 -04:00
|
|
|
|
2019-10-07 18:45:52 -04:00
|
|
|
function clearCookiesContext(cookieStoreId) {}
|
|
|
|
|
2019-05-02 17:31:11 -04:00
|
|
|
function forgetBrowsingData(storedSettings) {
|
2019-10-06 15:18:10 -04:00
|
|
|
function getSince(selectedSince) {
|
|
|
|
if (selectedSince === "forever") {
|
|
|
|
return 0;
|
2019-05-02 17:31:11 -04:00
|
|
|
}
|
|
|
|
|
2019-10-06 15:18:10 -04:00
|
|
|
const times = {
|
2019-11-10 20:28:31 -05:00
|
|
|
hour: () => 1000 * 60 * 60,
|
|
|
|
day: () => 1000 * 60 * 60 * 24,
|
|
|
|
week: () => 1000 * 60 * 60 * 24 * 7
|
2019-10-06 15:18:10 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
const sinceMilliseconds = times[selectedSince].call();
|
|
|
|
return Date.now() - sinceMilliseconds;
|
|
|
|
}
|
|
|
|
|
|
|
|
function getTypes(selectedTypes) {
|
|
|
|
let dataTypes = {};
|
|
|
|
for (let item of selectedTypes) {
|
|
|
|
dataTypes[item] = true;
|
2019-05-02 17:31:11 -04:00
|
|
|
}
|
2019-10-06 15:18:10 -04:00
|
|
|
return dataTypes;
|
|
|
|
}
|
|
|
|
|
|
|
|
const since = getSince(defaultSettings.since);
|
|
|
|
const dataTypes = getTypes(defaultSettings.dataTypes);
|
|
|
|
|
|
|
|
function notify() {
|
|
|
|
let dataTypesString = Object.keys(dataTypes).join(", ");
|
|
|
|
let sinceString = new Date(since).toLocaleString();
|
|
|
|
browser.notifications.create({
|
|
|
|
type: "basic",
|
|
|
|
title: "Removed browsing data",
|
2019-11-11 16:34:41 -05:00
|
|
|
message: `Removed ${dataTypesString}\n for I2P Browsing`
|
2019-10-06 15:18:10 -04:00
|
|
|
});
|
|
|
|
}
|
2019-05-02 17:31:11 -04:00
|
|
|
|
2019-10-16 15:31:30 -04:00
|
|
|
function deepCleanHistory(historyItems) {
|
2019-10-16 17:24:02 -04:00
|
|
|
console.log("Deep cleaning history");
|
2019-10-16 15:31:30 -04:00
|
|
|
for (item of historyItems) {
|
|
|
|
if (i2pHost(item.url)) {
|
|
|
|
browser.history.deleteUrl({
|
|
|
|
url: item.url
|
|
|
|
});
|
2019-10-16 17:24:02 -04:00
|
|
|
browser.browsingData.removeCache({});
|
|
|
|
console.log("cleared Cache");
|
|
|
|
browser.browsingData
|
|
|
|
.removePasswords({
|
|
|
|
hostnames: [i2pHostName(item.url)],
|
2019-11-10 20:28:31 -05:00
|
|
|
since
|
2019-10-16 17:24:02 -04:00
|
|
|
})
|
|
|
|
.then(onGot);
|
|
|
|
console.log("cleared Passwords");
|
|
|
|
browser.browsingData
|
|
|
|
.removeDownloads({
|
|
|
|
hostnames: [i2pHostName(item.url)],
|
2019-11-10 20:28:31 -05:00
|
|
|
since
|
2019-10-16 17:24:02 -04:00
|
|
|
})
|
|
|
|
.then(onGot);
|
|
|
|
console.log("cleared Downloads");
|
2019-10-16 15:31:30 -04:00
|
|
|
browser.browsingData
|
2019-10-16 17:24:02 -04:00
|
|
|
.removeFormData({
|
|
|
|
hostnames: [i2pHostName(item.url)],
|
2019-11-10 20:28:31 -05:00
|
|
|
since
|
2019-10-16 17:24:02 -04:00
|
|
|
})
|
|
|
|
.then(onGot);
|
|
|
|
console.log("cleared Form Data");
|
|
|
|
browser.browsingData
|
|
|
|
.removeLocalStorage({
|
|
|
|
hostnames: [i2pHostName(item.url)],
|
2019-11-10 20:28:31 -05:00
|
|
|
since
|
2019-10-16 17:24:02 -04:00
|
|
|
})
|
|
|
|
.then(onGot);
|
|
|
|
console.log("cleared Local Storage");
|
|
|
|
|
|
|
|
contexts = browser.contextualIdentities.query({
|
2019-11-11 23:31:37 -05:00
|
|
|
name: titlepref
|
2019-10-16 17:24:02 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
function deepCleanCookies(cookies) {
|
|
|
|
for (cookie of cookies) {
|
|
|
|
var removing = browser.cookies.remove({
|
|
|
|
firstPartyDomain: cookie.firstPartyDomain,
|
|
|
|
name: cookie.name,
|
|
|
|
url: item.url
|
|
|
|
});
|
|
|
|
removing.then(onGot, onError);
|
|
|
|
}
|
2019-10-28 01:11:16 -04:00
|
|
|
console.log("Cleared cookies");
|
2019-10-16 17:24:02 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
function deepCleanContext(cookieStoreIds) {
|
|
|
|
for (cookieStoreId of cookieStoreIds) {
|
|
|
|
var removing = browser.cookies.getAll({
|
|
|
|
firstPartyDomain: null,
|
|
|
|
storeId: cookieStoreId.cookieStoreId
|
|
|
|
});
|
|
|
|
removing.then(deepCleanCookies, onError);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
contexts.then(deepCleanContext, onError);
|
2019-10-16 15:31:30 -04:00
|
|
|
}
|
|
|
|
}
|
2019-10-16 17:24:02 -04:00
|
|
|
notify();
|
2019-10-16 15:31:30 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
var searching = browser.history.search({
|
|
|
|
text: "i2p",
|
|
|
|
startTime: 0
|
|
|
|
});
|
|
|
|
|
|
|
|
searching.then(deepCleanHistory);
|
2019-06-29 00:32:03 -04:00
|
|
|
|
2019-10-06 15:18:10 -04:00
|
|
|
setAllPrivacy();
|
|
|
|
ResetPeerConnection();
|
2019-05-02 17:31:11 -04:00
|
|
|
}
|
2019-07-10 02:29:38 -04:00
|
|
|
|
2019-10-16 15:31:30 -04:00
|
|
|
function i2pHostName(url) {
|
|
|
|
let hostname = "";
|
|
|
|
if (url.indexOf("://") > -1) {
|
|
|
|
hostname = url.split("/")[2];
|
|
|
|
} else {
|
|
|
|
hostname = url.split("/")[0];
|
|
|
|
}
|
|
|
|
return hostname;
|
|
|
|
}
|
|
|
|
|
|
|
|
function i2pHost(url) {
|
|
|
|
let hostname = i2pHostName(url);
|
|
|
|
return hostname.endsWith(".i2p");
|
|
|
|
}
|
|
|
|
|
2019-07-10 02:29:38 -04:00
|
|
|
function onGot(contexts) {
|
2019-10-16 17:24:02 -04:00
|
|
|
if (contexts != null) {
|
|
|
|
for (let context of contexts) {
|
|
|
|
console.log(context);
|
|
|
|
}
|
2019-10-06 15:18:10 -04:00
|
|
|
}
|
2019-07-10 02:29:38 -04:00
|
|
|
}
|
|
|
|
|
2019-10-28 01:11:16 -04:00
|
|
|
browser.runtime.onMessage.addListener(message);
|
2019-07-10 02:29:38 -04:00
|
|
|
|
2019-10-28 01:12:40 -04:00
|
|
|
function message(message) {
|
|
|
|
console.log(message);
|
|
|
|
if (message.rtc === "enableWebRTC") {
|
|
|
|
console.log("enableWebRTC");
|
|
|
|
EnablePeerConnection();
|
|
|
|
} else {
|
|
|
|
console.log("disableWebRTC");
|
|
|
|
ResetPeerConnection();
|
|
|
|
}
|
|
|
|
}
|