\documentclass{article}
\usepackage{xparse}
\let\RealFrac\frac
\RenewDocumentCommand\frac{mg}{
\IfNoValueTF{#2}
{\RealFrac{1}{#1}}
{\RealFrac{#1}{#2}}
}
\begin{document}
One arg: \verb|$\frac{10}$| prints $\frac{10}$.
Two args: \verb|$\frac{2}{30}$| prints $\frac{2}{30}$.
\end{document}