11'use strict' ;
22
3- // Service definitions with dependency requirements
3+ // Service definitions with codec requirements
44const services = [
55 { name : 'YouTube' , icon : 'youtube' , url : 'https://youtube.com/' , action : 'select' , requiresCodec : false } ,
66 { name : 'TikTok' , icon : 'tiktok' , url : 'https://tiktok.com/' , action : 'select' , requiresCodec : true } ,
@@ -18,7 +18,7 @@ const services = [
1818 { name : 'Rutube' , icon : 'rutube' , url : 'https://rutube.ru/' , action : 'open' , requiresCodec : true }
1919] ;
2020
21- // Simplified codec checking (removed x86-64 requirement)
21+ // Codec support detection
2222let hasCodecSupport = false ;
2323
2424function checkCodecSupport ( ) {
@@ -30,7 +30,7 @@ function checkCodecSupport() {
3030 } ) ;
3131}
3232
33- // Initialize services grid with codec-based disabling
33+ // Initialize service grid
3434async function initializeServices ( ) {
3535 const grid = document . getElementById ( 'services-grid' ) ;
3636 const codecCheck = await checkCodecSupport ( ) ;
@@ -42,12 +42,10 @@ async function initializeServices() {
4242 card . dataset . action = service . action ;
4343 card . dataset . serviceName = service . name ;
4444
45- // Disable service if it requires codec and codec is not available
4645 const isDisabled = service . requiresCodec && ! codecCheck . hasCodecSupport ;
4746
4847 if ( isDisabled ) {
4948 card . classList . add ( 'service-disabled' ) ;
50- // Add click handler for popup instead of title attribute
5149 card . addEventListener ( 'click' , ( e ) => {
5250 e . preventDefault ( ) ;
5351 showCodecPopup ( service . name ) ;
@@ -67,28 +65,21 @@ async function initializeServices() {
6765 } ) ;
6866}
6967
70- // Show codec requirements popup
7168function showCodecPopup ( serviceName ) {
7269 const popup = document . getElementById ( 'codec-popup' ) ;
7370 const serviceNameElement = document . getElementById ( 'service-name-popup' ) ;
7471
7572 serviceNameElement . textContent = serviceName ;
7673 popup . classList . remove ( 'hidden' ) ;
77-
78- // Prevent body scroll when popup is open
7974 document . body . style . overflow = 'hidden' ;
8075}
8176
82- // Close codec popup
8377function closeCodecPopup ( ) {
8478 const popup = document . getElementById ( 'codec-popup' ) ;
8579 popup . classList . add ( 'hidden' ) ;
86-
87- // Restore body scroll
8880 document . body . style . overflow = '' ;
8981}
9082
91- // Open codec fix instructions
9283function openCodecInstructions ( ) {
9384 const url = 'https://www.solsticegamestudios.com/fixmedia/' ;
9485
@@ -100,10 +91,9 @@ function openCodecInstructions() {
10091 closeCodecPopup ( ) ;
10192}
10293
103- // Simplified service selection (no codec warning, just block disabled services)
10494function selectService ( elem ) {
10595 if ( elem . classList . contains ( 'service-disabled' ) ) {
106- return ; // Do nothing for disabled services
96+ return ;
10797 }
10898
10999 playUISound ( true ) ;
@@ -127,8 +117,7 @@ function openService(elem) {
127117 }
128118}
129119
130- // Enhanced URL request with codec checking
131- async function requestUrl ( ) {
120+ function requestUrl ( ) {
132121 const elem = document . getElementById ( 'urlinput' ) ;
133122 const url = elem . value . trim ( ) ;
134123 const statusIndicator = document . getElementById ( 'status-indicator' ) ;
@@ -137,55 +126,13 @@ async function requestUrl() {
137126
138127 if ( url . length === 0 ) return ;
139128
140- // Show loading state
141129 statusIndicator . classList . remove ( 'hidden' ) ;
142- statusText . textContent = 'Validating URL... ' ;
130+ statusText . textContent = 'Request sent! ' ;
143131 submitBtn . disabled = true ;
144132
145- /* Needs further implementation
146- try {
147- // Basic URL validation
148- new URL(url);
149-
150- // Check if URL requires codec support
151- const requiresCodec = url.includes('youtube') || url.includes('bilibili') || url.includes('dailymotion');
152-
153- if (requiresCodec && !hasCodecSupport) {
154- statusText.textContent = 'URL requires CEF Codec Fix';
155- setTimeout(() => {
156- statusIndicator.classList.add('hidden');
157- }, 3000);
158- return;
159- }
160-
161- statusText.textContent = 'Requesting video...';
162-
163- // Call GMod function or fallback
164- if (typeof gmod !== 'undefined' && gmod.requestUrl) {
165- gmod.requestUrl(url);
166- } else {
167- console.log('Would request URL:', url);
168- }
169-
170- statusText.textContent = 'Request sent!';
171- setTimeout(() => {
172- statusIndicator.classList.add('hidden');
173- }, 2000);
174-
175- } catch (error) {
176- statusText.textContent = 'Invalid URL format';
177- setTimeout(() => {
178- statusIndicator.classList.add('hidden');
179- }, 3000);
180- } finally {
181- submitBtn.disabled = false;
182- }
183- */
184-
185- // This will do for now..
186- statusText . textContent = 'Request sent!' ;
187133 setTimeout ( ( ) => {
188134 statusIndicator . classList . add ( 'hidden' ) ;
135+ submitBtn . disabled = false ;
189136 } , 2000 ) ;
190137
191138 if ( typeof gmod !== 'undefined' && gmod . requestUrl ) {
@@ -210,12 +157,65 @@ function hoverService() {
210157 playUISound ( false ) ;
211158}
212159
213- // Initialize when DOM is loaded
160+ function initializeUrlInput ( ) {
161+ const urlInput = document . getElementById ( 'urlinput' ) ;
162+ if ( urlInput ) {
163+ urlInput . addEventListener ( 'keydown' , onUrlKeyDown ) ;
164+ }
165+ }
166+
167+ function initializeAutoInput ( ) {
168+ const urlInput = document . getElementById ( 'urlinput' ) ;
169+ if ( ! urlInput ) return ;
170+
171+ // Focus input on keypress
172+ document . addEventListener ( 'keydown' , ( event ) => {
173+ if ( document . activeElement === urlInput ||
174+ event . ctrlKey || event . metaKey || event . altKey ||
175+ event . key === 'Tab' || event . key === 'Escape' ) {
176+ return ;
177+ }
178+
179+ urlInput . focus ( ) ;
180+ } ) ;
181+
182+ // Handle clipboard paste
183+ document . addEventListener ( 'paste' , async ( event ) => {
184+ try {
185+ const clipboardText = event . clipboardData ?. getData ( 'text' ) ||
186+ await navigator . clipboard . readText ( ) ;
187+
188+ if ( clipboardText && isValidURL ( clipboardText ) ) {
189+ urlInput . value = clipboardText . trim ( ) ;
190+ urlInput . focus ( ) ;
191+
192+ urlInput . classList . add ( 'auto-filled' ) ;
193+ setTimeout ( ( ) => urlInput . classList . remove ( 'auto-filled' ) , 1000 ) ;
194+ }
195+ } catch ( error ) {
196+ // Clipboard access denied
197+ }
198+ } ) ;
199+ }
200+
201+ function isValidURL ( string ) {
202+ try {
203+ new URL ( string ) ;
204+ return true ;
205+ } catch {
206+ return / ^ h t t p s ? : \/ \/ / . test ( string ) ||
207+ / ^ w w w \. / . test ( string ) ||
208+ string . includes ( '.' ) && string . length > 5 ;
209+ }
210+ }
211+
214212document . addEventListener ( 'DOMContentLoaded' , ( ) => {
215213 initializeServices ( ) ;
214+ initializeUrlInput ( ) ;
215+ initializeAutoInput ( ) ;
216216} ) ;
217217
218- // Global functions for compatibility
218+ // Global function exports
219219window . requestUrl = requestUrl ;
220220window . selectService = selectService ;
221221window . openService = openService ;
0 commit comments