Skip to content

Instantly share code, notes, and snippets.

Avatar
😎
Awesome Motive-ing

Justin Sternberg jtsternberg

😎
Awesome Motive-ing
View GitHub Profile
@jtsternberg
jtsternberg / log-colors-group.js
Last active Feb 8, 2022
Log colors to console (and show colors) in a group
View log-colors-group.js
var colors = ['#EC0089','#0C1127','#00cfed'];
console.group('colors', {colors});
colors.forEach(c => console.log(`%c `,
`
display: block;
background: ${c};
width: 5px;
height: 5px;
padding: 5px 5px;
`
@jtsternberg
jtsternberg / video-overlay-click-play.html
Created Nov 18, 2021
Image placeholder overlay over video, click to play
View video-overlay-click-play.html
<html>
<head>
<style>
.placeholder {
position: relative;
display: inline-block;
}
.placeholder:not(.placeholder-hide):after {
background: rgba(255,255,255,.8) url("https://upload.wikimedia.org/wikipedia/commons/b/b8/YouTube_play_button_icon_%282013%E2%80%932017%29.svg") no-repeat center center;
@jtsternberg
jtsternberg / om-autopopulate-from-query-params.js
Created Sep 30, 2021
Autopopulate OM optin fields from query params
View om-autopopulate-from-query-params.js
document.addEventListener('om.Form.init', function(evt) {
console.log('om.Form.init')
var Form = evt.detail.Form;
var getQueryParam = function( param ) {
if (!getQueryParam.params) {
getQueryParam.params = {};
var query = window.location.search.substring(1);
var parts = query ? query.split('&').map(s => s.split('=')) : []
@jtsternberg
jtsternberg / biblegateway-links-shortcode-mods.php
Created Aug 5, 2021
BibleGateway Links Shortcode modifications
View biblegateway-links-shortcode-mods.php
@jtsternberg
jtsternberg / hubspot-optinmonster-custom-html-integration.html
Created Apr 28, 2021
hubspot optinmonster custom html integration
View hubspot-optinmonster-custom-html-integration.html
<!--[if lte IE 8]-->
<script charset="utf-8" type="text/javascript" src="//js.hsforms.net/forms/v2-legacy.js"></script>
<![endif]-->
<script>
(function() {
var addForm = function() {
window.hbspt.forms.create({
sfdcCampaignId: '70130000000ep2ZZZ',
portalId: '102310',
formId: '190ga042-56fc-4897-bed4-86ea519cb3e9',
@jtsternberg
jtsternberg / om-defer-embed-scripts.php
Created Mar 31, 2021
Add defer tag to OM plugin embed scripts
View om-defer-embed-scripts.php
<?php
add_filter( 'optin_monster_api_final_output', function( $campaigns ) {
if ( ! empty( $campaigns ) ) {
foreach ( $campaigns as $slug => $embed ) {
$campaigns[ $slug ] = str_replace( 's.async=true;', 's.async=true;s.defer=true;', $embed );
}
}
return $campaigns;
} );
@jtsternberg
jtsternberg / disable-monsterlinks.html
Created Mar 30, 2021
Disable all monsterlinks on a page (restores them to normal links)
View disable-monsterlinks.html
@jtsternberg
jtsternberg / prevent-all-om-campaigns.html
Created Mar 30, 2021
Prevent loading all OM campaigns
View prevent-all-om-campaigns.html
<script type="text/javascript">
document.addEventListener('om.Shutdown.init', function(evt) {
evt.detail.Shutdown.preventAll = true;
});
</script>
@jtsternberg
jtsternberg / om-hubspot-loading-form.html
Last active Aug 22, 2022
hubspot optinmonster form loading indicator
View om-hubspot-loading-form.html
<!--<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>-->
<!--[if lte IE 8]-->
<script charset="utf-8" type="text/javascript" src="//js.hsforms.net/forms/v2-legacy.js"></script>
<!--[endif]-->
<script>
document.addEventListener('om.Campaign.afterShow', function(event) {
jQuery.getScript("//js.hsforms.net/forms/v2.js", function() {
hbspt.forms.create({
portalId: "<HS_PORTAL_ID>",
formId: '<HS_FORM_ID>',
@jtsternberg
jtsternberg / om-validate-first-last-name.js
Created Jan 7, 2021
OptinMonster, validation to require first/last name
View om-validate-first-last-name.js
<script>
document.addEventListener('om.Campaign.afterShow', function(event) {
var campaign = event.detail.Campaign;
if ( '{{id}}' !== campaign.id ) {
return;
}
var validationError = 'A last name is required.';
var $nameField = document.getElementById( '{{ns}}-field-name' );