Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Firefox MV3 Migration #462

Merged
merged 17 commits into from
May 22, 2024
Prev Previous commit
Next Next commit
Fixed icon and well known data
  • Loading branch information
OliverWang13 committed Apr 8, 2024
commit ab05898cd45c7a37173a0e09d6b8496c2e75dd73
8 changes: 5 additions & 3 deletions src/background/protection/protection.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,6 @@ function dataToPopupHelper(){

// Info back to popup
function dataToPopup(wellknownData) {

let requestsData = dataToPopupHelper(); //get requests from the helper
chrome.tabs.query({active: true, currentWindow: true}, function(tabs){
let popupData = {
Expand Down Expand Up @@ -392,7 +391,9 @@ async function onMessageHandlerAsync(message, sender, sendResponse) {
dataToPopupRequests();
}
if (message.msg === "CONTENT_SCRIPT_WELLKNOWN") {
let url = new URL(sender.origin);
// sender.origin not working for Firefox MV3, instead added a new message argument, message.origin_url
//let url = new URL(sender.origin);
let url = new URL(message.origin_url);
let parsed = psl.parse(url.hostname);
let domain = parsed.domain;

Expand All @@ -402,7 +403,9 @@ async function onMessageHandlerAsync(message, sender, sendResponse) {

wellknown[tabID] = message.data;
let wellknownData = message.data;

initIAB(!sendSignal);

if (wellknown[tabID] === null && sendSignal == null) {
updatePopupIcon(tabID);
} else if (wellknown[tabID]["gpc"] === true && sendSignal == null) {
Expand Down Expand Up @@ -451,7 +454,6 @@ async function onMessageHandlerAsync(message, sender, sendResponse) {
initCookiesPerDomain(message.data);
}
if (message.msg === "DELETE_OPTOUT_COOKIES") {
console.log("Msg received. Info; ", message.data);
deleteCookiesPerDomain(message.data);
}

Expand Down
3 changes: 2 additions & 1 deletion src/content-scripts/contentScript.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ https://developer.chrome.com/extensions/content_scripts
/******************************************************************************/
/******************************************************************************/

console.log("contentScript.js ran");

// To be injected to call the USPAPI function in analysis mode
const uspapi = `
Expand Down Expand Up @@ -57,6 +56,7 @@ function injectScript(script) {

async function getWellknown(url) {
const response = await fetch(`${url.origin}/.well-known/gpc.json`);
new_url = url = JSON.parse(JSON.stringify(url));
let wellknownData;
try {
wellknownData = await response.json();
Expand All @@ -66,6 +66,7 @@ async function getWellknown(url) {
chrome.runtime.sendMessage({
msg: "CONTENT_SCRIPT_WELLKNOWN",
data: wellknownData,
origin_url: new_url
});
}

Expand Down