Skip to content

Commit

Permalink
Refactored our head code to support passing a cause into Raptive
Browse files Browse the repository at this point in the history
  • Loading branch information
Spicer Matthews committed Mar 12, 2024
1 parent fa2f67c commit aad9e40
Show file tree
Hide file tree
Showing 3 changed files with 323 additions and 291 deletions.
17 changes: 0 additions & 17 deletions src/components/TabCMPHeadElements.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,6 @@ import React from 'react'
// https://github.com/gladly-team/tab-cmp/blob/master/src/tagModified.html
const TabCMPHeadElements = () => (
<>
<script
dangerouslySetInnerHTML={{
__html: `(function(w, d) {
w.adthrive = w.adthrive || {};
w.adthrive.cmd = w.adthrive.cmd || [];
w.adthrive.plugin = 'adthrive-ads-manual';
w.adthrive.host = 'ads.adthrive.com';
var s = d.createElement('script');
s.async = true;
s.referrerpolicy='no-referrer-when-downgrade';
s.src = 'https://' + w.adthrive.host + '/sites/655cd66352dfc71af0778a48/ads.min.js?referrer=' + w.encodeURIComponent(w.location.href) + '&cb=' + (Math.floor(Math.random() * 100) + 1);
var n = d.getElementsByTagName('script')[0];
n.parentNode.insertBefore(s, n);
})(window, document);`,
}}
/>

<script
type="text/javascript"
data-cfasync="false"
Expand Down
40 changes: 40 additions & 0 deletions src/components/head/Raptive.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/* eslint react/no-danger: 0 */
import React from 'react'
import PropTypes from 'prop-types'

export default function Raptive({ causeId }) {
return (
<>
<script
dangerouslySetInnerHTML={{
__html: `(function(w, d) {
w.adthrive = w.adthrive || {};
w.adthrive.cmd = w.adthrive.cmd || [];
w.adthrive.plugin = 'adthrive-ads-manual';
w.adthrive.host = 'ads.adthrive.com';
var s = d.createElement('script');
s.async = true;
s.referrerpolicy='no-referrer-when-downgrade';
s.src = 'https://' + w.adthrive.host + '/sites/655cd66352dfc71af0778a48/ads.min.js?referrer=' + w.encodeURIComponent(w.location.href) + '&cb=' + (Math.floor(Math.random() * 100) + 1);
var n = d.getElementsByTagName('script')[0];
n.parentNode.insertBefore(s, n);
})(window, document);`,
}}
/>

<script
dangerouslySetInnerHTML={{
__html: `(function() {
window.adthrive.cmd.push(function() {
window.adthrive.siteAds.targeting.push( {key: 'at_custom_1', value: '${causeId}'} );
});
})();`,
}}
/>
</>
)
}

Raptive.propTypes = {
causeId: PropTypes.string.isRequired,
}
Loading

0 comments on commit aad9e40

Please sign in to comment.