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

addressed #552 #554

Merged
merged 6 commits into from
Jan 5, 2024
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
22 changes: 22 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"@popperjs/core": "^2.11.8",
"@tensorflow/tfjs": "^3.20.0",
"@tensorflow/tfjs-node": "^4.2.0",
"@types/psl": "^1.1.3",
"ansi-html": "^0.0.9",
"ansi-regex": "^6.0.1",
"async": "^3.2.4",
Expand All @@ -46,6 +47,7 @@
"markdown-it": "^13.0.1",
"marked": "^4.0.18",
"node-forge": "^1.3.1",
"psl": "^1.9.0",
"queue": "^6.0.2",
"react": "^17.0.1",
"react-dom": "^17.0.1",
Expand Down
18 changes: 2 additions & 16 deletions src/background/analysis/utility/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ privacy-tech-lab, https://privacytechlab.org/
*/

import { Evidence } from "../classModels.js";
import psl from "psl";

/**
* Utility function to create hash for watchlist key based on keyword and type
Expand Down Expand Up @@ -58,22 +59,7 @@ export function extractHostname(url) {
*/
export function getHostname(url) {
if (typeof url == "undefined") return "";
var domain = extractHostname(url),
splitArr = domain.split("."),
arrLen = splitArr.length;

//extracting the root domain here
//if there is a subdomain
if (arrLen > 2) {
// domain = second to last and last domain. could be (xyz.me.uk) or (xyz.uk)
domain = splitArr[arrLen - 2] + "." + splitArr[arrLen - 1];
//check to see if it's using a Country Code Top Level Domain (ccTLD) (i.e. ".me.uk")
if (splitArr[arrLen - 2].length == 2 && splitArr[arrLen - 1].length == 2) {
//this is using a ccTLD. set domain to include the actual host name
domain = splitArr[arrLen - 3] + "." + domain;
}
}
return domain;
return psl.parse(extractHostname(url)).domain ?? "";
}

/**
Expand Down
10 changes: 6 additions & 4 deletions src/popup/views/website-view/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ const WebsiteView = () => {
const [empty, setEmpty] = useState(true);
const [isOurHomePage, setIsOurHomePage] = useState(false);
const [extensionEnabled, setExtensionEnabled] = useState(false);
const [invalidSite, setInvalidSite] = useState(false);

/**
* Navigate to route in options page based on urlHash
Expand Down Expand Up @@ -110,7 +111,8 @@ const WebsiteView = () => {
const host = getHostname(request.data);

//@ts-ignore
setIsOurHomePage(browser.runtime.getURL("").includes(host));
setIsOurHomePage(request.data.includes(browser.runtime.getURL("")));
setInvalidSite(host == "");

getWebsiteLastVisitedEvidence(host).then((result) => {
setLabels(result);
Expand Down Expand Up @@ -220,7 +222,7 @@ const WebsiteView = () => {
<SBody>
{extensionEnabled && (
<SHeader>
{isOurHomePage ? (
{(isOurHomePage || invalidSite) ? (
<PrivacyPioneerLogo />
) : (
<WebsiteLogo
Expand All @@ -230,7 +232,7 @@ const WebsiteView = () => {
/>
)}
<STitle>{isOurHomePage ? "Privacy Pioneer" : website}</STitle>
<SSubtitle>{!isOurHomePage && getCount()}</SSubtitle>
<SSubtitle>{!(isOurHomePage || invalidSite) && getCount()}</SSubtitle>
</SHeader>
)}
{empty ? (
Expand All @@ -239,7 +241,7 @@ const WebsiteView = () => {
{extensionEnabled
? isOurHomePage
? "This is our homepage! You won't find anything here. Keep browsing and check back later."
: "Nothing yet...Keep browsing and check back later!"
: invalidSite ? "Privacy Pioneer is unable to analyze this page." : "Nothing yet...Keep browsing and check back later!"
: "The extension is currently disabled! Press the power button to re-enable analysis!"}
</SEmptyText>
<img src={floating} />
Expand Down