From 7bb0c42a95edf46aa3ec2a7f750c17b297f95e1d Mon Sep 17 00:00:00 2001 From: jvalente Date: Sat, 1 Jun 2024 02:24:36 +0100 Subject: [PATCH 1/3] add warning page --- public/warning.html | 41 +++++++++++++++++++++++++++++++++++ src/manifest.ts | 1 + src/pages/background/index.ts | 11 ++++++++++ src/pages/popup/Popup.tsx | 15 ++++++++++++- 4 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 public/warning.html diff --git a/public/warning.html b/public/warning.html new file mode 100644 index 0000000..730f8fb --- /dev/null +++ b/public/warning.html @@ -0,0 +1,41 @@ + + + + + Blocked Website + + + + +
Warning: Blocked Website
+
You are attempting to visit a website that is on the DefiLlama blacklist.
+
Turn 'Block blacklisted websites' off and refresh the page to proceed.
+ + + \ No newline at end of file diff --git a/src/manifest.ts b/src/manifest.ts index 8ca709f..e79eb91 100755 --- a/src/manifest.ts +++ b/src/manifest.ts @@ -27,6 +27,7 @@ const manifest: ManifestType = { web_accessible_resources: [ { resources: [ + "warning.html", "src/pages/content/index.js", "assets/js/*.js", "assets/css/*.css", diff --git a/src/pages/background/index.ts b/src/pages/background/index.ts index a93890d..78b33fa 100644 --- a/src/pages/background/index.ts +++ b/src/pages/background/index.ts @@ -28,6 +28,7 @@ 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; @@ -35,6 +36,7 @@ async function handlePhishingCheck() { let isPhishing = false; let isTrusted = false; + let isBlacklisted = false; let reason = "Unknown website"; const tab = await getCurrentTab(); try { @@ -68,6 +70,10 @@ async function handlePhishingCheck() { reason = "Unknown website"; } } + + if (blockBlacklisted && res.type === "blocked") { + isBlacklisted = true; + } } } catch (error) { console.log("handlePhishingCheck error", error); @@ -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 }); diff --git a/src/pages/popup/Popup.tsx b/src/pages/popup/Popup.tsx index e0ac9d6..ee9b3ed 100644 --- a/src/pages/popup/Popup.tsx +++ b/src/pages/popup/Popup.tsx @@ -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", @@ -42,13 +43,25 @@ const Popup = () => { } }} /> + + + Block blacklisted websites + { + setBlockBlacklisted(e.target.checked); + if (!e.target.checked) { + Browser.action.setIcon({ path: cuteStatic }); + } + }} + /> Twitter - Mitigate phishing scams Date: Sat, 1 Jun 2024 02:29:20 +0100 Subject: [PATCH 2/3] update warning message --- public/warning.html | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/public/warning.html b/public/warning.html index 730f8fb..72a8de0 100644 --- a/public/warning.html +++ b/public/warning.html @@ -35,7 +35,9 @@
Warning: Blocked Website
You are attempting to visit a website that is on the DefiLlama blacklist.
-
Turn 'Block blacklisted websites' off and refresh the page to proceed.
+
To proceed at your own risk, turn off 'Block blacklisted websites' in the DefiLlama extension. +
- \ No newline at end of file + +and try agai to proceed. \ No newline at end of file From fc1efdf54b56ac4a1d605790392f8074b1b677d4 Mon Sep 17 00:00:00 2001 From: jvalente Date: Sat, 1 Jun 2024 02:30:14 +0100 Subject: [PATCH 3/3] change watning message 2 --- public/warning.html | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/public/warning.html b/public/warning.html index 72a8de0..48e1f39 100644 --- a/public/warning.html +++ b/public/warning.html @@ -35,9 +35,7 @@
Warning: Blocked Website
You are attempting to visit a website that is on the DefiLlama blacklist.
-
To proceed at your own risk, turn off 'Block blacklisted websites' in the DefiLlama extension. -
+
To proceed at your own risk, turn off 'Block blacklisted websites' in the DefiLlama extension.
- -and try agai to proceed. \ No newline at end of file + \ No newline at end of file