Skip to content

Commit

Permalink
0b scheme (#254)
Browse files Browse the repository at this point in the history
* update manifest for new scheme

* add new scheme (0b) features

* firebase updates for 0b release
  • Loading branch information
ekuller authored Nov 7, 2022
1 parent e1663f3 commit 60ee503
Show file tree
Hide file tree
Showing 4 changed files with 169 additions and 160 deletions.
62 changes: 42 additions & 20 deletions src/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,7 @@ import {
addDisableDomainRule,
} from "./editRules.js";

import {
updatePrefScheme3,
} from "./options/views/domainlist-view/domainlist-view.js"
import { updatePrefScheme3 } from "./options/views/domainlist-view/domainlist-view.js";

// Connect with Database
const firebaseApp = initializeApp(firebaseConfig);
Expand Down Expand Up @@ -128,15 +126,15 @@ class ThirdPartyData {
this.count = 0;
this.sCollection = collection(
db,
"users-scheme7",
"users-scheme0b",
userDocId,
"Browser History",
docId,
"Third Party Requests Summary"
);
this.eCollection = collection(
db,
"users-scheme7",
"users-scheme0b",
userDocId,
"Browser History",
docId,
Expand Down Expand Up @@ -183,7 +181,7 @@ export async function createUser(prolificID, schemeNumber) {
let latitude = crd.latitude ? crd.latitude : "unknown latitude";
let date = new Date();
// generate unique user document and storage the id into local storage
const newUserRef = doc(collection(db, "users-scheme7"));
const newUserRef = doc(collection(db, "users-scheme0b"));
console.log("new user reference created: ", newUserRef);
chrome.storage.local.set(
{ USER_DOC_ID: newUserRef.id, UI_SCHEME: schemeNumber },
Expand Down Expand Up @@ -251,7 +249,7 @@ function addHistory(
GPC = "unset";
}
const newBrowserRef = doc(
collection(db, "users-scheme7", currentUserDocID, "Browser History")
collection(db, "users-scheme0b", currentUserDocID, "Browser History")
);
const userData = {
Timestamp: Timestamp.fromDate(date),
Expand Down Expand Up @@ -286,18 +284,28 @@ export function addSettingInteractionHistory(
) {
let date = new Date();
const intDoc1 = doc(
collection(db, "users-scheme7", currentUserDocID, "Domain Interaction History")
collection(
db,
"users-scheme0b",
currentUserDocID,
"Domain Interaction History"
)
);
const intDoc2 = doc(
collection(
db,
"users-scheme7",
"users-scheme0b",
currentUserDocID,
"Privacy Configuration Interaction History"
)
);
const intDoc3 = doc(
collection(db, "users-scheme7", currentUserDocID, "Mute Interaction History")
collection(
db,
"users-scheme0b",
currentUserDocID,
"Mute Interaction History"
)
);
if (subcollection === "Domain") {
const intData = {
Expand All @@ -316,7 +324,9 @@ export function addSettingInteractionHistory(
};
setDoc(intDoc1, intData);
} else if (subcollection === "Privacy Choice") {
if (originSite == undefined) {originSite = "None"};
if (originSite == undefined) {
originSite = "None";
}
const intData = {
Timestamp: Timestamp.fromDate(date),
Domain: domain,
Expand Down Expand Up @@ -346,7 +356,7 @@ export function updateDomains(domainsList) {
console.log("updating the domain list");
chrome.storage.local.get(["USER_DOC_ID"], function (result) {
if (result.USER_DOC_ID) {
const userRef = doc(db, "users-scheme7", result.USER_DOC_ID);
const userRef = doc(db, "users-scheme0b", result.USER_DOC_ID);
updateDoc(userRef, {
"Domain List": domainsList,
});
Expand Down Expand Up @@ -433,7 +443,7 @@ export function addAd(adEvent) {
chrome.storage.local.get(["USER_DOC_ID"], function (result) {
const historyRef = collection(
db,
"users-scheme7",
"users-scheme0b",
result.USER_DOC_ID,
"Browser History"
);
Expand All @@ -447,7 +457,7 @@ export function addAd(adEvent) {
querySnapshot.forEach((d) => {
const newBrowserRef = collection(
db,
"users-scheme7",
"users-scheme0b",
result.USER_DOC_ID,
"Browser History",
d.id,
Expand All @@ -465,7 +475,7 @@ export function addAd(adEvent) {
// console.log(adEvent.targetTabId)
const docRef = doc(
db,
"users-scheme7",
"users-scheme0b",
result.USER_DOC_ID,
"Browser History",
d.id,
Expand Down Expand Up @@ -551,7 +561,7 @@ chrome.runtime.onMessage.addListener(async function (request) {
request.domain
);
chrome.storage.local.get(["UI_SCHEME", "UV_SETTING"], function (result) {
if (result.UI_SCHEME < 3) {
if (result.UI_SCHEME < 3 || result.UI_SCHEME == 9) {
if (result.UV_SETTING == "Send signal to all") {
rmDisableDomainRule(request.domain);
} else {
Expand All @@ -569,7 +579,7 @@ chrome.runtime.onMessage.addListener(async function (request) {
request.domain
);
chrome.storage.local.get(["UI_SCHEME"], function (result) {
if (result.UI_SCHEME < 3) {
if (result.UI_SCHEME < 3 || result.UI_SCHEME == 9) {
removeDomainFromRule(request.domain);
} else {
rmRuleUrl(request.domain);
Expand Down Expand Up @@ -716,7 +726,7 @@ chrome.tabs.onRemoved.addListener((tabId, removeInfo) => {

// Set the initial configuration of the extension
chrome.runtime.onInstalled.addListener(async function (object) {
let userScheme = 7;
let userScheme = 9;
chrome.storage.local.set(
{
MUTED: [false, undefined],
Expand All @@ -730,7 +740,12 @@ chrome.runtime.onInstalled.addListener(async function (object) {
},
function () {
enable();
if (userScheme == 0 || userScheme == 1 || userScheme == 2) {
if (
userScheme == 0 ||
userScheme == 1 ||
userScheme == 2 ||
userScheme == 9
) {
openPage("registration/registration.html");
} else if (userScheme == 3) {
// parse the checklist needed for updating the sendSignals based on user's choice
Expand Down Expand Up @@ -835,7 +850,14 @@ chrome.webNavigation.onCommitted.addListener(function (details) {
) {
cleanFrames(details.tabId);
chrome.storage.local.get(
["APPLY_ALL", "ENABLED", "USER_DOC_ID", "UI_SCHEME", "DOMAINS", "MUTED"],
[
"APPLY_ALL",
"ENABLED",
"USER_DOC_ID",
"UI_SCHEME",
"DOMAINS",
"MUTED",
],
function (result) {
if (result.USER_DOC_ID) {
let domains = result.DOMAINS;
Expand Down
6 changes: 6 additions & 0 deletions src/contentScript.js
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,12 @@ chrome.storage.local.get(
bannerMuted[0] != true
)
showBanner(false, true);
} else if (result.UI_SCHEME == 9) {
if (
domains[currentDomain] === undefined ||
domains[currentDomain] == null
)
showBanner(false, false);
} else if (result.UI_SCHEME == 5) {
// the user has 1/4 chance of seeing the banner
// let random = Math.floor(Math.random() * 4);
Expand Down
180 changes: 90 additions & 90 deletions src/manifest.json
Original file line number Diff line number Diff line change
@@ -1,92 +1,92 @@
{
"name": "GPC Privacy Choice",
"version": "2.8.0",
"description": "GPC Privacy Choice is a research extension that studies usable privacy choice mechanisms on the web",
"permissions": [
"webRequest",
"webNavigation",
"storage",
"tabs",
"contentSettings",
"geolocation",
"declarativeNetRequest"
],
"host_permissions": ["<all_urls>"],
"action": {
"default_title": "GPC Privacy Choice"
},
"content_scripts": [
{
"matches": ["<all_urls>"],
"js": ["contentScript.js"],
"run_at": "document_end"
}
],
"background": {
"service_worker": "background.js",
"type": "module"
},
"manifest_version": 3,
"web_accessible_resources": [
{
"resources": ["adDomains.txt", "json/*.json"],
"matches": ["<all_urls>"]
}
],
"icons": {
"32": "./img/gpc-choice-icon.png",
"128": "./img/gpc-choice-icon.png"
},
"content_security_policy": {
"extension_pages": "script-src 'self'; object-src 'self'"
},
"declarative_net_request": {
"rule_resources": [
{
"id": "universal_GPC",
"enabled": false,
"path": "rulesets/global.json"
},
{
"id": "advertising",
"enabled": false,
"path": "rulesets/Advertising.json"
},
{
"id": "FG",
"enabled": false,
"path": "rulesets/FingerprintingGeneral.json"
},
{
"id": "FI",
"enabled": false,
"path": "rulesets/FingerprintingInvasive.json"
},
{
"id": "social",
"enabled": false,
"path": "rulesets/Social.json"
},
{
"id": "disconnect",
"enabled": false,
"path": "rulesets/Disconnect.json"
},
{
"id": "cryptomining",
"enabled": false,
"path": "rulesets/Cryptomining.json"
},
{
"id": "analytics",
"enabled": false,
"path": "rulesets/Analytics.json"
},
{
"id": "content",
"enabled": false,
"path": "rulesets/Content.json"
}
]
}
"name": "GPC Privacy Choice",
"version": "2.9.0",
"description": "GPC Privacy Choice is a research extension that studies usable privacy choice mechanisms on the web",
"permissions": [
"webRequest",
"webNavigation",
"storage",
"tabs",
"contentSettings",
"geolocation",
"declarativeNetRequest"
],
"host_permissions": ["<all_urls>"],
"action": {
"default_title": "GPC Privacy Choice"
},
"content_scripts": [
{
"matches": ["<all_urls>"],
"js": ["contentScript.js"],
"run_at": "document_end"
}
],
"background": {
"service_worker": "background.js",
"type": "module"
},
"manifest_version": 3,
"web_accessible_resources": [
{
"resources": ["adDomains.txt", "json/*.json"],
"matches": ["<all_urls>"]
}
],
"icons": {
"32": "./img/gpc-choice-icon.png",
"128": "./img/gpc-choice-icon.png"
},
"content_security_policy": {
"extension_pages": "script-src 'self'; object-src 'self'"
},
"declarative_net_request": {
"rule_resources": [
{
"id": "universal_GPC",
"enabled": false,
"path": "rulesets/global.json"
},
{
"id": "advertising",
"enabled": false,
"path": "rulesets/Advertising.json"
},
{
"id": "FG",
"enabled": false,
"path": "rulesets/FingerprintingGeneral.json"
},
{
"id": "FI",
"enabled": false,
"path": "rulesets/FingerprintingInvasive.json"
},
{
"id": "social",
"enabled": false,
"path": "rulesets/Social.json"
},
{
"id": "disconnect",
"enabled": false,
"path": "rulesets/Disconnect.json"
},
{
"id": "cryptomining",
"enabled": false,
"path": "rulesets/Cryptomining.json"
},
{
"id": "analytics",
"enabled": false,
"path": "rulesets/Analytics.json"
},
{
"id": "content",
"enabled": false,
"path": "rulesets/Content.json"
}
]
}
}
Loading

0 comments on commit 60ee503

Please sign in to comment.