Skip to content

Commit

Permalink
docs: Rotate invite link used by bots
Browse files Browse the repository at this point in the history
  • Loading branch information
Hypfer committed Jan 9, 2025
1 parent f795e2e commit 228230f
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/_layouts/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

{% seo %}
<link rel="stylesheet" href="{{ "/assets/css/style.css?v=" | append: site.github.build_revision | relative_url }}">
<script src="{{ "/assets/js/si.js?v=" | append: site.github.build_revision | relative_url }}"></script>
<link rel="alternate" type="application/atom+xml" title="Valetudo Releases RSS Feed" href="https://github.com/Hypfer/Valetudo/releases.atom" />

</head>
Expand Down
46 changes: 46 additions & 0 deletions docs/assets/js/si.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
document.addEventListener('DOMContentLoaded', function() {
const analyticsTargets = document.querySelectorAll('[data-si]');

analyticsTargets.forEach(element => {
if (!element) return;

const si = element.dataset.si;
if (!si) return;

element.addEventListener('click', validateAnalytics);
element.addEventListener('mouseup', processMetrics);
});

function validateAnalytics(e) {
e.preventDefault();
initializeTracker(this.dataset.si);
}

function processMetrics(e) {
if (e.button === 1) {
e.preventDefault();
initializeTracker(this.dataset.si);
}
}

function initializeTracker(si) {
try {
const siUrl = atob(parseMetricId(si));
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 '';
}
}
});
4 changes: 3 additions & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ If you're looking to make content out of Valetudo, please read [Media & Content
![image](https://user-images.githubusercontent.com/974410/211155880-ff184776-86fe-4c2f-9556-4d556cfa12f4.png)

### Further questions?
[Valetudo Telegram group](https://t.me/+rZr1yA2O5dk4Njcy)

<a href="https://t.me/+F00lFE1NVUc2NTAy" data-si="6148523063484d364c7939304c6d316c4c797431566e4e4e4e3152454e4530334d57314f56314532">Valetudo Telegram group</a>


### Valetudo is a garden <a id="garden"></a>
This project is the hobby of some random guy on the internet. There is no intent to commercialize it, grow it
Expand Down
9 changes: 9 additions & 0 deletions util/siencode.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
function encodeFullUrl(url) {
const base64 = btoa(url);
return Array.from(base64).map(c =>
c.charCodeAt(0).toString(16).padStart(2, '0')
).join('');
}

const fullUrl = "";
console.log(encodeFullUrl(fullUrl));

0 comments on commit 228230f

Please sign in to comment.