MCPcopy Create free account
hub / github.com/ampproject/amphtml / handleCookieOptOutPostMessage

Function handleCookieOptOutPostMessage

ads/google/a4a/cookie-utils.js:64–85  ·  view source on GitHub ↗
(win, event)

Source from the content-addressed store, hash-verified

62 * @param {!Event} event
63 */
64export function handleCookieOptOutPostMessage(win, event) {
65 try {
66 const message = JSON.parse(event.data);
67 if (message['googMsgType'] === 'gpi-uoo') {
68 const userOptOut = !!message['userOptOut'];
69 const clearAdsData = !!message['clearAdsData'];
70 const domain = getProxySafeDomain(win, win.location.hostname);
71 setCookie(
72 win,
73 '__gpi_opt_out',
74 userOptOut ? '1' : '0',
75 // Last valid date for 32-bit browsers; 2038-01-19
76 2147483646 * 1000,
77 {domain}
78 );
79 if (userOptOut || clearAdsData) {
80 setCookie(win, '__gads', 'delete', Date.now() - 1000, {domain});
81 setCookie(win, '__gpi', 'delete', Date.now() - 1000, {domain});
82 }
83 }
84 } catch {}
85}

Callers 3

onCreativeRenderMethod · 0.90
onCreativeRenderMethod · 0.90

Calls 4

setCookieFunction · 0.90
getProxySafeDomainFunction · 0.85
nowMethod · 0.80
parseMethod · 0.45

Tested by

no test coverage detected