Hide plus news with Shortcuts (BE)

A couple of local websites with plus news articles

You probably know the feeling. You visit one of the news sites and the most interesting articles are plus (paid) articles. Clicking them will simply show you a paywall.

Thanks to the arrival of Shortcuts there now is an easy way to make them go away.

I noticed that all plus articles have a different CSS class and that it was just a matter of finding them all and hiding them.

This plus article has a CSS class “dossier-carousel-vertical-teaser–plus”

So that’s exactly what I did. Let me show you how to get it working on your iOS device.

Open the Shortcuts app and click Create Shortcut. Next click Add Action. Now type JavaScript in the search window and click the action: ‘Run JavaScript on Web Page’.

It should look something like this:

You can go ahead and tap anywhere in the text. Go ahead and delete it all. Once you’ve done that, you can add the following JavaScript in there:

const selectorsToHide = [
//De Standaard
    { selector: 'article.article--plus', parentSelector: null },
    { selector: 'article.article-teaser--paco', parentSelector: null },
//De Morgen
    { selector: 'article span.teaser__plus-label', parentSelector: 'article' },
//HLN Desktop
{ selector: 'article.flow-small-vertical-teaser--plus', parentSelector: null },
{ selector: 'article.flow-medium-vertical-teaser--plus', parentSelector: null },
{ selector: 'article.flow-large-vertical-teaser--plus', parentSelector: null },
{ selector: 'article.dossier-small-vertical-teaser--plus', parentSelector: null },
{ selector: 'article.dossier-medium-vertical-teaser--plus', parentSelector: null },
{ selector: 'article.dossier-large-vertical-teaser--plus', parentSelector: null },
{ selector: 'article.dossier-carousel-horizontal-teaser--plus', parentSelector: null },
{ selector: 'article.bakskes-horizontal-teaser--plus', parentSelector: null },
{ selector: 'article.top-navigation-vertical-teaser--plus', parentSelector: null },
{ selector: 'article.navigation-section-carousel-vertical-teaser--plus', parentSelector: null },
//HLN Mobile
{ selector: 'article.fjs-vertical-plus-teaser', parentSelector: null },
{ selector: 'article.teaser--plus', parentSelector: null },
{ selector: 'article.ankeiler--plus', parentSelector: null },
{ selector: 'article.horizontal-plus-flow-teaser', parentSelector: null },
{ selector: 'article.vertical-navigation-carousel-teaser--plus', parentSelector: null },
{ selector: 'plr-mobile-ad', parentSelector: null },
//Het Nieuwsblad
{ selector: 'article.article-teaser--plus', parentSelector: null }
];
for (const selectorToHide of selectorsToHide) {
    let elements = document.querySelectorAll(selectorToHide.selector);
    if (null !== selectorToHide.parentSelector) {
        elements = Array.from(elements, (element) => {
            return element.closest(selectorToHide.parentSelector);
        });
    }
    for (const element of elements) {
        if (null !== element) {
            element.remove();
        }
    }
}
result = '';
completion(result);

This JavaScript is to hide all articles that are plus articles on De Standaard, De Morgen, HLN and Het Nieuwsblad.

Click next and give your New Shortcut a name. You can also change the icon and colour. Once this step is done, you’re back to the My Shortcuts page. Now tap the 3 dots (…) on the top right of your Shortcut. This will open the content of the Shortcut. Now tap the 3 dots in the top right corner again. This will bring up the details. Enable the option that says ‘Show in Share Sheet’. Once you’ve done this, the option ‘Share Sheet Types’ will become visible. Open this one, Deselect All and only select ‘Safari web pages’.

Now that you’ve created your shortcut, go to your favourite news site and press the Share button at the bottom, scroll all the way down and click the name you gave to your Shortcut.

This will run the JavaScript and hide all the adds.


Leave a Reply

Your email address will not be published. Required fields are marked *