  Timeline algorithms are key parts of online social networks, but during
recent years they have been blamed for increasing polarization and disagreement
in our society. Opinion-dynamics models have been used to study a variety of
phenomena in online social networks, but an open question remains on how these
models can be augmented to take into account the fine-grained impact of
user-level timeline algorithms. We make progress on this question by providing
a way to model the impact of timeline algorithms on opinion dynamics.
Specifically, we show how the popular Friedkin--Johnsen opinion-formation model
can be augmented based on aggregate information, extracted from timeline data.
We use our model to study the problem of minimizing the polarization and
disagreement; we assume that we are allowed to make small changes to the users'
timeline compositions by strengthening some topics of discussion and penalizing
some others. We present a gradient descent-based algorithm for this problem,
and show that under realistic parameter settings, our algorithm computes a
$(1+\varepsilon)$-approximate solution in time $\tilde{O}(m\sqrt{n}
\lg(1/\varepsilon))$, where $m$ is the number of edges in the graph and $n$ is
the number of vertices. We also present an algorithm that provably computes an
$\varepsilon$-approximation of our model in near-linear time. We evaluate our
method on real-world data and show that it effectively reduces the polarization
and disagreement in the network. Finally, we release an anonymized graph
dataset with ground-truth opinions and more than 27\,000 nodes (the previously
largest publicly available dataset contains less than 550 nodes).
