Skip to content

Commit

Permalink
490 enable adsense (#493)
Browse files Browse the repository at this point in the history
* Add Google Ads integration and ad blocking recovery scripts

* Update @types/react and @types/react-dom to compatible versions
  • Loading branch information
dharmesh-hemaram authored Dec 15, 2024
1 parent 2096608 commit e1c3597
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 11 deletions.
2 changes: 2 additions & 0 deletions apps/acf-options-page/src/app/configs/configs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { createRef, useEffect } from 'react';
import { Alert, Col, Container, Row } from 'react-bootstrap';
import { useTranslation } from 'react-i18next';
import { download } from '../../_helpers';
import { Ads } from '../../components';
import { useAppDispatch } from '../../hooks';
import { ConfigSettingsModal, RemoveConfigsModal, ReorderConfigsModal } from '../../modal';
import { BatchModal } from '../../modal/config-batch.modal';
Expand Down Expand Up @@ -79,6 +80,7 @@ function Configs(props) {
)}
<Config />
<Action />
<Ads />
<Footer />
<ConfigSettingsModal />
<BatchModal />
Expand Down
41 changes: 41 additions & 0 deletions apps/acf-options-page/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
<meta property="og:image:height" content="640" />
<link rel="image_src" href="https://getautoclicker.com/docs/4.x/assets/brand/bootstrap-social.png" />
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous" />
<!-- Google Ads -->
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-9512495707028343" crossorigin="anonymous"></script>
<!-- End Google Ads-->
</head>
<body class="bg-body-secondary">
<noscript>You need to enable JavaScript to run this app.</noscript>
Expand All @@ -59,5 +62,43 @@
})(window, document, 'script', 'dataLayer', 'GTM-KWCS372');
</script>
<!-- End Google Tag Manager -->
<!-- Ad blocking recovery -->
<script async src="https://fundingchoicesmessages.google.com/i/pub-9512495707028343?ers=1" nonce="zG-XMu9e9eZgUA3cG1msWw"></script>
<script nonce="zG-XMu9e9eZgUA3cG1msWw">
(function () {
function signalGooglefcPresent() {
if (!window.frames['googlefcPresent']) {
if (document.body) {
const iframe = document.createElement('iframe');
iframe.style = 'width: 0; height: 0; border: none; z-index: -1000; left: -1000px; top: -1000px;';
iframe.style.display = 'none';
iframe.name = 'googlefcPresent';
document.body.appendChild(iframe);
} else {
setTimeout(signalGooglefcPresent, 0);
}
}
}
signalGooglefcPresent();
})();
</script>
<!-- End of Ad blocking recovery -->
<!-- Delete the Funding Choices cookie if consent is more than 12 months old -->
<script>
try {
const nm = 'FCCDCF'; // Match name of Funding Choices cookie
const dm = 'getautoclicker.com'; // Match domain of Funding Choices cookie
const pa = '/'; // Match path of Funding Choices cookie
let tc = ('; ' + document.cookie).split('; ' + nm + '=');
if (tc.length === 2) {
tc = decodeURIComponent(tc.pop().split(';').shift());
tc = JSON.parse(tc)[3][0].substring(1, 9);
tc = Uint8Array.from(window.atob(tc), (v) => v.charCodeAt(0));
let dt = tc[0] * 2 ** 28 + tc[1] * 2 ** 20 + tc[2] * 2 ** 12 + tc[3] * 2 ** 4 + (tc[4] >> 4);
if (Date.now() / 1000 - dt / 10 > 86400 * 365) document.cookie = nm + '=;path=' + pa + ';domain=' + dm + ';expires=' + new Date(0).toUTCString();
}
} catch (e) {}
</script>
<!-- End of Deleting cooking -->
</body>
</html>
25 changes: 16 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@
"@types/express": "5.0.0",
"@types/jest": "29.5.14",
"@types/node": "22.10.2",
"@types/react": "19.0.1",
"@types/react-dom": "19.0.2",
"@types/react": "^18.3.16",
"@types/react-dom": "^18.3.5",
"@typescript-eslint/eslint-plugin": "8.18.0",
"@typescript-eslint/parser": "8.18.0",
"babel-jest": "29.7.0",
Expand Down

0 comments on commit e1c3597

Please sign in to comment.