This is from: https://www.celestialprogramming.com/risesetalgorithm.html . It has a Javascript implementation and example you can run for the rise, set, and transit times. Keep in mind that if you use this algorithm for objects that move, like the moon, sun, or planets, you may need to iterate to find an accurate solution.
$ \cos H_0 = \dfrac{\sin h_0 - \sin \varphi \sin \delta }{\cos \varphi \cos \delta} $
If $ cos H_0 $ < -1 or > 1, the point is either always above or below the horizon.
$ T=(jd-2451545.0)/36525.0 $
$ \Theta_0 = 280.46061837+360.98564736629*(jd-2451545.0)+0.000387933T^2 - T^3/38710000.0 $
$ transit = \dfrac{\delta + L - \Theta_0 }{360^{\circ}} $
$ rise = transit - \dfrac{H_0}{360^{\circ}} $
$ set = transit + \dfrac{H_0}{360^{\circ}} $
$ jd $ is the Julian Date for the date in question.
$ \delta $ Declination
$ L $ Longitude
$ \varphi $ Latitude
$ h_0 $ Apparent rise or set angle, -0.8333 for the Sun, +0.125 for the Moon, and -0.5667 for most other objects.
$ \Theta_0 $ Greenwich sidereal time at 0h for the day in question.
$ A_r $ is the azimuth of the object when it rises, and
$ A_s $ is the setting azimuth.
$ \cos A_r = \dfrac{\sin \delta + \sin h_0 \sin \varphi}{\cos h_0 \cos \varphi} $
$ \cos A_s = 360 - A_r $