add plausible script injector
This commit is contained in:
parent
9951904e6d
commit
c02e7fb4b6
27
script.js
27
script.js
@ -225,3 +225,30 @@ function checkStatus() {
|
||||
|
||||
// Update status every second
|
||||
setInterval(checkStatus, 1000);
|
||||
|
||||
function injectPlausibleScript() {
|
||||
const plausibleDomain = "beachpartyballoons.com";
|
||||
const scriptUrl = "https://metrics.beachpartyballoons.com/js/script.hash.outbound-links.js";
|
||||
|
||||
// Create the main script element
|
||||
const script = document.createElement('script');
|
||||
script.setAttribute('defer', '');
|
||||
script.setAttribute('data-domain', plausibleDomain);
|
||||
script.setAttribute('src', scriptUrl);
|
||||
|
||||
// Create the global plausible function snippet
|
||||
const functionScript = document.createElement('script');
|
||||
const functionContent = `
|
||||
window.plausible = window.plausible || function() { (window.plausible.q = window.plausible.q || []).push(arguments) };
|
||||
`;
|
||||
functionScript.textContent = functionContent;
|
||||
|
||||
// Append both scripts to the document's <head>
|
||||
document.head.appendChild(script);
|
||||
document.head.appendChild(functionScript);
|
||||
|
||||
console.log('Plausible script and function have been injected into the head.');
|
||||
}
|
||||
|
||||
// Run the function when the window loads.
|
||||
window.onload = injectPlausibleScript;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user