Skip to content

Instantly share code, notes, and snippets.

@robisatthefunction
Created August 1, 2025 19:48
Show Gist options
  • Select an option

  • Save robisatthefunction/2e9916c528805fafbe37af9371c714e0 to your computer and use it in GitHub Desktop.

Select an option

Save robisatthefunction/2e9916c528805fafbe37af9371c714e0 to your computer and use it in GitHub Desktop.
(function() {
'use strict';
console.log('πŸš€ Zaius injection script starting...');
console.log('πŸ“ Current URL:', window.location.href);
console.log('πŸ“Š Document ready state:', document.readyState);
// Function to inject the Zaius script
function injectZaiusScript() {
console.log('πŸ”§ Starting Zaius script injection process...');
// Check if Zaius is already loaded to avoid duplicates
if (window.zaius) {
console.warn('⚠️ Zaius script already exists on this page - skipping injection');
console.log('πŸ” Existing zaius object:', window.zaius);
return;
}
console.log('βœ… No existing Zaius found - proceeding with injection');
// Create the script element
console.log('πŸ“ Creating script element...');
var script = document.createElement('script');
script.type = 'text/javascript';
script.innerHTML = `
var zaius = window['zaius']||(window['zaius']=[]);zaius.methods=["initialize","onload","customer","entity","event","subscribe","unsubscribe","consent","identify","anonymize","dispatch"];zaius.factory=function(e){return function(){var t=Array.prototype.slice.call(arguments);t.unshift(e);zaius.push(t);return zaius}};(function(){for(var i=0;i<zaius.methods.length;i++){var method=zaius.methods[i];zaius[method]=zaius.factory(method)}var e=document.createElement("script");e.type="text/javascript";e.async=true;e.src=("https:"===document.location.protocol?"https://":"http://")+"d1igp3oop3iho5.cloudfront.net/v2/W4WzcEs-ABgXorzY7h1LCQ/zaius-min.js";var t=document.getElementsByTagName("script")[0];t.parentNode.insertBefore(e,t)})();
// Edits to this script should only be made below this line.
zaius.event('pageview');
`;
console.log('πŸ“„ Script content prepared, length:', script.innerHTML.length, 'characters');
// Find injection target
var target = document.head || document.getElementsByTagName('head')[0] || document.body;
console.log('🎯 Injection target found:', target ? target.tagName : 'NONE');
if (target) {
console.log('πŸ’‰ Injecting script into', target.tagName, 'element...');
target.appendChild(script);
console.log('πŸŽ‰ Zaius script successfully injected into PingIdentity page!');
// Verify injection
setTimeout(function() {
console.log('πŸ” Verifying injection - zaius object exists:', !!window.zaius);
if (window.zaius) {
console.log('βœ… Zaius object confirmed:', window.zaius);
}
}, 100);
} else {
console.error('❌ Could not find head or body element to inject script');
console.log('πŸ—οΈ Document structure:', {
head: !!document.head,
body: !!document.body,
documentElement: !!document.documentElement
});
}
}
// Run injection immediately
console.log('⚑ Running injection immediately...');
injectZaiusScript();
console.log('🏁 Injection script completed');
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment