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} ) ;
0 commit comments