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

Fix: Add unknown frames in extension. #361

Merged
merged 2 commits into from
Dec 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 26 additions & 4 deletions packages/common/src/utils/filterCookiesByFrame.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,39 @@ const filterCookiesByFrame = (
frameUrl: string | null
) => {
const frameFilteredCookies: { [key: string]: CookieTableData } = {};
if (!cookies || !frameUrl || !tabFrames || !tabFrames[frameUrl]) {
return Object.values(frameFilteredCookies);
}
let tabFramesIDMap: number[] = [];

Object.keys(tabFrames).forEach((url) => {
tabFramesIDMap = [
...new Set<number>([...tabFrames[url].frameIds, ...tabFramesIDMap]),
];
});

if (cookies && frameUrl && tabFrames && tabFrames[frameUrl]) {
if (tabFrames[frameUrl].frameIds?.length === 0) {
Object.entries(cookies).forEach(([key, cookie]) => {
tabFrames[frameUrl].frameIds?.forEach((frameId) => {
if (cookie.frameIdList?.includes(frameId)) {
frameFilteredCookies[key] = cookie;
let hasFrame = false;
cookie.frameIdList?.forEach((frameId) => {
if (tabFramesIDMap.includes(frameId as number)) {
hasFrame = true;
}
});
if (!hasFrame && cookie.frameIdList?.length > 0) {
frameFilteredCookies[key] = cookie;
}
});
}

Object.entries(cookies).forEach(([key, cookie]) => {
tabFrames[frameUrl].frameIds?.forEach((frameId) => {
if (cookie.frameIdList?.includes(frameId)) {
frameFilteredCookies[key] = cookie;
}
});
});

return Object.values(frameFilteredCookies);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,12 @@ const useFrameOverlay = (
? filteredCookies.filter((cookie) => cookie.isFirstParty)
: [];
const blockedCookies = filteredCookies
? filteredCookies.filter((cookie) => cookie.isBlocked)
? filteredCookies.filter(
(cookie) =>
cookie.isBlocked ||
(cookie.blockedReasons?.length !== undefined &&
cookie.blockedReasons?.length > 0)
)
: [];
const blockedReasons = filteredCookies
? filteredCookies
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ export const Provider = ({ children }: PropsWithChildren) => {
return tabFrame;
})
);
modifiedTabFrames['Unknown Frame(s)'] = { frameIds: [] };
setTabFrames(modifiedTabFrames);
},
[]
Expand Down
Loading