Redirect multi-page news articles to a single page view using Greasemonkey

A lot of news websites split their articles into multiple pages. In theory this drives page impressions and thus ad revenue. In practice it is just annoying. The Greasemonkey script below automagically redirects you to a news article’s full page (in this case on zeit.de). It uses a MutiationObserver to wait for the pager UI element. The script kicks in once it appears – no need to wait until their page (or ads?!) have been fully loaded. 🙂

You can easily modify it:

1. Include all pages that might contain a multi-page article
2. Exclude all pages that might lead to a loop (especially the target site) or that will not contain a pager element (MutiationObserver can easily add a couple of milliseconds of loading time on complex pages)
3. Change the class name of the pager element to the one used by your site
4. Change the target location to the one you want to be redirect to

// ==UserScript==
// @name         Zeit Onepager
// @namespace    kubath.com
// @version      1.0
// @description  Zeigt mehrseitige Zeit-Artikel auf einer Seite
// @author       Florian Kubath
// @match        *://www.zeit.de/*
// @exclude      *://www.zeit.de/*/komplettansicht
// @grant        none
// @run-at       document-start
// ==/UserScript==

var mutationObserver;

window.addEventListener('load', function() {
  
  mutationObserver.disconnect();
}, false);

(function onepager() {

    mutationObserver = new MutationObserver(function (mutations) {

        var pager = document.getElementsByClassName('article-pager__all'); // Change to your site's pager element's class name
        if (pager.length > 0) {

            window.location.replace(window.location.href + '/komplettansicht'); // Change to your target site's URL 
            mutationObserver.disconnect();
            return;
        }
    });

    mutationObserver.observe(document, {

        childList: true,
        subtree: true
    });
}());

 

Ready-to-install scripts for:

golem.de
heise.de
zeit.de

2 Replies to “Redirect multi-page news articles to a single page view using Greasemonkey”

  1. Most recent changes for Heise:

    var pager = document.getElementsByClassName(‘pagination-all-on-one-page__link’);
    if (pager.length > 0) {

    window.location.replace(window.location.href + ‘?seite=all’);
    mutationObserver.disconnect();
    return;
    }

Leave a Reply