Skip to content

Commit

Permalink
Merge pull request #48 from chris-mosley/fixFilterBypass
Browse files Browse the repository at this point in the history
Fix filter bypass
  • Loading branch information
chris-mosley authored Jan 16, 2024
2 parents 109a337 + cd103de commit d1121a8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 33 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "AmazonBrandFilter",
"description": "Filters out all unknown brands from Amazon search results.",
"version": "0.4.3",
"version": "0.5.0",
"keywords": [],
"author": "",
"license": "MIT",
Expand Down
38 changes: 6 additions & 32 deletions src/content/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,6 @@ import {
import { getItemDivs, unHideDivs } from "utils/helpers";
import { PopupMessage, StorageSettings } from "utils/types";

const checkBrandFilter = (): boolean => {
const boxesdiv = document.getElementById("brandsRefinements")?.children;
if (!boxesdiv) {
return false;
}

let boxes: HTMLCollectionOf<HTMLInputElement> | undefined;
for (const div of boxesdiv) {
boxes = div.getElementsByTagName("input");
if (boxes.length > 0) {
break;
}
}

if (!boxes) {
return false;
}

for (const box of boxes) {
if (box.checked) {
return true;
}
}
return false;
};

const descriptionSearch = async (settings: StorageSettings, div: HTMLDivElement) => {
const { syncSettings } = await getSettings();

Expand Down Expand Up @@ -164,9 +138,7 @@ const filterBrands = async (settings: StorageSettings) => {
console.log("AmazonBrandFilter: Brands found");

if (settings.refinerBypass) {
if (checkBrandFilter()) {
return;
}
return;
}

const divs = getItemDivs();
Expand Down Expand Up @@ -271,9 +243,11 @@ const listenForMessages = () => {
break;
case "refinerBypass":
if (message.isChecked) {
if (checkBrandFilter()) {
return;
}
resetBrands();
// previously hidden elements should be shown
unHideDivs();
} else {
filterBrands(settings);
}
break;
case "useDebugMode":
Expand Down

0 comments on commit d1121a8

Please sign in to comment.