Below, we interpret divergent integrals as germs of partial integrals at infinity:
$$\int_0^\infty f(x) dx=\operatorname{bigpart} \int_0^\omega f(x) dx$$
where $\operatorname{bigpart}$ means taking finite and infinite parts of $\int_0^\omega f(x) dx$ at $\omega\to\infty$ while throwing away infinitesimal and oscillating (with zero average) parts. The question is, how can we define this operator?
For instance,
$$\int_0^\omega 1 dx=\omega.$$
It is infinite, so our desired result is $\int_0^\infty 1 dx=\omega$. Thus, $\omega$ plays the role of an infinite constant.
$$\int_0^{\omega } \exp (x) \sin (2 x) \, dx=\frac{2}{5}-\frac{2}{5} e^{\omega } (\cos (2 \omega )-\sin (\omega ) \cos (\omega )).$$
Here, $2/5$ is finite part. The term $-\frac{2}{5} e^{\omega } (\cos (2 \omega )-\sin (\omega ) \cos (\omega ))$ is oscillating with zero average, so should be taken to be equal to zero. So, the desired result is $2/5$.
$$\int_0^{\omega } \cos ^2(x) \, dx=\frac{\omega }{2}+\frac{1}{4} \sin (2 \omega ).$$
The part $\frac{1}{4} \sin (2 \omega )$ is oscillating with zero average, so the desired result is the infinite part $\frac{\omega }{2}$.
$$\int_0^{\omega } \exp (\log (x)+x) \, dx=e^{\omega } (\omega -1)+1.$$
Here we have infinite and finite parts, so the desired result should be kept intact: $\int_0^\infty \exp (\log (x)+x) dx=e^{\omega } (\omega -1)+1$.
On the other hand,
$$\int_0^{\omega } \exp (\log (x)-x) \, dx=e^{-\omega } (-\omega -1)+1.$$
The term $e^{-\omega } (-\omega -1)$ is infinitesimal, so we throw it away, and our desired result is $\int_0^{\infty } \exp (\log (x)-x) \, dx=1$.
Is there a way to define such function $\operatorname{bigpart}$ consistently and automatize the process in a CAS system?
As far as the oscillating part is concerned, you provided a solution yourself in terms of averages. As far as decomposition into infinite + real + infinitesimal, this can be done in nonstandard analysis more generally than the context of integration as follows. Consider the standard part function $[\;]\colon\mathbb R\to [0,1)$. It has a natural extension to the hyperreals: $[\;]^\ast\colon \mathbb R^\ast \to [0,1)^\ast$. As usual, we will drop the asterisk on functions (but not on sets). Then given an arbitrary hyperreal $x$, we can decompose it as $x= [x]+r$ where $r$ is a finite hyperreal (between $0$ and $1$). Since $r$ is finite, we can decompose $r$ into its standard part st$(r)$ and an infinitesimal $\alpha$. In sum, we get $$x=[x]+\text{st}(r)+\alpha$$ (where $[x]$ could be infinite).