Simple script adding a "Weighted random" article button to the left screen, below the "Random article" button. It brings you to a random article as proportional to pageviews (more specifically, page views from August 2020, so not exactly recent). Hastily put together because it's kind of a novelty item. I also haven't programmed in a few months.

I use publicly available data (here) and merge the mobile and desktop versions of the site into a page view count for every page. We then select a weighted sampling of 10,000 articles representative of the data. Note that redirects are unfortunately included. This set of 10,000 pages is representative of what people in the month were reading. Finally, the button selects a random article out of the sampling.

Installation:

importScript("User:Ovinus/WeightedRandom.js");

Code:

  • /filter.py takes in the public data and turns it into a simpler format
  • /get_random.cc takes a weighted sample of the data
  • /data the data output which the script uses