Skip to content

Commit

Permalink
Update blockedDomainCheck to match extension
Browse files Browse the repository at this point in the history
  • Loading branch information
NicholasEllul committed Mar 6, 2024
1 parent fc1c2bc commit 0ee0612
Showing 1 changed file with 25 additions and 9 deletions.
34 changes: 25 additions & 9 deletions scripts/inpage-bridge/content-script/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,10 @@ function documentElementCheck() {
* @returns {boolean} {@code true} if the current domain is blocked
*/
function blockedDomainCheck() {
// If making any changes, please also update the same list found in the MetaMask-Mobile & SDK repositories
const blockedDomains = [
'execution.consensys.io',
'execution.metamask.io',
'uscourts.gov',
'dropbox.com',
'webbyawards.com',
Expand All @@ -115,19 +118,32 @@ function blockedDomainCheck() {
'ani.gamer.com.tw',
'blueskybooking.com',
'sharefile.com',
]
'battle.net',
];

const blockedHrefs = [
// Matching will happen based on the hostname, and path
const blockedUrlPaths = [
'cdn.shopify.com/s/javascripts/tricorder/xtld-read-only-frame.html',
]
];

const hostname = window.location.hostname;
const path = window.location.pathname;

const blockedDomainFound = blockedDomains.some(blockedDomain => blockedDomain === hostname || hostname.endsWith(`.${blockedDomain}`));
const blockedHrefFound = blockedHrefs.some(blockedHref => (hostname + path).includes(blockedHref));
const { hostname: currentHostname, pathname: currentPathname } =
window.location;

return blockedDomainFound || blockedHrefFound;
const trimTrailingSlash = (str) =>
str.endsWith('/') ? str.slice(0, -1) : str;

return (
blockedDomains.some(
(blockedDomain) =>
blockedDomain === currentHostname ||
currentHostname.endsWith(`.${blockedDomain}`),
) ||
blockedUrlPaths.some(
(blockedUrlPath) =>
trimTrailingSlash(blockedUrlPath) ===
trimTrailingSlash(currentHostname + currentPathname),
)
);
}

/**
Expand Down

0 comments on commit 0ee0612

Please sign in to comment.