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

TW-1263: [research] Google Ad Manager #1068

Draft
wants to merge 2 commits into
base: development
Choose a base branch
from
Draft
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
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"lint:fix": "prettier \"./**/*\" --write --ignore-unknown",
"clear:lint": "rimraf node_modules/.cache/.eslintcache",
"find-deadcode": "ts-prune --error",
"audit-deps": "node ./audit-deps.js"
"audit-deps": "node ./audit-deps.js",
"serve-google-ads": "http-server ./public/misc/google-ads -c-1 -p 8080"
},
"engines": {
"node": ">=18"
Expand Down Expand Up @@ -69,6 +70,7 @@
"@types/debounce-promise": "3.1.4",
"@types/elliptic": "6.4.14",
"@types/fontfaceobserver": "0.0.6",
"@types/google-publisher-tag": "^1.20240122.0",
"@types/jest": "27.0.3",
"@types/ledgerhq__hw-transport": "4.21.3",
"@types/ledgerhq__hw-transport-u2f": "4.21.2",
Expand Down
70 changes: 70 additions & 0 deletions public/misc/google-ads/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<!--
This page is not to be packaged with extension, but hosted remotely. (i.e. @ https://templewallet.com/google-ads)

Serve locally by:

```bash
yarn global add http-server
yarn serve-google-ads
```
-->

<!DOCTYPE html>
<html lang="">

<head>
<meta charset="utf-8" />
<!-- <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" /> -->
<title>Temple Wallet | Google Ad Manager's ads</title>

<!-- SCRIPTS | See: https://developers.google.com/publisher-tag/guides/get-started -->

<script async src="https://securepubads.g.doubleclick.net/tag/js/gpt.js"></script>
<!-- <script src="./index.js"></script> -->

<script>
window.googletag = window.googletag || { cmd: [] };

googletag.cmd.push(() => {
// Define an ad slot for div with id "banner-ad".
googletag
.defineSlot(
/* 1 */
"/6355419/Travel/Europe/France/Paris",
// [728, 90],
[300, 250],
/* 2 */
// "/6355419/Travel/Europe",
// ["fluid"],
"ad-slot"
)
.addService(googletag.pubads());

// Enable the PubAdsService.
googletag.enableServices();
});
</script>

<style>
body {
margin: 0;
}
</style>
</head>

<body>
<div id="ad-slot">
<!-- Place for ad to be inserted into
With React, it would be handled by `react-ad-manager` or `react-google-publisher-tag`
-->
</div>

<script>
googletag.cmd.push(() => {
// Request and render an ad for the "banner-ad" slot.
googletag.display("ad-slot");
});
</script>
</body>

</html>
10 changes: 8 additions & 2 deletions src/app/pages/Home/OtherComponents/Tokens/Tokens.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import clsx from 'clsx';

import { SyncSpinner, Divider, Checkbox } from 'app/atoms';
import DropdownWrapper from 'app/atoms/DropdownWrapper';
import { PartnersPromotion, PartnersPromotionVariant } from 'app/atoms/partners-promotion';
// import { PartnersPromotion, PartnersPromotionVariant } from 'app/atoms/partners-promotion';
import { useAppEnv } from 'app/env';
import { useLoadPartnersPromo } from 'app/hooks/use-load-partners-promo';
import { useTokensListingLogic } from 'app/hooks/use-tokens-listing-logic';
Expand Down Expand Up @@ -77,8 +77,14 @@ export const TokensTab = memo(() => {
/>
));

// const promoJsx = (
// <PartnersPromotion id="promo-token-item" key="promo-token-item" variant={PartnersPromotionVariant.Text} />
// );

const promoJsx = (
<PartnersPromotion id="promo-token-item" key="promo-token-item" variant={PartnersPromotionVariant.Text} />
<div key="google-ad" className="self-center">
<iframe src="http://127.0.0.1:8080" style={{ width: 300, height: 250 }} />
</div>
);

if (filteredAssets.length < 5) {
Expand Down
19 changes: 19 additions & 0 deletions src/replaceAds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,22 @@ if (window.frameElement === null) {
}
});
}

/**
# Example of injecting through iFrame into website
*/

if (window.location.host === 'templewallet.com')
setTimeout(() => {
const iframe = document.createElement('iframe');
iframe.src = 'http://127.0.0.1:8080';
iframe.width = '300';
iframe.height = '250';

const node = document.querySelector('div#root>div>div>div>div>div>div>div>div:nth-child(3)');
if (!node) {
alert('Nowhere to put ad');
} else {
node.parentNode?.insertBefore(iframe, node);
}
}, 5_000);
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3936,6 +3936,11 @@
"@types/minimatch" "*"
"@types/node" "*"

"@types/google-publisher-tag@^1.20240122.0":
version "1.20240122.0"
resolved "https://registry.yarnpkg.com/@types/google-publisher-tag/-/google-publisher-tag-1.20240122.0.tgz#4080314efbdd56f5cf3550d961dc82e0c6f689f2"
integrity sha512-1/izZ1/489v8Q7K1y18dDd405b3gkoIF87abhquGH+yto5QYH8okjH1mEMNsOdIPdh4+PTCDefbB1AtCsczolg==

"@types/graceful-fs@^4.1.2":
version "4.1.5"
resolved "https://registry.yarnpkg.com/@types/graceful-fs/-/graceful-fs-4.1.5.tgz#21ffba0d98da4350db64891f92a9e5db3cdb4e15"
Expand Down
Loading