Skip to content

Commit f3bcb54

Browse files
committed
- add logos to multiple tools/games
- make logo removable - update ensure_sidebar_inclusion.py to make it add the logo instead of the sidebar
1 parent 064ba41 commit f3bcb54

18 files changed

+110
-50
lines changed

games/blackjack.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1256,5 +1256,6 @@ <h2>Blackjack Rules</h2>
12561256
updateStats();
12571257
toggleGameButtons(false);
12581258
clearBetBtn.disabled = true;</script>
1259+
<script src="../logo.js" data-position="bottom-left"></script>
12591260
</body>
12601261
</html>

games/death_by_ai.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,5 +218,6 @@
218218
xp = parseInt(localStorage.getItem('deathByAIXP') || '0');
219219
document.body.className = `bg-gradient-to-r text-white ${backgrounds[Math.min(Math.floor(xp / 500), backgrounds.length - 1)]}`;
220220
startGame();</script>
221+
<script src="../logo.js"></script>
221222
</body>
222223
</html>

games/living_rps.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,5 +384,6 @@ <h2 class="text-lg font-bold mb-2">Game Options</h2>
384384
updateStats();
385385
updatePlaygroundSize();
386386
</script>
387+
<script src="../logo.js"></script>
387388
</body>
388389
</html>

games/rock_paper_scissors_mp.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,5 +230,6 @@ <h1 class="text-4xl font-bold mb-8 text-center">Rock Paper Scissors</h1>
230230
set(scoresRef, {player1: player1Score, player2: player2Score});
231231
}
232232
</script>
233+
<script src="../logo.js"></script>
233234
</body>
234235
</html>

games/snake.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1544,5 +1544,6 @@ <h2>Game Over</h2>
15441544
updateGridSize();
15451545
startHighScoreElement.textContent = highScore;
15461546
</script>
1547+
<script src="../logo.js"></script>
15471548
</body>
15481549
</html>

logo.js

Lines changed: 81 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,87 @@
1-
window.addEventListener('load', function() {
2-
const currentScript = Array.from(document.scripts).find(s => s.src.includes('logo.js'));
3-
const position = currentScript ? currentScript.getAttribute('data-position') || 'bottom-right' : 'bottom-right';
4-
5-
const logo = document.createElement('a');
6-
logo.href = 'https://gptgames.dev';
7-
logo.target = '_blank';
8-
logo.style.position = 'fixed';
9-
logo.style.width = '40px';
10-
logo.style.height = '40px';
11-
logo.style.zIndex = '9999';
12-
logo.style.transition = 'transform 0.2s ease';
13-
14-
// Position the logo based on data-position attribute
15-
if (position === 'top-left') {
16-
logo.style.top = '10px';
17-
logo.style.left = '10px';
18-
} else if (position === 'top-right') {
19-
logo.style.top = '10px';
20-
logo.style.right = '10px';
21-
} else if (position === 'bottom-left') {
22-
logo.style.bottom = '10px';
23-
logo.style.left = '10px';
1+
window.addEventListener('load', function () {
2+
if (localStorage.getItem('hideLogo') === 'true') return;
3+
const c = Array.from(document.scripts).find(s => s.src.includes('logo.js'));
4+
const p = c ? c.getAttribute('data-position') || 'bottom-right' : 'bottom-right';
5+
const l = document.createElement('a');
6+
l.href = 'https://gptgames.dev';
7+
l.target = '_blank';
8+
l.style.position = 'fixed';
9+
l.style.zIndex = '9999';
10+
l.style.transition = 'transform 0.2s ease';
11+
const m = window.innerWidth <= 768;
12+
l.style.width = m ? '30px' : '40px';
13+
l.style.height = m ? '30px' : '40px';
14+
if (p === 'top-left') {
15+
l.style.top = '10px';
16+
l.style.left = '10px'
17+
} else if (p === 'top-right') {
18+
l.style.top = '10px';
19+
l.style.right = '10px'
20+
} else if (p === 'bottom-left') {
21+
l.style.bottom = '10px';
22+
l.style.left = '10px'
2423
} else {
25-
logo.style.bottom = '10px';
26-
logo.style.right = '10px';
24+
l.style.bottom = '10px';
25+
l.style.right = '10px'
2726
}
28-
29-
const img = document.createElement('img');
30-
img.src = '../img/logo.svg';
31-
img.style.width = '100%';
32-
img.style.height = '100%';
33-
34-
logo.appendChild(img);
35-
36-
logo.addEventListener('mouseover', function() {
37-
this.style.transform = 'scale(1.2)';
27+
const i = document.createElement('img');
28+
i.src = '../img/logo.svg';
29+
i.style.width = '100%';
30+
i.style.height = '100%';
31+
l.appendChild(i);
32+
l.addEventListener('mouseover', function () {
33+
this.style.transform = 'scale(1.2)'
3834
});
39-
40-
logo.addEventListener('mouseout', function() {
41-
this.style.transform = 'scale(1)';
35+
l.addEventListener('mouseout', function () {
36+
this.style.transform = 'scale(1)'
4237
});
38+
l.addEventListener('contextmenu', function (e) {
39+
e.preventDefault();
40+
const x = document.querySelector('.l-ctx-menu');
41+
if (x && document.body.contains(x)) document.body.removeChild(x);
42+
const n = document.createElement('div');
43+
n.className = 'l-ctx-menu';
44+
n.style.position = 'fixed';
45+
n.style.backgroundColor = '#fff';
46+
n.style.color = '#333';
47+
n.style.borderRadius = '4px';
48+
n.style.boxShadow = '0 2px 8px rgba(0,0,0,0.2)';
49+
n.style.padding = '8px 12px';
50+
n.style.cursor = 'pointer';
51+
n.style.zIndex = '10000';
52+
n.style.fontFamily = 'sans-serif';
53+
n.style.fontSize = '14px';
54+
n.textContent = 'Hide this logo';
55+
const r = l.getBoundingClientRect();
56+
let left = r.left + (r.width / 2) - 75;
57+
let top = r.bottom + 5;
58+
if (left < 5) left = 5;
59+
if (left + 150 > window.innerWidth - 5) left = window.innerWidth - 155;
60+
if (top + 30 > window.innerHeight - 5) top = r.top - 35;
61+
n.style.left = left + 'px';
62+
n.style.top = top + 'px';
63+
n.addEventListener('click', function () {
64+
if (document.body.contains(l)) document.body.removeChild(l);
65+
localStorage.setItem('hideLogo', 'true');
66+
if (document.body.contains(n)) document.body.removeChild(n)
67+
});
68+
document.body.appendChild(n);
4369

44-
document.body.appendChild(logo);
70+
function c(e) {
71+
if (!n.contains(e.target) && e.target !== l) {
72+
if (document.body.contains(n)) document.body.removeChild(n);
73+
document.removeEventListener('click', c)
74+
}
75+
}
76+
77+
setTimeout(function () {
78+
document.addEventListener('click', c)
79+
}, 10)
80+
});
81+
document.body.appendChild(l);
82+
window.addEventListener('resize', function () {
83+
const m = window.innerWidth <= 768;
84+
l.style.width = m ? '30px' : '40px';
85+
l.style.height = m ? '30px' : '40px'
86+
})
4587
});

tools/ai_text_naturalizer.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -573,5 +573,6 @@ <h4 class="font-semibold text-neutral-800 dark:text-neutral-100 mb-2">Creative W
573573
});
574574
});
575575
</script>
576+
<script src="../logo.js"></script>
576577
</body>
577578
</html>

tools/code_editor.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,5 +190,6 @@
190190
}
191191
});
192192
</script>
193+
<script src="../logo.js"></script>
193194
</body>
194195
</html>

tools/gptranslator.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -974,5 +974,6 @@ <h3 style="cursor: pointer;" data-target="#aboutText">About ️👆</h3>
974974
}
975975
</script>
976976
<script data-goatcounter="https://gptgames.goatcounter.com/count" async src="//gc.zgo.at/count.js"></script>
977+
<script src="../logo.js"></script>
977978
</body>
978979
</html>

tools/grammar_check.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,5 +363,6 @@ <h3 class="text-lg font-semibold text-gray-900 dark:text-gray-100 flex items-cen
363363
updateWordCount();
364364
}
365365
});</script>
366+
<script src="../logo.js"></script>
366367
</body>
367368
</html>

0 commit comments

Comments
 (0)