The previous script used a custom prompt driven interface, it was a quick reworking of previous code that I had created and did not let you change quality level or other settings... You may prefer this new version that I just hacked together as it uses the standard interface, just preset as you originally requested, with the flexibility to change when required.
/*
Default JPEG Save to Baseline Standard.jsx
https://community.adobe.com/t5/photoshop-ecosystem-discussions/save-as-jpeg-again/td-p/12650865
Stephen Marsh, 12th January 2022 - v1.0
Info: Uses the standard Photoshop interface with preset JPEG options
*/
#target photoshop
if (app.documents.length > 0) {
var docName = app.activeDocument.name.replace(/\.[^\.]+$/, '');
try {
// Use the previously saved path
var docPath = app.activeDocument.path;
} catch (e) {
// If unsaved, prompt for save directory
var docPath = Folder.selectDialog("Unsaved base file, select the output folder:");
}
saveJPEG(10);
} else {
alert("You must have a document open!");
}
function saveJPEG(compValue) {
// Using the standard Photoshop dialog windows
var ID = function (s) {
return app.stringIDToTypeID(s);
};
var AD = new ActionDescriptor();
AD.putInteger(ID("extendedQuality"), compValue);
AD.putEnumerated(ID("matteColor"), ID("matteColor"), ID("none"));
AD.putObject(ID("as"), ID("JPEG"), AD);
AD.putPath(ID("in"), new File(docPath + "/" + docName + ".jpg"));
executeAction(ID("save"), AD, DialogModes.ALL);
}
https://prepression.blogspot.com/2017/11/downloading-and-installing-adobe-scripts.html