Forum Discussion
Is it possible to use JavaScript to edit frame.js?
If someone else has this need in the future, my final solution was to create a batch file that automatically updates the menuOption to restricted.
I know is a very specific need, but maybe it will help someone else later :)
Since I can't attached files somehow, here is the code:
@echo off
REM Set the search text and replace text
set "search_text=\"free\""
set "replace_text=\"restricted\""REM Determine the current directory and specify the file path
set "main_folder=%cd%"
set "file=%main_folder%\html5\data\js\frame.js"
set "temp_file=%file%.tmp"REM Check if the file exists
if not exist "%file%" (
echo File not found: %file%
pause
goto :eof
)echo Processing file: %file%
REM Use PowerShell to read and modify the file, writing to a temporary file
powershell -Command ^
"Get-Content '%file%' | ForEach-Object { $_ -replace '%search_text%', '%replace_text%' } | Set-Content '%temp_file%'"if %errorlevel% neq 0 (
echo Error processing the file with PowerShell.
pause
goto :eof
)REM Replace the original file with the modified temporary file
move /y "%temp_file%" "%file%" >nulif %errorlevel% neq 0 (
echo Error replacing the original file.
) else (
echo Updated file: %file%
)echo Done!
pause