Created
December 1, 2023 13:59
-
-
Save senaev/394ea58ade689dc1f819a905c9393885 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<title>Topics demo</title> | |
<meta charset="utf-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<meta http-equiv="origin-trial" | |
content="AseYc2DtZGb//W5XVWgcoP6UF3L+dzpvN5W30ZfyW0aY9GPRVT9CgZXlFz8KHt25ohltfnkuImnAY3JETFGc+AgAAABfeyJvcmlnaW4iOiJodHRwczovL2Fkcy5wdWJtYXRpYy5jb206NDQzIiwiZmVhdHVyZSI6IlByaXZhY3lTYW5kYm94QWRzQVBJcyIsImV4cGlyeSI6MTY4ODA4MzE5OX0="> | |
<link href="favicon.ico" rel="shortcut icon"> | |
<script> | |
async function getTopics() { | |
try { | |
if ( | |
"browsingTopics" in document && | |
document.featurePolicy.allowsFeature("browsing-topics") | |
) { | |
const topics = await document.browsingTopics(); | |
console.log( | |
"Called iframe:", | |
window.location.hostname, | |
topics, | |
"\nNumber of topics: ", | |
topics.length | |
); | |
return Promise.resolve(topics); | |
} else { | |
console.log("document.browsingTopics() not supported"); | |
} | |
} catch (error) { | |
console.log("Error:", error); | |
} | |
} | |
(async function () { | |
const topics = await getTopics(); | |
const url = new URL(window.location.href); | |
const params = new URLSearchParams(url.search); | |
const message = JSON.stringify({ | |
segment: { | |
domain: window.location.hostname, | |
topics, | |
bidder: params.get("bidder"), | |
}, | |
date: Date.now(), | |
}); | |
window.parent.postMessage(message, "*"); | |
})(); | |
</script> | |
</head> | |
<body> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment