From $^{\prime\prime}$Classical Mechanics$^{\prime\prime}$ by H.Goldstein-C.Poole-J.Safko, Third Edition 2000 :
$\boldsymbol{=\!=\!=\!==\!=\!=\!==\!=\!=\!==\!=\!=\!==\!=\!=\!==\!=\!=\!==\!=\!=\!==\!=\!=\!==\!=\!=\!==\!=\!=\!==\!=\!=\!==\!=\!=\!=}$
...the Eqs. (1.53) become
\begin{equation}
\dfrac{d\hphantom{t}}{dt}\left(\dfrac{\partial L}{\partial \dot{q}_j}\right)\boldsymbol{-}\dfrac{\partial L}{\partial q_j}\boldsymbol{=}0
\tag{1.57}\label{1.57}
\end{equation}
expressions referred to as $^{\prime\prime}$Lagrange's equations$^{\prime\prime}$.
Note that for a particular set of equations of motion there is no unique choice
of Lagrangian such that Eqs.\eqref{1.57} lead to the equations of motion in the given generalized coordinates. Thus, in Derivations 8 and 10 it is shown that if $\,L(q, \dot{q}, t)\,$ is an approximate Lagrangian and $\,F(q,t)\,$ is any differentiable function of the generalized coordinates and time, then
\begin{equation}
L^{\prime}(q, \dot{q}, t)\boldsymbol{=}L(q, \dot{q}, t)\boldsymbol{+}\dfrac{dF}{dt}
\tag{1.57'}\label{1.57'}
\end{equation}
is a Lagrangian also resulting in the same equations of motion.
$\vdots$
$\vdots$
DERIVATIONS
1.$\cdots$
$\vdots$
8.
If $\,L\,$ is a Lagrangian for a system of $\,n\,$ degrees of freedom satisfying Lagrange's equations, show by direct substitution that
\begin{equation}
L^{\prime}\boldsymbol{=}L\boldsymbol{+}\dfrac{d F\left(q_1,\cdots,q_n,t\right)}{dt}
\tag{[1.57']}\label{[1.57']}
\end{equation}
also satisfies Lagrange's equations where $\,F\,$ is any arbitrary, but differentiable, function of its arguments.
$\boldsymbol{=\!=\!=\!==\!=\!=\!==\!=\!=\!==\!=\!=\!==\!=\!=\!==\!=\!=\!==\!=\!=\!==\!=\!=\!==\!=\!=\!==\!=\!=\!==\!=\!=\!==\!=\!=\!=}$
Derivation 8
$\boldsymbol{\S} \bf A.$ By direct substitution
Consider the function
\begin{equation}
\mathcal M\boldsymbol{\equiv}\dfrac{\mathrm d F\left(q_1,\cdots,q_n,t\right)}{\mathrm dt}
\tag{A-01}\label{A-01}
\end{equation}
We have
\begin{equation}
\mathrm d F\boldsymbol{=}\dfrac{\partial F}{\partial t}\mathrm dt\boldsymbol{+}\sum\limits_{k\boldsymbol{=}1}^{k\boldsymbol{=}n}\dfrac{\partial F}{\partial q_k}\mathrm dq_k\quad \boldsymbol{\Longrightarrow} \quad \dfrac{\mathrm d F}{\mathrm dt}\boldsymbol{=}\dfrac{\partial F}{\partial t}\boldsymbol{+}\sum\limits_{k\boldsymbol{=}1}^{k\boldsymbol{=}n}\dfrac{\partial F}{\partial q_k}\dot{q}_k
\tag{A-02}\label{A-02}
\end{equation}
so
\begin{equation}
\!\!\!\!\!\!\boxed{\:\:\mathcal M\left(q_1,\dot{q}_1,\cdots,q_n,\dot{q}_n,t\right)\boldsymbol{=}\dfrac{\partial F\left(q_1,\cdots,q_n,t\right)}{\partial t}\boldsymbol{+}\sum\limits_{k\boldsymbol{=}1}^{k\boldsymbol{=}n}\dfrac{\partial F\left(q_1,\cdots,q_n,t\right)}{\partial q_k}\dot{q}_k\:\:}
\tag{A-03}\label{A-03}
\end{equation}
Note that while the function $\,F\,$ is a function of the generalized coordinates $\,q_j\,$ and time $\,t$, the fun- ction $\,\mathcal M\,$ is a function of the generalized coordinates $\,q_j$, the generalized momenta $\,\dot{q}_j\,$ and time $\,t$.
Now, to prove that the addition of the function $\,\mathcal M\,$ to a Lagrangian $\,L\,$ doesn't change the Lagrange equations \eqref{1.57} we proceed as follows : Considering that only $\,\mathcal M\,$ is a Lagrangian of the system we'll prove that the resulting Lagrange equations \eqref{1.57}
\begin{equation}
\dfrac{\mathrm d\hphantom{t}}{\mathrm d t}\left(\dfrac{\partial \mathcal M}{\partial \dot{q}_j}\right)\boldsymbol{-}\dfrac{\partial\mathcal M}{\partial q_j}\boldsymbol{=}0
\tag{A-04}\label{A-04}
\end{equation}
are identically zero, that is the left hand side is zero for any degree of freedom $\,j$.
Indeed, from \eqref{A-03}
\begin{equation}
\dfrac{\partial \mathcal M}{\partial \dot{q}_j}\boldsymbol{=}\dfrac{\partial F}{\partial q_j}
\tag{A-05}\label{A-05}
\end{equation}
so
\begin{equation}
\dfrac{\mathrm d\hphantom{t}}{\mathrm d t}\left(\dfrac{\partial \mathcal M}{\partial \dot{q}_j}\right)\boldsymbol{=}\dfrac{\mathrm d\hphantom{t}}{\mathrm d t}\left(\dfrac{\partial F}{\partial q_j}\right)\boldsymbol{=}\dfrac{\partial\hphantom{q_j} }{\partial q_j}\left(\dfrac{\mathrm d F}{\mathrm dt}\right) \boldsymbol{=}\dfrac{\partial\mathcal M}{\partial q_j}
\tag{A-06}\label{A-06}
\end{equation}
quod erat demonstrandum ($\dot{o}\pi\epsilon\rho\:\:\epsilon\delta\epsilon\dot{\iota}\chi\theta\eta$).
$\boldsymbol{\S} \bf B.$ By calculus of variations
Lagrange equations \eqref{1.57} follow from Hamilton's principle stated as
The motion of the system from time $\,t_1\,$ to time $\,t_2\,$ is such that the line integral (called the action or the action integral)
\begin{equation}
S\boldsymbol{=}\int\limits_{t_1}^{t_2}L\mathrm d t
\tag{B-01}\label{B-01}
\end{equation}
has a stationary value for the actual path of the
Motion.
Hamilton's principle is summarized by saying that the motion is such that the variation of the line integral $\,S\,$ for fixed $\,t_1\,$ and $\,t_2\,$ is zero:
\begin{equation}
\delta S\boldsymbol{=}\delta\int\limits_{t_1}^{t_2}L\left(q_1,\cdots,q_n,\dot{q}_1,\cdots,\dot{q}_n,t\right)\mathrm d t\boldsymbol{=}0
\tag{B-02}\label{B-02}
\end{equation}
For a new Lagrangian $\,L^{\prime}\,$ according to equation \eqref{[1.57']}
\begin{equation}
L^{\prime}\boldsymbol{=}L\boldsymbol{+}\dfrac{\mathrm d F\left(q_1,\cdots,q_n,t\right)}{\mathrm d t}
\tag{B-03}\label{B-03}
\end{equation}
we have a new action $\,S^{\prime}\,$
\begin{equation}
S^{\prime}\boldsymbol{=}\int\limits_{t_1}^{t_2}\left(L\boldsymbol{+}\dfrac{\mathrm d F}{\mathrm d t}\right)\mathrm d t\boldsymbol{=}\int\limits_{t_1}^{t_2}L\mathrm d t\boldsymbol{+}\int\limits_{t_1}^{t_2}\mathrm d F\boldsymbol{=}S\boldsymbol{+}\underbrace{F\left(t_2\right)\boldsymbol{-}F\left(t_1\right)}_{\boldsymbol{=}C\boldsymbol{=}\text{constant}}
\tag{B-04}\label{B-04}
\end{equation}
so
\begin{equation}
\delta S^{\prime}\boldsymbol{=}\delta S\boldsymbol{+}\underbrace{\delta\left[F\left(t_2\right)\boldsymbol{-}F\left(t_1\right)\right]}_{\boldsymbol{=}\delta C\boldsymbol{=}0}
\tag{B-05}\label{B-05}
\end{equation}
that is
\begin{equation}
\delta S^{\prime}\boldsymbol{=}\delta S
\tag{B-06}\label{B-06}
\end{equation}
From the equality of variations of the actions equation \eqref{B-06} we have the same Lagrange equations.