This should work. it's not pretty though :D. - It's just script listener code with a vertical and horizontal offset applied to the function.
I hope that's what you're after. Ironically your Photopea code doesn't work with my version of Photoshop (19.16)
applyColorOverlay(
{
r: 255,
g: 0,
b: 0,
}, 10, 0);
function applyColorOverlay(color, v, h)
{
// =======================================================
var idsetd = charIDToTypeID( "setd" );
var desc28 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref9 = new ActionReference();
var idPrpr = charIDToTypeID( "Prpr" );
var idLefx = charIDToTypeID( "Lefx" );
ref9.putProperty( idPrpr, idLefx );
var idLyr = charIDToTypeID( "Lyr " );
var idOrdn = charIDToTypeID( "Ordn" );
var idTrgt = charIDToTypeID( "Trgt" );
ref9.putEnumerated( idLyr, idOrdn, idTrgt );
desc28.putReference( idnull, ref9 );
var idT = charIDToTypeID( "T " );
var desc29 = new ActionDescriptor();
var idScl = charIDToTypeID( "Scl " );
var idPrc = charIDToTypeID( "#Prc" );
desc29.putUnitDouble( idScl, idPrc, 416.666667 );
var idGrFl = charIDToTypeID( "GrFl" );
var desc30 = new ActionDescriptor();
var idenab = charIDToTypeID( "enab" );
desc30.putBoolean( idenab, true );
var idpresent = stringIDToTypeID( "present" );
desc30.putBoolean( idpresent, true );
var idshowInDialog = stringIDToTypeID( "showInDialog" );
desc30.putBoolean( idshowInDialog, true );
var idMd = charIDToTypeID( "Md " );
var idBlnM = charIDToTypeID( "BlnM" );
var idNrml = charIDToTypeID( "Nrml" );
desc30.putEnumerated( idMd, idBlnM, idNrml );
var idOpct = charIDToTypeID( "Opct" );
var idPrc = charIDToTypeID( "#Prc" );
desc30.putUnitDouble( idOpct, idPrc, 100.000000 );
var idGrad = charIDToTypeID( "Grad" );
var desc31 = new ActionDescriptor();
var idNm = charIDToTypeID( "Nm " );
desc31.putString( idNm, """$$$/DefaultGradient/ForegroundToBackground=Foreground to Background""" );
var idGrdF = charIDToTypeID( "GrdF" );
var idGrdF = charIDToTypeID( "GrdF" );
var idCstS = charIDToTypeID( "CstS" );
desc31.putEnumerated( idGrdF, idGrdF, idCstS );
var idIntr = charIDToTypeID( "Intr" );
desc31.putDouble( idIntr, 4096.000000 );
var idClrs = charIDToTypeID( "Clrs" );
var list2 = new ActionList();
var desc32 = new ActionDescriptor();
var idClr = charIDToTypeID( "Clr " );
var desc33 = new ActionDescriptor();
var idRd = charIDToTypeID( "Rd " );
desc33.putDouble( idRd, color.r ); //R
var idGrn = charIDToTypeID( "Grn " );
desc33.putDouble( idGrn, color.g ); //g
var idBl = charIDToTypeID( "Bl " );
desc33.putDouble( idBl, color.b );
var idRGBC = charIDToTypeID( "RGBC" );
desc32.putObject( idClr, idRGBC, desc33 );
var idType = charIDToTypeID( "Type" );
var idClry = charIDToTypeID( "Clry" );
var idUsrS = charIDToTypeID( "UsrS" );
desc32.putEnumerated( idType, idClry, idUsrS );
var idLctn = charIDToTypeID( "Lctn" );
desc32.putInteger( idLctn, 0 );
var idMdpn = charIDToTypeID( "Mdpn" );
desc32.putInteger( idMdpn, 50 );
var idClrt = charIDToTypeID( "Clrt" );
list2.putObject( idClrt, desc32 );
var desc34 = new ActionDescriptor();
var idClr = charIDToTypeID( "Clr " );
var desc35 = new ActionDescriptor();
var idRd = charIDToTypeID( "Rd " );
desc35.putDouble( idRd, 255.000000 );
var idGrn = charIDToTypeID( "Grn " );
desc35.putDouble( idGrn, 255.000000 );
var idBl = charIDToTypeID( "Bl " );
desc35.putDouble( idBl, 255.000000 );
var idRGBC = charIDToTypeID( "RGBC" );
desc34.putObject( idClr, idRGBC, desc35 );
var idType = charIDToTypeID( "Type" );
var idClry = charIDToTypeID( "Clry" );
var idUsrS = charIDToTypeID( "UsrS" );
desc34.putEnumerated( idType, idClry, idUsrS );
var idLctn = charIDToTypeID( "Lctn" );
desc34.putInteger( idLctn, 4096 );
var idMdpn = charIDToTypeID( "Mdpn" );
desc34.putInteger( idMdpn, 50 );
var idClrt = charIDToTypeID( "Clrt" );
list2.putObject( idClrt, desc34 );
desc31.putList( idClrs, list2 );
var idTrns = charIDToTypeID( "Trns" );
var list3 = new ActionList();
var desc36 = new ActionDescriptor();
var idOpct = charIDToTypeID( "Opct" );
var idPrc = charIDToTypeID( "#Prc" );
desc36.putUnitDouble( idOpct, idPrc, 100.000000 );
var idLctn = charIDToTypeID( "Lctn" );
desc36.putInteger( idLctn, 0 );
var idMdpn = charIDToTypeID( "Mdpn" );
desc36.putInteger( idMdpn, 50 );
var idTrnS = charIDToTypeID( "TrnS" );
list3.putObject( idTrnS, desc36 );
var desc37 = new ActionDescriptor();
var idOpct = charIDToTypeID( "Opct" );
var idPrc = charIDToTypeID( "#Prc" );
desc37.putUnitDouble( idOpct, idPrc, 100.000000 );
var idLctn = charIDToTypeID( "Lctn" );
desc37.putInteger( idLctn, 4096 );
var idMdpn = charIDToTypeID( "Mdpn" );
desc37.putInteger( idMdpn, 50 );
var idTrnS = charIDToTypeID( "TrnS" );
list3.putObject( idTrnS, desc37 );
desc31.putList( idTrns, list3 );
var idGrdn = charIDToTypeID( "Grdn" );
desc30.putObject( idGrad, idGrdn, desc31 );
var idAngl = charIDToTypeID( "Angl" );
var idAng = charIDToTypeID( "#Ang" );
desc30.putUnitDouble( idAngl, idAng, 90.000000 );
var idType = charIDToTypeID( "Type" );
var idGrdT = charIDToTypeID( "GrdT" );
var idLnr = charIDToTypeID( "Lnr " );
desc30.putEnumerated( idType, idGrdT, idLnr );
var idRvrs = charIDToTypeID( "Rvrs" );
desc30.putBoolean( idRvrs, false );
var idDthr = charIDToTypeID( "Dthr" );
desc30.putBoolean( idDthr, false );
var idAlgn = charIDToTypeID( "Algn" );
desc30.putBoolean( idAlgn, true );
var idScl = charIDToTypeID( "Scl " );
var idPrc = charIDToTypeID( "#Prc" );
desc30.putUnitDouble( idScl, idPrc, 100.000000 );
var idOfst = charIDToTypeID( "Ofst" );
var desc38 = new ActionDescriptor();
var idHrzn = charIDToTypeID( "Hrzn" );
var idPrc = charIDToTypeID( "#Prc" );
desc38.putUnitDouble( idHrzn, idPrc, h );
var idVrtc = charIDToTypeID( "Vrtc" );
var idPrc = charIDToTypeID( "#Prc" );
desc38.putUnitDouble( idVrtc, idPrc, v );
var idPnt = charIDToTypeID( "Pnt " );
desc30.putObject( idOfst, idPnt, desc38 );
var idGrFl = charIDToTypeID( "GrFl" );
desc29.putObject( idGrFl, idGrFl, desc30 );
var idLefx = charIDToTypeID( "Lefx" );
desc28.putObject( idT, idLefx, desc29 );
executeAction( idsetd, desc28, DialogModes.NO );
};