Google Sheets: button that creates a new row and copies functions / format

I am trying to write a button that, when pressed, will create a new row below the currently active cell and will copy all the formats and formulas from the row of the selected cell.

I was able to find a version of this question that uses getLastRow. This causes a row to be added to the end of my spreadsheet instead of below my active row.

I have tried the following that does not use the getLastRow function. Hopefully, this makes my intention clear, but I'm not sure how to make it work properly.

addRow () {function
var ss = SpreadsheetApp.getActiveSpreadsheet ();
sheet var = ss.getSheets ()[0];
var range = ss.getActiveRange ();
var R = range.getRowIndex ();

sheet.insertRowsAfter (R, 1);
sheet.copyTo (sheet.insertRowsAfter (R, 1), {contentsOnly: false});
}

Here is the other code that I found that only adds to the last row:

var ss = SpreadsheetApp.getActive ();

onOpen () {function
var menu = [{name:"Add New Last Row", functionName:"addRow"}];
ss.addMenu ("AM FUNCTIONS", menu);
}

addRow () {function
var sh = ss.getActiveSheet (), lRow = sh.getLastRow ();
var lCol = sh.getLastColumn (), range = sh.getRange (lRow, 1,1, lCol);
sh.insertRowsAfter (lRow, 1);
formulas of var = range.getFormulas ();
var newRange = sh.getRange (lRow + 1,1,1, lCol);
newRange.setFormulas (formulas);
}