I got the following code from the website:
https://forums.adobe.com/thread/708641
======Code starts here ====
replaceTextByFont (“mam”, “man”);
replaceTextByStyle (“mam”, “man”);
function replaceTextByStyle (input, output)
{
app.findTextPreferences = app.changeTextPreferences = NothingEnum.nothing;
app.findTextPreferences.findWhat = input;
app.findTextPreferences.appliedParagraphStyle = app.activeDocument.paragraphStyles.item(“SampleFindStyle”);
app.changeTextPreferences.appliedParagraphStyle = app.activeDocument.paragraphStyles.item(“SampleReplaceStyle”);
app.changeTextPreferences.changeTo = output;
app.activeDocument.changeText();
app.findTextPreferences = app.changeTextPreferences = NothingEnum.nothing;
}
function replaceTextByFont (input, output)
{
app.findTextPreferences = app.changeTextPreferences = NothingEnum.nothing;
app.findTextPreferences.findWhat = input;
app.findTextPreferences.appliedFont = app.fonts.item(“Arial Bold”);
app.changeTextPreferences.appliedFont = app.fonts.item(“Arial BoldItalic”);
app.changeTextPreferences.changeTo = output;
app.activeDocument.changeText();
app.findTextPreferences = app.changeTextPreferences = NothingEnum.nothing;
}
======Code Ends here ====
I request anyone to help me to change the entire code in JavaScript.