Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
aws
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
aws
Commits
308ed794
Commit
308ed794
authored
Nov 07, 2024
by
Ahmad
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
inikt
parent
c3665d55
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
63 additions
and
0 deletions
+63
-0
clear.bat
clear.bat
+7
-0
clr.js
clr.js
+56
-0
No files found.
clear.bat
0 → 100644
View file @
308ed794
@echo off
title Running Node.js Clr
echo Starting Node.js Create...
cd /d "%~dp0" // Ensures the script runs from the directory where the batch file is located
node clr.js // Runs your Node.js application
pause // Keeps the command prompt open after the script finishes
clr.js
0 → 100644
View file @
308ed794
const
fs
=
require
(
'
fs
'
);
const
path
=
require
(
'
path
'
);
const
{
exec
}
=
require
(
'
child_process
'
);
// Function to clear Downloads folder
function
clearDownloadsFolder
()
{
const
downloadsPath
=
path
.
join
(
process
.
env
.
HOMEPATH
,
'
Downloads
'
);
fs
.
readdir
(
downloadsPath
,
(
err
,
files
)
=>
{
if
(
err
)
{
console
.
error
(
'
Error reading Downloads folder:
'
,
err
);
return
;
}
files
.
forEach
((
file
)
=>
{
const
filePath
=
path
.
join
(
downloadsPath
,
file
);
fs
.
unlink
(
filePath
,
(
err
)
=>
{
if
(
err
)
{
console
.
error
(
`Failed to delete
${
file
}
:`
,
err
);
}
else
{
console
.
log
(
`Deleted:
${
file
}
`
);
}
});
});
});
}
// Function to close incognito Firefox
function
closeIncognitoFirefox
()
{
exec
(
'
tasklist
'
,
(
err
,
stdout
)
=>
{
if
(
err
)
{
console
.
error
(
'
Error listing tasks:
'
,
err
);
return
;
}
const
firefoxProcesses
=
stdout
.
split
(
'
\n
'
)
.
filter
(
line
=>
line
.
includes
(
'
firefox.exe
'
));
if
(
firefoxProcesses
.
length
>
0
)
{
exec
(
'
taskkill /IM firefox.exe /F
'
,
(
err
)
=>
{
if
(
err
)
{
console
.
error
(
'
Error closing Firefox:
'
,
err
);
}
else
{
console
.
log
(
'
Closed Firefox incognito windows
'
);
}
});
}
else
{
console
.
log
(
'
No Firefox processes running
'
);
}
});
}
// Run the functions
clearDownloadsFolder
();
closeIncognitoFirefox
();
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment