Skip to content
Open
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
41 changes: 41 additions & 0 deletions public/warning.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<!DOCTYPE html>
<html>

<head>
<title>Blocked Website</title>
<style>
body {
font-family: Arial, sans-serif;
text-align: center;
margin-top: 50px;
}

.warning {
margin: 40px;
color: red;
font-size: 24px;
}

.message {
margin: 40px;
font-size: 18px;
}

.link {
display: block;
margin-top: 20px;
font-size: 18px;
color: blue;
text-decoration: underline;
cursor: pointer;
}
</style>
</head>

<body>
<div class="warning">Warning: Blocked Website</div>
<div class="message">You are attempting to visit a website that is on the DefiLlama blacklist.</div>
<div class="message">To proceed at your own risk, turn off 'Block blacklisted websites' in the DefiLlama extension.</div>
</body>

</html>
1 change: 1 addition & 0 deletions src/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const manifest: ManifestType = {
web_accessible_resources: [
{
resources: [
"warning.html",
"src/pages/content/index.js",
"assets/js/*.js",
"assets/css/*.css",
Expand Down
11 changes: 11 additions & 0 deletions src/pages/background/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,15 @@ async function getCurrentTab() {

async function handlePhishingCheck() {
const phishingDetector = await getStorage("local", "settings:phishingDetector", true);
const blockBlacklisted = await getStorage("local", "settings:blockBlacklisted", true);
if (!phishingDetector) {
Browser.action.setIcon({ path: cute });
return;
}

let isPhishing = false;
let isTrusted = false;
let isBlacklisted = false;
let reason = "Unknown website";
const tab = await getCurrentTab();
try {
Expand Down Expand Up @@ -68,6 +70,10 @@ async function handlePhishingCheck() {
reason = "Unknown website";
}
}

if (blockBlacklisted && res.type === "blocked") {
isBlacklisted = true;
}
}
} catch (error) {
console.log("handlePhishingCheck error", error);
Expand All @@ -76,6 +82,11 @@ async function handlePhishingCheck() {
reason = "Invalid URL";
}

if (isBlacklisted) {
Browser.tabs.update(tab.id, { url: Browser.runtime.getURL('warning.html?url=' + encodeURIComponent(tab.url)) });
return;
}

if (isTrusted) {
Browser.action.setIcon({ path: upOnly });
Browser.action.setTitle({ title: reason });
Expand Down
15 changes: 14 additions & 1 deletion src/pages/popup/Popup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const Popup = () => {
const [priceInjector, setPriceInjector] = useBrowserStorage("local", "settings:priceInjector", true);
const [tagsInjector, setTagsInjector] = useBrowserStorage("local", "settings:tagsInjector", true);
const [phishingDetector, setPhishingDetector] = useBrowserStorage("local", "settings:phishingDetector", true);
const [blockBlacklisted, setBlockBlacklisted] = useBrowserStorage("local", "settings:blockBlacklisted", true);
const [phishingHandleDetector, setPhishingHandleDetector] = useBrowserStorage(
"local",
"settings:phishingHandleDetector",
Expand Down Expand Up @@ -42,13 +43,25 @@ const Popup = () => {
}
}}
/>
</HStack>
<HStack justify="space-between" w="full">
<Text fontSize="sm">Block blacklisted websites</Text>
<Switch
size="sm"
isChecked={blockBlacklisted}
onChange={(e) => {
setBlockBlacklisted(e.target.checked);
if (!e.target.checked) {
Browser.action.setIcon({ path: cuteStatic });
}
}}
/>
</HStack>
<HStack w="full">
<Text fontSize="l" fontWeight="bold">
Twitter
</Text>
</HStack>

<HStack justify="space-between" w="full" pl={7}>
<Text fontSize="sm">Mitigate phishing scams</Text>
<Switch
Expand Down