8000 Korea free trial restrict by overmyheadandbody · Pull Request #4282 · adobecom/milo · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Korea free trial restrict #4282

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

Merged
merged 21 commits into from
Jun 2, 2025
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
8 changes: 7 additions & 1 deletion libs/blocks/global-navigation/utilities/utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
getFederatedContentRoot,
getFederatedUrl,
getFedsPlaceholderConfig,
shouldBlockFreeTrialLinks,
} from '../../../utils/utils.js';
import { processTrackingLabels } from '../../../martech/attributes.js';
import { replaceKey, replaceText } from '../../../features/placeholders.js';
Expand Down Expand Up @@ -101,7 +102,7 @@ export const logPerformance = (
sampleRate: 0.01,
});
} catch (e) {
console.error(e);
// eslint-disable-next-line no-empty
}
};

Expand Down Expand Up @@ -246,6 +247,11 @@ export async function loadDecorateMenu() {
}

export function decorateCta({ elem, type = 'primaryCta', index } = {}) {
if (shouldBlockFreeTrialLinks({
button: elem,
localePrefix: getConfig()?.locale?.prefix,
parent: elem.parentElement,
})) return null;
const modifier = type === 'secondaryCta' ? 'secondary' : 'primary';

const clone = elem.cloneNode(true);
Expand Down
6 changes: 6 additions & 0 deletions libs/blocks/merch/merch.js
Original file line number Diff line number Diff line change
Expand Up @@ -844,6 +844,12 @@ export async function buildCta(el, params) {
cta.setAttribute('aria-label', ariaLabel);
});
}

// @see https://jira.corp.adobe.com/browse/MWPW-173470
cta.onceSettled().then(() => {
if (getConfig()?.locale?.prefix === '/kr' && cta.value[0]?.offerType === OFFER_TYPE_TRIAL) cta.remove();
});

return cta;
}

Expand Down
6 changes: 5 additions & 1 deletion libs/utils/decorate.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
createIntersectionObserver,
getFederatedContentRoot,
getFedsPlaceholderConfig,
shouldBlockFreeTrialLinks,
} from './utils.js';

const { miloLibs, codeRoot } = getConfig();
Expand All @@ -23,9 +24,12 @@ export function decorateButtons(el, size) {
const buttons = el.querySelectorAll('em a, strong a, p > a strong');
if (buttons.length === 0) return;
const buttonTypeMap = { STRONG: 'blue', EM: 'outline', A: 'blue' };
const localePrefix = getConfig()?.locale?.prefix;

buttons.forEach((button) => {
let target = button;
const parent = button.parentElement;
if (shouldBlockFreeTrialLinks({ button, localePrefix, parent })) return;
let target = button;
const buttonType = buttonTypeMap[parent.nodeName] || 'outline';
if (button.nodeName === 'STRONG') {
target = parent;
Expand Down
12 changes: 12 additions & 0 deletions libs/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,18 @@ export const getFedsPlaceholderConfig = ({ useCache = true } = {}) => {
return fedsPlaceholderConfig;
};

export const shouldBlockFreeTrialLinks = ({ button, localePrefix, parent }) => {
if (localePrefix !== '/kr' || (!button.dataset?.modalPath?.includes('/kr/cc-shared/fragments/trial-modals')
&& !['free-trial', 'free trial', '무료 체험판', '무료 체험하기', '{{try-for-free}}']
.some((pattern) => button.textContent?.toLowerCase()?.includes(pattern.toLowerCase())))) {
return false;
}

const elementToRemove = (parent?.tagName === 'STRONG' || parent?.tagName === 'EM') && parent?.children?.length === 1 ? parent : button;
elementToRemove.remove();
return true;
};

export function isInTextNode(node) {
return (node.parentElement.childNodes.length > 1 && node.parentElement.firstChild.tagName === 'A') || node.parentElement.firstChild.nodeType === Node.TEXT_NODE;
}
Expand Down
Loading
0